Skip to content

Commit f152e85

Browse files
authored
Merge branch 'master' into prcode
2 parents 09b8fb7 + 108805c commit f152e85

38 files changed

+1295
-387
lines changed

.github/workflows/phoenix/submit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sbatch_cpu_opts="\
2020
"
2121

2222
sbatch_gpu_opts="\
23-
#SBATCH -p gpu-v100,gpu-a100,gpu-h100
23+
#SBATCH -p gpu-v100,gpu-a100,gpu-h100,gpu-l40s
2424
#SBATCH -G2\
2525
"
2626

src/common/m_chemistry.fpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
!!>
2+
!! @file m_chemistry.f90
3+
!! @brief Contains module m_chemistry
4+
!! @author Henry Le Berre <hberre3@gatech.edu>
5+
6+
#:include 'macros.fpp'
7+
#:include 'case.fpp'
8+
9+
module m_chemistry
10+
11+
use m_thermochem, only: &
12+
num_species, mol_weights, get_temperature, get_net_production_rates
13+
14+
use m_global_parameters
15+
16+
implicit none
17+
18+
contains
19+
20+
subroutine s_compute_q_T_sf(q_T_sf, q_cons_vf, bounds)
21+
22+
! Initialize the temperature field at the start of the simulation to
23+
! reasonable values. Temperature is computed the regular way using the
24+
! conservative variables.
25+
26+
type(scalar_field), intent(inout) :: q_T_sf
27+
type(scalar_field), dimension(sys_size), intent(in) :: q_cons_vf
28+
type(int_bounds_info), dimension(1:3), intent(in) :: bounds
29+
30+
integer :: x, y, z, eqn
31+
real(wp) :: energy, mean_molecular_weight
32+
real(wp), dimension(num_species) :: Ys
33+
34+
do z = bounds(3)%beg, bounds(3)%end
35+
do y = bounds(2)%beg, bounds(2)%end
36+
do x = bounds(1)%beg, bounds(1)%end
37+
!$acc loop seq
38+
do eqn = chemxb, chemxe
39+
Ys(eqn - chemxb + 1) = &
40+
q_cons_vf(eqn)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z)
41+
end do
42+
43+
! e = E - 1/2*|u|^2
44+
! cons. E_idx = \rho E
45+
! cons. contxb = \rho (1-fluid model)
46+
! cons. momxb + i = \rho u_i
47+
energy = q_cons_vf(E_idx)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z)
48+
!$acc loop seq
49+
do eqn = momxb, momxe
50+
energy = energy - &
51+
0.5_wp*(q_cons_vf(eqn)%sf(x, y, z)/q_cons_vf(contxb)%sf(x, y, z))**2._wp
52+
end do
53+
54+
call get_temperature(energy, dflt_T_guess, Ys, .true., q_T_sf%sf(x, y, z))
55+
end do
56+
end do
57+
end do
58+
59+
end subroutine s_compute_q_T_sf
60+
61+
subroutine s_compute_chemistry_reaction_flux(rhs_vf, q_cons_qp, q_T_sf, q_prim_qp, bounds)
62+
63+
type(scalar_field), dimension(sys_size), intent(inout) :: rhs_vf
64+
type(scalar_field), intent(inout) :: q_T_sf
65+
type(scalar_field), dimension(sys_size), intent(inout) :: q_cons_qp, q_prim_qp
66+
type(int_bounds_info), dimension(1:3), intent(in) :: bounds
67+
68+
integer :: x, y, z
69+
integer :: eqn
70+
real(wp) :: T
71+
real(wp) :: rho, omega_m
72+
real(wp), dimension(num_species) :: Ys
73+
real(wp), dimension(num_species) :: omega
74+
75+
!$acc parallel loop collapse(3) gang vector default(present) &
76+
!$acc private(Ys, omega)
77+
do z = bounds(3)%beg, bounds(3)%end
78+
do y = bounds(2)%beg, bounds(2)%end
79+
do x = bounds(1)%beg, bounds(1)%end
80+
81+
!$acc loop seq
82+
do eqn = chemxb, chemxe
83+
Ys(eqn - chemxb + 1) = q_prim_qp(eqn)%sf(x, y, z)
84+
end do
85+
86+
rho = q_cons_qp(contxe)%sf(x, y, z)
87+
T = q_T_sf%sf(x, y, z)
88+
89+
call get_net_production_rates(rho, T, Ys, omega)
90+
91+
!$acc loop seq
92+
do eqn = chemxb, chemxe
93+
94+
omega_m = mol_weights(eqn - chemxb + 1)*omega(eqn - chemxb + 1)
95+
96+
rhs_vf(eqn)%sf(x, y, z) = rhs_vf(eqn)%sf(x, y, z) + omega_m
97+
98+
end do
99+
100+
end do
101+
end do
102+
end do
103+
104+
end subroutine s_compute_chemistry_reaction_flux
105+
106+
end module m_chemistry

