diff --git a/doc/sphinx/cython/onedim.rst b/doc/sphinx/cython/onedim.rst index 0b76f19f1..c67735b5e 100644 --- a/doc/sphinx/cython/onedim.rst +++ b/doc/sphinx/cython/onedim.rst @@ -21,7 +21,7 @@ BurnerFlame CounterflowDiffusionFlame ^^^^^^^^^^^^^^^^^^^^^^^^^ -.. autoclass:: CounterflowDiffusionFlame(gas, grid=None) +.. autoclass:: CounterflowDiffusionFlame(gas, grid=None, width=None) CounterflowPremixedFlame ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/interfaces/cython/cantera/examples/onedim/diffusion_flame.py b/interfaces/cython/cantera/examples/onedim/diffusion_flame.py index 303ec013a..a6b0d6b4e 100644 --- a/interfaces/cython/cantera/examples/onedim/diffusion_flame.py +++ b/interfaces/cython/cantera/examples/onedim/diffusion_flame.py @@ -16,9 +16,7 @@ mdot_f = 0.24 # kg/m^2/s comp_o = 'O2:0.21, N2:0.78, AR:0.01' # air composition comp_f = 'C2H6:1' # fuel composition -# Distance between inlets is 2 cm. -# Start with an evenly-spaced 6-point grid. -initial_grid = np.linspace(0, 0.02, 6) +width = 0.02 # Distance between inlets is 2 cm tol_ss = [1.0e-5, 1.0e-12] # [rtol, atol] for steady-state problem tol_ts = [5.0e-4, 1.0e-11] # [rtol, atol] for time stepping @@ -34,7 +32,7 @@ gas.TP = gas.T, p # Create an object representing the counterflow flame configuration, # which consists of a fuel inlet on the left, the flow in the middle, # and the oxidizer inlet on the right. -f = ct.CounterflowDiffusionFlame(gas, initial_grid) +f = ct.CounterflowDiffusionFlame(gas, width=width) # Set the state of the two inlets f.fuel_inlet.mdot = mdot_f diff --git a/interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py b/interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py index f4c364ba2..f69312797 100644 --- a/interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py +++ b/interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py @@ -36,11 +36,10 @@ refine = True # Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain # rate (maximum axial velocity gradient = 2414 1/s) -# Initial grid: 18mm wide, 21 points reaction_mechanism = 'h2o2.xml' gas = ct.Solution(reaction_mechanism) -initial_grid = np.linspace(0.0, 18e-3, 21) -f = ct.CounterflowDiffusionFlame(gas, initial_grid) +width = 18e-3 # 18mm wide +f = ct.CounterflowDiffusionFlame(gas, width=width) # Define the operating pressure and boundary conditions f.P = 1.e5 # 1 bar diff --git a/interfaces/cython/cantera/examples/onedim/diffusion_flame_extinction.py b/interfaces/cython/cantera/examples/onedim/diffusion_flame_extinction.py index 4707eaabe..38edee4e1 100644 --- a/interfaces/cython/cantera/examples/onedim/diffusion_flame_extinction.py +++ b/interfaces/cython/cantera/examples/onedim/diffusion_flame_extinction.py @@ -29,11 +29,10 @@ if not os.path.exists(data_directory): # Set up an initial hydrogen-oxygen counterflow flame at 1 bar and low strain # rate (maximum axial velocity gradient = 2414 1/s) -# Initial grid: 18mm wide, 21 points reaction_mechanism = 'h2o2.xml' gas = ct.Solution(reaction_mechanism) -initial_grid = np.linspace(0.0, 18.e-3, 21) -f = ct.CounterflowDiffusionFlame(gas, initial_grid) +width = 18.e-3 # 18mm wide +f = ct.CounterflowDiffusionFlame(gas, width=width) # Define the operating pressure and boundary conditions f.P = 1.e5 # 1 bar diff --git a/interfaces/cython/cantera/onedim.py b/interfaces/cython/cantera/onedim.py index 60c534516..86b067dd1 100644 --- a/interfaces/cython/cantera/onedim.py +++ b/interfaces/cython/cantera/onedim.py @@ -506,13 +506,18 @@ class CounterflowDiffusionFlame(FlameBase): """ A counterflow diffusion flame """ __slots__ = ('fuel_inlet', 'flame', 'oxidizer_inlet') - 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 @@ -527,6 +532,9 @@ class CounterflowDiffusionFlame(FlameBase): self.flame = AxisymmetricStagnationFlow(gas, name='flame') + if width is not None: + grid = np.array([0.0, 0.2, 0.4, 0.6, 0.8, 1.0]) * width + super(CounterflowDiffusionFlame, self).__init__( (self.fuel_inlet, self.flame, self.oxidizer_inlet), gas, grid) diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index ad971f5ac..556de177c 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -387,7 +387,7 @@ class TestDiffusionFlame(utilities.CanteraTest): def create_sim(self, p, fuel='H2:1.0, AR:1.0', T_fuel=300, mdot_fuel=0.24, oxidizer='O2:0.2, AR:0.8', T_ox=300, mdot_ox=0.72): - initial_grid = np.linspace(0, 0.02, 6) # m + width = 0.02 # m tol_ss = [2.0e-5, 1.0e-11] # [rtol, atol] for steady-state problem tol_ts = [5.0e-4, 1.0e-11] # [rtol, atol] for time stepping @@ -396,7 +396,7 @@ class TestDiffusionFlame(utilities.CanteraTest): self.gas.TP = T_fuel, p # Flame object - self.sim = ct.CounterflowDiffusionFlame(self.gas, initial_grid) + self.sim = ct.CounterflowDiffusionFlame(self.gas, width=width) self.sim.flame.set_steady_tolerances(default=tol_ss) self.sim.flame.set_transient_tolerances(default=tol_ts)