[1D] Use a better default initial grid for FreeFlame

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.
This commit is contained in:
Ray Speth 2015-12-04 13:18:18 -05:00
parent 7484827f2b
commit de8348ecb2
5 changed files with 18 additions and 10 deletions

View file

@ -13,7 +13,7 @@ Composite Domains
FreeFlame FreeFlame
^^^^^^^^^ ^^^^^^^^^
.. autoclass:: FreeFlame(gas, grid=None) .. autoclass:: FreeFlame(gas, grid=None, width=None)
BurnerFlame BurnerFlame
^^^^^^^^^^^ ^^^^^^^^^^^

View file

@ -11,7 +11,7 @@ p = ct.one_atm # pressure [Pa]
Tin = 300.0 # unburned gas temperature [K] Tin = 300.0 # unburned gas temperature [K]
reactants = 'H2:1.1, O2:1, AR:5' # premixed gas composition 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_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 tol_ts = [1.0e-4, 1.0e-13] # [rtol atol] for time stepping
loglevel = 1 # amount of diagnostic output (0 to 8) loglevel = 1 # amount of diagnostic output (0 to 8)
@ -23,7 +23,7 @@ gas = ct.Solution('h2o2.xml')
gas.TPX = Tin, p, reactants gas.TPX = Tin, p, reactants
# Flame object # 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_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts) f.flame.set_transient_tolerances(default=tol_ts)

View file

@ -14,7 +14,7 @@ p = ct.one_atm # pressure [Pa]
Tin = 300.0 # unburned gas temperature [K] Tin = 300.0 # unburned gas temperature [K]
reactants = 'CH4:0.45, O2:1.0, N2:3.76' 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_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 tol_ts = [1.0e-5, 1.0e-14] # [rtol atol] for time stepping
@ -23,7 +23,7 @@ gas = ct.Solution('gri30.xml', 'gri30_mix')
gas.TPX = Tin, p, reactants gas.TPX = Tin, p, reactants
# Flame object # 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_steady_tolerances(default=tol_ss)
f.flame.set_transient_tolerances(default=tol_ts) f.flame.set_transient_tolerances(default=tol_ts)

View file

@ -363,16 +363,27 @@ class FreeFlame(FlameBase):
"""A freely-propagating flat flame.""" """A freely-propagating flat flame."""
__slots__ = ('inlet', 'outlet', '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 A domain of type FreeFlow named 'flame' will be created to represent
the flame. The three domains comprising the stack are stored as the flame. The three domains comprising the stack are stored as
``self.inlet``, ``self.flame``, and ``self.outlet``. ``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.inlet = Inlet1D(name='reactants', phase=gas)
self.outlet = Outlet1D(name='products', phase=gas) self.outlet = Outlet1D(name='products', phase=gas)
self.flame = FreeFlow(gas, name='flame') 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), super(FreeFlame, self).__init__((self.inlet, self.flame, self.outlet),
gas, grid) gas, grid)

View file

@ -92,15 +92,12 @@ class TestFreeFlame(utilities.CanteraTest):
tol_ts = [1.0e-4, 1.0e-11] # [rtol atol] for time stepping tol_ts = [1.0e-4, 1.0e-11] # [rtol atol] for time stepping
def create_sim(self, p, Tin, reactants, mech='h2o2.xml'): 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 # IdealGasMix object used to compute mixture properties
self.gas = ct.Solution(mech) self.gas = ct.Solution(mech)
self.gas.TPX = Tin, p, reactants self.gas.TPX = Tin, p, reactants
# Flame object # 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_steady_tolerances(default=self.tol_ss)
self.sim.flame.set_transient_tolerances(default=self.tol_ts) self.sim.flame.set_transient_tolerances(default=self.tol_ts)