Skip to content

Commit 8eee506

Browse files
HLLC Roe speed of sound
Co-Authored-By: Henry Le Berre <[email protected]>
1 parent 2887494 commit 8eee506

File tree

10 files changed

+214
-60
lines changed

10 files changed

+214
-60
lines changed

src/common/m_derived_types.fpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ module m_derived_types
313313
314314
logical :: diffusion
315315
logical :: reactions
316+
317+
integer :: gamma_method
316318
end type chemistry_parameters
317319
318320
end module m_derived_types

src/common/m_thermochem.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module m_thermochem
88
get_temperature, get_net_production_rates, get_pressure, &
99
get_mixture_molecular_weight, get_mixture_energy_mass, &
1010
get_mixture_specific_heat_cv_mass, get_mixture_specific_heat_cp_mass, &
11-
get_species_enthalpies_rt
11+
get_species_enthalpies_rt, get_species_specific_heats_r
1212
#:endif
1313

1414
implicit none

src/common/m_variables_conversion.fpp

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ contains
13981398
end subroutine s_finalize_variables_conversion_module
13991399

14001400
#ifndef MFC_PRE_PROCESS
1401-
subroutine s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv, vel_sum, c)
1401+
subroutine s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, adv, vel_sum, c, c_avggg)
14021402
#ifdef CRAY_ACC_WAR
14031403
!DIR$ INLINEALWAYS s_compute_speed_of_sound
14041404
#else
@@ -1412,44 +1412,57 @@ contains
14121412
real(kind(0d0)), intent(out) :: c
14131413

14141414
real(kind(0d0)) :: blkmod1, blkmod2
1415-
1415+
real(kind(0d0)) :: Tolerance, c_c
1416+
real(kind(0d0)), optional, intent(in) :: c_avggg
14161417
integer :: q
1418+
if (chemistry) then
1419+
if (present(c_avggg)) then
1420+
c_c = c_avggg
1421+
else
1422+
c_c = 0.0d0 ! Default value if 'b' is absent
1423+
end if
14171424

1418-
if (alt_soundspeed) then
1419-
blkmod1 = ((gammas(1) + 1d0)*pres + &
1420-
pi_infs(1))/gammas(1)
1421-
blkmod2 = ((gammas(2) + 1d0)*pres + &
1422-
pi_infs(2))/gammas(2)
1423-
c = (1d0/(rho*(adv(1)/blkmod1 + adv(2)/blkmod2)))
1424-
elseif (model_eqns == 3) then
1425-
c = 0d0
1426-
!$acc loop seq
1427-
do q = 1, num_fluids
1428-
c = c + adv(q)*(1d0/gammas(q) + 1d0)* &
1429-
(pres + pi_infs(q)/(gammas(q) + 1d0))
1430-
end do
1431-
c = c/rho
1432-
1433-
elseif (((model_eqns == 4) .or. (model_eqns == 2 .and. bubbles))) then
1434-
! Sound speed for bubble mmixture to order O(\alpha)
1435-
1436-
if (mpp_lim .and. (num_fluids > 1)) then
1437-
c = (1d0/gamma + 1d0)* &
1438-
(pres + pi_inf/(gamma + 1d0))/rho
1425+
if (avg_state == 1 .and. abs(c_c) > Tolerance) then
1426+
c = sqrt(c_c - (gamma - 1.0d0)*(vel_sum - H))
14391427
else
1440-
c = &
1441-
(1d0/gamma + 1d0)* &
1442-
(pres + pi_inf/(gamma + 1d0))/ &
1443-
(rho*(1d0 - adv(num_fluids)))
1428+
c = sqrt((1.0d0 + 1.0d0/gamma)*pres/rho)
14441429
end if
14451430
else
1446-
c = ((H - 5d-1*vel_sum)/gamma)
1447-
end if
1431+
if (alt_soundspeed) then
1432+
blkmod1 = ((gammas(1) + 1d0)*pres + &
1433+
pi_infs(1))/gammas(1)
1434+
blkmod2 = ((gammas(2) + 1d0)*pres + &
1435+
pi_infs(2))/gammas(2)
1436+
c = (1d0/(rho*(adv(1)/blkmod1 + adv(2)/blkmod2)))
1437+
elseif (model_eqns == 3) then
1438+
c = 0d0
1439+
!$acc loop seq
1440+
do q = 1, num_fluids
1441+
c = c + adv(q)*(1d0/gammas(q) + 1d0)* &
1442+
(pres + pi_infs(q)/(gammas(q) + 1d0))
1443+
end do
1444+
c = c/rho
1445+
elseif (((model_eqns == 4) .or. (model_eqns == 2 .and. bubbles))) then
1446+
! Sound speed for bubble mmixture to order O(\alpha)
1447+
1448+
if (mpp_lim .and. (num_fluids > 1)) then
1449+
c = (1d0/gamma + 1d0)* &
1450+
(pres + pi_inf/(gamma + 1d0))/rho
1451+
else
1452+
c = &
1453+
(1d0/gamma + 1d0)* &
1454+
(pres + pi_inf/(gamma + 1d0))/ &
1455+
(rho*(1d0 - adv(num_fluids)))
1456+
end if
1457+
else
1458+
c = ((H - 5d-1*vel_sum)/gamma)
1459+
end if
14481460

1449-
if (mixture_err .and. c < 0d0) then
1450-
c = 100.d0*sgm_eps
1451-
else
1452-
c = sqrt(c)
1461+
if (mixture_err .and. c < 0d0) then
1462+
c = 100.d0*sgm_eps
1463+
else
1464+
c = sqrt(c)
1465+
end if
14531466
end if
14541467
end subroutine s_compute_speed_of_sound
14551468
#endif

