Skip to content

Commit

Permalink
[1D] Use a better default initial grid for FreeFlame
Browse files Browse the repository at this point in the history
This initial grid is designed to work well with how the initial profile and
temperature fixed point are set. The only parameter that needs to be
user-specified is the width of the domain.
  • Loading branch information
speth committed Mar 25, 2016
1 parent 7484827 commit de8348e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx/cython/onedim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Composite Domains

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

BurnerFlame
^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions interfaces/cython/cantera/examples/onedim/adiabatic_flame.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Tin = 300.0 # unburned gas temperature [K]
reactants = 'H2:1.1, O2:1, AR:5' # premixed gas composition

initial_grid = np.linspace(0.0, 0.03, 7) # m
width = 0.03 # m
tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state problem
tol_ts = [1.0e-4, 1.0e-13] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 8)
Expand All @@ -23,7 +23,7 @@
gas.TPX = Tin, p, reactants

# Flame object
f = ct.FreeFlame(gas, initial_grid)
f = ct.FreeFlame(gas, width=width)
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Tin = 300.0 # unburned gas temperature [K]
reactants = 'CH4:0.45, O2:1.0, N2:3.76'

initial_grid = np.linspace(0, 0.03, 5) # m
width = 0.03 # m
tol_ss = [1.0e-9, 1.0e-14] # [rtol atol] for steady-state problem
tol_ts = [1.0e-5, 1.0e-14] # [rtol atol] for time stepping

Expand All @@ -23,7 +23,7 @@
gas.TPX = Tin, p, reactants

# Flame object
f = ct.FreeFlame(gas, initial_grid)
f = ct.FreeFlame(gas, width=width)
f.flame.set_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts)

Expand Down
13 changes: 12 additions & 1 deletion interfaces/cython/cantera/onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,27 @@ class FreeFlame(FlameBase):
"""A freely-propagating flat flame."""
__slots__ = ('inlet', 'outlet', 'flame')

def __init__(self, gas, grid=None):
def __init__(self, gas, grid=None, width=None):
"""
A domain of type FreeFlow named 'flame' will be created to represent
the flame. The three domains comprising the stack are stored as
``self.inlet``, ``self.flame``, and ``self.outlet``.
:param grid:
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.
"""
self.inlet = Inlet1D(name='reactants', phase=gas)
self.outlet = Outlet1D(name='products', phase=gas)
self.flame = FreeFlow(gas, name='flame')

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

super(FreeFlame, self).__init__((self.inlet, self.flame, self.outlet),
gas, grid)

Expand Down
5 changes: 1 addition & 4 deletions interfaces/cython/cantera/test/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,12 @@ class TestFreeFlame(utilities.CanteraTest):
tol_ts = [1.0e-4, 1.0e-11] # [rtol atol] for time stepping

def create_sim(self, p, Tin, reactants, mech='h2o2.xml'):

initial_grid = [0.0, 0.001, 0.01, 0.02, 0.029, 0.03] # m

# IdealGasMix object used to compute mixture properties
self.gas = ct.Solution(mech)
self.gas.TPX = Tin, p, reactants

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

Expand Down

0 comments on commit de8348e

Please sign in to comment.