Skip to content

Commit 461f228

Browse files
Dimitrios AdamDimitrios Adam
authored andcommitted
2D Cavity
1 parent 3cb0cc9 commit 461f228

4 files changed

Lines changed: 169 additions & 108 deletions

File tree

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,96 @@
1+
#!/usr/bin/env python3
12
import json
23
import math
3-
4-
h = 0.2
5-
6-
gam_a = 1.4
7-
p0 = 1
8-
rho0 = 1.4
9-
c0 = math.sqrt(gam_a * p0 / rho0)
10-
v0 = 3 * c0
11-
mu = rho0 * v0 * h / 2e5
4+
Lx = 0.04347
5+
Ly = 0.01466+3.048/1000
6+
Cav_Lx = 43.47/1000-21.99/1000-14.19/1000
7+
Cav_Ly = 3.048/1000
8+
Cav_CenterX = (Lx - 21.99/1000-14.15/1000)/2
9+
Cav_CenterY = 3.048/2000
10+
Cav_Center2X = 2*Cav_CenterX+14.15/1000+21.99/2000
1211

1312
# Configuring case dictionary
1413
print(
1514
json.dumps(
1615
{
1716
# Logistics
1817
"run_time_info": "T",
18+
# Computational Domain Parameters
1919
"x_domain%beg": 0.0,
20-
"x_domain%end": 15 * h,
20+
"x_domain%end": 0.04347,
2121
"y_domain%beg": 0.0,
22-
"y_domain%end": 5 * h,
23-
"cyl_coord": "F",
24-
"m": 1499,
22+
"y_domain%end": Ly,
23+
"m": 499,
2524
"n": 499,
2625
"p": 0,
27-
"cfl_adap_dt": "T",
28-
"cfl_target": 0.8,
29-
"n_start": 0,
30-
"t_save": 0.04,
31-
"t_stop": 4,
26+
"dt": 5e-09,
27+
"t_step_start": 0,
28+
"t_step_stop":60,
29+
"t_step_save": 20,
3230
# Simulation Algorithm Parameters
3331
"num_patches": 1,
3432
"model_eqns": 2,
3533
"alt_soundspeed": "F",
3634
"num_fluids": 1,
3735
"mpp_lim": "F",
38-
"mixture_err": "F",
36+
"mixture_err": "T",
3937
"time_stepper": 3,
40-
"weno_avg": "T",
38+
"mp_weno": "F",
39+
# 'recon_type' : 1,
4140
"weno_order": 5,
42-
"weno_eps": 1.0e-16,
43-
"avg_state": 2,
44-
"mapped_weno": "T",
45-
"null_weights": "F",
46-
"mp_weno": "T",
41+
"weno_eps": 1e-16,
42+
#'muscl_order' : 2,
43+
#'muscl_lim' : 1,
4744
"riemann_solver": 2,
4845
"wave_speeds": 1,
49-
"bc_x%beg": -3,
50-
"bc_x%end": -3,
51-
"bc_y%beg": -2,
52-
"bc_y%end": -2,
53-
"ib": "T",
54-
"num_ibs": 1,
46+
"avg_state": 2,
47+
"bc_x%beg": -7,
48+
"bc_x%end": -8,
49+
"bc_y%beg": -16,
50+
"bc_y%end": -16,
51+
"bc_x%grcbc_in": "T",
52+
"bc_x%vel_in(1)": 50.0,
53+
"bc_x%vel_in(2)": 0,
54+
"bc_x%pres_in": 101325.0,
55+
"bc_x%alpha_rho_in(1)": 1.00,
5556
# Formatted Database Files Structure Parameters
5657
"format": 1,
5758
"precision": 2,
5859
"prim_vars_wrt": "T",
5960
"parallel_io": "T",
60-
# Patch 1 Background
61+
"ib": "T",
62+
"num_ibs": 2,
63+
# Patch 1: Base
6164
"patch_icpp(1)%geometry": 3,
62-
"patch_icpp(1)%x_centroid": 7.5 * h,
63-
"patch_icpp(1)%y_centroid": 2.5 * h,
64-
"patch_icpp(1)%length_x": 15 * h,
65-
"patch_icpp(1)%length_y": 5 * h,
66-
"patch_icpp(1)%vel(1)": v0,
67-
"patch_icpp(1)%vel(2)": 0.0,
68-
"patch_icpp(1)%pres": p0,
69-
"patch_icpp(1)%alpha_rho(1)": rho0,
70-
"patch_icpp(1)%alpha(1)": 1.0,
71-
# Patch: No slip rectangle
72-
"patch_ib(1)%geometry": 3,
73-
"patch_ib(1)%x_centroid": 11.5 * h,
74-
"patch_ib(1)%y_centroid": 0 * h,
75-
"patch_ib(1)%length_x": 17 * h,
76-
"patch_ib(1)%length_y": 2 * h,
77-
"patch_ib(1)%slip": "T",
65+
"patch_icpp(1)%hcid": 291,
66+
"patch_icpp(1)%x_centroid": Lx/2,
67+
"patch_icpp(1)%y_centroid": Ly/2,
68+
"patch_icpp(1)%length_x": Lx,
69+
"patch_icpp(1)%length_y": Ly,
70+
"patch_icpp(1)%vel(1)": 0,
71+
"patch_icpp(1)%vel(2)": 0,
72+
"patch_icpp(1)%pres": 101325,
73+
"patch_icpp(1)%alpha_rho(1)": 1.00,
74+
"patch_icpp(1)%alpha(1)": 1,
75+
# Patch 1: IBM
76+
"patch_ib(1)%geometry": 3,
77+
"patch_ib(1)%x_centroid": 0,
78+
"patch_ib(1)%y_centroid": 0,
79+
"patch_ib(1)%length_x": 2*Cav_Lx,
80+
"patch_ib(1)%length_y": 2*Cav_Ly,
81+
"patch_ib(1)%slip": "F",
82+
# Patch 2: IBM
83+
"patch_ib(2)%geometry": 3,
84+
"patch_ib(2)%x_centroid": Lx,
85+
"patch_ib(2)%y_centroid": 0,
86+
"patch_ib(2)%length_x": 2*21.99/1000,
87+
"patch_ib(2)%length_y": 2*Cav_Ly,
88+
"patch_ib(2)%slip": "F",
7889
# Fluids Physical Parameters
79-
"fluid_pp(1)%gamma": 1.0 / (gam_a - 1.0),
80-
"fluid_pp(1)%pi_inf": 0.0,
81-
"viscous": "T",
82-
"fluid_pp(1)%Re(1)": 1 / mu,
83-
},
84-
indent=4,
90+
"fluid_pp(1)%gamma": 1.0e00 / (1.4e00 - 1.0e00),
91+
"fluid_pp(1)%pi_inf": 0.0e00,
92+
"viscous": "T",
93+
"fluid_pp(1)%Re(1)": 100000,
94+
}
8595
)
8696
)