src/post_process/m_global_parameters.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ module m_global_parameters
112112
logical, parameter :: chemistry = .${chemistry}$. !< Chemistry modeling
113113
!> @}
114114

115+
integer :: avg_state !< Average state evaluation method
116+
115117
!> @name Annotations of the structure, i.e. the organization, of the state vectors
116118
!> @{
117119
type(int_bounds_info) :: cont_idx !< Indexes of first & last continuity eqns.
@@ -379,6 +381,7 @@ contains
379381
schlieren_alpha = dflt_real
380382

381383
fd_order = dflt_int
384+
avg_state = dflt_int
382385

383386
! Tait EOS
384387
rhoref = dflt_real

src/post_process/m_start_up.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ subroutine s_read_input_file
7070
weno_order, bc_x, &
7171
bc_y, bc_z, fluid_pp, format, precision, &
7272
hypoelasticity, G, &
73-
chem_wrt_Y, chem_wrt_T, &
73+
chem_wrt_Y, chem_wrt_T, avg_state, &
7474
alpha_rho_wrt, rho_wrt, mom_wrt, vel_wrt, &
7575
E_wrt, pres_wrt, alpha_wrt, gamma_wrt, &
7676
heat_ratio_wrt, pi_inf_wrt, pres_inf_wrt, &

src/simulation/include/inline_riemann.fpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
#:enddef arithmetic_avg
1313

1414
#:def roe_avg()
15+
1516
rho_avg = sqrt(rho_L*rho_R)
1617
vel_avg_rms = 0d0
18+
1719
!$acc loop seq
1820
do i = 1, num_dims
1921
vel_avg_rms = vel_avg_rms + (sqrt(rho_L)*vel_L(i) + sqrt(rho_R)*vel_R(i))**2d0/ &
@@ -26,10 +28,45 @@
2628
gamma_avg = (sqrt(rho_L)*gamma_L + sqrt(rho_R)*gamma_R)/ &
2729
(sqrt(rho_L) + sqrt(rho_R))
2830

29-
rho_avg = sqrt(rho_L*rho_R)
3031
vel_avg_rms = (sqrt(rho_L)*vel_L(1) + sqrt(rho_R)*vel_R(1))**2d0/ &
3132
(sqrt(rho_L) + sqrt(rho_R))**2d0
3233

34+
#:if chemistry
35+
eps = 0.001d0
36+
call get_species_enthalpies_rt(T_L, h_iL)
37+
call get_species_enthalpies_rt(T_R, h_iR)
38+
39+
h_iL = h_iL*gas_constant/mol_weights*T_L
40+
h_iR = h_iR*gas_constant/mol_weights*T_R
41+
call get_species_specific_heats_r(T_L, Cp_iL)
42+
call get_species_specific_heats_r(T_R, Cp_iR)
43+
44+
h_avg_2 = (sqrt(rho_L)*h_iL + sqrt(rho_R)*h_iR)/(sqrt(rho_L) + sqrt(rho_R))
45+
Yi_avg = (sqrt(rho_L)*Ys_L + sqrt(rho_R)*Ys_R)/(sqrt(rho_L) + sqrt(rho_R))
46+
T_avg = (sqrt(rho_L)*T_L + sqrt(rho_R)*T_R)/(sqrt(rho_L) + sqrt(rho_R))
47+
Cp_avg = 0.0d0
48+
Cv_avg = 0.0d0
49+
50+
do i = 1, num_species
51+
if (abs(T_L - T_R) < eps) then
52+
! Case when T_L and T_R are very close
53+
Cp_avg = Cp_avg + Yi_avg(i)*(0.5d0*Cp_iL(i) + 0.5d0*Cp_iR(i))*gas_constant/mol_weights(i)
54+
Cv_avg = Cv_avg + Yi_avg(i)*((0.5d0*Cp_iL(i) + 0.5d0*Cp_iR(i))*gas_constant/mol_weights(i) - gas_constant/mol_weights(i))
55+
else
56+
! Normal calculation when T_L and T_R are sufficiently different
57+
Cp_avg = Cp_avg + Yi_avg(i)*(h_iR(i) - h_iL(i))/(T_R - T_L)
58+
Cv_avg = Cv_avg + Yi_avg(i)*((h_iR(i) - h_iL(i))/(T_R - T_L) - gas_constant/mol_weights(i))
59+
end if
60+
end do
61+
gamma_avg = Cp_avg/Cv_avg
62+
c_avggg = 0.0d0
63+
64+
do i = 1, num_species
65+
Phi_avg(i) = (gamma_avg - 1.d0)*(vel_avg_rms/2.0d0 - h_avg_2(i)) + gamma_avg*gas_constant/mol_weights(i)*T_avg
66+
c_avggg = c_avggg + Yi_avg(i)*Phi_avg(i)
67+
end do
68+
#:endif
69+
3370
#:enddef roe_avg
3471

3572
#:def compute_average_state()

src/simulation/m_global_parameters.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ contains
571571

572572
chem_params%diffusion = .false.
573573
chem_params%reactions = .false.
574+
chem_params%gamma_method = 1
574575

575576
bc_x%beg = dflt_int; bc_x%end = dflt_int
576577
bc_y%beg = dflt_int; bc_y%end = dflt_int

src/simulation/m_mpi_proxy.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ contains
211211
#:for VAR in [ 'diffusion', 'reactions' ]
212212
call MPI_BCAST(chem_params%${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
213213
#:endfor
214+
215+
#:for VAR in [ 'gamma_method' ]
216+
call MPI_BCAST(chem_params%${VAR}$, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
217+
#:endfor
214218
end if
215219
216220
#:for VAR in [ 'dt','weno_eps','teno_CT','pref','rhoref','R0ref','Web','Ca', 'sigma', &

0 commit comments

Comments
 (0)