Skip to content

Commit 4949c07

Browse files
Fix chemistry‑related bugs (#829)
Co-authored-by: Spencer Bryngelson <shb@gatech.edu> Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent da13f7f commit 4949c07

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

src/common/m_chemistry.fpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
module m_chemistry
1010

1111
use m_thermochem, only: &
12-
num_species, mol_weights, get_temperature, get_net_production_rates
12+
num_species, molecular_weights, get_temperature, get_net_production_rates
1313

1414
use m_global_parameters
1515

@@ -91,7 +91,7 @@ contains
9191
!$acc loop seq
9292
do eqn = chemxb, chemxe
9393

94-
omega_m = mol_weights(eqn - chemxb + 1)*omega(eqn - chemxb + 1)
94+
omega_m = molecular_weights(eqn - chemxb + 1)*omega(eqn - chemxb + 1)
9595

9696
rhs_vf(eqn)%sf(x, y, z) = rhs_vf(eqn)%sf(x, y, z) + omega_m
9797

src/post_process/m_mpi_proxy.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ contains
165165
& 'alt_soundspeed', 'hypoelasticity', 'mhd', 'parallel_io', &
166166
& 'rho_wrt', 'E_wrt', 'pres_wrt', 'gamma_wrt', 'sim_data', &
167167
& 'heat_ratio_wrt', 'pi_inf_wrt', 'pres_inf_wrt', 'cons_vars_wrt', &
168-
& 'prim_vars_wrt', 'c_wrt', 'qm_wrt','schlieren_wrt', &
168+
& 'prim_vars_wrt', 'c_wrt', 'qm_wrt','schlieren_wrt','chem_wrt_T', &
169169
& 'bubbles_euler', 'qbmm', 'polytropic', 'polydisperse', &
170170
& 'file_per_process', 'relax', 'cf_wrt', &
171171
& 'adv_n', 'ib', 'cfl_adap_dt', 'cfl_const_dt', 'cfl_dt', &

src/pre_process/m_mpi_proxy.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ contains
128128
129129
call MPI_BCAST(patch_icpp(i)%model_spc, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
130130
131+
if (chemistry) then
132+
call MPI_BCAST(patch_icpp(i)%Y, size(patch_icpp(i)%Y), mpi_p, 0, MPI_COMM_WORLD, ierr)
133+
end if
131134
! Broadcast IB variables
132135
call MPI_BCAST(patch_ib(i)%geometry, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
133136
call MPI_BCAST(patch_ib(i)%model_filepath, len(patch_ib(i)%model_filepath), MPI_CHARACTER, 0, MPI_COMM_WORLD, ierr)

src/simulation/include/inline_riemann.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
call get_species_enthalpies_rt(T_L, h_iL)
3838
call get_species_enthalpies_rt(T_R, h_iR)
3939

40-
h_iL = h_iL*gas_constant/mol_weights*T_L
41-
h_iR = h_iR*gas_constant/mol_weights*T_R
40+
h_iL = h_iL*gas_constant/molecular_weights*T_L
41+
h_iR = h_iR*gas_constant/molecular_weights*T_R
4242
call get_species_specific_heats_r(T_L, Cp_iL)
4343
call get_species_specific_heats_r(T_R, Cp_iR)
4444

@@ -48,17 +48,17 @@
4848

4949
if (abs(T_L - T_R) < eps) then
5050
! Case when T_L and T_R are very close
51-
Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(i) + 0.5_wp*Cp_iR(:))*gas_constant/mol_weights(:))
52-
Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(i) + 0.5_wp*Cp_iR(:))*gas_constant/mol_weights(:) - gas_constant/mol_weights(:)))
51+
Cp_avg = sum(Yi_avg(:)*(0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:))
52+
Cv_avg = sum(Yi_avg(:)*((0.5_wp*Cp_iL(:) + 0.5_wp*Cp_iR(:))*gas_constant/molecular_weights(:) - gas_constant/molecular_weights(:)))
5353
else
5454
! Normal calculation when T_L and T_R are sufficiently different
5555
Cp_avg = sum(Yi_avg(:)*(h_iR(:) - h_iL(:))/(T_R - T_L))
56-
Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/mol_weights(:)))
56+
Cv_avg = sum(Yi_avg(:)*((h_iR(:) - h_iL(:))/(T_R - T_L) - gas_constant/molecular_weights(:)))
5757
end if
5858

