def test_ion_profile(self): reactants = 'CH4:0.216, O2:2' p = ct.one_atm Tin = 300 width = 0.03 # Solution object used to compute mixture properties self.gas = ct.Solution('ch4_ion.cti') self.gas.TPX = Tin, p, reactants self.sim = ct.IonFreeFlame(self.gas, width=width) self.sim.set_refine_criteria(ratio=4, slope=0.8, curve=1.0) # Ionized species may require tighter absolute tolerances self.sim.flame.set_steady_tolerances(Y=(1e-4, 1e-12)) self.sim.transport_model = 'Ion' # stage one self.sim.solve(loglevel=0, auto=True) #stage two self.sim.solve(loglevel=0, stage=2, enable_energy=True) # Regression test self.assertNear(max(self.sim.E), 142.2677, 1e-3)
import cantera as ct # Simulation parameters p = ct.one_atm # pressure [Pa] Tin = 300.0 # unburned gas temperature [K] reactants = 'CH4:1, O2:2, N2:7.52' # premixed gas composition width = 0.05 # m loglevel = 1 # amount of diagnostic output (0 to 8) # Solution object used to compute mixture properties, set to the state of the # upstream fuel-air mixture gas = ct.Solution('gri30_ion.yaml') gas.TPX = Tin, p, reactants # Set up flame object f = ct.IonFreeFlame(gas, width=width) f.set_refine_criteria(ratio=3, slope=0.05, curve=0.1) f.show_solution() # stage one f.solve(loglevel=loglevel, auto=True) # stage two f.solve(loglevel=loglevel, stage=2, enable_energy=True) f.save('CH4_adiabatic.xml', 'ion', 'solution with ionized gas transport') f.show_solution() print('mixture-averaged flamespeed = {0:7f} m/s'.format(f.u[0])) # write the velocity, temperature, density, and mole fractions to a CSV file f.write_csv('CH4_adiabatic.csv', quiet=False)