|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# References: |
| 3 | +# + https://doi.org/10.1016/j.compfluid.2013.10.014: 4.3. Multi-component inert shock tube |
| 4 | + |
| 5 | +import json |
| 6 | +import argparse |
| 7 | +import math |
| 8 | + |
| 9 | +import cantera as ct |
| 10 | + |
| 11 | +parser = argparse.ArgumentParser(prog="nD_inert_shocktube", formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 12 | + |
| 13 | +parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT", help="MFC's toolchain's internal state.") |
| 14 | +parser.add_argument("--no-chem", dest="chemistry", default=True, action="store_false", help="Disable chemstry.") |
| 15 | + |
| 16 | +args = parser.parse_args() |
| 17 | + |
| 18 | +ctfile = "h2o2.yaml" |
| 19 | +sol_L = ct.Solution(ctfile) |
| 20 | +sol_L.TPX = 300, 101325, "O:1" |
| 21 | +u_r = -487.34 |
| 22 | +L = 0.12 |
| 23 | +Nx = 400 |
| 24 | +dx = L / Nx |
| 25 | +dt = dx / abs(u_r) * 0.02 |
| 26 | +Tend = 230e-6 |
| 27 | + |
| 28 | +NT = int(Tend / dt) |
| 29 | +SAVE_COUNT = 100 |
| 30 | +NS = NT // SAVE_COUNT |
| 31 | + |
| 32 | +case = { |
| 33 | + # Logistics ================================================================ |
| 34 | + "run_time_info": "T", |
| 35 | + # ========================================================================== |
| 36 | + # Computational Domain Parameters ========================================== |
| 37 | + "x_domain%beg": 0, |
| 38 | + "x_domain%end": +L, |
| 39 | + "m": Nx, |
| 40 | + "n": 0, |
| 41 | + "p": 0, |
| 42 | + "dt": float(dt), |
| 43 | + "t_step_start": 0, |
| 44 | + "t_step_stop": NT, |
| 45 | + "t_step_save": NS, |
| 46 | + "t_step_print": NS, |
| 47 | + "parallel_io": "F", |
| 48 | + # ========================================================================== |
| 49 | + # Simulation Algorithm Parameters ========================================== |
| 50 | + "model_eqns": 2, |
| 51 | + "num_fluids": 1, |
| 52 | + "num_patches": 1, |
| 53 | + "mpp_lim": "F", |
| 54 | + "mixture_err": "F", |
| 55 | + "time_stepper": 3, |
| 56 | + "weno_order": 5, |
| 57 | + "weno_eps": 1e-16, |
| 58 | + "weno_avg": "F", |
| 59 | + "mapped_weno": "T", |
| 60 | + "mp_weno": "T", |
| 61 | + "riemann_solver": 2, |
| 62 | + "wave_speeds": 2, |
| 63 | + "avg_state": 1, |
| 64 | + "bc_x%beg": -2, |
| 65 | + "bc_x%end": -3, |
| 66 | + "viscous": "F", |
| 67 | + # ========================================================================== |
| 68 | + # Chemistry ================================================================ |
| 69 | + "chemistry": "T" if not args.chemistry else "T", |
| 70 | + "chem_params%diffusion": "F", |
| 71 | + "chem_params%reactions": "T", |
| 72 | + # ========================================================================== |
| 73 | + # Formatted Database Files Structure Parameters ============================ |
| 74 | + "format": 1, |
| 75 | + "precision": 2, |
| 76 | + "prim_vars_wrt": "F", |
| 77 | + # ========================================================================== |
| 78 | + # ========================================================================== |
| 79 | + "patch_icpp(1)%geometry": 15, |
| 80 | + "patch_icpp(1)%hcid": 170, |
| 81 | + "patch_icpp(1)%x_centroid": L / 2, |
| 82 | + "patch_icpp(1)%length_x": L, |
| 83 | + "patch_icpp(1)%vel(1)": "8*exp(-400*((x-0.002/2)/0.002)**2)", |
| 84 | + "patch_icpp(1)%pres": 1.01315e5, |
| 85 | + "patch_icpp(1)%alpha(1)": 1, |
| 86 | + # 'patch_icpp(1)%Y(1)' : '0.4+x/0.002*0.2', |
| 87 | + # 'patch_icpp(1)%Y(4)' : '0.6-x/0.002*0.2', |
| 88 | + # 'patch_icpp(1)%Y(5)' : '0.6-x/0.002*0.2', |
| 89 | + "patch_icpp(1)%alpha_rho(1)": "1", #'(1.01325*10**5-1100*exp(-400*((x-0.002/2)/0.002)**2))/(8.314*1000*( (0.4+x/0.002*0.2)/2.016+(0.6-x/0.002*0.2)/32)*(300+30*exp(-400*((x-0.002/2)/0.002)**2)))', |
| 90 | + # ========================================================================== |
| 91 | + # Fluids Physical Parameters =============================================== |
| 92 | + "fluid_pp(1)%gamma": 1.0e00 / (1.32e00 - 1.0e00), |
| 93 | + "fluid_pp(1)%pi_inf": 0, |
| 94 | + # ========================================================================== |
| 95 | + # Chemistry ================================================================ |
| 96 | + "cantera_file": ctfile, |
| 97 | + # ========================================================================== |
| 98 | +} |
| 99 | + |
| 100 | + |
| 101 | +if __name__ == "__main__": |
| 102 | + print(json.dumps(case)) |
0 commit comments