Skip to content

Commit e4d333d

Browse files
committed
update
1 parent 6a155cc commit e4d333d

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed
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+
![Initial Condition](initial.png)
11+
12+
## Results
13+
14+
![Results](result.png)
35.4 MB
Binary file not shown.
48.5 KB
Loading
83.1 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import mfc.viz
2+
3+
import os
4+
5+
import subprocess
6+
import seaborn as sns
7+
import matplotlib.pyplot as plt
8+
from tqdm import tqdm
9+
10+
from case import sol_L as sol
11+
12+
case = mfc.viz.Case(".")
13+
14+
os.makedirs("viz", exist_ok=True)
15+
16+
sns.set_theme(style=mfc.viz.generate_cpg_style())
17+
18+
Y_VARS = ["H2", "O2", "H2O", "N2"]
19+
20+
variables = [
21+
("rho", "prim.1"),
22+
("u_x", "prim.2"),
23+
("p", "prim.3"),
24+
("E", "cons.3"),
25+
*[(f"Y_{name}", f"prim.{5 + sol.species_index(name)}") for name in Y_VARS],
26+
("T", "prim.15"),
27+
]
28+
29+
for variable in tqdm(variables, desc="Loading Variables"):
30+
case.load_variable(*variable)
31+
32+
for step in tqdm(case.get_timesteps(), desc="Rendering Frames"):
33+
fig, axes = plt.subplots(2, 3, figsize=(16, 9))
34+
35+
def pad_ylim(ylim, pad=0.1):
36+
return (ylim[0] - pad*(ylim[1] - ylim[0]), ylim[1] + pad*(ylim[1] - ylim[0]))
37+
38+
case.plot_step(step, "rho", ax=axes[0, 0])
39+
axes[0, 0].set_ylim(*pad_ylim(case.get_minmax_time("rho")))
40+
axes[0, 0].set_ylabel("$\\rho$")
41+
case.plot_step(step, "u_x", ax=axes[0, 1])
42+
axes[0, 1].set_ylim(*pad_ylim(case.get_minmax_time("u_x")))
43+
axes[0, 1].set_ylabel("$u_x$")
44+
case.plot_step(step, "p", ax=axes[1, 0])
45+
axes[1, 0].set_ylim(*pad_ylim(case.get_minmax_time("p")))
46+
axes[1, 0].set_ylabel("$p$")
47+
for y in Y_VARS:
48+
case.plot_step(step, f"Y_{y}", ax=axes[1, 1], label=y)
49+
axes[1, 1].set_ylim(0, 1.1*max(case.get_minmax_time(f"Y_{y}")[1] for y in Y_VARS))
50+
axes[1, 1].set_ylabel("$Y_k$")
51+
case.plot_step(step, "T", ax=axes[1, 2])
52+
axes[1, 2].set_ylim(*pad_ylim(case.get_minmax_time("T")))
53+
axes[1, 2].set_ylabel("$T$")
54+
case.plot_step(step, "E", ax=axes[0, 2])
55+
axes[0, 2].set_ylim(*pad_ylim(case.get_minmax_time("E")))
56+
axes[0, 2].set_ylabel("$E$")
57+
58+
plt.tight_layout()
59+
plt.savefig(f"viz/{step:06d}.png")
60+
plt.close()
61+
62+
subprocess.run([
63+
"ffmpeg", "-y", "-framerate", "60", "-pattern_type", "glob", "-i",
64+
"viz/*.png", "-c:v", "libx264", "-pix_fmt", "yuv420p", "viz.mp4"
65+
])

0 commit comments

Comments
 (0)