Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions examples/1D_mhd_smooth_alfven_wave/case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
import json
import math

# Case for smooth Alfven waves from section 6.3.1 of:
# The ∇·B=0 Constraint in Shock-Capturing Magnetohydrodynamics Codes
# Gábor Tóth

print(
json.dumps(
{
# Logistics
"run_time_info": "T",
# Computational Domain Parameters
"x_domain%beg": 0.0,
"x_domain%end": 1.0,
"m": 1023,
"n": 0,
"p": 0,
"dt": 1.0e-5,
"t_step_start": 0,
"t_step_stop": 100000,
"t_step_save": 10000,
# Simulation Algorithm Parameters
"num_patches": 1,
"model_eqns": 2,
"alt_soundspeed": "F",
"num_fluids": 1,
"mpp_lim": "F",
"mixture_err": "F",
"time_stepper": 3,
"weno_order": 3,
"weno_eps": 1e-7,
"null_weights": "F",
"mp_weno": "F",
"riemann_solver": 4,
"wave_speeds": 1,
"avg_state": 2,
"bc_x%beg": -1,
"bc_x%end": -1,
# Formatted Database Files Structure Parameters
"format": 1,
"precision": 2,
"prim_vars_wrt": "T",
"rho_wrt": "T",
"parallel_io": "F",
# MHD
"mhd": "T",
"Bx0": 1.0,
"patch_icpp(1)%geometry": 1,
"patch_icpp(1)%hcid": 150,
"patch_icpp(1)%x_centroid": 0.5,
"patch_icpp(1)%length_x": 1.0,
"patch_icpp(1)%vel(1)": 0.0,
"patch_icpp(1)%vel(2)": 0.0,
"patch_icpp(1)%vel(3)": 0.0,
"patch_icpp(1)%pres": 0.1,
"patch_icpp(1)%By": 0.0,
"patch_icpp(1)%Bz": 0.0,
"patch_icpp(1)%alpha_rho(1)": 1.0,
"patch_icpp(1)%alpha(1)": 1.0,
# Fluids Physical Parameters
"fluid_pp(1)%gamma": 1.0e00 / (5.0 / 3.0 - 1.0e00),
"fluid_pp(1)%pi_inf": 0.0,
}
)
)
77 changes: 77 additions & 0 deletions examples/2D_mhd_magnetic_vortex/case.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level Suggestion

The 2D magnetic vortex test case is known to fail its convergence test due to existing solver limitations. It should be removed from this PR and introduced later, along with the necessary solver fixes, to avoid adding non-functional code and maintenance overhead. [High-level, importance: 8]

Solution Walkthrough:

Before:

# PR adds a new 2D test case and its implementation
# examples/2D_mhd_magnetic_vortex/case.py
json.dumps(
    {
        "patch_icpp(1)%hcid": 252,
        # ... other parameters
    }
)

! src/common/include/2dHardcodedIC.fpp
...
case (252) ! MHD Smooth Magnetic Vortex
    ! ... calculations for vortex initial conditions
case (270)
...

# tests/A48CA601/
# (new directory with golden files for the failing test)

After:

# The 2D test case and its related files are removed.
# examples/2D_mhd_magnetic_vortex/case.py
# (file is removed)

! src/common/include/2dHardcodedIC.fpp
...
! case (252) is removed
case (270)
...

# tests/A48CA601/
# (directory is removed)

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
import json
import math

# Case for smoothmagnetic vortex from:
# Implicit hybridized discontinuous Galerkin methods for
# compressible magnetohydrodynamics
# C. Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire

# A 2D magnetic vortex advects for a period of T=10 diagonally

