Skip to content

Commit 31c938f

Browse files
DimAdam-01qodo-code-review[bot]Dimitrios Adamsbryngelson
authored
Unity Lewis Implementation (MFlowCode#1084)
Co-authored-by: qodo-code-review[bot] <151058649+qodo-code-review[bot]@users.noreply.github.com> Co-authored-by: Dimitrios Adam <dimitriosadam@Dimitrioss-MacBook-Air.local> Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent 639c313 commit 31c938f

File tree

10 files changed

+317
-111
lines changed

10 files changed

+317
-111
lines changed

docs/documentation/case.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,22 @@ When ``cyl_coord = 'T'`` is set in 2D the following constraints must be met:
993993

994994
- `bc_y%beg = -2` to enable reflective boundary conditions
995995

996+
### 17. Chemistry
997+
998+
| Parameter | Type | Description |
999+
| ---: | :---: | :--- |
1000+
| `chemistry` | Logical | Enable chemistry simulation |
1001+
| `chem_params%diffusion` | Logical | Enable multispecies diffusion |
1002+
| `chem_params%reactions` | Logical | Enable chemical reactions |
1003+
| `chem_params%gamma_method` | Integer | Methodology for calculating the heat capacity ratio |
1004+
| `chem_params%transport_model` | Integer | Methodology for calculating the diffusion coefficients |
1005+
| `cantera_file` | String | Cantera-format mechanism file (e.g., .yaml) |
1006+
1007+
- `chem_params%transport_model` specifies the methodology for calculating diffusion coefficients and other transport properties, `1` for mixture-average, `2` for Unity-Lewis
1008+
1009+
- `cantera_file` specifies the chemical mechanism file. If the file is part of the standard Cantera library, only the filename is required. Otherwise, the file must be located in the same directory as your `case.py` file
1010+
1011+
9961012
## Enumerations
9971013

9981014
### Boundary conditions
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python3
2+
# References:
3+
# + https://doi.org/10.1016/j.compfluid.2013.10.014: 4.4. Multicomponent diffusion test case
4+
5+
import json
6+
import argparse
7+
import math
8+
import cantera as ct
9+
10+
ctfile = "gri30.yaml"
11+
sol_L = ct.Solution(ctfile)
12+
sol_L.TPX = 300, 8000, "O2:2,N2:2,H2O:5"
13+
14+
L = 0.05
15+
Nx = 100
16+
dx = L / Nx
17+
dt = 0.3e-6
18+
Tend = 0.05
19+
20+
NT = int(Tend / dt)
21+
SAVE_COUNT = 2000
22+
NS = 2000
23+
case = {
24+
"run_time_info": "T",
25+
"x_domain%beg": 0,
26+
"x_domain%end": +L,
27+
"m": Nx,
28+
"n": 0,
29+
"p": 0,
30+
"dt": float(dt),
31+
"t_step_start": 0,
32+
"t_step_stop": NT,
33+
"t_step_save": NS,
34+
"t_step_print": NS,
35+
"parallel_io": "F",
36+
"model_eqns": 2,
37+
"num_fluids": 1,
38+
"num_patches": 1,
39+
"mpp_lim": "F",
40+
"mixture_err": "F",
41+
"time_stepper": 3,
42+
"weno_order": 5,
43+
"weno_eps": 1e-16,
44+
"weno_avg": "F",
45+
"mapped_weno": "T",
46+
"mp_weno": "T",
47+
"riemann_solver": 2,
48+
"wave_speeds": 2,
49+
"avg_state": 1,
50+
"bc_x%beg": -1,
51+
"bc_x%end": -1,
52+
"viscous": "F",
53+
"chemistry": "T",
54+
"chem_params%diffusion": "T",
55+
"chem_params%reactions": "F",
56+
"chem_params%transport_model": 2, # Unity-Lewis
57+
"format": 1,
58+
"precision": 2,
59+
"prim_vars_wrt": "T",
60+
"chem_wrt_T": "T",
61+
"patch_icpp(1)%geometry": 1,
62+
"patch_icpp(1)%hcid": 182,
63+
"patch_icpp(1)%x_centroid": L / 2,
64+
"patch_icpp(1)%length_x": L,
65+
"patch_icpp(1)%vel(1)": "0",
66+
"patch_icpp(1)%pres": 1.01325e5,
67+
"patch_icpp(1)%alpha(1)": 1,
68+
"patch_icpp(1)%alpha_rho(1)": 1,
69+
"fluid_pp(1)%gamma": 1.0e00 / (1.9326e00 - 1.0e00),
70+
"fluid_pp(1)%pi_inf": 0,
71+
"cantera_file": ctfile,
72+
}
73+
74+
for i in range(len(sol_L.Y)):
75+
case[f"chem_wrt_Y({i + 1})"] = "T"
76+
case[f"patch_icpp(1)%Y({i+1})"] = 0.0
77+
if __name__ == "__main__":
78+
print(json.dumps(case))

src/common/m_chemistry.fpp

Lines changed: 210 additions & 108 deletions
Large diffs are not rendered by default.

src/common/m_derived_types.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ module m_derived_types
456456
!> gamma_method = 1: Ref. Section 2.3.1 Formulation of doi:10.7907/ZKW8-ES97.
457457
!> gamma_method = 2: c_p / c_v where c_p, c_v are specific heats.
458458
integer :: gamma_method
459+
integer :: transport_model
459460
end type chemistry_parameters
460461
461462
!> Lagrangian bubble parameters

src/post_process/m_global_parameters.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ module m_global_parameters
303303
real(wp) :: rhoref, pref
304304
!> @}
305305

