Skip to content

Commit bcaaa35

Browse files
committed
Chemistry Bug Fixes
1 parent 8230af1 commit bcaaa35

File tree

13 files changed

+474
-21
lines changed

13 files changed

+474
-21
lines changed

examples/1D_Dilution_Flame/li.yaml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
description: |-
2+
""
3+
4+
generator: cti2yaml
5+
cantera-version: 3.1.0
6+
date: Thu, 10 Apr 2025 09:43:38 -0500
7+
input-files: [li.cti]
8+
9+
units: {length: cm, quantity: mol, activation-energy: cal/mol}
10+
11+
phases:
12+
- name: gas
13+
thermo: ideal-gas
14+
elements: [H, O, N]
15+
species: [H, H2, O, OH, H2O, N2, O2, HO2, H2O2]
16+
kinetics: gas
17+
reactions: all
18+
transport: multicomponent
19+
state:
20+
T: 300.0
21+
P: 1.01325e+05
22+
23+
species:
24+
- name: H
25+
composition: {H: 1}
26+
thermo:
27+
model: NASA7
28+
temperature-ranges: [300.0, 1000.0, 5000.0]
29+
data:
30+
- [2.5, 0.0, 0.0, 0.0, 0.0, 2.547163e+04, -0.4601176]
31+
- [2.5, 0.0, 0.0, 0.0, 0.0, 2.547163e+04, -0.4601176]
32+
transport:
33+
model: gas
34+
geometry: atom
35+
diameter: 2.05
36+
well-depth: 145.0
37+
note: '120186'
38+
- name: H2
39+
composition: {H: 2}
40+
thermo:
41+
model: NASA7
42+
temperature-ranges: [300.0, 1000.0, 5000.0]
43+
data:
44+
- [3.298124, 8.249442e-04, -8.143015e-07, -9.475434e-11, 4.134872e-13,
45+
-1012.521, -3.294094]
46+
- [2.991423, 7.000644e-04, -5.633829e-08, -9.231578e-12, 1.582752e-15,
47+
-835.034, -1.35511]
48+
transport:
49+
model: gas
50+
geometry: linear
51+
diameter: 2.92
52+
well-depth: 38.0
53+
polarizability: 0.79
54+
rotational-relaxation: 280.0
55+
note: '121286'
56+
- name: O
57+
composition: {O: 1}
58+
thermo:
59+
model: NASA7
60+
temperature-ranges: [300.0, 1000.0, 5000.0]
61+
data:
62+
- [2.946429, -1.638166e-03, 2.421032e-06, -1.602843e-09, 3.890696e-13,
63+
2.914764e+04, 2.963995]
64+
- [2.54206, -2.755062e-05, -3.102803e-09, 4.551067e-12, -4.368052e-16,
65+
2.92308e+04, 4.920308]
66+
transport:
67+
model: gas
68+
geometry: atom
69+
diameter: 2.75
70+
well-depth: 80.0
71+
note: '120186'
72+
- name: OH
73+
composition: {H: 1, O: 1}
74+
thermo:
75+
model: NASA7
76+
temperature-ranges: [200.0, 1000.0, 6000.0]
77+
data:
78+
- [4.12530561, -3.22544939e-03, 6.52764691e-06, -5.79853643e-09, 2.06237379e-12,
79+
3346.30913, -0.69043296]
80+
- [2.86472886, 1.05650448e-03, -2.59082758e-07, 3.05218674e-11, -1.33195876e-15,
81+
3683.62875, 5.70164073]
82+
transport:
83+
model: gas
84+
geometry: linear
85+
diameter: 2.75
86+
well-depth: 80.0
87+
note: S9/01
88+
- name: H2O
89+
composition: {H: 2, O: 1}
90+
thermo:
91+
model: NASA7
92+
temperature-ranges: [300.0, 1000.0, 5000.0]
93+
data:
94+
- [3.386842, 3.474982e-03, -6.354696e-06, 6.968581e-09, -2.506588e-12,
95+
-3.020811e+04, 2.590233]
96+
- [2.672146, 3.056293e-03, -8.73026e-07, 1.200996e-10, -6.391618e-15,
97+
-2.989921e+04, 6.862817]
98+
transport:
99+
model: gas
100+
geometry: nonlinear
101+
diameter: 2.605
102+
well-depth: 572.4
103+
dipole: 1.844
104+
rotational-relaxation: 4.0
105+
note: '20387'
106+
- name: N2
107+
composition: {N: 2}
108+
thermo:
109+
model: NASA7
110+
temperature-ranges: [300.0, 1000.0, 5000.0]
111+
data:
112+
- [3.298677, 1.40824e-03, -3.963222e-06, 5.641515e-09, -2.444855e-12,
113+
-1020.9, 3.950372]
114+
- [2.92664, 1.487977e-03, -5.684761e-07, 1.009704e-10, -6.753351e-15,
115+
-922.7977, 5.980528]
116+
transport:
117+
model: gas
118+
geometry: linear
119+
diameter: 3.62
120+
well-depth: 97.53
121+
polarizability: 1.76
122+
rotational-relaxation: 4.0
123+
note: '121286'
124+
- name: O2
125+
composition: {O: 2}
126+
thermo:
127+
model: NASA7
128+
temperature-ranges: [300.0, 1000.0, 5000.0]
129+
data:
130+
- [3.212936, 1.127486e-03, -5.75615e-07, 1.313877e-09, -8.768554e-13,
131+
-1005.249, 6.034738]
132+
- [3.697578, 6.135197e-04, -1.258842e-07, 1.775281e-11, -1.136435e-15,
133+
-1233.93, 3.189166]
134+
transport:
135+
model: gas
136+
geometry: linear
137+
diameter: 3.458
138+
well-depth: 107.4
139+
polarizability: 1.6
140+
rotational-relaxation: 3.8
141+
note: '121386'
142+
- name: HO2
143+
composition: {H: 1, O: 2}
144+
thermo:
145+
model: NASA7
146+
temperature-ranges: [200.0, 1000.0, 3500.0]
147+
data:
148+
- [4.30179801, -4.74912051e-03, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12,
149+
294.80804, 3.71666245]
150+
- [4.0172109, 2.23982013e-03, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14,
151+
111.856713, 3.78510215]
152+
transport:
153+
model: gas
154+
geometry: nonlinear
155+
diameter: 3.458
156+
well-depth: 107.4
157+
rotational-relaxation: 1.0
158+
note: L5/89
159+
- name: H2O2
160+
composition: {H: 2, O: 2}
161+
thermo:
162+
model: NASA7
163+
temperature-ranges: [300.0, 1000.0, 5000.0]
164+
data:
165+
- [3.388754, 6.569226e-03, -1.485013e-07, -4.625806e-09, 2.471515e-12,
166+
-1.766315e+04, 6.785363]
167+
- [4.573167, 4.336136e-03, -1.474689e-06, 2.348904e-10, -1.431654e-14,
168+
-1.800696e+04, 0.501137]
169+
transport:
170+
model: gas
171+
geometry: nonlinear
172+
diameter: 3.458
173+
well-depth: 107.4
174+
rotational-relaxation: 3.8
175+
note: '120186'
176+
177+
reactions:
178+
- equation: H + O2 <=> O + OH # Reaction 1
179+
rate-constant: {A: 3.547e+15, b: -0.406, Ea: 1.6599e+04}
180+
- equation: O + H2 <=> H + OH # Reaction 2
181+
rate-constant: {A: 5.08e+04, b: 2.67, Ea: 6290.0}
182+
- equation: H2 + OH <=> H2O + H # Reaction 3
183+
rate-constant: {A: 2.16e+08, b: 1.51, Ea: 3430.0}
184+
- equation: O + H2O <=> OH + OH # Reaction 4
185+
rate-constant: {A: 2.97e+06, b: 2.02, Ea: 1.34e+04}
186+
- equation: H2 + M <=> H + H + M # Reaction 5
187+
type: three-body
188+
rate-constant: {A: 4.577e+19, b: -1.4, Ea: 1.0438e+05}
189+
efficiencies: {H2: 2.5, H2O: 12.0}
190+
- equation: O + O + M <=> O2 + M # Reaction 6
191+
type: three-body
192+
rate-constant: {A: 6.165e+15, b: -0.5, Ea: 0.0}
193+
efficiencies: {H2: 2.5, H2O: 12.0}
194+
- equation: O + H + M <=> OH + M # Reaction 7
195+
type: three-body
196+
rate-constant: {A: 4.714e+18, b: -1.0, Ea: 0.0}
197+
efficiencies: {H2: 2.5, H2O: 12.0}
198+
- equation: H + OH + M <=> H2O + M # Reaction 8
199+
type: three-body
200+
rate-constant: {A: 3.8e+22, b: -2.0, Ea: 0.0}
201+
efficiencies: {H2: 2.5, H2O: 12.0}
202+
- equation: H + O2 (+ M) <=> HO2 (+ M) # Reaction 9
203+
type: falloff
204+
low-P-rate-constant: {A: 6.366e+20, b: -1.72, Ea: 524.8}
205+
high-P-rate-constant: {A: 1.475e+12, b: 0.6, Ea: 0.0}
206+
Troe: {A: 0.8, T3: 1.0e-30, T1: 1.0e+30}
207+
efficiencies: {H2: 2.0, H2O: 11.0, O2: 0.78}
208+
- equation: HO2 + H <=> H2 + O2 # Reaction 10
209+
rate-constant: {A: 1.66e+13, b: 0.0, Ea: 823.0}
210+
- equation: HO2 + H <=> OH + OH # Reaction 11
211+
rate-constant: {A: 7.079e+13, b: 0.0, Ea: 295.0}
212+
- equation: HO2 + O <=> O2 + OH # Reaction 12
213+
rate-constant: {A: 3.25e+13, b: 0.0, Ea: 0.0}
214+
- equation: HO2 + OH <=> H2O + O2 # Reaction 13
215+
rate-constant: {A: 2.89e+13, b: 0.0, Ea: -497.0}
216+
- equation: HO2 + HO2 <=> H2O2 + O2 # Reaction 14
217+
rate-constant: {A: 4.2e+14, b: 0.0, Ea: 1.1982e+04}
218+
duplicate: true
219+
- equation: HO2 + HO2 <=> H2O2 + O2 # Reaction 15
220+
rate-constant: {A: 1.3e+11, b: 0.0, Ea: -1629.3}
221+
duplicate: true
222+
- equation: H2O2 (+ M) <=> OH + OH (+ M) # Reaction 16
223+
type: falloff
224+
low-P-rate-constant: {A: 1.202e+17, b: 0.0, Ea: 4.55e+04}
225+
high-P-rate-constant: {A: 2.951e+14, b: 0.0, Ea: 4.843e+04}
226+
Troe: {A: 0.5, T3: 1.0e-30, T1: 1.0e+30}
227+
efficiencies: {H2: 2.5, H2O: 12.0}
228+
- equation: H2O2 + H <=> H2O + OH # Reaction 17
229+
rate-constant: {A: 2.41e+13, b: 0.0, Ea: 3970.0}
230+
- equation: H2O2 + H <=> HO2 + H2 # Reaction 18
231+
rate-constant: {A: 4.82e+13, b: 0.0, Ea: 7950.0}
232+
- equation: H2O2 + O <=> OH + HO2 # Reaction 19
233+
rate-constant: {A: 9.55e+06, b: 2.0, Ea: 3970.0}
234+
- equation: H2O2 + OH <=> HO2 + H2O # Reaction 20
235+
rate-constant: {A: 1.0e+12, b: 0.0, Ea: 0.0}
236+
duplicate: true
237+
- equation: H2O2 + OH <=> HO2 + H2O # Reaction 21
238+
rate-constant: {A: 5.8e+14, b: 0.0, Ea: 9557.0}
239+
duplicate: true

