|
1 | 1 | #!/usr/bin/env python3 |
| 2 | +import argparse |
2 | 3 | import json |
3 | 4 | import math |
4 | 5 |
|
5 | | -Ma = 1.4 |
6 | | -ps = 238558 |
7 | | -rho_post_a = 2.18 |
| 6 | +parser = argparse.ArgumentParser(prog="2D_shockdroplet", formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 7 | +parser.add_argument( |
| 8 | + "--mfc", |
| 9 | + type=json.loads, |
| 10 | + default="{}", |
| 11 | + metavar="DICT", |
| 12 | + help="MFC's toolchain's internal state.", |
| 13 | +) |
| 14 | +parser.add_argument("--mach", type=float, default=1.4, help="Shock Mach number.") |
| 15 | +parser.add_argument("--adap-dt", action="store_true", help="Use CFL-based adaptive time-stepping.") |
| 16 | +parser.add_argument("--cfl", type=float, default=0.2, help="CFL number.") |
| 17 | +parser.add_argument("--tend", type=float, default=1.0, help="Dimensionless end time.") |
| 18 | +parser.add_argument("--res", type=float, default=1.0, help="Resolution scaling factor.") |
| 19 | +args = parser.parse_args() |
| 20 | + |
| 21 | +Ma = args.mach |
| 22 | +p_a = 101325.0 |
8 | 23 | rho_a = 1.204 |
9 | 24 | rho_w = 1000 |
10 | 25 | gam_a = 1.4 |
11 | 26 | gam_w = 6.12 |
12 | 27 | pi_w = 3.43e8 |
13 | | -vel = 226 |
14 | | -rho = 1 |
15 | | -c_l = math.sqrt(1.4 * ps / rho) |
16 | | -eps = 1e-9 |
| 28 | + |
| 29 | +# Post-shock state from the Rankine-Hugoniot conditions (shock moving into still air) |
| 30 | +ps = p_a * (1 + 2 * gam_a / (gam_a + 1) * (Ma**2 - 1)) |
| 31 | +rho_post_a = rho_a * (gam_a + 1) * Ma**2 / ((gam_a - 1) * Ma**2 + 2) |
| 32 | +c_a = math.sqrt(gam_a * p_a / rho_a) |
| 33 | +vel = 2 * c_a / (gam_a + 1) * (Ma**2 - 1) / Ma |
| 34 | + |
| 35 | +c_l = math.sqrt(gam_a * ps / rho_a) |
| 36 | +eps = 1e-6 |
17 | 37 |
|
18 | 38 | D = 0.048 |
19 | | -Ny = 299.0 |
20 | | -Nx = 1199.0 |
21 | | -dx = 0.25 / Nx # 8.3e-6 |
| 39 | +Ny = (300 * args.res) - 1 |
| 40 | +Nx = (1200 * args.res) - 1 |
| 41 | +dx = 24 * D / Nx |
| 42 | + |
| 43 | +# End time in units of the Ranger & Nicholls (1969) breakup time scale |
| 44 | +# t_breakup = D sqrt(rho_l/rho_g) / u_g, with post-shock gas conditions |
| 45 | +tau_end = args.tend |
| 46 | +time_end = tau_end * D * math.sqrt(rho_w / rho_post_a) / vel |
| 47 | +cfl = args.cfl |
22 | 48 |
|
23 | | -time_end = 0.005 # 50us |
24 | | -cfl = 0.25 |
| 49 | +dt = cfl * dx / c_l |
| 50 | +Nt = int(time_end / dt) |
25 | 51 |
|
26 | | -dt = cfl * dx / c_l # 5.3E-9 |
27 | | -Nt = int(time_end / dt) # 10000 |
| 52 | +if args.adap_dt: |
| 53 | + time_stepping = { |
| 54 | + "cfl_adap_dt": "T", |
| 55 | + "cfl_target": cfl, |
| 56 | + "n_start": 0, |
| 57 | + "t_stop": time_end, |
| 58 | + "t_save": time_end / 100, |
| 59 | + } |
| 60 | +else: |
| 61 | + time_stepping = { |
| 62 | + "dt": dt, |
| 63 | + "t_step_start": 0, |
| 64 | + "t_step_stop": Nt, |
| 65 | + "t_step_save": math.ceil(Nt / 100), |
| 66 | + } |
28 | 67 |
|
29 | 68 | print( |
30 | 69 | json.dumps( |
|
44 | 83 | "m": int(Nx), |
45 | 84 | "n": int(Ny), |
46 | 85 | "p": 0, |
47 | | - "dt": dt, |
48 | | - "t_step_start": 0, |
49 | | - "t_step_stop": Nt, |
50 | | - "t_step_save": Nt, # math.ceil(Nt/100), |
| 86 | + **time_stepping, |
| 87 | + "elliptic_smoothing": "T", |
| 88 | + "elliptic_smoothing_iters": 20, |
51 | 89 | # Simulation Algorithm Parameters |
52 | 90 | "num_patches": 3, |
53 | 91 | "model_eqns": "5eq", |
54 | 92 | "alt_soundspeed": "F", |
55 | 93 | "num_fluids": 2, |
56 | | - "mpp_lim": "T", |
57 | | - "mixture_err": "T", |
| 94 | + "mpp_lim": "F", |
| 95 | + "mixture_err": "F", |
58 | 96 | "time_stepper": "rk3", |
59 | | - "weno_order": 5, |
| 97 | + "weno_order": 3, |
60 | 98 | "weno_eps": 1.0e-16, |
61 | 99 | "weno_Re_flux": "F", |
62 | 100 | "weno_avg": "F", |
|
83 | 121 | "patch_icpp(1)%length_y": 14 * D, |
84 | 122 | "patch_icpp(1)%vel(1)": 0.0, |
85 | 123 | "patch_icpp(1)%vel(2)": 0.0e00, |
86 | | - "patch_icpp(1)%pres": 101325.0, |
87 | | - "patch_icpp(1)%alpha_rho(1)": eps * 1000, |
88 | | - "patch_icpp(1)%alpha_rho(2)": (1 - eps) * 1.17, |
| 124 | + "patch_icpp(1)%pres": p_a, |
| 125 | + "patch_icpp(1)%alpha_rho(1)": eps * rho_w, |
| 126 | + "patch_icpp(1)%alpha_rho(2)": (1 - eps) * rho_a, |
89 | 127 | "patch_icpp(1)%alpha(1)": eps, |
90 | 128 | "patch_icpp(1)%alpha(2)": 1 - eps, |
91 | 129 | # Patch 2: Shocked state |
|
98 | 136 | "patch_icpp(2)%vel(1)": vel, |
99 | 137 | "patch_icpp(2)%vel(2)": 0.0e00, |
100 | 138 | "patch_icpp(2)%pres": ps, |
101 | | - "patch_icpp(2)%alpha_rho(1)": eps * 1000, |
| 139 | + "patch_icpp(2)%alpha_rho(1)": eps * rho_w, |
102 | 140 | "patch_icpp(2)%alpha_rho(2)": (1 - eps) * rho_post_a, |
103 | 141 | "patch_icpp(2)%alpha(1)": eps, |
104 | 142 | "patch_icpp(2)%alpha(2)": 1 - eps, |
|
110 | 148 | "patch_icpp(3)%alter_patch(1)": "T", |
111 | 149 | "patch_icpp(3)%vel(1)": 0.0, |
112 | 150 | "patch_icpp(3)%vel(2)": 0.0e00, |
113 | | - "patch_icpp(3)%pres": 101325.0, |
| 151 | + "patch_icpp(3)%pres": p_a, |
114 | 152 | "patch_icpp(3)%alpha_rho(1)": (1 - eps) * rho_w, |
115 | 153 | "patch_icpp(3)%alpha_rho(2)": eps * 1.17, |
116 | 154 | "patch_icpp(3)%alpha(1)": 1 - eps, # 0.95 |
|
0 commit comments