src/common/m_constants.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ module m_constants
3030
real(wp), parameter :: broadband_spectral_level_constant = 20._wp !< The constant to scale the spectral level at the lower frequency bound
3131
real(wp), parameter :: broadband_spectral_level_growth_rate = 10._wp !< The spectral level constant to correct the magnitude at each frqeuency to ensure the source is overall broadband
3232

33+
! Chemistry
34+
real(wp), parameter :: dflt_T_guess = 1200._wp ! Default guess for temperature (when a previous value is not available)
35+
3336
! IBM+STL interpolation constants
3437
integer, parameter :: Ifactor_2D = 50 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 2D models
3538
integer, parameter :: Ifactor_3D = 5 !< Multiple factor of the ratio (edge to cell width) for interpolation along edges for 3D models

src/common/m_variables_conversion.fpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,15 @@ contains
128128
real(wp), intent(in) :: energy, alf
129129
real(wp), intent(in) :: dyn_p
130130
real(wp), intent(in) :: pi_inf, gamma, rho, qv
131-
real(wp), intent(out) :: pres, T
131+
real(wp), intent(out) :: pres
132+
real(wp), intent(inout) :: T
132133
real(wp), intent(in), optional :: stress, mom, G
133134

134135
! Chemistry
135136
real(wp), dimension(1:num_species), intent(in) :: rhoYks
136137
real(wp) :: E_e
137138
real(wp) :: e_Per_Kg, Pdyn_Per_Kg
139+
real(wp) :: T_guess
138140
real(wp), dimension(1:num_species) :: Y_rs
139141

140142
integer :: s !< Generic loop iterator
@@ -183,7 +185,9 @@ contains
183185
e_Per_Kg = energy/rho
184186
Pdyn_Per_Kg = dyn_p/rho
185187

186-
call get_temperature(e_Per_Kg - Pdyn_Per_Kg, 1200._wp, Y_rs, .true., T)
188+
T_guess = T
189+
190+
call get_temperature(e_Per_Kg - Pdyn_Per_Kg, T_guess, Y_rs, .true., T)
187191
call get_pressure(rho, T, Y_rs, pres)
188192

189193
#:endif
@@ -815,11 +819,13 @@ contains
815819
!! @param iy Index bounds in second coordinate direction
816820
!! @param iz Index bounds in third coordinate direction
817821
subroutine s_convert_conservative_to_primitive_variables(qK_cons_vf, &
822+
q_T_sf, &
818823
qK_prim_vf, &
819824
ibounds, &
820825
gm_alphaK_vf)
821826

822827
type(scalar_field), dimension(sys_size), intent(in) :: qK_cons_vf
828+
type(scalar_field), intent(inout) :: q_T_sf
823829
type(scalar_field), dimension(sys_size), intent(inout) :: qK_prim_vf
824830
type(int_bounds_info), dimension(1:3), intent(in) :: ibounds
825831
type(scalar_field), &
@@ -846,11 +852,11 @@ contains
846852

847853
real(wp) :: G_K
848854

849-
real(wp) :: pres, Yksum, T
855+
real(wp) :: pres, Yksum
850856

851857
integer :: i, j, k, l, q !< Generic loop iterators
852858

