Skip to content

Commit e2f0e26

Browse files
SCC26 Practice Problem Prep (#1731)
Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent 3a9bb76 commit e2f0e26

4 files changed

Lines changed: 175 additions & 127 deletions

File tree

‎examples/2D_shockdroplet/case.py‎

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,69 @@
11
#!/usr/bin/env python3
2+
import argparse
23
import json
34
import math
45

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
823
rho_a = 1.204
924
rho_w = 1000
1025
gam_a = 1.4
1126
gam_w = 6.12
1227
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
1737

1838
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
2248

23-
time_end = 0.005 # 50us
24-
cfl = 0.25
49+
dt = cfl * dx / c_l
50+
Nt = int(time_end / dt)
2551

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+
}
2867

2968
print(
3069
json.dumps(
@@ -44,19 +83,18 @@
4483
"m": int(Nx),
4584
"n": int(Ny),
4685
"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,
5189
# Simulation Algorithm Parameters
5290
"num_patches": 3,
5391
"model_eqns": "5eq",
5492
"alt_soundspeed": "F",
5593
"num_fluids": 2,
56-
"mpp_lim": "T",
57-
"mixture_err": "T",
94+
"mpp_lim": "F",
95+
"mixture_err": "F",
5896
"time_stepper": "rk3",
59-
"weno_order": 5,
97+
"weno_order": 3,
6098
"weno_eps": 1.0e-16,
6199
"weno_Re_flux": "F",
62100
"weno_avg": "F",
@@ -83,9 +121,9 @@
83121
"patch_icpp(1)%length_y": 14 * D,
84122
"patch_icpp(1)%vel(1)": 0.0,
85123
"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,
89127
"patch_icpp(1)%alpha(1)": eps,
90128
"patch_icpp(1)%alpha(2)": 1 - eps,
91129
# Patch 2: Shocked state
@@ -98,7 +136,7 @@
98136
"patch_icpp(2)%vel(1)": vel,
99137
"patch_icpp(2)%vel(2)": 0.0e00,
100138
"patch_icpp(2)%pres": ps,
101-
"patch_icpp(2)%alpha_rho(1)": eps * 1000,
139+
"patch_icpp(2)%alpha_rho(1)": eps * rho_w,
102140
"patch_icpp(2)%alpha_rho(2)": (1 - eps) * rho_post_a,
103141
"patch_icpp(2)%alpha(1)": eps,
104142
"patch_icpp(2)%alpha(2)": 1 - eps,
@@ -110,7 +148,7 @@
110148
"patch_icpp(3)%alter_patch(1)": "T",
111149
"patch_icpp(3)%vel(1)": 0.0,
112150
"patch_icpp(3)%vel(2)": 0.0e00,
113-
"patch_icpp(3)%pres": 101325.0,
151+
"patch_icpp(3)%pres": p_a,
114152
"patch_icpp(3)%alpha_rho(1)": (1 - eps) * rho_w,
115153
"patch_icpp(3)%alpha_rho(2)": eps * 1.17,
116154
"patch_icpp(3)%alpha(1)": 1 - eps, # 0.95

‎src/common/m_variables_conversion.fpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ contains
424424
!! each model has different variable sets and EOS.
425425
subroutine s_convert_conservative_to_primitive_variables(qK_cons_vf, q_T_sf, qK_prim_vf, ibounds)
426426

427+
use m_global_parameters_common, only: shear_indices ! Performance fix with AMDFlang
428+
427429
type(scalar_field), dimension(sys_size), intent(in) :: qK_cons_vf
428430
type(scalar_field), intent(inout) :: q_T_sf
429431
type(scalar_field), dimension(sys_size), intent(inout) :: qK_prim_vf

0 commit comments

Comments
 (0)