examples/2D_riemann_test/case.py

Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
#!/usr/bin/env python3
22
import json
33
import math
4+
Lx = 0.04347
5+
Ly = 0.01466+3.048/1000
6+
Cav_Lx = 43.47/1000-21.99/1000-14.19/1000
7+
Cav_Ly = 3.048/1000
8+
Cav_CenterX = (Lx - 21.99/1000-14.15/1000)/2
9+
Cav_CenterY = 3.048/2000
10+
Cav_Center2X = 2*Cav_CenterX+14.15/1000+21.99/2000
411

512
# Configuring case dictionary
613
print(
@@ -10,18 +17,18 @@
1017
"run_time_info": "T",
1118
# Computational Domain Parameters
1219
"x_domain%beg": 0.0,
13-
"x_domain%end": 1.0,
20+
"x_domain%end": 0.04347,
1421
"y_domain%beg": 0.0,
15-
"y_domain%end": 1.0,
22+
"y_domain%end": Ly,
1623
"m": 499,
1724
"n": 499,
1825
"p": 0,
19-
"dt": 8e-05,
26+
"dt": 8.0e-08,
2027
"t_step_start": 0,
21-
"t_step_stop": 10000,
22-
"t_step_save": 100,
28+
"t_step_stop": 2000,
29+
"t_step_save": 50,
2330
# Simulation Algorithm Parameters
24-
"num_patches": 4,
31+
"num_patches": 1,
2532
"model_eqns": 2,
2633
"alt_soundspeed": "F",
2734
"num_fluids": 1,
@@ -37,62 +44,48 @@
3744
"riemann_solver": 2,
3845
"wave_speeds": 1,
3946
"avg_state": 2,
40-
"bc_x%beg": -3,
41-
"bc_x%end": -3,
42-
"bc_y%beg": -3,
43-
"bc_y%end": -3,
47+
"bc_x%beg": -7,
48+
"bc_x%end": -8,
49+
"bc_y%beg": -16,
50+
"bc_y%end": -16,
4451
# Formatted Database Files Structure Parameters
4552
"format": 1,
4653
"precision": 2,
4754
"prim_vars_wrt": "T",
4855
"parallel_io": "T",
56+
"ib": "T",
57+
"num_ibs": 2,
4958
# Patch 1: Base
5059
"patch_icpp(1)%geometry": 3,
51-
"patch_icpp(1)%x_centroid": 0.4,
52-
"patch_icpp(1)%y_centroid": 0.4,
53-
"patch_icpp(1)%length_x": 0.8,
54-
"patch_icpp(1)%length_y": 0.8,
55-
"patch_icpp(1)%vel(1)": 4 / math.sqrt(11),
56-
"patch_icpp(1)%vel(2)": 4 / math.sqrt(11),
57-
"patch_icpp(1)%pres": 9 / 310,
58-
"patch_icpp(1)%alpha_rho(1)": 77 / 558,
60+
"patch_icpp(1)%hcid": 291,
61+
"patch_icpp(1)%x_centroid": Lx/2,
62+
"patch_icpp(1)%y_centroid": Ly/2,
63+
"patch_icpp(1)%length_x": Lx,
64+
"patch_icpp(1)%length_y": Ly,
65+
"patch_icpp(1)%vel(1)": 0,
66+
"patch_icpp(1)%vel(2)": 0,
67+
"patch_icpp(1)%pres": 101325,
68+
"patch_icpp(1)%alpha_rho(1)": 1.00,
5969
"patch_icpp(1)%alpha(1)": 1,
60-
# Patch 1: Base
61-
"patch_icpp(2)%geometry": 3,
62-
"patch_icpp(2)%x_centroid": 0.4,
63-
"patch_icpp(2)%y_centroid": 0.9,
64-
"patch_icpp(2)%length_x": 0.8,
65-
"patch_icpp(2)%length_y": 0.2,
66-
"patch_icpp(2)%vel(1)": 4 / math.sqrt(11),
67-
"patch_icpp(2)%vel(2)": 0,
68-
"patch_icpp(2)%pres": 0.3,
69-
"patch_icpp(2)%alpha_rho(1)": 33 / 62,
70-
"patch_icpp(2)%alpha(1)": 1,
71-
# Patch 1: Base
72-
"patch_icpp(3)%geometry": 3,
73-
"patch_icpp(3)%x_centroid": 0.9,
74-
"patch_icpp(3)%y_centroid": 0.4,
75-
"patch_icpp(3)%length_x": 0.2,
76-
"patch_icpp(3)%length_y": 0.8,
77-
"patch_icpp(3)%vel(1)": 0,
78-
"patch_icpp(3)%vel(2)": 4 / math.sqrt(11),
79-
"patch_icpp(3)%pres": 0.3,
80-
"patch_icpp(3)%alpha_rho(1)": 33 / 62,
81-
"patch_icpp(3)%alpha(1)": 1,
82-
# Patch 1: Base
83-
"patch_icpp(4)%geometry": 3,
84-
"patch_icpp(4)%x_centroid": 0.9,
85-
"patch_icpp(4)%y_centroid": 0.9,
86-
"patch_icpp(4)%length_x": 0.2,
87-
"patch_icpp(4)%length_y": 0.2,
88-
"patch_icpp(4)%vel(1)": 0,
89-
"patch_icpp(4)%vel(2)": 0,
90-
"patch_icpp(4)%pres": 1.5,
91-
"patch_icpp(4)%alpha_rho(1)": 1.5,
92-
"patch_icpp(4)%alpha(1)": 1.0,
70+
# Patch 1: IBM
71+
"patch_ib(1)%geometry": 3,
72+
"patch_ib(1)%x_centroid": 0,
73+
"patch_ib(1)%y_centroid": 0,
74+
"patch_ib(1)%length_x": 2*Cav_Lx,
75+
"patch_ib(1)%length_y": 2*Cav_Ly,
76+
"patch_ib(1)%slip": "F",
77+
# Patch 2: IBM
78+
"patch_ib(2)%geometry": 3,
79+
"patch_ib(2)%x_centroid": Lx,
80+
"patch_ib(2)%y_centroid": 0,
81+
"patch_ib(2)%length_x": 2*21.99/1000,
82+
"patch_ib(2)%length_y": 2*Cav_Ly,
83+
"patch_ib(2)%slip": "F",
9384
# Fluids Physical Parameters
9485
"fluid_pp(1)%gamma": 1.0e00 / (1.4e00 - 1.0e00),
9586
"fluid_pp(1)%pi_inf": 0.0e00,
87+
"viscous": "T",
88+
"fluid_pp(1)%Re(1)": 100000,
9689
}
9790
)
9891
)

