Skip to content

Commit daa8e85

Browse files
authored
Add Body Forces (#449)
Co-authored-by: Ben Wilfong <[email protected]>
1 parent 9369312 commit daa8e85

File tree

26 files changed

+1235
-12
lines changed

26 files changed

+1235
-12
lines changed

docs/documentation/case.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,24 @@ The parameters are optionally used to define initial velocity profiles and pertu
668668
| ---: | :----: | :--- |
669669
| `pi_fac` | Real | Ratio of artificial and true `pi_\infty` values|
670670

671-
- `pi_fac` specifies the ratio of artificial and true `pi_\infty` values (`=` artificial `pi_\infty` / true `pi_\infty`). This parameter enables the use of true `pi_\infty` in bubble dynamics models, when the `pi_\infty` given in the `case.py` file is an artificial value.
671+
- `pi_fac` specifies the ratio of artificial and true `pi_\infty` values (`=` artificial `pi_\infty` / true `pi_\infty`). i
672+
This parameter enables the use of true `pi_\infty` in bubble dynamics models, when the `pi_\infty` given in the `case.py` file is an artificial value.
672673

674+
### 13. Body Forces
675+
676+
| Parameter | Type | Description |
677+
| ---: | :---: | :--- |
678+
| `bf_x[y,z]` | Logical | Enable body forces in the x[y,z] direction |
679+
| `k_x[y,y]` | Real | Magnitude of oscillating acceleration |
680+
| `w_x[y,z]` | Real | Frequency of oscillating acceleration |
681+
| `p_x[y,z]` | Real | Phase shift of oscillating acceleration |
682+
| `g_x[y,z]` | Real | Magnitude of bacground acceleration |
683+
684+
`k_x[y,z]`, `w_x[y,z]`, `p_x[y,z]`, and `g_x[y,z]` define an oscillating acceleration in the `x[y,z]` direction with the form
685+
686+
$$ a_{x[y,z]} = g_{x[y,z]} + k_{x[y,z]}\sin\left(w_{x[y,z]}t + p_{x[y,z]}\right). $$
687+
688+
Positive accelerations are in the `x[y,z]` direction are in the positive `x[y,z]` direction by convention.
673689

674690
## Enumerations
675691

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Rayleigh-Taylor Instability (2D)
2+
3+
## Final Condition
4+
5+
![Final Condition](final_condition.png)
6+
7+
## Centerline Velocities
8+
9+
![Linear Theory Comparision](linear_theory.jpg)
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env python3
2+
3+
import math
4+
import json
5+
6+
lam = 0.2
7+
h = 1.2
8+
k = 2*math.pi/lam
9+
amp = 0.05/k
10+
11+
# Numerical setup
12+
x0 = -lam/2
13+
x1 = lam/2
14+
y0 = 0.
15+
y1 = h
16+
17+
Nx = 199
18+
Ny = 1199
19+
20+
eps = 1e-6
21+
22+
dx = lam/(Nx + 1)
23+
c = math.sqrt(1.4*1e5/1)
24+
cfl = 0.5
25+
dt = cfl*dx/c
26+
27+
Nt = math.ceil(2/dt)
28+
Ns = math.ceil(Nt/100)
29+
30+
#Configuration case dictionary
31+
data = {
32+
# Logistics =============================
33+
#'case_dir' : '\'.\'',
34+
'run_time_info' : 'T',
35+
# =======================================
36+
37+
# Computational Domain ==================
38+
'x_domain%beg' : x0,
39+
'x_domain%end' : x1,
40+
'y_domain%beg' : y0,
41+
'y_domain%end' : y1,
42+
'm' : Nx,
43+
'n' : Ny,
44+
'p' : 0,
45+
'cyl_coord' : 'F',
46+
'dt' : dt,
47+
't_step_start' : 0,
48+
't_step_stop' : Nt,
49+
't_step_save' : Ns,
50+
# =======================================
51+
52+
# Simulation Algorithm ==================
53+
'model_eqns' : 3,
54+
'alt_soundspeed' : 'F',
55+
'adv_alphan' : 'T',
56+
'mixture_err' : 'T',
57+
'mpp_lim' : 'T',
58+
'time_stepper' : 3,
59+
'avg_state' : 2,
60+
'weno_order' : 5,
61+
'weno_eps' : 1e-16,
62+
'mapped_weno' : 'T',
63+
'null_weights' : 'F',
64+
'mp_weno' : 'T',
65+
'weno_Re_flux' : 'T',
66+
'riemann_solver' : 2,
67+
'wave_speeds' : 1,
68+
'bc_x%beg' : -2,
69+
'bc_x%end' : -2,
70+
'bc_y%beg' : -16,
71+
'bc_y%end' : -16,
72+
'num_patches' : 1,
73+
'num_fluids' : 2,
74+
# =======================================
75+
76+
# Database Structure Parameters =========
77+
'format' : 1,
78+
'precision' : 2,
79+
'prim_vars_wrt' : 'T',
80+
'parallel_io' : 'T',
81+
# =======================================
82+
83+
# Fluid Parameters (Heavy Gas) ==========
84+
'fluid_pp(1)%gamma' : 1.E+00/(1.4E+00-1.E+00),
85+
'fluid_pp(1)%pi_inf' : 0.E+00,
86+
'fluid_pp(1)%Re(1)' : 1/0.0219,
87+
# =======================================
88+
89+
# Fluid Parameters (Light Gas) ==========
90+
'fluid_pp(2)%gamma' : 1.E+00/(1.4E+00-1.E+00),
91+
'fluid_pp(2)%pi_inf' : 0.E+00,
92+
'fluid_pp(2)%Re(1)' : 1/0.0073,
93+
# =======================================
94+
95+
# Body Forces ===========================
96+
'bf_y' : 'T',
97+
'k_y' : 0.,
98+
'w_y' : 0.,
99+
'p_y' : 0.,
100+
'g_y' : -9.81,
101+
# ======================================
102+
103+
# Water Patch ==========================
104+
'patch_icpp(1)%geometry' : 7,
105+
'patch_icpp(1)%hcid' : 204,
106+
'patch_icpp(1)%x_centroid' : 0,
107+
'patch_icpp(1)%y_centroid' : h/2,
108+
'patch_icpp(1)%length_x' : lam,
109+
'patch_icpp(1)%length_y' : h,
110+
'patch_icpp(1)%vel(1)' : 0.0,
111+
'patch_icpp(1)%vel(2)' : 0.0,
112+
'patch_icpp(1)%pres' : 1e5,
113+
'patch_icpp(1)%alpha_rho(1)': (1-eps),
114+
'patch_icpp(1)%alpha_rho(2)': eps*1,
115+
'patch_icpp(1)%alpha(1)' : 1-eps,
116+
'patch_icpp(1)%alpha(2)' : eps,
117+
# ======================================
118+
119+
}
120+
121+
print(json.dumps(data))
166 KB
Loading
21.6 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Rayleigh-Taylor Instability (3D)
2+
3+
## Final Condition
4+
5+
![Final Condition](final_condition.png)
6+
7+
## Centerline Velocities
8+
9+
![Linear Theory Comparision](linear_theory.jpg)
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/usr/bin/env python3
2+
3+
import math
4+
import json
5+
6+
lam = 0.2
7+
h = 1.2
8+
k = 2*math.pi/lam
9+
amp = 0.05/k
10+
11+
# Numerical setup
12+
x0 = 0
13+
x1 = lam/2
14+
y0 = 0.
15+
y1 = h
16+
z0 = 0
17+
z1 = lam/2
18+
19+
Nx = 99
20+
Ny = 1199
21+
Nz = 99
22+
23+
eps = 1e-6
24+
25+
dx = lam/2/(Nx + 1)
26+
c = math.sqrt(1.4*1e5/1)
27+
cfl = 0.4
28+
dt = cfl*dx/c
29+
30+
Nt = math.ceil(0.2/dt)
31+
Ns = math.ceil(Nt/100)
32+
33+
#Configuration case dictionary
34+
data = {
35+
# Logistics =============================
36+
#'case_dir' : '\'.\'',
37+
'run_time_info' : 'T',
38+
# =======================================
39+
40+
# Computational Domain ==================
41+
'x_domain%beg' : x0,
42+
'x_domain%end' : x1,
43+
'y_domain%beg' : y0,
44+
'y_domain%end' : y1,
45+
'z_domain%beg' : z0,
46+
'z_domain%end' : z1,
47+
'm' : Nx,
48+
'n' : Ny,
49+
'p' : Nz,
50+
'cyl_coord' : 'F',
51+
'dt' : dt,
52+
't_step_start' : 0,
53+
't_step_stop' : Nt,
54+
't_step_save' : Ns,
55+
# =======================================
56+
57+
# Simulation Algorithm ==================
58+
'model_eqns' : 2,
59+
'alt_soundspeed' : 'F',
60+
'adv_alphan' : 'T',
61+
'mixture_err' : 'T',
62+
'mpp_lim' : 'T',
63+
'time_stepper' : 3,
64+
'avg_state' : 2,
65+
'weno_order' : 5,
66+
'weno_eps' : 1e-16,
67+
'mapped_weno' : 'T',
68+
'null_weights' : 'F',
69+
'mp_weno' : 'T',
70+
'weno_Re_flux' : 'T',
71+
'riemann_solver' : 2,
72+
'wave_speeds' : 1,
73+
'bc_x%beg' : -2,
74+
'bc_x%end' : -3,
75+
'bc_y%beg' : -16,
76+
'bc_y%end' : -16,
77+
'bc_z%beg' : -2,
78+
'bc_z%end' : -3,
79+
'num_patches' : 1,
80+
'num_fluids' : 2,
81+
# =======================================
82+
83+
# Database Structure Parameters =========
84+
'format' : 1,
85+
'precision' : 2,
86+
'prim_vars_wrt' : 'T',
87+
'parallel_io' : 'T',
88+
# =======================================
89+
90+
# Fluid Parameters (Heavy Gas) ==========
91+
'fluid_pp(1)%gamma' : 1.E+00/(1.4E+00-1.E+00),
92+
'fluid_pp(1)%pi_inf' : 0.E+00,
93+
'fluid_pp(1)%Re(1)' : 1/0.0219,
94+
# =======================================
95+
96+
# Fluid Parameters (Light Gas) ==========
97+
'fluid_pp(2)%gamma' : 1.E+00/(1.4E+00-1.E+00),
98+
'fluid_pp(2)%pi_inf' : 0.E+00,
99+
'fluid_pp(2)%Re(1)' : 1/0.0073,
100+
# =======================================
101+
102+
# Body Forces ===========================
103+
'bf_y' : 'T',
104+
'k_y' : 0.,
105+
'w_y' : 0.,
106+
'p_y' : 0.,
107+
'g_y' : -98.1,
108+
# ======================================
109+
110+
# Water Patch ==========================
111+
'patch_icpp(1)%geometry' : 13,
112+
'patch_icpp(1)%hcid' : 300,
113+
'patch_icpp(1)%x_centroid' : 0,
114+
'patch_icpp(1)%y_centroid' : h/2,
115+
'patch_icpp(1)%z_centroid' : 0,
116+
'patch_icpp(1)%length_x' : lam,
117+
'patch_icpp(1)%length_y' : h,
118+
'patch_icpp(1)%length_z' : h,
119+
'patch_icpp(1)%vel(1)' : 0.0,
120+
'patch_icpp(1)%vel(2)' : 0.0,
121+
'patch_icpp(1)%vel(3)' : 0.0,
122+
'patch_icpp(1)%pres' : 1e5,
123+
'patch_icpp(1)%alpha_rho(1)': (1-eps),
124+
'patch_icpp(1)%alpha_rho(2)': eps*1,
125+
'patch_icpp(1)%alpha(1)' : 1-eps,
126+
'patch_icpp(1)%alpha(2)' : eps,
127+
# ======================================
128+
129+
}
130+
131+
print(json.dumps(data))
230 KB
Loading
24.1 KB
Loading

src/pre_process/include/2dHardcodedIC.fpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
real(kind(0d0)) :: eps
44
real(kind(0d0)) :: r, rmax, gam, umax, p0
55

6+
real(kind(0d0)) :: rhoH, rhoL, pRef, pInt, h, lam, wl, amp, intH, alph
7+
68
eps = 1e-9
79

810
#:enddef
@@ -66,6 +68,38 @@
6668

6769
q_prim_vf(contxb)%sf(i, j, 0) = q_prim_vf(E_idx)%sf(i, j, 0)**(1d0/gam)
6870

71+
case (204) ! Rayleigh-Taylor instability
72+
rhoH = 3
73+
rhoL = 1
74+
pRef = 1e5
75+
pInt = pRef
76+
h = 0.7
77+
lam = 0.2
78+
wl = 2*pi/lam
79+
amp = 0.05/wl
80+
81+
intH = amp*sin(2*pi*x_cc(i)/lam - pi/2) + h
82+
83+
alph = 5d-1*(1 + tanh((y_cc(j) - intH)/2.5e-3))
84+
85+
if (alph < eps) alph = eps
86+
if (alph > 1 - eps) alph = 1 - eps
87+
88+
if (y_cc(j) > intH) then
89+
q_prim_vf(advxb)%sf(i, j, 0) = alph
90+
q_prim_vf(advxe)%sf(i, j, 0) = 1 - alph
91+
q_prim_vf(contxb)%sf(i, j, 0) = alph*rhoH
92+
q_prim_vf(contxe)%sf(i, j, 0) = (1 - alph)*rhoL
93+
q_prim_vf(E_idx)%sf(i, j, 0) = pref + rhoH*9.81*(1.2 - y_cc(j))
94+
else
95+
q_prim_vf(advxb)%sf(i, j, 0) = alph
96+
q_prim_vf(advxe)%sf(i, j, 0) = 1 - alph
97+
q_prim_vf(contxb)%sf(i, j, 0) = alph*rhoH
98+
q_prim_vf(contxe)%sf(i, j, 0) = (1 - alph)*rhoL
99+
pInt = pref + rhoH*9.81*(1.2 - intH)
100+
q_prim_vf(E_idx)%sf(i, j, 0) = pInt + rhoL*9.81*(intH - y_cc(j))
101+
end if
102+
69103
case default
70104
if (proc_rank == 0) then
71105
call s_int_to_str(patch_id, iStr)

0 commit comments

Comments
 (0)