examples/1D_New_React/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 1D Multi-Component Reactive Shock Tube
2+
3+
References:
4+
> P. J. Martínez Ferrer, R. Buttay, G. Lehnasch, and A. Mura, “A detailed verification procedure for compressible reactive multicomponent Navier–Stokes solvers”, Comput. & Fluids, vol. 89, pp. 88–110, Jan. 2014. Accessed: Oct. 13, 2024. [Online]. Available: https://doi.org/10.1016/j.compfluid.2013.10.014
5+
6+
> H. Chen, C. Si, Y. Wu, H. Hu, and Y. Zhu, “Numerical investigation of the effect of equivalence ratio on the propagation characteristics and performance of rotating detonation engine”, Int. J. Hydrogen Energy, Mar. 2023. Accessed: Oct. 13, 2024. [Online]. Available: https://doi.org/10.1016/j.ijhydene.2023.03.190
7+
8+
## Initial Condition
9+
10+
<img src="initial.png" height="MAX_HEIGHT"/>
11+
12+
## Results
13+
14+
<img src="result.png" height="MAX_HEIGHT"/>

examples/1D_New_React/case.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env python3
2+
# References:
3+
# + https://doi.org/10.1016/j.ijhydene.2023.03.190: Verification of numerical method
4+
# + https://doi.org/10.1016/j.compfluid.2013.10.014: 4.7. Multi-species reactive shock tube
5+
6+
import json, argparse
7+
import cantera as ct
8+
9+
parser = argparse.ArgumentParser(prog="1D_reactive_shocktube", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
10+
11+
parser.add_argument(
12+
"--mfc",
13+
type=json.loads,
14+
default="{}",
15+
metavar="DICT",
16+
help="MFC's toolchain's internal state.",
17+
)
18+
parser.add_argument(
19+
"--no-chem",
20+
dest="chemistry",
21+
default=True,
22+
action="store_false",
23+
help="Disable chemistry.",
24+
)
25+
parser.add_argument("--scale", type=float, default=1, help="Scale.")
26+
27+
args = parser.parse_args()
28+
29+
ctfile = "h2o2.yaml"
30+
sol_L = ct.Solution(ctfile)
31+
sol_L.DPX = 0.4214,193138.63 , "H2:2,O2:1,AR:7"
32+
33+
sol_R = ct.Solution(ctfile)
34+
sol_R.DPX = 0.085, 6670, "H2:2,O2:1,AR:7"
35+
36+
u_l = 0
37+
u_r = 0
38+
39+
L = 0.12
40+
Nx = 1200 * args.scale
41+
dx = L / Nx
42+
dt = dx / 1600 * 0.02
43+
Tend = 100e-6
44+
45+
NT = int(Tend / dt)
46+
SAVE_COUNT = 100
47+
NS = NT // SAVE_COUNT
48+
49+
case = {
50+
# Logistics
51+
"run_time_info": "T",
52+
# Computational Domain Parameters
53+
"x_domain%beg": 0,
54+
"x_domain%end": L,
55+
"m": Nx,
56+
"n": 0,
57+
"p": 0,
58+
"dt": float(dt),
59+
"t_step_start": 0,
60+
"t_step_stop": NT,
61+
"t_step_save": 150,
62+
"t_step_print": NS,
63+
"parallel_io": "F" if args.mfc.get("mpi", True) else "F",
64+
# Simulation Algorithm Parameters
65+
"model_eqns": 2,
66+
"num_fluids": 1,
67+
"num_patches": 2,
68+
"mpp_lim": "F",
69+
"mixture_err": "F",
70+
"time_stepper": 3,
71+
"weno_order": 5,
72+
"weno_eps": 1e-16,
73+
"weno_avg": "F",
74+
"mapped_weno": "T",
75+
"mp_weno": "T",
76+
"riemann_solver": 2,
77+
"wave_speeds": 1,
78+
"avg_state": 2,
79+
"bc_x%beg": -2,
80+
"bc_x%end": -3,
81+
# Chemistry
82+
"chemistry": "T" if not args.chemistry else "T",
83+
"chem_params%diffusion": "F",
84+
"chem_params%reactions": "T",
85+
"cantera_file": ctfile,
86+
# Formatted Database Files Structure Parameters
87+
"format": 1,
88+
"precision": 2,
89+
"prim_vars_wrt": "T",
90+
"chem_wrt_T": "T",
91+
"patch_icpp(1)%geometry": 1,
92+
"patch_icpp(1)%x_centroid": L / 40,
93+
"patch_icpp(1)%length_x": L / 20,
94+
"patch_icpp(1)%vel(1)": u_l,
95+
"patch_icpp(1)%pres": 6.3*10**5,
96+
"patch_icpp(1)%alpha(1)": 1,
97+
"patch_icpp(1)%alpha_rho(1)": 0.77,
98+
"patch_icpp(2)%geometry": 1,
99+
"patch_icpp(2)%x_centroid": 21*L/40,
100+
"patch_icpp(2)%length_x": 19*L/20,
101+
"patch_icpp(2)%vel(1)": 0,
102+
"patch_icpp(2)%pres": sol_R.P,
103+
"patch_icpp(2)%alpha(1)": 1,
104+
"patch_icpp(2)%alpha_rho(1)": sol_R.density,
105+
# Fluids Physical Parameters
106+
"fluid_pp(1)%gamma": 1.0e00 / (4.4e00 - 1.0e00),
107+
"fluid_pp(1)%pi_inf": 0,
108+
}
109+
110+
if args.chemistry:
111+
for i in range(len(sol_L.Y)):
112+
case[f"chem_wrt_Y({i + 1})"] = "T"
113+
case[f"patch_icpp(1)%Y({i+1})"] = sol_L.Y[i]
114+
case[f"patch_icpp(2)%Y({i+1})"] = sol_R.Y[i]
115+
116+
if __name__ == "__main__":
117+
print(json.dumps(case))

examples/1D_New_React/initial.png

48.5 KB
Loading

examples/1D_New_React/result.png

83.1 KB
Loading

0 commit comments

Comments
 (0)