src/common/include/2dHardcodedIC.fpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
real(wp) :: factor
77
real(wp) :: r0, alpha, r2
88
real(wp) :: sinA, cosA
9+
real(wp) :: deee
910

1011
real(wp) :: r_sq
1112

1213
! # 207
1314
real(wp) :: sigma, gauss1, gauss2
1415
! # 208
1516
real(wp) :: ei, d, fsm, alpha_air, alpha_sf6
17+
real(wp) :: x_transition ! Location of transition center
18+
real(wp) :: y_shear_layer, delta_shear, tanh_arg, mix_factor
19+
real(wp) :: u_max, p_ref, rho_ref
20+
real(wp) :: u_mean, v_kick, perturbation_amp, perturbation_k
1621

1722
eps = 1.e-9_wp
1823
#:enddef
@@ -331,6 +336,55 @@
331336
q_prim_vf(momxb + 1)%sf(i, j, 0) = 112.99092883944267*((0.1/0.3))*x_cc(i)*exp(0.5*(1 - sqrt(x_cc(i)**2 + y_cc(j)**2)))
332337
end if
333338

339+
case (291)
340+
341+
y_shear_layer = 3.048e-3_wp
342+
343+
! 2. Shear Layer Thickness (Smoothing)
344+
! This spreads the jump over approx 1.0 mm to prevent acoustic shock.
345+
delta_shear = 0.5e-3_wp
346+
347+
! 3. Flow Reference Conditions
348+
u_max = 50.0_wp ! Freestream Velocity (m/s)
349+
p_ref = 101325.0_wp ! Reference Pressure (Pa) - KEEP CONSTANT
350+
rho_ref = 1.0_wp ! Reference Density (kg/m3) - KEEP CONSTANT
351+
352+
! 4. Perturbation Parameters (To trigger vortices)
353+
! Amplitude: 5% of freestream velocity
354+
! Wavenumber: Makes the kick oscillate along X
355+
perturbation_amp = 0.05_wp * u_max
356+
perturbation_k = 200.0_wp ! Adjust to fit
357+
358+
tanh_arg = (y_cc(j) - y_shear_layer) / delta_shear
359+
mix_factor = 0.5_wp * (1.0_wp + tanh(tanh_arg))
360+
361+
! --- B. Mean Velocity ---
362+
u_mean = u_max * mix_factor
363+
364+
! --- C. Vertical Perturbation (The "Kick") ---
365+
! This adds a small vertical wiggle ONLY near the shear layer.
366+
! exp(...) ensures the kick is zero far away from the interface.
367+
! sin(...) makes it oscillate along the streamwise direction.
368+
369+
v_kick = perturbation_amp * &
370+
sin(perturbation_k * x_cc(i)) * &
371+
exp( -1.0_wp * (tanh_arg**2) )
372+
373+
! --- D. Assign to State Vector ---
374+
! 1. Density (Constant)
375+
q_prim_vf(contxb)%sf(i,j,0) = rho_ref
376+
377+
! 2. U-Velocity (Smooth Profile)
378+
q_prim_vf(momxb)%sf(i,j,0) = u_mean
379+
380+
! 3. V-Velocity (The Perturbation)
381+
q_prim_vf(momxe)%sf(i,j,0) = v_kick
382+
383+
! 4. W-Velocity (assuming 2D or 0 initially)
384+
! q_prim_vf(momxz)%sf(i,j,0) = 0.0_wp
385+
386+
! 5. Pressure (Constant - Crucial for stability!)
387+
q_prim_vf(E_idx)%sf(i,j,0) = p_ref
334388
case default
335389
if (proc_rank == 0) then
336390
call s_int_to_str(patch_id, iStr)

