Hi Robert,
Thanks for the interesting question. This calculation can be done using the CounterflowPremixedFlame class. While the default behavior is to use equilibrium products of the reactant flow, a different counterflow mixture can be specified. The key steps are to define the composition and temperature of the products object, and to call the set_initial_guess method with the equilibrate=False option to avoid the default behavior. Here’s a complete example of a lean-lean flame:
from pathlib import Path import cantera as ct import numpy as np # parameter values p = ct.one_atm # pressure T_in = 300.0 # inlet temperature mdot_reactants = 3.0 # kg/m^2/s mdot_products = 2.0 # kg/m^2/s rxnmech = 'gri30.yaml' # reaction mechanism file fuel = 'CH4:1.0' ox = 'O2:1.0, N2:3.76' phi_r = 0.8 # unburned reactants equivalence ratio phi_p = 0.5 # burned products equivalence ratio width = 0.02 # m loglevel = 1 # amount of diagnostic output (0 to 5) # Set up the problem gas = ct.Solution(rxnmech) # set unburned mixture gas.TP = T_in, p gas.set_equivalence_ratio(phi_r, fuel, ox) # Create the flame simulation object sim = ct.CounterflowPremixedFlame(gas=gas, grid=np.linspace(0, width, 20)) # Set products composition gas.TP = T_in, p gas.set_equivalence_ratio(phi_p, fuel, ox) gas.equilibrate('HP') sim.products.T = gas.T sim.products.Y = gas.Y # set the boundary flow rates sim.reactants.mdot = mdot_reactants sim.products.mdot = mdot_products # Use pre-defined products composition and temperature sim.set_initial_guess(equilibrate=False) # Set grid refinement parameters sim.set_refine_criteria(ratio=3, slope=0.08, curve=0.15, prune=0.02) sim.solve(loglevel, auto=True)And to get the equivalence ratio at each point, you can just loop over the states using the set_gas_state method:
phi = np.zeros(sim.grid.shape) for j in range(len(sim.grid)): sim.set_gas_state(j) phi[j] = gas.equivalence_ratio(fuel=fuel, oxidizer=ox)Regards,
Ray