diff --git a/doc/sphinx/cython/onedim.rst b/doc/sphinx/cython/onedim.rst index 2dac6ddcd..448c1e12f 100644 --- a/doc/sphinx/cython/onedim.rst +++ b/doc/sphinx/cython/onedim.rst @@ -13,7 +13,7 @@ Composite Domains FreeFlame ^^^^^^^^^ -.. autoclass:: FreeFlame(gas, grid=None) +.. autoclass:: FreeFlame(gas, grid=None, width=None) BurnerFlame ^^^^^^^^^^^ diff --git a/interfaces/cython/cantera/examples/onedim/adiabatic_flame.py b/interfaces/cython/cantera/examples/onedim/adiabatic_flame.py index 317cedb00..55e07f184 100644 --- a/interfaces/cython/cantera/examples/onedim/adiabatic_flame.py +++ b/interfaces/cython/cantera/examples/onedim/adiabatic_flame.py @@ -11,7 +11,7 @@ p = ct.one_atm # pressure [Pa] 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) @@ -23,7 +23,7 @@ gas = ct.Solution('h2o2.xml') 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) diff --git a/interfaces/cython/cantera/examples/onedim/flamespeed_sensitivity.py b/interfaces/cython/cantera/examples/onedim/flamespeed_sensitivity.py index 4ea22a76b..21938b116 100644 --- a/interfaces/cython/cantera/examples/onedim/flamespeed_sensitivity.py +++ b/interfaces/cython/cantera/examples/onedim/flamespeed_sensitivity.py @@ -14,7 +14,7 @@ p = ct.one_atm # pressure [Pa] 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 @@ -23,7 +23,7 @@ gas = ct.Solution('gri30.xml', 'gri30_mix') 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) diff --git a/interfaces/cython/cantera/onedim.py b/interfaces/cython/cantera/onedim.py index 480713c60..d06d84903 100644 --- a/interfaces/cython/cantera/onedim.py +++ b/interfaces/cython/cantera/onedim.py @@ -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) diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index a86103a15..230a51170 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -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)