Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Implement the multi-ion MHD system of Toth #1427

Draft
wants to merge 138 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
ed1673e
Started to implement the multi-ion MHD equations
amrueda Mar 28, 2023
e83ce8b
Some progress with the 1D multi-ion MHD equations: First "working" ve…
amrueda Mar 29, 2023
5ec8c0b
Added entropy variables
amrueda Mar 29, 2023
bbc3a0e
Added (most of) one EC flux for multi-ion MHD
amrueda Mar 30, 2023
46f2500
Added non-conservative term 2 (MHD term) and tested consistency in th…
amrueda Mar 30, 2023
7db0931
Added non-conservative "term 3".. The multi-ion are EC for constant B1!
amrueda Mar 30, 2023
f120f16
Added central non-conservative "flux" for multi-ion MHD (needed for a…
amrueda Mar 31, 2023
b23161f
Added standard source terms for the multi-ion MHD equations
amrueda Mar 31, 2023
89ce92c
Added auxiliar variables and a shock-capturing example for 1D multi-i…
amrueda Mar 31, 2023
2b74f79
Added multi-ion MHD equations in 2D
amrueda Apr 20, 2023
7a91b6e
Added density_pressure function and double rotor test for multi-ion
amrueda Apr 21, 2023
5dd9874
Cleaned up the multi-ion implementation a bit and added divB analysis
amrueda May 5, 2023
05771e8
Removed GLM from the struct name, as GLM is not implemented for multi…
amrueda May 5, 2023
6527aea
Fix (most) allocations
sloede May 5, 2023
eac2842
Apply suggestions from code review (0.0 -> 0)
amrueda May 8, 2023
179877b
Changed all occurrences of '0.0' and 'zero(eltype(u))' to '0'
amrueda May 8, 2023
1e0aca5
Apply suggestions from code review
amrueda May 8, 2023
57b8ea4
Added set_component function
amrueda May 8, 2023
76325d0
Fixed other potential type instabilities
amrueda May 8, 2023
8662c8f
Changed MVectors definitions to avoid creating arrays filled with zer…
amrueda May 8, 2023
30636d6
Apply suggestions from code review
amrueda May 8, 2023
968b688
Use MVectors in cons2prim, prim2cons, and cons2entropy
amrueda May 8, 2023
29c5a51
initial_condition_weak_blast_wave (2D) uses MVector
amrueda May 8, 2023
363fca2
Performance optimizations for ideal MHD multi-ion 1D
amrueda May 8, 2023
cd8acb5
Merge pull request #2 from sloede/msl/fix-allocations
amrueda May 9, 2023
0b165ef
Apply styling suggestions from code review
amrueda May 9, 2023
272bdcf
Styling changes
amrueda May 10, 2023
e6fc017
More styling changes
amrueda May 10, 2023
b144498
Added tests for multi-ion MHD in 1D and 2D
amrueda May 10, 2023
980f7f6
Attempt to improve coverage: added new 1D test and removed density_pr…
amrueda May 11, 2023
72384e8
Modified multi-ion rotor test to improve coverage
amrueda May 11, 2023
5b65806
Merge branch 'main' into multi_ion_mhd
amrueda May 11, 2023
12606b2
Fixed bugs in multi-ion MHD source term
amrueda Jun 28, 2023
140b2f9
Merge branch 'main' into multi_ion_mhd
amrueda Oct 2, 2023
10b74b1
Added electron pressure terms
amrueda Oct 17, 2023
1ba2092
First attempt to enable save solution with time intervals for SimpleI…
amrueda Oct 18, 2023
e05363d
Importing `add_tstop!`
amrueda Oct 19, 2023
64e9784
First working version of SimpleIntegratorSSP with SaveSolutionCallbac…
amrueda Oct 19, 2023
05fcaaa
Improved formatting and updated reference solution for test
amrueda Oct 19, 2023
71f5c7a
Modified initialization of tstops to ensure a stop at the end of the …
amrueda Oct 19, 2023
df34188
Added missing docstring
amrueda Oct 23, 2023
d04fd98
Removed OrdinaryDiffEq from Trixi's dependencies
amrueda Oct 23, 2023
c3b4d5d
Merge branch 'main' into simplessprk_dt
amrueda Oct 23, 2023
7aa515b
Empty tstops BinaryHeap during the call to `terminate!(integrator::Si…
amrueda Oct 23, 2023
4322f5b
Fixed bug and added explanatory comments
amrueda Oct 23, 2023
772a388
Updated Project.toml
amrueda Oct 23, 2023
7748aba
Merge branch 'main' into simplessprk_dt
amrueda Oct 25, 2023
dced12f
Merge branch 'main' into multi_ion_mhd
amrueda Nov 6, 2023
83f89b6
format
amrueda Nov 6, 2023
9e15d81
format
amrueda Nov 6, 2023
4859d92
format: noindent in multi-ion equations
amrueda Nov 6, 2023
1731bca
Added empty line at the beginning of elixirs for format
amrueda Nov 6, 2023
7f58f91
Removed comment
amrueda Nov 6, 2023
1f85e98
Remove empty line
amrueda Nov 6, 2023
db51600
Added empty lines at the end of elixirs for formatting
amrueda Nov 6, 2023
84966be
Updated tests of the multi-ion MHD equations after bug fixes
amrueda Nov 7, 2023
1dd114d
format
amrueda Nov 7, 2023
4462871
format
amrueda Nov 7, 2023
683e82e
Merge branch 'main' into simplessprk_dt
amrueda Dec 12, 2023
a3fb5e5
format
amrueda Dec 12, 2023
43aec2f
Merge branch 'main' into multi_ion_mhd
amrueda Dec 13, 2023
86f7ab8
format
amrueda Dec 13, 2023
58d06c7
Merge branch 'main' into multi_ion_mhd
amrueda Dec 13, 2023
b8d1a2a
Merge branch 'main' into simplessprk_dt
amrueda Dec 13, 2023
a908fd7
Merge remote-tracking branch 'amrueda/simplessprk_dt' into multi_ion_mhd
amrueda Dec 13, 2023
31d27ad
Implemented GLM divergence cleaning for multi-ion MHD
amrueda Dec 19, 2023
a33ad14
Added new ES numerical fluxes
amrueda Jan 24, 2024
a6b831c
Added missing terms to multi-ion ES flux
amrueda Feb 15, 2024
9fbd286
Export magnetic_field and divergence_clenaing_field
amrueda Feb 15, 2024
f0f55a9
Removed 'lumped' ES flux as it is not really useful
amrueda Feb 21, 2024
79ca7c0
Fixed bug in the discretization of the electron pressure!
amrueda Feb 21, 2024
9e1dbff
format
amrueda Feb 21, 2024
9676a8b
Merge pull request #14 from amrueda/multi_ion_mhd_glm
amrueda Nov 21, 2024
f044967
Merge branch 'main' into multi_ion_mhd
amrueda Nov 21, 2024
827bf4f
Merge branch 'main' into multi_ion_mhd
amrueda Nov 22, 2024
d265da6
Format
amrueda Nov 22, 2024
2527f50
Merge branch 'main' into multi_ion_mhd
amrueda Nov 23, 2024
3dc164b
Merge branch 'main' into multi_ion_mhd
amrueda Nov 26, 2024
a555e55
Removed specialized divB routines for multi-ion MHD
amrueda Nov 26, 2024
0732746
Merge branch 'main' into multi_ion_mhd
amrueda Dec 6, 2024
ac54ebd
Added 'GLM' to the name of the 2D multi-ion MHD equations
amrueda Dec 6, 2024
8c1ab2f
Improved comments for multi-ion MHD equation (2D) and renamed source_…
amrueda Dec 6, 2024
73c3bb6
Merge branch 'main' into multi_ion_mhd
amrueda Dec 6, 2024
7416798
Added DOI
amrueda Dec 9, 2024
f66eca2
Adapted 2D multi-ion MHD equations to new GLM constant update with @r…
amrueda Dec 9, 2024
7d5c21c
Cleaned up implementation of DissipationEntropyStable and improved do…
amrueda Dec 9, 2024
fc360b3
Changed the strategy to compute the non-conservative terms: use local…
amrueda Dec 9, 2024
0b3db84
Updated tests for 2D GLM-MHD multi-ion equations
amrueda Dec 9, 2024
fef17d2
Added 2D GLM-MHD equations, examples and tests
amrueda Dec 9, 2024
81792ee
Fixed typos and removed non-existing function from export
amrueda Dec 9, 2024
76eaaf8
Remove ES test
amrueda Dec 10, 2024
0b17871
Compatibility for single precision
amrueda Dec 10, 2024
42dbc96
Changed initial condition back to double precision
amrueda Dec 10, 2024
c6fd5f3
Merge branch 'main' into arr/multi-ion_mhd_2d
amrueda Dec 10, 2024
9c2f97e
Single precision compatibility
amrueda Dec 10, 2024
bb3b786
Merge branch 'main' into multi_ion_mhd
amrueda Dec 10, 2024
8919821
Update reference to Hennemann et al.
amrueda Dec 10, 2024
f58ae62
Added 3D GLM-MHD equations with some repeated code
amrueda Dec 10, 2024
feac4b8
Replaced all occurrences of 2.0f0 and 4.0f0 with 2 and 4
amrueda Dec 10, 2024
2d8c833
Use a single elixir to test EC and EC+LLF
amrueda Dec 10, 2024
ffaf52f
Removed duplicated code in the outer constructor for @reset
amrueda Dec 10, 2024
7cc8dc9
Renamed AbstractIdealMhdMultiIonEquations to AbstractIdealGlmMhdMulti…
amrueda Dec 10, 2024
5f3d46c
GLM callback dispatches on AbstractIdealGlmMhdMultiIonEquations
amrueda Dec 10, 2024
5e7bed5
Moved routines that will be used by all AbstractIdealGlmMhdMultiIonEq…
amrueda Dec 10, 2024
be72d8d
Apply suggestions from code review
amrueda Dec 11, 2024
ad1509a
Apply suggestions from code review
amrueda Dec 11, 2024
6e68caf
Added appropriate formatting to admonitions in docstrings
amrueda Dec 11, 2024
f16b80f
Apply suggestions from code review
amrueda Dec 11, 2024
f3a3e7d
Make multi-ion GLM-MHD's initial condition initial_condition_weak_bla…
amrueda Dec 11, 2024
ee33ce1
Replaced divisions with multiplications
amrueda Dec 11, 2024
249ccf7
Merge branch 'main' into arr/multi-ion_mhd_2d
amrueda Dec 11, 2024
3411e3c
Changed code order...
amrueda Dec 11, 2024
2fbc1d7
Unexport get_component
amrueda Dec 11, 2024
373aab0
Replace division with multiplication
amrueda Dec 11, 2024
79b0e29
Added unit tests for type stability
amrueda Dec 11, 2024
b8e4a29
Added experimental admonitions
amrueda Dec 11, 2024
d31d5f9
Merge branch 'main' into arr/multi-ion_mhd_2d
ranocha Dec 11, 2024
5909d0f
Update src/equations/ideal_glm_mhd_multiion_2d.jl
ranocha Dec 11, 2024
e44b52e
Improved documentation for DissipationEntropyStable
amrueda Dec 11, 2024
d26713e
Apply suggestions from code review
sloede Dec 11, 2024
8cfd895
Merge branch 'arr/multi-ion_mhd_2d' into multi_ion_mhd
amrueda Dec 11, 2024
0eb9ddb
Moved routines that are dimension-agnostic to ideal_glm_mhd_multiion.jl
amrueda Dec 11, 2024
099b64f
Improved ideal_glm_mhd_multiion_3d.jl with improvements rom the 2D PR…
amrueda Dec 11, 2024
16bb31e
Use a single elixir to prove EC, ES, and EC+LLF for multi-ion GLM-MHD
amrueda Dec 11, 2024
8d26873
Merge branch 'main' into multi_ion_mhd
amrueda Dec 11, 2024
2ee244d
format
amrueda Dec 11, 2024
70205b6
Merge branch 'main' into multi_ion_mhd
amrueda Dec 12, 2024
e84f7a3
Single precision compatibility for dissipation ES
amrueda Dec 12, 2024
8710b8c
Formatting
amrueda Dec 12, 2024
c525f68
Fixed issue with analysis integrals in 1D and removed duplicated code
amrueda Dec 12, 2024
1d01d2f
Fixed Euler test
amrueda Dec 12, 2024
697c7bd
Fix documentation issue
amrueda Dec 12, 2024
2ce007b
Merge branch 'main' into multi_ion_mhd
amrueda Dec 12, 2024
474fa8c
Merge branch 'main' into multi_ion_mhd
amrueda Dec 16, 2024
edfb7ef
Merge branch 'main' into multi_ion_mhd
amrueda Dec 18, 2024
f220df6
Added tests for 3D multi-ion MHD
amrueda Dec 19, 2024
c62b480
Merge branch 'main' into multi_ion_mhd
amrueda Dec 19, 2024
423af9f
Merge branch 'main' into multi_ion_mhd
amrueda Dec 20, 2024
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
55 changes: 55 additions & 0 deletions examples/tree_1d_dgsem/elixir_mhdmultiion_ec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealMhdMultiIonEquations1D(gammas = (2.0, 2.0),
charge_to_mass = (1.0, 1.0))

initial_condition = initial_condition_weak_blast_wave

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
solver = DGSEM(polydeg = 3, surface_flux = surface_flux,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = 0.0
coordinates_max = 1.0
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_lorentz)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
58 changes: 58 additions & 0 deletions examples/tree_1d_dgsem/elixir_mhdmultiion_ec_onespecies.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealMhdMultiIonEquations1D(gammas = (2.0),
charge_to_mass = (1.0))

initial_condition = initial_condition_weak_blast_wave

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
solver = DGSEM(polydeg = 3, surface_flux = surface_flux,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = 0.0
coordinates_max = 1.0
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

# In the one-species case, the source terms are not really needed, but this variant produces the same results:
# semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
# source_terms=source_terms_lorentz)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
55 changes: 55 additions & 0 deletions examples/tree_1d_dgsem/elixir_mhdmultiion_es.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealMhdMultiIonEquations1D(gammas = (2.0, 2.0),
charge_to_mass = (1.0, 1.0))

initial_condition = initial_condition_weak_blast_wave

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_lax_friedrichs, flux_nonconservative_central)
solver = DGSEM(polydeg = 3, surface_flux = surface_flux,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = 0.0
coordinates_max = 1.0
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_lorentz)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
66 changes: 66 additions & 0 deletions examples/tree_1d_dgsem/elixir_mhdmultiion_es_shock_capturing.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealMhdMultiIonEquations1D(gammas = (2.0, 2.0),
charge_to_mass = (1.0, 1.0))

initial_condition = initial_condition_weak_blast_wave

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_lax_friedrichs, flux_nonconservative_central)

basis = LobattoLegendreBasis(3)

indicator_sc = IndicatorHennemannGassner(equations, basis,
alpha_max = 0.5,
alpha_min = 0.001,
alpha_smooth = true,
variable = density)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)

solver = DGSEM(basis, surface_flux, volume_integral)

coordinates_min = 0.0
coordinates_max = 1.0
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_lorentz)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
61 changes: 61 additions & 0 deletions examples/tree_3d_dgsem/elixir_mhdmultiion_ec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealGlmMhdMultiIonEquations3D(gammas = (1.4, 1.667),
charge_to_mass = (1.0, 2.0))

initial_condition = initial_condition_weak_blast_wave

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
solver = DGSEM(polydeg = 3, surface_flux = surface_flux,
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))

coordinates_min = (-2.0, -2.0, -2.0)
coordinates_max = (2.0, 2.0, 2.0)
mesh = TreeMesh(coordinates_min, coordinates_max,
initial_refinement_level = 4,
n_cells_max = 10_000)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_lorentz)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 0.4)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 10
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(dt = 0.1, # interval=100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

cfl = 0.5

stepsize_callback = StepsizeCallback(cfl = cfl)

glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
stepsize_callback,
glm_speed_callback)

###############################################################################
# run the simulation

sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback() # print the timer summary
4 changes: 3 additions & 1 deletion src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export AcousticPerturbationEquations2D,
CompressibleEulerEquationsQuasi1D,
IdealGlmMhdEquations1D, IdealGlmMhdEquations2D, IdealGlmMhdEquations3D,
IdealGlmMhdMulticomponentEquations1D, IdealGlmMhdMulticomponentEquations2D,
IdealGlmMhdMultiIonEquations2D,
IdealMhdMultiIonEquations1D, IdealGlmMhdMultiIonEquations2D,
IdealGlmMhdMultiIonEquations3D,
HyperbolicDiffusionEquations1D, HyperbolicDiffusionEquations2D,
HyperbolicDiffusionEquations3D,
LinearScalarAdvectionEquation1D, LinearScalarAdvectionEquation2D,
Expand Down Expand Up @@ -233,6 +234,7 @@ export entropy, energy_total, energy_kinetic, energy_internal, energy_magnetic,
enstrophy, magnetic_field, divergence_cleaning_field
export lake_at_rest_error
export ncomponents, eachcomponent
export get_component

export TreeMesh, StructuredMesh, StructuredMeshView, UnstructuredMesh2D, P4estMesh,
T8codeMesh
Expand Down
2 changes: 2 additions & 0 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ include("ideal_glm_mhd_multicomponent_2d.jl")
abstract type AbstractIdealGlmMhdMultiIonEquations{NDIMS, NVARS, NCOMP} <:
AbstractEquations{NDIMS, NVARS} end
include("ideal_glm_mhd_multiion.jl")
include("ideal_mhd_multiion_1d.jl")
include("ideal_glm_mhd_multiion_2d.jl")
include("ideal_glm_mhd_multiion_3d.jl")

# Retrieve number of components from equation instance for the multicomponent case
@inline function ncomponents(::AbstractIdealGlmMhdMulticomponentEquations{NDIMS, NVARS,
Expand Down
32 changes: 27 additions & 5 deletions src/equations/ideal_glm_mhd_multiion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ function varnames(::typeof(cons2prim), equations::AbstractIdealGlmMhdMultiIonEqu
return prim
end

function default_analysis_integrals(::AbstractIdealGlmMhdMultiIonEquations)
(entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
end

"""
source_terms_lorentz(u, x, t, equations::AbstractIdealGlmMhdMultiIonEquations)

Source terms due to the Lorentz' force for plasmas with more than one ion species. These source
terms are a fundamental, inseparable part of the multi-ion GLM-MHD equations, and vanish for
a single-species plasma. In particular, they have to be used for every
simulation of [`IdealGlmMhdMultiIonEquations2D`](@ref).
simulation of [`IdealMhdMultiIonEquations1D`](@ref), [`IdealGlmMhdMultiIonEquations2D`](@ref),
and [`IdealGlmMhdMultiIonEquations3D`](@ref).
"""
function source_terms_lorentz(u, x, t, equations::AbstractIdealGlmMhdMultiIonEquations)
@unpack charge_to_mass = equations
Expand Down Expand Up @@ -183,6 +180,31 @@ divergence_cleaning_field(u, equations::AbstractIdealGlmMhdMultiIonEquations) =
return rho
end

# Computes the sum of the densities times the sum of the pressures
@inline function density_pressure(u, equations::AbstractIdealGlmMhdMultiIonEquations)
B1, B2, B3 = magnetic_field(u, equations)
psi = divergence_cleaning_field(cons, equations)

rho_total = zero(real(equations))
p_total = zero(real(equations))
for k in eachcomponent(equations)
rho, rho_v1, rho_v2, rho_v3, rho_e = get_component(k, u, equations)

v1 = rho_v1 / rho
v2 = rho_v2 / rho
v3 = rho_v3 / rho
v_mag = sqrt(v1^2 + v2^2 + v3^2)
gamma = equations.gammas[k]

p = (gamma - 1) *
(rho_e - 0.5 * rho * v_mag^2 - 0.5 * (B1^2 + B2^2 + B3^2) - 0.5 * psi^2)

rho_total += rho
p_total += p
end
return rho_total * p_total
end

#Convert conservative variables to primitive
function cons2prim(u, equations::AbstractIdealGlmMhdMultiIonEquations)
@unpack gammas = equations
Expand Down
Loading
Loading