306+
type(chemistry_parameters) :: chem_params
306307
!> @name Bubble modeling variables and parameters
307308
!> @{
308309
integer :: nb
@@ -420,6 +421,9 @@ contains
420421
#:endfor
421422
#:endfor
422423

424+
chem_params%gamma_method = 1
425+
chem_params%transport_model = 1
426+
423427
! Fluids physical parameters
424428
do i = 1, num_fluids_max
425429
fluid_pp(i)%gamma = dflt_real

src/pre_process/m_global_parameters.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ module m_global_parameters
220220

221221
real(wp) :: rhoref, pref !< Reference parameters for Tait EOS
222222

223+
type(chemistry_parameters) :: chem_params
223224
!> @name Bubble modeling
224225
!> @{
225226
integer :: nb
@@ -580,6 +581,9 @@ contains
580581
patch_ib(i)%rotation_matrix_inverse = patch_ib(i)%rotation_matrix
581582
end do
582583

584+
chem_params%gamma_method = 1
585+
chem_params%transport_model = 1
586+
583587
! Fluids physical parameters
584588
do i = 1, num_fluids_max
585589
fluid_pp(i)%gamma = dflt_real

src/simulation/m_global_parameters.fpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ contains
649649
chem_params%diffusion = .false.
650650
chem_params%reactions = .false.
651651
chem_params%gamma_method = 1
652+
chem_params%transport_model = 1
652653
653654
num_bc_patches = 0
654655
bc_io = .false.

src/simulation/m_mpi_proxy.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ contains
125125
call MPI_BCAST(chem_params%${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
126126
#:endfor
127127
128-
#:for VAR in [ 'gamma_method' ]
128+
#:for VAR in [ 'gamma_method', 'transport_model' ]
129129
call MPI_BCAST(chem_params%${VAR}$, 1, MPI_INTEGER, 0, MPI_COMM_WORLD, ierr)
130130
#:endfor
131131
end if

toolchain/mfc/run/case_dicts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def analytic(self):
355355
for var in [ 'diffusion', 'reactions' ]:
356356
SIMULATION[f'chem_params%{var}'] = ParamType.LOG
357357

358-
for var in [ 'gamma_method' ]:
358+
for var in [ 'gamma_method', 'transport_model']:
359359
SIMULATION[f'chem_params%{var}'] = ParamType.INT
360360

361361
for var in ["R0ref", "p0ref", "rho0ref", "T0ref", "ss", "pv", "vd",

toolchain/mfc/test/cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ def foreach_example():
10311031
"2D_backward_facing_step",
10321032
"2D_forward_facing_step",
10331033
"1D_convergence",
1034-
"3D_IGR_33jet"]
1034+
"3D_IGR_33jet","1D_multispecies_diffusion"]
10351035
if path in casesToSkip:
10361036
continue
10371037
name = f"{path.split('_')[0]} -> Example -> {'_'.join(path.split('_')[1:])}"

0 commit comments

Comments
 (0)