From 87a841938006710bcf1be642623b1d3b6b4f667d Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 13 Mar 2016 23:41:56 -0400 Subject: [PATCH] [1D] Provide reasonable initial grid for BurnerFlame --- doc/sphinx/cython/onedim.rst | 2 +- .../cython/cantera/examples/onedim/burner_flame.py | 4 ++-- .../cython/cantera/examples/onedim/flame_fixed_T.py | 4 ++-- interfaces/cython/cantera/onedim.py | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/sphinx/cython/onedim.rst b/doc/sphinx/cython/onedim.rst index 424372142..0b76f19f1 100644 --- a/doc/sphinx/cython/onedim.rst +++ b/doc/sphinx/cython/onedim.rst @@ -17,7 +17,7 @@ FreeFlame BurnerFlame ^^^^^^^^^^^ -.. autoclass:: BurnerFlame(gas, grid=None) +.. autoclass:: BurnerFlame(gas, grid=None, width=None) CounterflowDiffusionFlame ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/interfaces/cython/cantera/examples/onedim/burner_flame.py b/interfaces/cython/cantera/examples/onedim/burner_flame.py index 3a23fe440..4d30e2fce 100644 --- a/interfaces/cython/cantera/examples/onedim/burner_flame.py +++ b/interfaces/cython/cantera/examples/onedim/burner_flame.py @@ -10,7 +10,7 @@ tburner = 373.0 mdot = 0.06 reactants = 'H2:1.5, O2:1, AR:7' # premixed gas composition -initial_grid = np.linspace(0.0, 0.5, 10) # m +width = 0.5 # m tol_ss = [1.0e-5, 1.0e-13] # [rtol atol] for steady-state problem tol_ts = [1.0e-4, 1.0e-10] # [rtol atol] for time stepping loglevel = 1 # amount of diagnostic output (0 to 5) @@ -19,7 +19,7 @@ refine_grid = 1 # 1 to enable refinement, 0 to disable gas = ct.Solution('h2o2.xml') gas.TPX = tburner, p, reactants -f = ct.BurnerFlame(gas, initial_grid) +f = ct.BurnerFlame(gas, width=width) f.burner.mdot = mdot f.set_initial_guess() diff --git a/interfaces/cython/cantera/examples/onedim/flame_fixed_T.py b/interfaces/cython/cantera/examples/onedim/flame_fixed_T.py index 05a08459d..6b68fa9a8 100644 --- a/interfaces/cython/cantera/examples/onedim/flame_fixed_T.py +++ b/interfaces/cython/cantera/examples/onedim/flame_fixed_T.py @@ -14,7 +14,7 @@ mdot = 0.04 # kg/m^2/s comp = 'CH4:0.65, O2:1, N2:3.76' # premixed gas composition # The solution domain is chosen to be 1 cm -initial_grid = np.linspace(0.0, 0.01, 6) # m +width = 0.01 # m tol_ss = [1.0e-5, 1.0e-9] # [rtol atol] for steady-state problem tol_ts = [1.0e-5, 1.0e-4] # [rtol atol] for time stepping @@ -33,7 +33,7 @@ gas = ct.Solution('gri30.xml', 'gri30_mix') gas.TPX = tburner, p, comp # create the BurnerFlame object. -f = ct.BurnerFlame(gas=gas, grid=initial_grid) +f = ct.BurnerFlame(gas=gas, width=width) # set the mass flow rate at the burner f.burner.mdot = mdot diff --git a/interfaces/cython/cantera/onedim.py b/interfaces/cython/cantera/onedim.py index f4a19e855..60c534516 100644 --- a/interfaces/cython/cantera/onedim.py +++ b/interfaces/cython/cantera/onedim.py @@ -441,13 +441,18 @@ class BurnerFlame(FlameBase): """A burner-stabilized flat flame.""" __slots__ = ('burner', 'flame', 'outlet') - 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 @@ -458,6 +463,9 @@ class BurnerFlame(FlameBase): self.outlet = Outlet1D(name='outlet', phase=gas) self.flame = AxisymmetricStagnationFlow(gas, name='flame') + if width is not None: + grid = np.array([0.0, 0.1, 0.2, 0.3, 0.5, 0.7, 1.0]) * width + super(BurnerFlame, self).__init__((self.burner, self.flame, self.outlet), gas, grid)