Skip to content

Commit

Permalink
[1D] Provide reasonable default grid for CounterflowDiffusionFlame
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Mar 27, 2016
1 parent 87a8419 commit 8e81292
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx/cython/onedim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BurnerFlame

CounterflowDiffusionFlame
^^^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: CounterflowDiffusionFlame(gas, grid=None)
.. autoclass:: CounterflowDiffusionFlame(gas, grid=None, width=None)

CounterflowPremixedFlame
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 2 additions & 4 deletions interfaces/cython/cantera/examples/onedim/diffusion_flame.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
comp_o = 'O2:0.21, N2:0.78, AR:0.01' # air composition
comp_f = 'C2H6:1' # fuel composition

# Distance between inlets is 2 cm.
# Start with an evenly-spaced 6-point grid.
initial_grid = np.linspace(0, 0.02, 6)
width = 0.02 # Distance between inlets is 2 cm

tol_ss = [1.0e-5, 1.0e-12] # [rtol, atol] for steady-state problem
tol_ts = [5.0e-4, 1.0e-11] # [rtol, atol] for time stepping
Expand All @@ -34,7 +32,7 @@
# Create an object representing the counterflow flame configuration,
# which consists of a fuel inlet on the left, the flow in the middle,
# and the oxidizer inlet on the right.
f = ct.CounterflowDiffusionFlame(gas, initial_grid)
f = ct.CounterflowDiffusionFlame(gas, width=width)

# Set the state of the two inlets
f.fuel_inlet.mdot = mdot_f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
# Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain
# rate (maximum axial velocity gradient = 2414 1/s)

# Initial grid: 18mm wide, 21 points
reaction_mechanism = 'h2o2.xml'
gas = ct.Solution(reaction_mechanism)
initial_grid = np.linspace(0.0, 18e-3, 21)
f = ct.CounterflowDiffusionFlame(gas, initial_grid)
width = 18e-3 # 18mm wide
f = ct.CounterflowDiffusionFlame(gas, width=width)

# Define the operating pressure and boundary conditions
f.P = 1.e5 # 1 bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
# Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain
# rate (maximum axial velocity gradient = 2414 1/s)

# Initial grid: 18mm wide, 21 points
reaction_mechanism = 'h2o2.xml'
gas = ct.Solution(reaction_mechanism)
initial_grid = np.linspace(0.0, 18.e-3, 21)
f = ct.CounterflowDiffusionFlame(gas, initial_grid)
width = 18.e-3 # 18mm wide
f = ct.CounterflowDiffusionFlame(gas, width=width)

# Define the operating pressure and boundary conditions
f.P = 1.e5 # 1 bar
Expand Down
12 changes: 10 additions & 2 deletions interfaces/cython/cantera/onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,18 @@ class CounterflowDiffusionFlame(FlameBase):
""" A counterflow diffusion flame """
__slots__ = ('fuel_inlet', 'flame', 'oxidizer_inlet')

def __init__(self, gas, grid=None):
def __init__(self, gas, grid=None, width=None):
"""
:param gas:
`Solution` (using the IdealGas thermodynamic model) used to
evaluate all gas properties and reaction rates.
:param grid:
Array of initial grid points
A list of points to be used as the initial grid. Not recommended
unless solving only on a fixed grid; Use the `width` parameter
instead.
:param width:
Defines a grid on the interval [0, width] with internal points
determined automatically by the solver.
A domain of class `AxisymmetricStagnationFlow` named ``flame`` will
be created to represent the flame. The three domains comprising the
Expand All @@ -527,6 +532,9 @@ def __init__(self, gas, grid=None):

self.flame = AxisymmetricStagnationFlow(gas, name='flame')

if width is not None:
grid = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0]) * width

super(CounterflowDiffusionFlame, self).__init__(
(self.fuel_inlet, self.flame, self.oxidizer_inlet), gas, grid)

Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/test/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class TestDiffusionFlame(utilities.CanteraTest):
def create_sim(self, p, fuel='H2:1.0, AR:1.0', T_fuel=300, mdot_fuel=0.24,
oxidizer='O2:0.2, AR:0.8', T_ox=300, mdot_ox=0.72):

initial_grid = np.linspace(0, 0.02, 6) # m
width = 0.02 # m
tol_ss = [2.0e-5, 1.0e-11] # [rtol, atol] for steady-state problem
tol_ts = [5.0e-4, 1.0e-11] # [rtol, atol] for time stepping

Expand All @@ -396,7 +396,7 @@ def create_sim(self, p, fuel='H2:1.0, AR:1.0', T_fuel=300, mdot_fuel=0.24,
self.gas.TP = T_fuel, p

# Flame object
self.sim = ct.CounterflowDiffusionFlame(self.gas, initial_grid)
self.sim = ct.CounterflowDiffusionFlame(self.gas, width=width)
self.sim.flame.set_steady_tolerances(default=tol_ss)
self.sim.flame.set_transient_tolerances(default=tol_ts)

Expand Down

0 comments on commit 8e81292

Please sign in to comment.