853-
real(wp) :: ntmp
859+
real(wp) :: ntmp, T
854860

855861
#:if MFC_CASE_OPTIMIZATION
856862
#ifndef MFC_SIMULATION
@@ -923,8 +929,6 @@ contains
923929
do i = chemxb, chemxe
924930
qK_prim_vf(i)%sf(j, k, l) = max(0._wp, qK_cons_vf(i)%sf(j, k, l)/rho_K)
925931
end do
926-
927-
qK_prim_vf(T_idx)%sf(j, k, l) = qK_cons_vf(T_idx)%sf(j, k, l)
928932
else
929933
!$acc loop seq
930934
do i = 1, contxe
@@ -954,15 +958,19 @@ contains
954958
do i = 1, num_species
955959
rhoYks(i) = qK_cons_vf(chemxb + i - 1)%sf(j, k, l)
956960
end do
961+
962+
T = q_T_sf%sf(j, k, l)
957963
end if
958964

959965
call s_compute_pressure(qK_cons_vf(E_idx)%sf(j, k, l), &
960966
qK_cons_vf(alf_idx)%sf(j, k, l), &
961-
dyn_pres_K, pi_inf_K, gamma_K, rho_K, qv_K, rhoYks, pres, T)
967+
dyn_pres_K, pi_inf_K, gamma_K, rho_K, &
968+
qv_K, rhoYks, pres, T)
962969

963970
qK_prim_vf(E_idx)%sf(j, k, l) = pres
971+
964972
if (chemistry) then
965-
qK_prim_vf(T_idx)%sf(j, k, l) = T
973+
q_T_sf%sf(j, k, l) = T
966974
end if
967975

968976
if (bubbles) then
@@ -1129,8 +1137,6 @@ contains
11291137

11301138
q_cons_vf(E_idx)%sf(j, k, l) = &
11311139
dyn_pres + rho*e_mix
1132-
1133-
q_cons_vf(T_idx)%sf(j, k, l) = q_prim_vf(T_idx)%sf(j, k, l)
11341140
else
11351141
! Computing the energy from the pressure
11361142
if ((model_eqns /= 4) .and. (bubbles .neqv. .true.)) then

src/post_process/m_data_input.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ end subroutine s_read_abstract_data_files
5151
type(scalar_field), allocatable, dimension(:), public :: q_prim_vf !<
5252
!! Primitive variables
5353

54+
type(scalar_field), public :: q_T_sf !<
55+
!! Temperature field
56+
5457
! type(scalar_field), public :: ib_markers !<
5558
type(integer_field), public :: ib_markers
5659

@@ -1173,6 +1176,12 @@ subroutine s_initialize_data_input_module
11731176
-buff_size:p + buff_size))
11741177
end if
11751178

1179+
if (chemistry) then
1180+
allocate (q_T_sf%sf(-buff_size:m + buff_size, &
1181+
-buff_size:n + buff_size, &
1182+
-buff_size:p + buff_size))
1183+
end if
1184+
11761185
! Simulation is 2D
11771186
else
11781187

@@ -1190,6 +1199,12 @@ subroutine s_initialize_data_input_module
11901199
-buff_size:n + buff_size, &
11911200
0:0))
11921201
end if
1202+
1203+
if (chemistry) then
1204+
allocate (q_T_sf%sf(-buff_size:m + buff_size, &
1205+
-buff_size:n + buff_size, &
1206+
0:0))
1207+
end if
11931208
end if
11941209

11951210
! Simulation is 1D
@@ -1208,6 +1223,10 @@ subroutine s_initialize_data_input_module
12081223
allocate (ib_markers%sf(-buff_size:m + buff_size, 0:0, 0:0))
12091224
end if
12101225

1226+
if (chemistry) then
1227+
allocate (q_T_sf%sf(-buff_size:m + buff_size, 0:0, 0:0))
1228+
end if
1229+
12111230
end if
12121231

12131232
if (parallel_io .neqv. .true.) then
@@ -1236,6 +1255,10 @@ subroutine s_finalize_data_input_module
12361255
deallocate (ib_markers%sf)
12371256
end if
12381257

