print(sample_header) # Gas model setup gmodel = GasModel("h2-o2-n2-5sp.lua") nsp = gmodel.n_species nmodes = gmodel.n_modes if debug: print("nsp=", nsp, " nmodes=", nmodes, " gmodel=", gmodel) print("# Gas properties at the start of the pipe.") gas0 = GasState(gmodel) gas0.p = 81.0e3 # Pa x = 0.0 # m (inlet of duct) area = duct_area(x) v = 1230.0 # m/s gas0.T = 1900.0 # degree K gas0.molef = {"O2":0.1865, "N2":0.7016, "H2":0.1119} gas0.update_thermo_from_pT() dt_suggest = 1.0e-12 # suggested starting time-step for chemistry print(sample_data(x, area, v, gas0, dt_suggest)) if debug: print("# species=", gmodel.species_names) print("# massf=", gas0.massf) print("# Start reactions...") reactor = ThermochemicalReactor(gmodel, "h2-o2-n2-5sp-2r.lua") t = 0 # time is in seconds t_final = 1.15e-3 # long enough to convect past exit t_inc = 0.005e-6 # start small t_inc_max = 0.05e-6 x_end = 2.0
print("# Reacting pipe flow -- Bittker-Scullin test case 3.") print(sample_header) # Gas model setup gmodel = GasModel("h2-o2-n2-9sp.lua") nsp = gmodel.n_species nmodes = gmodel.n_modes if debug: print("nsp=", nsp, " nmodes=", nmodes, " gmodel=", gmodel) print("# Gas properties at the start of the pipe.") gas0 = GasState(gmodel) gas0.p = 96.87e3 # Pa x = 0.0 # m (inlet of pipe) v = 4551.73 # m/s gas0.T = 1559.0 # degree K gas0.molef = {"O2": 0.1480, "N2": 0.5562, "H2": 0.2958} gas0.update_thermo_from_pT() dt_suggest = 1.0e-8 # suggested starting time-step for chemistry updater print(sample_data(x, v, gas0, dt_suggest)) print("# Start reactions...") reactor = ThermochemicalReactor(gmodel, "h2-o2-n2-9sp-18r.lua") t = 0 # time is in seconds t_final = 22.0e-6 t_inc = 0.05e-6 nsteps = int(t_final / t_inc) for j in range(1, nsteps + 1): # At the start of the step... rho = gas0.rho T = gas0.T p = gas0.p
# To prepare: # $ prep-gas nitrogen-2sp.inp nitrogen-2sp.lua # $ prep-chem nitrogen-2sp.lua nitrogen-2sp-2r.lua chem.lua # # To run: # $ python3 fvreactor.py from eilmer.gas import GasModel, GasState, ThermochemicalReactor gm = GasModel("nitrogen-2sp.lua") reactor = ThermochemicalReactor(gm, "chem.lua") gs = GasState(gm) gs.p = 1.0e5 # Pa gs.T = 4000.0 # degree K gs.molef = {'N2': 2 / 3, 'N': 1 / 3} gs.update_thermo_from_pT() tFinal = 200.0e-6 # s t = 0.0 dt = 1.0e-6 dtSuggest = 1.0e-11 print("# Start integration") f = open("fvreactor.data", 'w') f.write( '# 1:t(s) 2:T(K) 3:p(Pa) 4:massf_N2 5:massf_N 6:conc_N2 7:conc_N\n') f.write("%10.3e %10.3f %10.3e %20.12e %20.12e %20.12e %20.12e\n" % (t, gs.T, gs.p, gs.massf[0], gs.massf[1], gs.conc[0], gs.conc[1])) while t <= tFinal: dtSuggest = reactor.update_state(gs, dt, dtSuggest) t = t + dt