# Configuring case dictionary
print(
json.dumps(
{
# Logistics
"run_time_info": "T",
# Computational Domain Parameters
"x_domain%beg": -5.0,
"x_domain%end": 5.0,
"y_domain%beg": -5.0,
"y_domain%end": 5.0,
"m": 1024,
"n": 1024,
"p": 0,
"dt": 1.0e-4,
"t_step_start": 0,
"t_step_stop": 100000,
"t_step_save": 1000,
# Simulation Algorithm Parameters
"num_patches": 1,
"model_eqns": 2,
"alt_soundspeed": "F",
"num_fluids": 1,
"mpp_lim": "F",
"mixture_err": "F",
"time_stepper": 3,
"weno_order": 5,
"weno_eps": 1.0e-12,
"null_weights": "F",
"mp_weno": "F",
"riemann_solver": 4,
"wave_speeds": 1,
"avg_state": 2,
"bc_x%beg": -1,
"bc_x%end": -1,
"bc_y%beg": -1,
"bc_y%end": -1,
# Formatted Database Files Structure Parameters
"format": 1,
"precision": 2,
"prim_vars_wrt": "T",
"rho_wrt": "T",
"parallel_io": "T",
# MHD
"mhd": "T",
"patch_icpp(1)%hcid": 252,
"patch_icpp(1)%geometry": 3,
"patch_icpp(1)%x_centroid": 0.0,
"patch_icpp(1)%y_centroid": 0.0,
"patch_icpp(1)%length_x": 10.0,
"patch_icpp(1)%length_y": 10.0,
"patch_icpp(1)%vel(1)": 0.0,
"patch_icpp(1)%vel(2)": 0.0,
"patch_icpp(1)%vel(3)": 0.0,
"patch_icpp(1)%pres": 5.0 / (12 * math.pi),
"patch_icpp(1)%Bx": 0.0,
"patch_icpp(1)%By": 0.0,
"patch_icpp(1)%Bz": 0.0,
"patch_icpp(1)%alpha_rho(1)": 25.0 / (36.0 * math.pi),
"patch_icpp(1)%alpha(1)": 1.0,
# Fluids Physical Parameters
"fluid_pp(1)%gamma": 1.0e00 / (5.0 / 3.0 - 1.0e00),
"fluid_pp(1)%pi_inf": 0.0,
}
)
)
9 changes: 9 additions & 0 deletions src/common/include/1dHardcodedIC.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@

#:def Hardcoded1D()
select case (patch_icpp(patch_id)%hcid)
case (150) ! 1D Smooth Alfven Case for MHD
! velocity
q_prim_vf(momxb + 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i))
q_prim_vf(momxb + 2)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i))

! magnetic field
q_prim_vf(B_idx%end - 1)%sf(i, 0, 0) = 0.1_wp*sin(2._wp*pi*x_cc(i))
q_prim_vf(B_idx%end)%sf(i, 0, 0) = 0.1_wp*cos(2._wp*pi*x_cc(i))

case (170)
! This hardcoded case can be used to start a simulation with initial conditions given from a known 1D profile (e.g. Cantera, SDtoolbox)
@: HardcodedReadValues()
Expand Down
16 changes: 16 additions & 0 deletions src/common/include/2dHardcodedIC.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
q_prim_vf(E_idx)%sf(i, j, 0) = 3.e-5_wp
end if

case (252) ! MHD Smooth Magnetic Vortex
! Section 5.2 of
! Implicit hybridized discontinuous Galerkin methods for compressible magnetohydrodynamics
! C. Ciuca, P. Fernandez, A. Christophe, N.C. Nguyen, J. Peraire

! velocity
q_prim_vf(momxb)%sf(i, j, 0) = 1._wp - (y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi))
q_prim_vf(momxb + 1)%sf(i, j, 0) = 1._wp + (x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi))

! magnetic field
q_prim_vf(B_idx%beg)%sf(i, j, 0) = -y_cc(j)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)
q_prim_vf(B_idx%beg + 1)%sf(i, j, 0) = x_cc(i)*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/(2.*pi)

! pressure
q_prim_vf(E_idx)%sf(i, j, 0) = 1._wp + (1 - 2._wp*(x_cc(i)**2 + y_cc(j)**2))*exp(1 - (x_cc(i)**2 + y_cc(j)**2))/((2._wp*pi)**3)

case (270)
! This hardcoded case extrudes a 1D profile to initialize a 2D simulation domain
@: HardcodedReadValues()
Expand Down
155 changes: 155 additions & 0 deletions tests/4A759316/golden-metadata.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading