Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
18797ce
Implemented fluxes using normal_direction.
SimonCan Jun 18, 2025
a29b2e2
Added example using IdealGlmMhdMultiIonEquations2D equations on a str…
SimonCan Jun 20, 2025
31cc07d
Corrected projections for numerical fluxes using normal_direction.
SimonCan Jun 23, 2025
c1bab01
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
4b79219
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
d8d19aa
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
806122f
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
dd2c8b9
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
5e71d79
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
7681029
Compute normal component of velocites to save computaional time.
SimonCan Jun 23, 2025
c461f93
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of https://…
SimonCan Jun 23, 2025
ac03104
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jun 23, 2025
02547aa
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jun 23, 2025
040451d
Applied the autoformatter.
SimonCan Jun 23, 2025
fb7cd6e
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jun 25, 2025
40b023e
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jul 2, 2025
90584e6
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 2, 2025
1f9ae00
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 2, 2025
7a35acc
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 2, 2025
e1c2464
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 2, 2025
e46d9ff
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 2, 2025
16015ab
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jul 8, 2025
1b2f5e9
Corrections in flux_nonconservative_ruedaramirez_etal for general dir…
SimonCan Jul 24, 2025
efbdb5f
Change the norma_Direction to:
SimonCan Dec 19, 2025
abc5425
Corrected real type to be more generic.
SimonCan Dec 19, 2025
8b249b7
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jan 5, 2026
f8c1c14
Applied autoformatter.
SimonCan Jan 5, 2026
de59ae9
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 5, 2026
eb6f4f4
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 7, 2026
eeb3c06
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jan 7, 2026
91d9475
Applied atoformatter.
SimonCan Jan 7, 2026
262d831
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Jan 7, 2026
485aaf2
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jan 7, 2026
3c0510e
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jan 7, 2026
dd71339
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 9, 2026
239e841
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 12, 2026
bd77980
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 14, 2026
7b19a93
Corrected various typos in the calculation of the fluxes
SimonCan Jan 14, 2026
5034173
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 16, 2026
b2bd456
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 23, 2026
4e03464
Removed commented out code.
SimonCan Jan 27, 2026
12005ef
Added multi ion test for structured mesh.
SimonCan Jan 27, 2026
0657fc4
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Jan 27, 2026
dd0b474
Added unit test for IdealGlmMhdMultiIonEquations2D fluxes.
SimonCan Jan 27, 2026
20a00fe
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Jan 27, 2026
dfdb0ff
Added vector normalization.
SimonCan Jan 27, 2026
1f5bef1
Corrected unit test.
SimonCan Jan 27, 2026
f1fa892
Added test for structured elixir_mhdmultiion_ec.jl and FluxLaxFriedri…
SimonCan Jan 27, 2026
ff2aaa3
Update test/test_unit.jl
SimonCan Jan 27, 2026
7c6ae46
Removed commented out code.
SimonCan Jan 28, 2026
e305eb8
Optimized calculation of terms involving B.n_avg.
SimonCan Jan 29, 2026
95dcc3c
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Jan 29, 2026
6678ca1
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Feb 9, 2026
572a71f
Added missing definition of boundary conditions.
SimonCan Feb 10, 2026
081ad2f
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Feb 17, 2026
de54983
Added convergence test as initial condition.
SimonCan Feb 20, 2026
7f9c5ef
Added further test for IdealGlmMhdMultiIonEquations2D on structured m…
SimonCan Feb 20, 2026
f779219
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Feb 23, 2026
8b88bc4
Changed normal_direction::SVector{2, T} to normal_direction::Abstract…
SimonCan Feb 23, 2026
1b92af4
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Feb 23, 2026
54b0b03
Update test/test_type.jl
SimonCan Feb 23, 2026
1ab9a0d
Update test/test_type.jl
SimonCan Feb 23, 2026
64e0fa1
Removed spurious where {T <: Real} arguments.
SimonCan Feb 24, 2026
024c645
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Feb 24, 2026
ec709c5
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Feb 24, 2026
006193c
Added convergence elixir for IdealGlmMhdMultiIonEquations2D equations.
SimonCan Feb 24, 2026
c805f2c
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Feb 24, 2026
e916569
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Feb 24, 2026
b562d7f
Added 2-species convergence test that is failing (but works on TreeMesh)
amrueda Feb 24, 2026
8f8e632
Fixed issues in flux_nonconservative_ruedaramirez_etal
amrueda Feb 25, 2026
00bb717
Spice up convergence test with a curvilinear mapping
amrueda Feb 25, 2026
573487c
Added test for elixir_mhdmultiion_convergence_twospecies.jl.
SimonCan Feb 25, 2026
76e3d0e
Update test/test_structured_2d.jl
SimonCan Feb 25, 2026
a7fee1d
Fixed issue with extra memory allocation.
SimonCan Feb 25, 2026
4d13a72
Updated errors for elixir_mhdmultiion_ec.jl.
SimonCan Feb 25, 2026
9d8813a
Updated errors for elixir_mhdmultiion_ec.jl test.
SimonCan Feb 25, 2026
7b62471
Removed unused initial_condition_convergence_test for IdealGlmMhdMult…
SimonCan Feb 27, 2026
02f48cf
Removed redundant line from flux calculations.
SimonCan Feb 27, 2026
0ff8d61
Changed rho_e to rho_e_total.
SimonCan Feb 27, 2026
4488d9b
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
ranocha Feb 28, 2026
e34993a
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Mar 2, 2026
188bbc7
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
SimonCan Mar 2, 2026
08f3425
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
amrueda Mar 3, 2026
29571ec
Merge branch 'sc/flux_ruedaramirez_etal_normal_direction' of github.c…
SimonCan Mar 3, 2026
7cbe590
Added test for max_abs and IdealGlmMhdMultiIonEquations2D
SimonCan Mar 3, 2026
62f6ba9
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
sloede Mar 4, 2026
fec54f5
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Mar 4, 2026
035cf39
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Mar 4, 2026
fbcc537
Applied code formatting.
SimonCan Mar 4, 2026
30dffdd
Update src/equations/ideal_glm_mhd_multiion_2d.jl
SimonCan Mar 4, 2026
5455c4f
Merge branch 'main' into sc/flux_ruedaramirez_etal_normal_direction
ranocha Mar 5, 2026
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
using OrdinaryDiffEqLowStorageRK
using Trixi

