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