1258+
if (chemistry) then
1259+
deallocate (q_T_sf%sf)
1260+
end if
1261+
12391262
s_read_data_files => null()
12401263

12411264
end subroutine s_finalize_data_input_module

src/post_process/m_global_parameters.fpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ module m_global_parameters
135135
type(int_bounds_info) :: xi_idx !< Indexes of first and last reference map eqns.
136136
integer :: c_idx !< Index of color function
137137
type(int_bounds_info) :: species_idx !< Indexes of first & last concentration eqns.
138-
integer :: T_idx !< Index of temperature eqn.
139138
!> @}
140139

141140
! Cell Indices for the (local) interior points (O-m, O-n, 0-p).
@@ -678,13 +677,9 @@ contains
678677
species_idx%beg = sys_size + 1
679678
species_idx%end = sys_size + num_species
680679
sys_size = species_idx%end
681-
682-
T_idx = sys_size + 1
683-
sys_size = T_idx
684680
else
685681
species_idx%beg = 1
686682
species_idx%end = 1
687-
T_idx = 1
688683
end if
689684

690685
momxb = mom_idx%beg

src/post_process/m_start_up.f90

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ module m_start_up
3939

4040
use m_finite_differences
4141

42+
use m_chemistry
43+
4244
! ==========================================================================
4345

4446
implicit none
@@ -179,8 +181,11 @@ subroutine s_perform_time_step(t_step)
179181
call s_populate_conservative_variables_buffer_regions()
180182
end if
181183

184+
! Initialize the Temperature cache.
185+
if (chemistry) call s_compute_q_T_sf(q_T_sf, q_cons_vf, idwbuff)
186+
182187
! Converting the conservative variables to the primitive ones
183-
call s_convert_conservative_to_primitive_variables(q_cons_vf, q_prim_vf, idwbuff)
188+
call s_convert_conservative_to_primitive_variables(q_cons_vf, q_T_sf, q_prim_vf, idwbuff)
184189

185190
end subroutine s_perform_time_step
186191

@@ -322,9 +327,9 @@ subroutine s_save_data(t_step, varname, pres, c, H)
322327
end do
323328

324329
if (chem_wrt_T) then
325-
q_sf = q_prim_vf(T_idx)%sf(-offset_x%beg:m + offset_x%end, &
326-
-offset_y%beg:n + offset_y%end, &
327-
-offset_z%beg:p + offset_z%end)
330+
q_sf = q_T_sf%sf(-offset_x%beg:m + offset_x%end, &
331+
-offset_y%beg:n + offset_y%end, &
332+
-offset_z%beg:p + offset_z%end)
328333

329334
write (varname, '(A)') 'T'
330335
call s_write_variable_to_formatted_database_file(varname, t_step)

src/pre_process/m_assign_variables.fpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ contains
189189
Ys(i) = q_prim_vf(chemxb + i - 1)%sf(j, k, l)
190190
end do
191191
end block
192-
193-
call get_mixture_molecular_weight(Ys, mean_molecular_weight)
194-
q_prim_vf(T_idx)%sf(j, k, l) = &
195-
q_prim_vf(E_idx)%sf(j, k, l)*mean_molecular_weight &
196-
/(gas_constant*q_prim_vf(1)%sf(j, k, l))
197192
end if
198193
199194
! Updating the patch identities bookkeeping variable
@@ -596,10 +591,6 @@ contains
596591
Ys(i) = q_prim_vf(chemxb + i - 1)%sf(j, k, l)
597592
end do
598593
end block
599-
600-
call get_mixture_molecular_weight(Ys, mean_molecular_weight)
601-
q_prim_vf(T_idx)%sf(j, k, l) = &
602-
q_prim_vf(E_idx)%sf(j, k, l)*mean_molecular_weight/(gas_constant*q_prim_vf(1)%sf(j, k, l))
603594
end if
604595
605596
! Set streamwise velocity to hyperbolic tangent function of y

0 commit comments

Comments
 (0)