Skip to content

Commit 4298db0

Browse files
MHD & RMHD (#809)
* B equations added * 1D Brio Wu works * 2D Brio Wu works * add Orszag Tang test * 3D works; add case folder * add Powell * HLLD as copy of HLL * 1D & 2D HLLD works * 3D RMHD works * format and add cases * more examples * add tests * minor clean ups * case opt * golden for examples * docs and checker * small GPU fix * fix tests * exclude HLLD from single-precision tests * fix prim vs cons density * fix GPU tests * regenerate rmhd golden * clean * fix merge bug * fix unassigned flux_src_rs (evident in intel compiler hlld tests) * fix ieee module bug for intel * remove case * fix hlld example test * remove magic number * remove unicode * riemann states type * fix gpu bug * remove Bxb Bxe * update README * fix frontier bug * fix frontier bug 2 * fix frontier bug 3 * fix gpu case-opt * refactor and clean up --------- Co-authored-by: Spencer Bryngelson <sbryngelson@gmail.com>
1 parent b4c9096 commit 4298db0

File tree

83 files changed

+5946
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+5946
-181
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ They are organized below.
132132
* Ideal and stiffened gas equations of state
133133
* Body forces
134134
* Acoustic wave generation (one- and two-way sound sources)
135+
* Magnetohydrodynamics (MHD)
136+
* Relativistic Magnetohydrodynamics (RMHD)
135137
</details>
136138

137139
### Numerics
@@ -142,7 +144,7 @@ They are organized below.
142144
* WENO variants: WENO-JS, WENO-M, WENO-Z, TENO
143145
* Monotonicity-preserving reconstructions
144146
* Reliable handling of large density ratios
145-
* Exact and approximate (e.g., HLL, HLLC) Riemann solvers
147+
* Exact and approximate (e.g., HLL, HLLC, HLLD) Riemann solvers
146148
* Boundary conditions
147149
* Periodic, reflective, extrapolation/Neumann
148150
* Slip and no-slip

docs/documentation/case.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Details of implementation of viscosity in MFC can be found in [Coralic (2015)](r
372372
| `teno_CT` | Real | TENO threshold for smoothness detection |
373373
| `null_weights` | Logical | Null WENO weights at boundaries |
374374
| `mp_weno` | Logical | Monotonicity preserving WENO |
375-
| `riemann_solver` | Integer | Riemann solver algorithm: [1] HLL*; [2] HLLC; [3] Exact* |
375+
| `riemann_solver` | Integer | Riemann solver algorithm: [1] HLL*; [2] HLLC; [3] Exact*; [4] HLLD (only for MHD) |
376376
| `low_Mach` | Integer | Low Mach number correction for HLLC Riemann solver: [0] None; [1] Pressure (Chen et al. 2022); [2] Velocity (Thornber et al. 2008) |
377377
| `avg_state` | Integer | Averaged state evaluation method: [1] Roe average*; [2] Arithmetic mean |
378378
| `wave_speeds` | Integer | Wave-speed estimation: [1] Direct (Batten et al. 1997); [2] Pressure-velocity* (Toro 1999) |
@@ -450,6 +450,7 @@ It is recommended to set `weno_eps` to $10^{-6}$ for WENO-JS, and to $10^{-40}$
450450

451451
- `riemann_solver` specifies the choice of the Riemann solver that is used in simulation by an integer from 1 through 3.
452452
`riemann_solver = 1`, `2`, and `3` correspond to HLL, HLLC, and Exact Riemann solver, respectively ([Toro, 2013](references.md#Toro13)).
453+
`riemann_solver = 4` is only for MHD simulations. It resolves 5 of the full seven-wave structure of the MHD equations ([Miyoshi and Kusano, 2005](references.md#Miyoshi05)).
453454

454455
- `low_Mach` specifies the choice of the low Mach number correction scheme for the HLLC Riemann solver. `low_Mach = 0` is default value and does not apply any correction scheme. `low_Mach = 1` and `2` apply the anti-dissipation pressure correction method ([Chen et al., 2022](references.md#Chen22)) and the improved velocity reconstruction method ([Thornber et al., 2008](references.md#Thornber08)). This feature requires `riemann_solver = 2` and `model_eqns = 2`.
455456

@@ -848,7 +849,34 @@ $$ a_{x[y,z]} = g_{x[y,z]} + k_{x[y,z]}\sin\left(w_{x[y,z]}t + p_{x[y,z]}\right)
848849

849850
By convention, positive accelerations in the `x[y,z]` direction are in the positive `x[y,z]` direction.
850851

851-
### 14. Cylindrical Coordinates
852+
### 14. Magnetohydrodynamics (MHD)
853+
854+
| Parameter | Type | Description |
855+
| ---: | :---: | :--- |
856+
| `mhd` | Logical | Enable ideal MHD simulation |
857+
| `relativity` | Logical | Enable relativistic MHD simulation |
858+
| `powell` | Logical | Enable Powell's method for solenoidal constraint |
859+
| `fd_order` | Integer | Finite difference order for Powell's method |
860+
| `Bx[y,z]` | Real | Initial magnetic field in the x[y,z] direction |
861+
| `Bx0` | Real | Constant magnetic field in the x direction (1D only)|
862+
863+
- `mhd` is currently only available for single-component flows and 5-equation model. Its compatibility with most other features is work in progress.
864+
865+
- `relativity` only works for `mhd` enabled and activates relativistic MHD (RMHD) simulation.
866+
867+
- `powell` activates Powell's eight-wave method to impose the solenoidal constraint in the MHD simulation [Powell (1994)](references.md#Powell94). It should not be used in conjunction with HLLD (`riemann_solver = 4`).
868+
869+
- `fd_order` specifies the finite difference order for computing the RHS of the Powell's method. `fd_order = 1`, `2`, and `4` are allowed.
870+
871+
- `Bx0` is only used in 1D simulations to specify the constant magnetic field in the x direction. It must be specified in 1D simulations. `Bx` must not be used in 1D simulations.
872+
873+
- `Bx`, `By`, and `Bz` are used to specify the initial magnetic field in the x, y, and z directions, respectively. They must be specified in all 1D/2D/3D MHD simulations, with the exception of `Bx` in 1D simulations.
874+
875+
Note: In 1D/2D/3D simulations, all three velocity components are treated as state variables and must be specified in the case file.
876+
877+
Note: For relativistic flow, the conservative and primitive densities are different. `rho_wrt` outputs the primitive (rest mass) density.
878+
879+
### 15. Cylindrical Coordinates
852880

853881
When ``cyl_coord = 'T'`` is set in 3D the following constraints must be met:
854882

docs/documentation/references.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@
5757
- <a id="Tiwari13">Tiwari, A., Freund, J. B., and Pantano, C. (2013). A diffuse interface model with immiscibility preservation. Journal of computational physics, 252:290–309.</a>
5858

5959
- <a id="Toro13">Toro, E. F. (2013). Riemann solvers and numerical methods for fluid dynamics: a practical introduction. Springer Science & Business Media.</a>
60+
61+
- <a id="Miyoshi05">Miyoishi, T., and Kusano, K. (2005). A multi-state HLL approximate Riemann solver for ideal magnetohydrodynamics. Journal of Computational Physics, 208(1), 315-344.</a>
62+
63+
- <a id="Powell94">Powell, K. G. (1994). An approximate Riemann solver for magnetohydrodynamics: (That works in more than one dimension). In Upwind and high-resolution schemes (pp. 570-583). Springer.</a>

examples/1D_brio_wu/case.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env python3
2+
import json
3+
4+
# An upwind differencing scheme for the equations of ideal magnetohydrodynamics
5+
# M. Brio and C. C. Wu
6+
7+
# Configuring case dictionary
8+
print(
9+
json.dumps(
10+
{
11+
# Logistics
12+
"run_time_info": "T",
13+
# Computational Domain Parameters
14+
"x_domain%beg": 0,
15+
"x_domain%end": 1.0,
16+
"m": 800,
17+
"n": 0,
18+
"p": 0,
19+
"dt": 0.0002,
20+
"t_step_start": 0,
21+
"t_step_stop": 1000,
22+
"t_step_save": 100,
23+
# Simulation Algorithm Parameters
24+
"num_patches": 2,
25+
"model_eqns": 2,
26+
"alt_soundspeed": "F",
27+
"num_fluids": 1,
28+
"mpp_lim": "F",
29+
"mixture_err": "F",
30+
"time_stepper": 3,
31+
"weno_order": 5,
32+
"mapped_weno": "T",
33+
"weno_eps": 1.0e-16,
34+
"null_weights": "F",
35+
"mp_weno": "F",
36+
"riemann_solver": 1,
37+
"wave_speeds": 1,
38+
"avg_state": 2,
39+
"bc_x%beg": -3,
40+
"bc_x%end": -3,
41+
# Formatted Database Files Structure Parameters
42+
"format": 1,
43+
"precision": 2,
44+
"prim_vars_wrt": "T",
45+
"rho_wrt": "T",
46+
"parallel_io": "T",
47+
# MHD
48+
"mhd": "T",
49+
"Bx0": 0.75,
50+
# Patch 1 Left
51+
"patch_icpp(1)%geometry": 1,
52+
"patch_icpp(1)%x_centroid": 0.25,
53+
"patch_icpp(1)%length_x": 0.5,
54+
"patch_icpp(1)%vel(1)": 0.0,
55+
"patch_icpp(1)%vel(2)": 0.0,
56+
"patch_icpp(1)%vel(3)": 0.0,
57+
"patch_icpp(1)%pres": 1.0,
58+
"patch_icpp(1)%By": 1.0,
59+
"patch_icpp(1)%Bz": 0.0,
60+
"patch_icpp(1)%alpha_rho(1)": 1.0,
61+
"patch_icpp(1)%alpha(1)": 1.0,
62+
# Patch 2 Right
63+
"patch_icpp(2)%geometry": 1,
64+
"patch_icpp(2)%x_centroid": 0.75,
65+
"patch_icpp(2)%length_x": 0.5,
66+
"patch_icpp(2)%vel(1)": 0.0,
67+
"patch_icpp(2)%vel(2)": 0.0,
68+
"patch_icpp(2)%vel(3)": 0.0,
69+
"patch_icpp(2)%pres": 0.1,
70+
"patch_icpp(2)%By": -1.0,
71+
"patch_icpp(2)%Bz": 0.0,
72+
"patch_icpp(2)%alpha_rho(1)": 0.125,
73+
"patch_icpp(2)%alpha(1)": 1.0,
74+
# Fluids Physical Parameters
75+
"fluid_pp(1)%gamma": 1.0e00 / (2.0e00 - 1.0e00),
76+
"fluid_pp(1)%pi_inf": 0.0,
77+
}
78+
)
79+
)

examples/1D_brio_wu_hlld/case.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env python3
2+
import json
3+
4+
# An upwind differencing scheme for the equations of ideal magnetohydrodynamics
5+
# M. Brio and C. C. Wu
6+
# Note: HLLD is not used in the paper
7+
8+
# Configuring case dictionary
9+
print(
10+
json.dumps(
11+
{
12+
# Logistics
13+
"run_time_info": "T",
14+
# Computational Domain Parameters
15+
"x_domain%beg": 0,
16+
"x_domain%end": 1.0,
17+
"m": 800,
18+
"n": 0,
19+
"p": 0,
20+
"dt": 0.0002,
21+
"t_step_start": 0,
22+
"t_step_stop": 1000,
23+
"t_step_save": 100,
24+
# Simulation Algorithm Parameters
25+
"num_patches": 2,
26+
"model_eqns": 2,
27+
"alt_soundspeed": "F",
28+
"num_fluids": 1,
29+
"mpp_lim": "F",
30+
"mixture_err": "F",
31+
"time_stepper": 3,
32+
"weno_order": 5,
33+
"mapped_weno": "T",
34+
"weno_eps": 1.0e-16,
35+
"null_weights": "F",
36+
"mp_weno": "F",
37+
"riemann_solver": 4,
38+
"wave_speeds": 1,
39+
"avg_state": 2,
40+
"bc_x%beg": -3,
41+
"bc_x%end": -3,
42+
# Formatted Database Files Structure Parameters
43+
"format": 1,
44+
"precision": 2,
45+
"prim_vars_wrt": "T",
46+
"rho_wrt": "T",
47+
"parallel_io": "T",
48+
# MHD
49+
"mhd": "T",
50+
"Bx0": 0.75,
51+
# Patch 1 Left
52+
"patch_icpp(1)%geometry": 1,
53+
"patch_icpp(1)%x_centroid": 0.25,
54+
"patch_icpp(1)%length_x": 0.5,
55+
"patch_icpp(1)%vel(1)": 0.0,
56+
"patch_icpp(1)%vel(2)": 0.0,
57+
"patch_icpp(1)%vel(3)": 0.0,
58+
"patch_icpp(1)%pres": 1.0,
59+
"patch_icpp(1)%By": 1.0,
60+
"patch_icpp(1)%Bz": 0.0,
61+
"patch_icpp(1)%alpha_rho(1)": 1.0,
62+
"patch_icpp(1)%alpha(1)": 1.0,
63+
# Patch 2 Right
64+
"patch_icpp(2)%geometry": 1,
65+
"patch_icpp(2)%x_centroid": 0.75,
66+
"patch_icpp(2)%length_x": 0.5,
67+
"patch_icpp(2)%vel(1)": 0.0,
68+
"patch_icpp(2)%vel(2)": 0.0,
69+
"patch_icpp(2)%vel(3)": 0.0,
70+
"patch_icpp(2)%pres": 0.1,
71+
"patch_icpp(2)%By": -1.0,
72+
"patch_icpp(2)%Bz": 0.0,
73+
"patch_icpp(2)%alpha_rho(1)": 0.125,
74+
"patch_icpp(2)%alpha(1)": 1.0,
75+
# Fluids Physical Parameters
76+
"fluid_pp(1)%gamma": 1.0e00 / (2.0e00 - 1.0e00),
77+
"fluid_pp(1)%pi_inf": 0.0,
78+
}
79+
)
80+
)

examples/1D_brio_wu_rmhd/case.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python3
2+
import json
3+
4+
# An HLLC Riemann solver for relativistic flows – II. Magnetohydrodynamics
5+
# A. Mignone and G. Bodo
6+
# Problem 1 Figure 3
7+
8+
# Configuring case dictionary
9+
print(
10+
json.dumps(
11+
{
12+
# Logistics
13+
"run_time_info": "T",
14+
# Computational Domain Parameters
15+
"x_domain%beg": 0,
16+
"x_domain%end": 1.0,
17+
"m": 1600,
18+
"n": 0,
19+
"p": 0,
20+
"dt": 0.0002,
21+
"t_step_start": 0,
22+
"t_step_stop": 2000,
23+
"t_step_save": 100,
24+
# Simulation Algorithm Parameters
25+
"num_patches": 2,
26+
"model_eqns": 2,
27+
"alt_soundspeed": "F",
28+
"num_fluids": 1,
29+
"mpp_lim": "F",
30+
"mixture_err": "F",
31+
"time_stepper": 3,
32+
"weno_order": 5,
33+
"mapped_weno": "T",
34+
"weno_eps": 1.0e-16,
35+
"null_weights": "F",
36+
"mp_weno": "F",
37+
"riemann_solver": 1,
38+
"wave_speeds": 1,
39+
"avg_state": 2,
40+
"bc_x%beg": -3,
41+
"bc_x%end": -3,
42+
# Formatted Database Files Structure Parameters
43+
"format": 1,
44+
"precision": 2,
45+
"prim_vars_wrt": "T",
46+
"rho_wrt": "T",
47+
"parallel_io": "T",
48+
# RMHD
49+
"mhd": "T",
50+
"relativity": "T",
51+
"Bx0": 0.5,
52+
# Patch 1 Left
53+
"patch_icpp(1)%geometry": 1,
54+
"patch_icpp(1)%x_centroid": 0.25,
55+
"patch_icpp(1)%length_x": 0.5,
56+
"patch_icpp(1)%vel(1)": 0.0,
57+
"patch_icpp(1)%vel(2)": 0.0,
58+
"patch_icpp(1)%vel(3)": 0.0,
59+
"patch_icpp(1)%pres": 1.0,
60+
"patch_icpp(1)%By": 1.0,
61+
"patch_icpp(1)%Bz": 0.0,
62+
"patch_icpp(1)%alpha_rho(1)": 1.0,
63+
"patch_icpp(1)%alpha(1)": 1.0,
64+
# Patch 2 Right
65+
"patch_icpp(2)%geometry": 1,
66+
"patch_icpp(2)%x_centroid": 0.75,
67+
"patch_icpp(2)%length_x": 0.5,
68+
"patch_icpp(2)%vel(1)": 0.0,
69+
"patch_icpp(2)%vel(2)": 0.0,
70+
"patch_icpp(2)%vel(3)": 0.0,
71+
"patch_icpp(2)%pres": 0.1,
72+
"patch_icpp(2)%By": -1.0,
73+
"patch_icpp(2)%Bz": 0.0,
74+
"patch_icpp(2)%alpha_rho(1)": 0.125,
75+
"patch_icpp(2)%alpha(1)": 1.0,
76+
# Fluids Physical Parameters
77+
"fluid_pp(1)%gamma": 1.0e00 / (2.0e00 - 1.0e00),
78+
"fluid_pp(1)%pi_inf": 0.0,
79+
}
80+
)
81+
)

0 commit comments

Comments
 (0)