###############################################################################
"""
electron_pressure_alpha(u, equations::IdealGlmMhdMultiIonEquations2D)
Returns a fraction (alpha) of the total ion pressure for the electron pressure.
"""
function electron_pressure_alpha(u, equations::IdealGlmMhdMultiIonEquations2D)
alpha = 0.2
prim = cons2prim(u, equations)
p_e = zero(u[1])
for k in eachcomponent(equations)
_, _, _, _, p_k = Trixi.get_component(k, prim, equations)
p_e += p_k
end
return alpha * p_e
end
# semidiscretization of the ideal multi-ion MHD equations
equations = IdealGlmMhdMultiIonEquations2D(gammas = (2.0, 4.0),
charge_to_mass = (2.0, 1.0),
electron_pressure = electron_pressure_alpha)

"""
Initial (and exact) solution for the the manufactured solution test. Runs with
* gammas = (2.0, 4.0),
* charge_to_mass = (2.0, 1.0)
* Domain size: [-1,1]²
"""
function initial_condition_manufactured_solution(x, t,
equations::IdealGlmMhdMultiIonEquations2D)
am = 0.1
om = π
h = am * sin(om * (x[1] + x[2] - t)) + 2
hh1 = am * 0.4 * sin(om * (x[1] + x[2] - t)) + 1
hh2 = h - hh1

u1 = hh1
u2 = hh1
u3 = hh1
u4 = 0.1 * hh1
u5 = 2 * hh1^2 + hh1
u6 = hh2
u7 = hh2
u8 = hh2
u9 = 0.1 * hh2
u10 = 2 * hh2^2 + hh2
u11 = 0.25 * h
u12 = -0.25 * h
u13 = 0.1 * h

return SVector{nvariables(equations), real(equations)}(u11, u12, u13,
u1, u2, u3, u4, u5,
u6, u7, u8, u9, u10,
0)
end

"""
Source term that corresponds to the manufactured solution test. Runs with
* gammas = (2.0, 4.0),
* charge_to_mass = (2.0, 1.0)
* Domain size: [-1,1]²
"""
function source_terms_manufactured_solution_pe(u, x, t,
equations::IdealGlmMhdMultiIonEquations2D)
am = 0.1
om = pi
h1 = am * sin(om * (x[1] + x[2] - t))
hx = am * om * cos(om * (x[1] + x[2] - t))

s1 = (2 * hx) / 5
s2 = (38055 * hx * h1^2 + 185541 * hx * h1 + 220190 * hx) / (35000 * h1 + 75000)
s3 = (38055 * hx * h1^2 + 185541 * hx * h1 + 220190 * hx) / (35000 * h1 + 75000)
s4 = hx / 25
s5 = (1835811702576186755 * hx * h1^2 + 8592627463681183181 * hx * h1 +
9884050459977240490 * hx) / (652252660543767500 * h1 + 1397684272593787500)
s6 = (3 * hx) / 5
s7 = (76155 * hx * h1^2 + 295306 * hx * h1 + 284435 * hx) / (17500 * h1 + 37500)
s8 = (76155 * hx * h1^2 + 295306 * hx * h1 + 284435 * hx) / (17500 * h1 + 37500)
s9 = (3 * hx) / 50
s10 = (88755 * hx * h1^2 + 338056 * hx * h1 + 318185 * hx) / (8750 * h1 + 18750)
s11 = hx / 4
s12 = -hx / 4
s13 = hx / 10

s = SVector{nvariables(equations), real(equations)}(s11, s12, s13,
s1, s2, s3, s4, s5,
s6, s7, s8, s9, s10,
0)
S_std = source_terms_lorentz(u, x, t, equations::IdealGlmMhdMultiIonEquations2D)

return SVector{nvariables(equations), real(equations)}(S_std .+ s)
end

initial_condition = initial_condition_manufactured_solution
source_terms = source_terms_manufactured_solution_pe

volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal)
surface_flux = (FluxLaxFriedrichs(max_abs_speed_naive),
flux_nonconservative_central) # Also works with flux_nonconservative_ruedaramirez_etal

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

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)

# To test convergence use:
# convergence_test("../examples/structured_2d_dgsem/elixir_mhdmultiion_convergence_twospecies.jl", 3, cells_per_dimension = (2, 2), polydeg = 3)
# Mapping as described in https://arxiv.org/abs/2012.12040
function mapping(xi_, eta_)
# Transform input variables between -1 and 1 onto [0,3]
xi = 1.5 * xi_ + 1.5
eta = 1.5 * eta_ + 1.5

y = eta +
0.05 * (cospi(1.5 * (2 * xi - 3) / 3) *
cospi(0.5 * (2 * eta - 3) / 3))

x = xi +
0.05 * (cospi(0.5 * (2 * xi - 3) / 3) *
cospi(2 * (2 * y - 3) / 3))

# Go back to [-1,1]^3
x = x * 2 / 3 - 1
y = y * 2 / 3 - 1

return SVector(x, y)
end
cells_per_dimension = (2, 2)
mesh = StructuredMesh(cells_per_dimension, mapping;
periodicity = true)

# # Alternatively, you can test with a TreeMesh
# # convergence_test("../examples/structured_2d_dgsem/elixir_mhdmultiion_convergence_twospecies.jl", 3, initial_refinement_level = 1, polydeg = 3)
# initial_refinement_level = 1
# mesh = TreeMesh(coordinates_min, coordinates_max,
# initial_refinement_level = initial_refinement_level,
# n_cells_max = 1_000_000,
# periodicity = true)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms,
boundary_conditions = boundary_condition_periodic)

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

tspan = (0.0, 1.0)
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 = 1000,
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);
64 changes: 64 additions & 0 deletions examples/structured_2d_dgsem/elixir_mhdmultiion_ec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using OrdinaryDiffEqLowStorageRK
using Trixi

###############################################################################
# semidiscretization of the ideal multi-ion MHD equations
equations = IdealGlmMhdMultiIonEquations2D(gammas = (1.4, 1.667),
charge_to_mass = (1.0, 2.0))

initial_condition = initial_condition_weak_blast_wave

# Entropy conservative numerical fluxes
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)
coordinates_max = (2.0, 2.0)
cells_per_dimension = (100, 100)
mesh = StructuredMesh(cells_per_dimension, coordinates_min,
coordinates_max, periodicity = true)

# The multi-ion GLM-MHD equations require the inclusion of source_terms_lorentz
# whenever multiple ion species are present
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
source_terms = source_terms_lorentz,
boundary_conditions = boundary_condition_periodic)

###############################################################################
# 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
ode_default_options()..., callback = callbacks);
Loading
Loading