src/simulation/m_ibm.fpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ contains
181181
real(wp) :: pres_IP
182182
real(wp), dimension(3) :: vel_IP, vel_norm_IP
183183
real(wp) :: c_IP
184+
real(wp) :: T_IP
185+
real(wp), dimension(num_species) :: Ys_IP
184186
#:if not MFC_CASE_OPTIMIZATION and USING_AMD
185187
real(wp), dimension(3) :: Gs
186188
real(wp), dimension(3) :: alpha_rho_IP, alpha_IP
@@ -264,9 +266,9 @@ contains
264266
call s_interpolate_image_point(q_prim_vf, gp, &
265267
alpha_rho_IP, alpha_IP, pres_IP, vel_IP, c_IP, &
266268
r_IP, v_IP, pb_IP, mv_IP, nmom_IP, pb_in, mv_in, presb_IP, massv_IP)
267-
else
269+
else
268270
call s_interpolate_image_point(q_prim_vf, gp, &
269-
alpha_rho_IP, alpha_IP, pres_IP, vel_IP, c_IP)
271+
alpha_rho_IP, alpha_IP, pres_IP, vel_IP, c_IP, T_IP=T_IP, Ys_IP=Ys_IP)
270272
end if
271273

272274
dyn_pres = 0._wp
@@ -852,7 +854,7 @@ contains
852854
!! at the cell centers in order to estimate the state at the image point
853855
subroutine s_interpolate_image_point(q_prim_vf, gp, alpha_rho_IP, alpha_IP, &
854856
pres_IP, vel_IP, c_IP, r_IP, v_IP, pb_IP, &
855-
mv_IP, nmom_IP, pb_in, mv_in, presb_IP, massv_IP)
857+
mv_IP, nmom_IP, pb_in, mv_in, presb_IP, massv_IP,T_IP,Ys_IP)
856858
$:GPU_ROUTINE(parallelism='[seq]')
857859
type(scalar_field), &
858860
dimension(sys_size), &
@@ -872,6 +874,8 @@ contains
872874
real(wp), optional, dimension(:), intent(INOUT) :: r_IP, v_IP, pb_IP, mv_IP
873875
real(wp), optional, dimension(:), intent(INOUT) :: nmom_IP
874876
real(wp), optional, dimension(:), intent(INOUT) :: presb_IP, massv_IP
877+
real(wp), optional, dimension(num_species), intent(INOUT) :: Ys_IP
878+
real(wp), optional, intent(INOUT) :: T_IP
875879
876880
integer :: i, j, k, l, q !< Iterator variables
877881
integer :: i1, i2, j1, j2, k1, k2 !< Iterator variables

0 commit comments

Comments
 (0)