Skip to content

Commit 6acd75e

Browse files
Dimitrios AdamDimitrios Adam
authored andcommitted
hehe
1 parent 461f228 commit 6acd75e

10 files changed

Lines changed: 340 additions & 66 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
240240
message(STATUS "LTO/IPO is not available with NVHPC using Unified Memory")
241241
elseif(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "23.11")
242242
message(STATUS "LTO/IPO is not supported in NVHPC Version < 23.11. Use a newer version of NVHPC for best performance.")
243-
else()
243+
elseif (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER "24.11" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "25.9")
244+
message(STATUS "LTO/IPO is not supported in NVHPC Version 24.11 to 25.9. Use >=25.9 or (<=24.11 && > 23.11) Performance will be degraded.")
245+
set(NVHPC_USE_TWO_PASS_IPO FALSE)
246+
else()
247+
244248
message(STATUS "Performing IPO using -Mextract followed by -Minline")
245249
set(NVHPC_USE_TWO_PASS_IPO TRUE)
246250
endif()

examples/1D_reactive_shocktube/case.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@
110110
if args.chemistry:
111111
for i in range(len(sol_L.Y)):
112112
case[f"chem_wrt_Y({i + 1})"] = "T"
113-
case[f"patch_icpp(1)%Y({i+1})"] = sol_L.Y[i]
114-
case[f"patch_icpp(2)%Y({i+1})"] = sol_R.Y[i]
115113

116114
if __name__ == "__main__":
117115
print(json.dumps(case))

examples/2D_riemann_test/case.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22
import json
33
import math
4+
import cantera as ct
5+
46
Lx = 0.04347
57
Ly = 0.01466+3.048/1000
68
Cav_Lx = 43.47/1000-21.99/1000-14.19/1000
@@ -9,10 +11,12 @@
911
Cav_CenterY = 3.048/2000
1012
Cav_Center2X = 2*Cav_CenterX+14.15/1000+21.99/2000
1113

