diff --git a/interfaces/cython/cantera/onedim.pyx b/interfaces/cython/cantera/onedim.pyx index b8d73697b..8f0b9da21 100644 --- a/interfaces/cython/cantera/onedim.pyx +++ b/interfaces/cython/cantera/onedim.pyx @@ -801,13 +801,15 @@ cdef class Sim1D: class FlameBase(Sim1D): """ Base class for flames with a single flow domain """ - def __init__(self, domains, gas, grid): + def __init__(self, domains, gas, grid=None): """ :param gas: object to use to evaluate all gas properties and reaction rates :param grid: array of initial grid points """ + if grid is None: + grid = np.linspace(0.0, 0.1, 6) self.flame.grid = grid super().__init__(domains) self.gas = gas @@ -1009,7 +1011,7 @@ for attr in ['forward_rates_of_progress', 'reverse_rates_of_progress', 'net_rate class FreeFlame(FlameBase): """A freely-propagating flat flame.""" - def __init__(self, gas, grid): + def __init__(self, gas, grid=None): """ A domain of type FreeFlow named 'flame' will be created to represent the flame. The three domains comprising the stack are stored as @@ -1053,7 +1055,7 @@ class FreeFlame(FlameBase): class BurnerFlame(FlameBase): """A burner-stabilized flat flame.""" - def __init__(self, gas, grid): + def __init__(self, gas, grid=None): """ :param gas: `Solution` (using the IdealGas thermodynamic model) used to @@ -1105,7 +1107,7 @@ class BurnerFlame(FlameBase): class CounterflowDiffusionFlame(FlameBase): """ A counterflow diffusion flame """ - def __init__(self, gas, grid): + def __init__(self, gas, grid=None): """ :param gas: `Solution` (using the IdealGas thermodynamic model) used to @@ -1217,7 +1219,7 @@ class CounterflowDiffusionFlame(FlameBase): class ImpingingJet(FlameBase): """An axisymmetric flow impinging on a surface at normal incidence.""" - def __init__(self, gas, grid, surface=None): + def __init__(self, gas, grid=None, surface=None): """ :param gas: `Solution` (using the IdealGas thermodynamic model) used to diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index 8943a3366..2a9f16c4d 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -49,11 +49,12 @@ class TestOnedim(utilities.CanteraTest): class TestFreeFlame(utilities.CanteraTest): + 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 + def create_sim(self, p, Tin, reactants): initial_grid = [0.0, 0.001, 0.01, 0.02, 0.029, 0.03] # 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 # IdealGasMix object used to compute mixture properties self.gas = ct.Solution('h2o2.xml') @@ -61,8 +62,8 @@ class TestFreeFlame(utilities.CanteraTest): # Flame object self.sim = ct.FreeFlame(self.gas, initial_grid) - self.sim.flame.set_steady_tolerances(default=tol_ss) - self.sim.flame.set_transient_tolerances(default=tol_ts) + self.sim.flame.set_steady_tolerances(default=self.tol_ss) + self.sim.flame.set_transient_tolerances(default=self.tol_ts) # Set properties of the upstream fuel-air mixture self.sim.inlet.T = Tin @@ -212,8 +213,11 @@ class TestFreeFlame(utilities.CanteraTest): self.sim.save(filename, 'test', loglevel=0) - self.create_sim(ct.one_atm, Tin, reactants) - self.sim.energy_enabled = False + # Create flame object with dummy initial grid + self.sim = ct.FreeFlame(self.gas) + self.sim.flame.set_steady_tolerances(default=self.tol_ss) + self.sim.flame.set_transient_tolerances(default=self.tol_ts) + self.sim.restore(filename, 'test', loglevel=0) P2a = self.sim.P