|
1 | 1 | import json, argparse |
2 | 2 | import cantera as ct |
3 | 3 |
|
4 | | -parser = argparse.ArgumentParser( |
5 | | - prog="2D_Detonation", |
6 | | - formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 4 | +parser = argparse.ArgumentParser(prog="2D_Detonation", formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
7 | 5 |
|
8 | | -parser.add_argument("--mfc", type=json.loads, default='{}', metavar="DICT", |
9 | | - help="MFC's toolchain's internal state.") |
10 | | -parser.add_argument("--no-chem", dest='chemistry', default=True, action="store_false", |
11 | | - help="Disable chemistry.") |
12 | | -parser.add_argument("--scale", type=float, default=1, help="Scale.") |
| 6 | +parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT", help="MFC's toolchain's internal state.") |
| 7 | +parser.add_argument("--no-chem", dest="chemistry", default=True, action="store_false", help="Disable chemistry.") |
| 8 | +parser.add_argument("--scale", type=float, default=1, help="Scale.") |
13 | 9 |
|
14 | 10 | args = parser.parse_args() |
15 | 11 |
|
16 | | -ctfile = 'h2o2.yaml' |
17 | | -sol_L = ct.Solution(ctfile) |
18 | | -sol_L.DPX = 0.072, 7173, 'H2:2,O2:1,AR:7' |
| 12 | +ctfile = "h2o2.yaml" |
| 13 | +sol_L = ct.Solution(ctfile) |
| 14 | +sol_L.DPX = 0.072, 7173, "H2:2,O2:1,AR:7" |
19 | 15 |
|
20 | | -sol_R = ct.Solution(ctfile) |
21 | | -sol_R.DPX = 0.18075, 35594, 'H2:2,O2:1,AR:7' |
| 16 | +sol_R = ct.Solution(ctfile) |
| 17 | +sol_R.DPX = 0.18075, 35594, "H2:2,O2:1,AR:7" |
22 | 18 |
|
23 | 19 | u_l = 0 |
24 | 20 | u_r = -487.34 |
25 | 21 |
|
26 | | -L = 0.12 |
| 22 | +L = 0.12 |
27 | 23 | Nx = 800 |
28 | 24 | Ny = 200 |
29 | | -dx = L/Nx |
30 | | -dy = (L/4)/Ny |
31 | | -dt = min(dx,dy)/abs(u_r)*0.05*0.1*0.2 |
32 | | -Tend=830e-6 |
| 25 | +dx = L / Nx |
| 26 | +dy = (L / 4) / Ny |
| 27 | +dt = min(dx, dy) / abs(u_r) * 0.05 * 0.1 * 0.2 |
| 28 | +Tend = 830e-6 |
33 | 29 |
|
34 | | -NT=int(Tend/dt) |
35 | | -SAVE_COUNT=100 |
36 | | -NS=NT//SAVE_COUNT |
| 30 | +NT = int(Tend / dt) |
| 31 | +SAVE_COUNT = 100 |
| 32 | +NS = NT // SAVE_COUNT |
37 | 33 |
|
38 | 34 | case = { |
39 | 35 | # Logistics ================================================================ |
40 | | - 'run_time_info' : 'T', |
| 36 | + "run_time_info": "T", |
41 | 37 | # ========================================================================== |
42 | | - |
43 | 38 | # Computational Domain Parameters ========================================== |
44 | | - 'x_domain%beg' : 0, |
45 | | - 'x_domain%end' : L, |
46 | | - 'y_domain%beg' : 0, |
47 | | - 'y_domain%end' : L/4, |
48 | | - 'm' : Nx, |
49 | | - 'n' : Ny, |
50 | | - 'p' : 0, |
51 | | - 'dt' : float(dt), |
52 | | - 't_step_start' : 0, |
53 | | - 't_step_stop' : 1, |
54 | | - 't_step_save' : 1, |
55 | | - 't_step_print' : 1, |
56 | | - 'parallel_io' : 'F', #if args.mfc.get("mpi", True) else 'F', |
57 | | - |
| 39 | + "x_domain%beg": 0, |
| 40 | + "x_domain%end": L, |
| 41 | + "y_domain%beg": 0, |
| 42 | + "y_domain%end": L / 4, |
| 43 | + "m": Nx, |
| 44 | + "n": Ny, |
| 45 | + "p": 0, |
| 46 | + "dt": float(dt), |
| 47 | + "t_step_start": 0, |
| 48 | + "t_step_stop": 1, |
| 49 | + "t_step_save": 1, |
| 50 | + "t_step_print": 1, |
| 51 | + "parallel_io": "F", # if args.mfc.get("mpi", True) else 'F', |
58 | 52 | # Simulation Algorithm Parameters ========================================== |
59 | | - 'model_eqns' : 2, |
60 | | - 'num_fluids' : 1, |
61 | | - 'num_patches' : 2, |
62 | | - 'mpp_lim' : 'F', |
63 | | - 'mixture_err' : 'F', |
64 | | - 'time_stepper' : 3, |
65 | | - 'weno_order' : 5, |
66 | | - 'weno_eps' : 1E-16, |
67 | | - 'weno_avg' : 'F', |
68 | | - 'mapped_weno' : 'T', |
69 | | - 'mp_weno' : 'T', |
70 | | - 'riemann_solver' : 2, |
71 | | - 'wave_speeds' : 1, |
72 | | - 'avg_state' : 2, |
73 | | - 'bc_x%beg' :-3, |
74 | | - 'bc_x%end' :-3, |
75 | | - 'bc_y%beg' :-1, |
76 | | - 'bc_y%end' :-1, |
77 | | - |
| 53 | + "model_eqns": 2, |
| 54 | + "num_fluids": 1, |
| 55 | + "num_patches": 2, |
| 56 | + "mpp_lim": "F", |
| 57 | + "mixture_err": "F", |
| 58 | + "time_stepper": 3, |
| 59 | + "weno_order": 5, |
| 60 | + "weno_eps": 1e-16, |
| 61 | + "weno_avg": "F", |
| 62 | + "mapped_weno": "T", |
| 63 | + "mp_weno": "T", |
| 64 | + "riemann_solver": 2, |
| 65 | + "wave_speeds": 1, |
| 66 | + "avg_state": 2, |
| 67 | + "bc_x%beg": -3, |
| 68 | + "bc_x%end": -3, |
| 69 | + "bc_y%beg": -1, |
| 70 | + "bc_y%end": -1, |
78 | 71 | # Chemistry ================================================================ |
79 | | - 'chemistry' : 'T' if not args.chemistry else 'T', |
80 | | - 'chem_params%diffusion' : 'F', |
81 | | - 'chem_params%reactions' : 'F', |
82 | | - 'cantera_file' : ctfile, |
| 72 | + "chemistry": "T" if not args.chemistry else "T", |
| 73 | + "chem_params%diffusion": "F", |
| 74 | + "chem_params%reactions": "F", |
| 75 | + "cantera_file": ctfile, |
83 | 76 | # ========================================================================== |
84 | | - |
85 | 77 | # Formatted Database Files Structure Parameters ============================ |
86 | | - 'format' : 1, |
87 | | - 'precision' : 2, |
88 | | - 'prim_vars_wrt' : 'T', |
89 | | - 'chem_wrt_T' : 'T', |
| 78 | + "format": 1, |
| 79 | + "precision": 2, |
| 80 | + "prim_vars_wrt": "T", |
| 81 | + "chem_wrt_T": "T", |
90 | 82 | # ========================================================================== |
91 | | - 'patch_icpp(1)%geometry' : 3, |
92 | | - 'patch_icpp(1)%x_centroid' : L/2, |
93 | | - 'patch_icpp(1)%y_centroid' : L/8, |
94 | | - 'patch_icpp(1)%length_x' : L, |
95 | | - 'patch_icpp(1)%length_y' : L/4, |
96 | | - 'patch_icpp(1)%vel(1)' : -487.34, |
97 | | - 'patch_icpp(1)%vel(2)' : 0.0, |
98 | | - 'patch_icpp(1)%pres' : sol_R.P, |
99 | | - 'patch_icpp(1)%alpha(1)' : 1, |
100 | | - 'patch_icpp(1)%alpha_rho(1)' : sol_R.density, |
| 83 | + "patch_icpp(1)%geometry": 3, |
| 84 | + "patch_icpp(1)%x_centroid": L / 2, |
| 85 | + "patch_icpp(1)%y_centroid": L / 8, |
| 86 | + "patch_icpp(1)%length_x": L, |
| 87 | + "patch_icpp(1)%length_y": L / 4, |
| 88 | + "patch_icpp(1)%vel(1)": -487.34, |
| 89 | + "patch_icpp(1)%vel(2)": 0.0, |
| 90 | + "patch_icpp(1)%pres": sol_R.P, |
| 91 | + "patch_icpp(1)%alpha(1)": 1, |
| 92 | + "patch_icpp(1)%alpha_rho(1)": sol_R.density, |
101 | 93 | # ========================================================================== |
102 | 94 | # ========================================================================== |
103 | 95 | # ========================================================================== |
104 | | - 'patch_icpp(2)%geometry' : 7, |
105 | | - 'patch_icpp(2)%x_centroid' : L/4, |
106 | | - 'patch_icpp(2)%y_centroid' : L/8, |
107 | | - 'patch_icpp(2)%length_x' : L/2, |
108 | | - 'patch_icpp(2)%length_y' : L/4, |
109 | | - 'patch_icpp(2)%hcid' : 270, |
110 | | - 'patch_icpp(2)%vel(1)' : 0, |
111 | | - 'patch_icpp(2)%vel(2)' : 0, |
112 | | - 'patch_icpp(2)%pres' : sol_R.P, |
113 | | - 'patch_icpp(2)%alpha(1)' : 1, |
114 | | - 'patch_icpp(2)%alpha_rho(1)' : sol_R.density, |
115 | | - # 'patch_icpp(1)%alter_patch(1)' : 'F', |
116 | | - 'patch_icpp(2)%alter_patch(1)' : 'T', |
| 96 | + "patch_icpp(2)%geometry": 7, |
| 97 | + "patch_icpp(2)%x_centroid": L / 4, |
| 98 | + "patch_icpp(2)%y_centroid": L / 8, |
| 99 | + "patch_icpp(2)%length_x": L / 2, |
| 100 | + "patch_icpp(2)%length_y": L / 4, |
| 101 | + "patch_icpp(2)%hcid": 270, |
| 102 | + "patch_icpp(2)%vel(1)": 0, |
| 103 | + "patch_icpp(2)%vel(2)": 0, |
| 104 | + "patch_icpp(2)%pres": sol_R.P, |
| 105 | + "patch_icpp(2)%alpha(1)": 1, |
| 106 | + "patch_icpp(2)%alpha_rho(1)": sol_R.density, |
| 107 | + # 'patch_icpp(1)%alter_patch(1)' : 'F', |
| 108 | + "patch_icpp(2)%alter_patch(1)": "T", |
117 | 109 | # ========================================================================== |
118 | 110 | # Fluids Physical Parameters =============================================== |
119 | | - 'fluid_pp(1)%gamma' : 1.0E+00/(4.4E+00-1.0E+00), |
120 | | - 'fluid_pp(1)%pi_inf' : 0, |
| 111 | + "fluid_pp(1)%gamma": 1.0e00 / (4.4e00 - 1.0e00), |
| 112 | + "fluid_pp(1)%pi_inf": 0, |
121 | 113 | # ========================================================================== |
122 | 114 | } |
123 | 115 |
|
124 | 116 | if args.chemistry: |
125 | | - for i in range(len(sol_L.Y)): |
126 | | - case[f'chem_wrt_Y({1})'] = 'T' |
| 117 | + for i in range(len(sol_L.Y)): |
| 118 | + case[f"chem_wrt_Y({1})"] = "T" |
127 | 119 |
|
128 | | -if __name__ == '__main__': |
| 120 | +if __name__ == "__main__": |
129 | 121 | print(json.dumps(case)) |
0 commit comments