|
| 1 | +import json, argparse |
| 2 | +import cantera as ct |
| 3 | + |
| 4 | +parser = argparse.ArgumentParser( |
| 5 | + prog="2D_detonation", |
| 6 | + formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 7 | + |
| 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.") |
| 13 | + |
| 14 | +args = parser.parse_args() |
| 15 | + |
| 16 | +ctfile = 'h2o2.yaml' |
| 17 | +sol_L = ct.Solution(ctfile) |
| 18 | +sol_L.DPX = 0.072, 7173, 'H2:2,O2:1,AR:7' |
| 19 | + |
| 20 | +sol_R = ct.Solution(ctfile) |
| 21 | +sol_R.DPX = 0.18075, 35594, 'H2:2,O2:1,AR:7' |
| 22 | + |
| 23 | +u_l = 0 |
| 24 | +u_r = -487.34 |
| 25 | + |
| 26 | +L = 0.12 |
| 27 | +Nx = 800 |
| 28 | +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 |
| 33 | + |
| 34 | +NT=int(Tend/dt) |
| 35 | +SAVE_COUNT=100 |
| 36 | +NS=NT//SAVE_COUNT |
| 37 | + |
| 38 | +case = { |
| 39 | + # Logistics ================================================================ |
| 40 | + 'run_time_info' : 'T', |
| 41 | + # ========================================================================== |
| 42 | + |
| 43 | + # 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 | + |
| 58 | + # 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 | + |
| 78 | + # Chemistry ================================================================ |
| 79 | + 'chemistry' : 'T' if not args.chemistry else 'T', |
| 80 | + 'chem_params%diffusion' : 'F', |
| 81 | + 'chem_params%reactions' : 'F', |
| 82 | + 'cantera_file' : ctfile, |
| 83 | + # ========================================================================== |
| 84 | + |
| 85 | + # Formatted Database Files Structure Parameters ============================ |
| 86 | + 'format' : 1, |
| 87 | + 'precision' : 2, |
| 88 | + 'prim_vars_wrt' : 'T', |
| 89 | + 'chem_wrt_T' : 'T', |
| 90 | + 'vel_wrt(1)' : 'T', |
| 91 | + 'vel_wrt(2)' : 'T', |
| 92 | + 'pres_wrt' : 'T', |
| 93 | + # ========================================================================== |
| 94 | + # 'rho_wrt' : 'T', |
| 95 | + |
| 96 | + |
| 97 | + 'patch_icpp(1)%geometry' : 3, |
| 98 | + 'patch_icpp(1)%x_centroid' : L/2, |
| 99 | + 'patch_icpp(1)%y_centroid' : L/8, |
| 100 | + 'patch_icpp(1)%length_x' : L, |
| 101 | + 'patch_icpp(1)%length_y' : L/4, |
| 102 | + 'patch_icpp(1)%vel(1)' : -487.34, |
| 103 | + 'patch_icpp(1)%vel(2)' : 0.0, |
| 104 | + 'patch_icpp(1)%pres' : sol_R.P, |
| 105 | + 'patch_icpp(1)%alpha(1)' : 1, |
| 106 | + 'patch_icpp(1)%alpha_rho(1)' : sol_R.density, |
| 107 | + # 'patch_icpp(1)%Y(1)' : 0.5, |
| 108 | + # 'patch_icpp(1)%Y(2)' : 0.5, |
| 109 | + # ========================================================================== |
| 110 | + # ========================================================================== |
| 111 | + # ========================================================================== |
| 112 | + |
| 113 | + 'patch_icpp(2)%geometry' : 7, |
| 114 | + 'patch_icpp(2)%x_centroid' : L/4, |
| 115 | + 'patch_icpp(2)%y_centroid' : L/8, |
| 116 | + 'patch_icpp(2)%length_x' : L/2, |
| 117 | + 'patch_icpp(2)%length_y' : L/4, |
| 118 | + 'patch_icpp(2)%hcid' : 270, |
| 119 | + 'patch_icpp(2)%vel(1)' : 0, |
| 120 | + 'patch_icpp(2)%vel(2)' : 0, |
| 121 | + 'patch_icpp(2)%pres' : sol_R.P, |
| 122 | + 'patch_icpp(2)%alpha(1)' : 1, |
| 123 | + 'patch_icpp(2)%alpha_rho(1)' : sol_R.density, |
| 124 | + # 'patch_icpp(1)%alter_patch(1)' : 'F', |
| 125 | + 'patch_icpp(2)%alter_patch(1)' : 'T', |
| 126 | + # ========================================================================== |
| 127 | + |
| 128 | + # ========================================================================== |
| 129 | + #'patch_icpp(3)%geometry' : 21, |
| 130 | + #'patch_icpp(3)%x_centroid' : 3*L/2, |
| 131 | + #'patch_icpp(3)%y_centroid' : L/4, |
| 132 | + #'patch_icpp(3)%length_x' : L, |
| 133 | + #'patch_icpp(3)%length_y' : L/2, |
| 134 | + #'patch_icpp(3)%vel(1)' : 0, |
| 135 | + #'patch_icpp(3)%vel(2)' : 100, |
| 136 | + #'patch_icpp(3)%model_scale(1)' : 1/20.0, |
| 137 | + #'patch_icpp(3)%model_scale(2)' : 1/2.0, |
| 138 | + #'patch_icpp(3)%model_scale(3)' : 1/10.0, |
| 139 | + #'patch_icpp(3)%model_translate(1)' : L/2+L/1.2, |
| 140 | + #'patch_icpp(3)%model_translate(2)' : L/4, |
| 141 | + #'patch_icpp(3)%model_translate(3)' : 0, |
| 142 | + #'patch_icpp(3)%model_threshold' : 0.5, |
| 143 | + #'patch_icpp(3)%model_spc' : 'mfc-small.stl', |
| 144 | + #'patch_icpp(3)%pres' : 1000*sol_R.P, |
| 145 | + #'patch_icpp(3)%alpha(1)' : 1, |
| 146 | + #'patch_icpp(3)%alpha_rho(1)' : sol_R.density, |
| 147 | + #'patch_icpp(3)%model_filepath' : 'mfc-small.stl', |
| 148 | + #'patch_icpp(3)%alter_patch(1)' : 'T', |
| 149 | + #'patch_icpp(3)%alter_patch(2)' : 'T', |
| 150 | + # ========================================================================== |
| 151 | + |
| 152 | + # 'vel_wrt(1)' : 'T', |
| 153 | + #'vel_wrt(2)' : 'T', |
| 154 | + # 'pres_wrt' : 'T', |
| 155 | + |
| 156 | + # Fluids Physical Parameters =============================================== |
| 157 | + 'fluid_pp(1)%gamma' : 1.0E+00/(4.4E+00-1.0E+00), |
| 158 | + 'fluid_pp(1)%pi_inf' : 0, |
| 159 | + # ========================================================================== |
| 160 | +} |
| 161 | + |
| 162 | +if args.chemistry: |
| 163 | + for i in range(len(sol_L.Y)): |
| 164 | + case[f'chem_wrt_Y({1})'] = 'T' |
| 165 | + case[f'patch_icpp(1)%Y({i+1})'] = sol_L.Y[i] |
| 166 | + # case[f'patch_icpp(2)%Y({i+1})'] = sol_L.Y[i] |
| 167 | + # #case[f'patch_icpp(3)%Y({i+1})'] = sol_L.Y[i] |
| 168 | + |
| 169 | +if __name__ == '__main__': |
| 170 | + print(json.dumps(case)) |
0 commit comments