14+
15+
ctfile = "h2.yaml"
16+
sol_L = ct.Solution(ctfile)
17+
sol_L.TPY = 1125, ct.one_atm, "O2:0.21,N2:0.79"
1218
# Configuring case dictionary
13-
print(
14-
json.dumps(
15-
{
19+
case = {
1620
# Logistics
1721
"run_time_info": "T",
1822
# Computational Domain Parameters
@@ -23,10 +27,10 @@
2327
"m": 499,
2428
"n": 499,
2529
"p": 0,
26-
"dt": 8.0e-08,
30+
"dt": 4.0e-08,
2731
"t_step_start": 0,
28-
"t_step_stop": 2000,
29-
"t_step_save": 50,
32+
"t_step_stop": 10000,
33+
"t_step_save": 1000,
3034
# Simulation Algorithm Parameters
3135
"num_patches": 1,
3236
"model_eqns": 2,
@@ -45,7 +49,7 @@
4549
"wave_speeds": 1,
4650
"avg_state": 2,
4751
"bc_x%beg": -7,
48-
"bc_x%end": -8,
52+
"bc_x%end": -3,
4953
"bc_y%beg": -16,
5054
"bc_y%end": -16,
5155
# Formatted Database Files Structure Parameters
@@ -54,7 +58,14 @@
5458
"prim_vars_wrt": "T",
5559
"parallel_io": "T",
5660
"ib": "T",
57-
"num_ibs": 2,
61+
"num_ibs": 1,
62+
"omega_wrt(3)": "T",
63+
"fd_order": 2,
64+
"chemistry": "T" ,
65+
"chem_params%diffusion": "T",
66+
"chem_params%reactions": "F",
67+
"cantera_file": ctfile,
68+
"chem_wrt_T": "T",
5869
# Patch 1: Base
5970
"patch_icpp(1)%geometry": 3,
6071
"patch_icpp(1)%hcid": 291,
@@ -71,21 +82,26 @@
7182
"patch_ib(1)%geometry": 3,
7283
"patch_ib(1)%x_centroid": 0,
7384
"patch_ib(1)%y_centroid": 0,
74-
"patch_ib(1)%length_x": 2*Cav_Lx,
85+
"patch_ib(1)%length_x": 0.1,
7586
"patch_ib(1)%length_y": 2*Cav_Ly,
7687
"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",
88+
89+
# # Patch 2: IBM
90+
# "patch_ib(2)%geometry": 3,
91+
# "patch_ib(2)%x_centroid": Lx,
92+
# "patch_ib(2)%y_centroid": 0,
93+
# "patch_ib(2)%length_x": 2*21.99/1000,
94+
# "patch_ib(2)%length_y": 2*Cav_Ly,
95+
# "patch_ib(2)%slip": "F",
8496
# Fluids Physical Parameters
8597
"fluid_pp(1)%gamma": 1.0e00 / (1.4e00 - 1.0e00),
8698
"fluid_pp(1)%pi_inf": 0.0e00,
8799
"viscous": "T",
88100
"fluid_pp(1)%Re(1)": 100000,
89101
}
90-
)
91-
)
102+
for i in range(len(sol_L.Y)):
103+
case[f"chem_wrt_Y({i + 1})"] = "T"
104+
case[f"patch_icpp(1)%Y({i+1})"] = sol_L.Y[i]
105+
106+
if __name__ == "__main__":
107+
print(json.dumps(case))

examples/2D_riemann_test/h2.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
description: |-
2+
Hydrogen-Oxygen submechanism extracted from GRI-Mech 3.0.
3+
Modified from the original to include N2.
4+
5+
Redlich-Kwong coefficients are based on tabulated critical properties or
6+
estimated according to the method of Joback and Reid, "Estimation of pure-
7+
component properties from group-contributions," Chem. Eng. Comm. 57 (1987)
8+
233-243
9+
10+
generator: ck2yaml
11+
input-files: [h2o2.inp, gri30_tran.dat]
12+
cantera-version: 2.5.0
13+
date: Wed, 11 Dec 2019 16:59:04 -0500
14+
15+
units: {length: cm, time: s, quantity: mol, activation-energy: cal/mol}
16+
17+
phases:
18+
- name: ohmech
19+
thermo: ideal-gas
20+
elements: [O, N]
21+
species: [ O2, N2]
22+
kinetics: gas
23+
transport: mixture-averaged
24+
state: {T: 300.0, P: 1 atm}
25+
26+
- name: ohmech-RK
27+
thermo: Redlich-Kwong
28+
elements: [O, N]
29+
species: [ O2, N2]
30+
kinetics: gas
31+
transport: mixture-averaged
32+
state: {T: 300.0, P: 1 atm}
33+
34+
species:
35+
- name: O2
36+
composition: {O: 2}
37+
thermo:
38+
model: NASA7
39+
temperature-ranges: [200.0, 1000.0, 3500.0]
40+
data:
41+
- [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12,
42+
-1063.94356, 3.65767573]
43+
- [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14,
44+
-1088.45772, 5.45323129]
45+
note: TPIS89
46+
transport:
47+
model: gas
48+
geometry: linear
49+
well-depth: 107.4
50+
diameter: 3.458
51+
polarizability: 1.6
52+
rotational-relaxation: 3.8
53+
equation-of-state:
54+
model: Redlich-Kwong
55+
a: 1.74102e+12
56+
b: 22.08100907
57+
58+
- name: N2
59+
composition: {N: 2}
60+
thermo:
61+
model: NASA7
62+
temperature-ranges: [300.0, 1000.0, 5000.0]
63+
data:
64+
- [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12,
65+
-1020.8999, 3.950372]
66+
- [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15,
67+
-922.7977, 5.980528]
68+
note: '121286'
69+
transport:
70+
model: gas
71+
geometry: linear
72+
well-depth: 97.53
73+
diameter: 3.621
74+
polarizability: 1.76
75+
rotational-relaxation: 4.0
76+
equation-of-state:
77+
model: Redlich-Kwong
78+
a: 1.55976e+12
79+
b: 26.81724983
80+
81+
reactions:
82+
- equation: O2 + N2 + M <=> O2 + N2 + M # Reaction 1
83+
type: three-body
84+
rate-constant: {A: 1.2e+17, b: -1.0, Ea: 0.0}

src/common/include/2dHardcodedIC.fpp

Lines changed: 64 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
real(wp) :: y_shear_layer, delta_shear, tanh_arg, mix_factor
1919
real(wp) :: u_max, p_ref, rho_ref
2020
real(wp) :: u_mean, v_kick, perturbation_amp, perturbation_k
21+
real(wp) :: T_wall, T_inf, P_atm, y_height, T_loc,y_dist
22+
real(wp) :: delta_th, T_target, rho_target, R_mix
23+
real(wp) :: Y_N2, Y_O2, MW_N2, MW_O2
24+
real(wp) :: x_lim_left, x_lim_right
2125

2226
eps = 1.e-9_wp
2327
#:enddef
@@ -338,53 +342,82 @@ real(wp) :: u_mean, v_kick, perturbation_amp, perturbation_k
338342

339343
case (291)
340344

341-
y_shear_layer = 3.048e-3_wp
345+
! Setup Values
346+
T_wall = 600.0_wp
347+
T_inf = 1125.0_wp
348+
P_atm = 101325.0_wp ! 1 atm in Pa
349+
delta_th = 0.0001_wp ! Thermal BL thickness (e.g., 2mm - ADJUST THIS)
350+
351+
! Geometry Limits (converting mm to meters if your grid is in meters)
352+
x_lim_left = (43.48e-3_wp - 21.99e-3_wp - 14.15e-3_wp)
353+
x_lim_right = (43.48e-3_wp - 21.99e-3_wp)
354+
355+
! Air Properties (Approximate)
356+
MW_N2 = 28.0134e-3_wp ! kg/mol
357+
MW_O2 = 31.999e-3_wp ! kg/mol
358+
Y_N2 = 0.767_wp ! Mass fraction
359+
Y_O2 = 0.233_wp
360+
361+
! Calculate Mixture Gas Constant R_mix = R_u * sum(Y_i / MW_i)
362+
R_mix = 8.314462618_wp * ( (Y_N2 / MW_N2) + (Y_O2 / MW_O2) )
363+
364+
y_shear_layer = 3.048e-3_wp
342365

343366
! 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
367+
delta_shear = 0.8e-3_wp
346368

347-
! 3. Flow Reference Conditions
369+
! Flow Reference Conditions
348370
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
371+
p_ref = 101325.0_wp ! Reference Pressure (Pa)
372+
rho_ref = 1.0_wp ! Reference Density (kg/m3)
373+
374+
! Perturbation Parameters (To trigger vortices/Rossiter modes)
375+
perturbation_amp = 0.05_wp * u_max ! Amplitude: 5% of freestream
376+
perturbation_k = 200.0_wp ! Wavenumber: Oscillations along X
377+
378+
379+
380+
381+
IF (y_cc(j) > y_shear_layer) THEN
351382

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
383+
tanh_arg = (y_cc(j) - y_shear_layer) / delta_shear
384+
mix_factor = tanh(tanh_arg)
385+
u_mean = u_max * mix_factor
357386

358-
tanh_arg = (y_cc(j) - y_shear_layer) / delta_shear
359-
mix_factor = 0.5_wp * (1.0_wp + tanh(tanh_arg))
387+
v_kick = 0.0_wp
360388

361-
! --- B. Mean Velocity ---
362-
u_mean = u_max * mix_factor
389+
ELSE
390+
391+
392+
u_mean = 0.0_wp
393+
v_kick = 0.0_wp
394+
395+
END IF
396+
397+
!IF (y_cc(j) > y_shear_layer-0.01) THEN
363398

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.
368399

369-
v_kick = perturbation_amp * &
370-
sin(perturbation_k * x_cc(i)) * &
371-
exp( -1.0_wp * (tanh_arg**2) )
400+
! We are in the Left or Right regions: Apply Tanh Profile
401+
! y_dist = y_cc(j) ! Distance from bottom wall
402+
403+
! Tanh Temperature Profile: T = Tw + (Tinf - Tw) * tanh(y/delta)
404+
! T_loc = T_wall + (T_inf - T_wall) * tanh((y_dist-y_shear_layer) / delta_th)
405+
372406

373-
! --- D. Assign to State Vector ---
374-
! 1. Density (Constant)
375-
q_prim_vf(contxb)%sf(i,j,0) = rho_ref
407+
! else
408+
! We are in the middle gap: Uniform Freestream Temperature
409+
T_loc = T_inf
410+
! end if
376411

377-
! 2. U-Velocity (Smooth Profile)
412+
q_prim_vf(contxb)%sf(i,j,0) = P_atm / (R_mix * T_loc)
378413
q_prim_vf(momxb)%sf(i,j,0) = u_mean
379414

380-
! 3. V-Velocity (The Perturbation)
381415
q_prim_vf(momxe)%sf(i,j,0) = v_kick
382416

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!)
387417
q_prim_vf(E_idx)%sf(i,j,0) = p_ref
418+
419+
q_prim_vf(chemxb)%sf(i,j,0) = 0.21_wp
420+
q_prim_vf(chemxe)%sf(i,j,0) = 0.79_wp
388421
case default
389422
if (proc_rank == 0) then
390423
call s_int_to_str(patch_id, iStr)

src/common/m_chemistry.fpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,16 @@ contains
248248
rho_L = q_prim_qp(1)%sf(x, y, z)
249249
rho_R = q_prim_qp(1)%sf(x + offsets(1), y + offsets(2), z + offsets(3))
250250

251-
T_L = P_L/rho_L/Rgas_L
251+
T_L = P_L/rho_L/Rgas_L
252252
T_R = P_R/rho_R/Rgas_R
253253

254254
rho_cell = 0.5_wp*(rho_L + rho_R)
255255
dT_dxi = (T_R - T_L)/grid_spacing
256256

257+
if (x .eq. 200 .and. idir .eq. 2) then
258+
print *, dT_dxi, y , T_L, T_R
259+
end if
260+
257261
! Get transport properties
258262
call get_species_mass_diffusivities_mixavg(P_L, T_L, Ys_L, mass_diffusivities_mixavg1)
259263
call get_species_mass_diffusivities_mixavg(P_R, T_R, Ys_R, mass_diffusivities_mixavg2)

0 commit comments

Comments
 (0)