Skip to content

Commit

Permalink
[1D] Better initial grid for CounterflowPremixedFlame
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Mar 25, 2016
1 parent a9293c3 commit f0a1e25
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 77 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx/cython/onedim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CounterflowDiffusionFlame

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

ImpingingJet
^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def solve_flame(gas):
gas.TPX = 373, 0.05*ct.one_atm, 'H2:0.4, CO:0.6, O2:1, N2:3.76'

# Create the flame simulation object
sim = ct.CounterflowPremixedFlame(gas=gas, grid=np.linspace(0.0, 0.2, 10))
sim = ct.CounterflowPremixedFlame(gas=gas, width=0.2)

sim.reactants.mdot = 0.12 # kg/m^2/s
sim.products.mdot = 0.06 # kg/m^2/s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
rxnmech = 'h2o2.cti' # reaction mechanism file
comp = 'H2:1.6, O2:1, AR:7' # premixed gas composition

initial_grid = np.linspace(0.0, 0.2, 12) # m
width = 0.2 # m
tol_ss = [1.0e-7, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-7, 1.0e-11] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 5)
Expand All @@ -35,7 +35,7 @@
gas.TPX = T_in, p, comp

# Create the flame simulation object
sim = ct.CounterflowPremixedFlame(gas=gas, grid=initial_grid)
sim = ct.CounterflowPremixedFlame(gas=gas, width=width)

# set the boundary flow rates
sim.reactants.mdot = mdot_reactants
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 @@ -834,13 +834,17 @@ class CounterflowPremixedFlame(FlameBase):
""" A premixed counterflow flame """
__slots__ = ('reactants', 'flame', 'products')

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
Array of initial grid points. 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 @@ -855,6 +859,10 @@ def __init__(self, gas, grid=None):

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

if width is not None:
# Create grid points aligned with initial guess profile
grid = np.array([0.0, 0.3, 0.5, 0.7, 1.0]) * width

super(CounterflowPremixedFlame, self).__init__(
(self.reactants, self.flame, self.products), 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 @@ -533,9 +533,9 @@ def test_mixture_averaged(self, saveReference=False):

gas = ct.Solution('h2o2.xml')
gas.TPX = T_in, 0.05 * ct.one_atm, comp
initial_grid = np.linspace(0.0, 0.2, 12) # m
width = 0.2 # m

sim = ct.CounterflowPremixedFlame(gas=gas, grid=initial_grid)
sim = ct.CounterflowPremixedFlame(gas=gas, width=width)

# set the properties at the inlets
sim.reactants.mdot = 0.12 # kg/m^2/s
Expand Down
Loading

0 comments on commit f0a1e25

Please sign in to comment.