5959
gamma_avg = Cp_avg/Cv_avg
6060

61-
Phi_avg(:) = (gamma_avg - 1._wp)*(vel_avg_rms/2.0_wp - h_avg_2(:)) + gamma_avg*gas_constant/mol_weights(:)*T_avg
61+
Phi_avg(:) = (gamma_avg - 1._wp)*(vel_avg_rms/2.0_wp - h_avg_2(:)) + gamma_avg*gas_constant/molecular_weights(:)*T_avg
6262
c_sum_Yi_Phi = sum(Yi_avg(:)*Phi_avg(:))
6363
end if
6464

src/simulation/m_riemann_solvers.fpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ contains
513513
call get_mixture_molecular_weight(Ys_L, MW_L)
514514
call get_mixture_molecular_weight(Ys_R, MW_R)
515515

516-
Xs_L(:) = Ys_L(:)*MW_L/mol_weights(:)
517-
Xs_R(:) = Ys_R(:)*MW_R/mol_weights(:)
516+
Xs_L(:) = Ys_L(:)*MW_L/molecular_weights(:)
517+
Xs_R(:) = Ys_R(:)*MW_R/molecular_weights(:)
518518

519519
R_gas_L = gas_constant/MW_L
520520
R_gas_R = gas_constant/MW_R
@@ -1029,8 +1029,8 @@ contains
10291029
Y_L = qL_prim_rs${XYZ}$_vf(j, k, l, i)
10301030
Y_R = qR_prim_rs${XYZ}$_vf(j + 1, k, l, i)
10311031
1032-
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(norm_dir)) &
1033-
- s_P*Y_L*rho_L*vel_L(dir_idx(norm_dir)) &
1032+
flux_rs${XYZ}$_vf(j, k, l, i) = (s_M*Y_R*rho_R*vel_R(dir_idx(1)) &
1033+
- s_P*Y_L*rho_L*vel_L(dir_idx(1)) &
10341034
+ s_M*s_P*(Y_L*rho_L - Y_R*rho_R)) &
10351035
/(s_M - s_P)
10361036
flux_src_rs${XYZ}$_vf(j, k, l, i) = 0._wp
@@ -2573,8 +2573,8 @@ contains
25732573
call get_mixture_molecular_weight(Ys_L, MW_L)
25742574
call get_mixture_molecular_weight(Ys_R, MW_R)
25752575
2576-
Xs_L(:) = Ys_L(:)*MW_L/mol_weights(:)
2577-
Xs_R(:) = Ys_R(:)*MW_R/mol_weights(:)
2576+
Xs_L(:) = Ys_L(:)*MW_L/molecular_weights(:)
2577+
Xs_R(:) = Ys_R(:)*MW_R/molecular_weights(:)
25782578
25792579
R_gas_L = gas_constant/MW_L
25802580
R_gas_R = gas_constant/MW_R

toolchain/mfc/run/input.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def generate_fpp(self, target) -> None:
7676
# Write the generated Fortran code to the m_thermochem.f90 file with the chosen precision
7777
common.file_write(
7878
os.path.join(modules_dir, "m_thermochem.f90"),
79-
pyro.codegen.fortran90.gen_thermochem_code(
79+
pyro.FortranCodeGenerator().generate(
80+
"m_thermochem",
8081
self.get_cantera_solution(),
81-
module_name="m_thermochem",
82-
real_type=real_type
82+
pyro.CodeGenerationOptions(scalar_type = real_type)
8383
),
8484
True
8585
)

toolchain/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ dependencies = [
3838
"matplotlib",
3939

4040
# Chemistry
41-
"cantera==3.0.1",
42-
"pyrometheus==1.0.2"
41+
"cantera==3.1.0",
42+
"pyrometheus == 1.0.3"
4343
]
4444

4545
[tool.hatch.metadata]

0 commit comments

Comments
 (0)