Skip to content

Commit d5f225a

Browse files
committed
Merge branch 'multi_ion_mhd' into multi_ion_collision_sources
2 parents 3d311c3 + 2ce007b commit d5f225a

7 files changed

+14
-132
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Trixi"
22
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
33
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"]
4-
version = "0.9.11-DEV"
4+
version = "0.9.12-DEV"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"

src/equations/ideal_glm_mhd_multiion.jl

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ function varnames(::typeof(cons2prim), equations::AbstractIdealGlmMhdMultiIonEqu
3333
return prim
3434
end
3535

36-
function default_analysis_integrals(::AbstractIdealGlmMhdMultiIonEquations)
37-
(entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
38-
end
39-
4036
"""
4137
source_terms_lorentz(u, x, t, equations::AbstractIdealGlmMhdMultiIonEquations)
4238
4339
Source terms due to the Lorentz' force for plasmas with more than one ion species. These source
4440
terms are a fundamental, inseparable part of the multi-ion GLM-MHD equations, and vanish for
4541
a single-species plasma. In particular, they have to be used for every
46-
simulation of [`IdealGlmMhdMultiIonEquations1D`](@ref), [`IdealGlmMhdMultiIonEquations2D`](@ref),
42+
simulation of [`IdealMhdMultiIonEquations1D`](@ref), [`IdealGlmMhdMultiIonEquations2D`](@ref),
4743
and [`IdealGlmMhdMultiIonEquations3D`](@ref).
4844
"""
4945
function source_terms_lorentz(u, x, t, equations::AbstractIdealGlmMhdMultiIonEquations)

src/equations/ideal_glm_mhd_multiion_2d.jl

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ end
151151
RealT
152152
end
153153

154+
function default_analysis_integrals(::IdealGlmMhdMultiIonEquations2D)
155+
(entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
156+
end
157+
154158
"""
155159
initial_condition_weak_blast_wave(x, t, equations::IdealGlmMhdMultiIonEquations2D)
156160

src/equations/ideal_glm_mhd_multiion_3d.jl

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ end
9696
RealT
9797
end
9898

99+
function default_analysis_integrals(::IdealGlmMhdMultiIonEquations3D)
100+
(entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
101+
end
102+
99103
"""
100104
initial_condition_weak_blast_wave(x, t, equations::IdealGlmMhdMultiIonEquations3D)
101105

src/equations/ideal_mhd_multiion_1d.jl

+3-123
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ end
5050
RealT
5151
end
5252

53-
have_nonconservative_terms(::IdealMhdMultiIonEquations1D) = True()
54-
5553
function varnames(::typeof(cons2cons), equations::IdealMhdMultiIonEquations1D)
5654
cons = ("B1", "B2", "B3")
5755
for i in eachcomponent(equations)
@@ -74,28 +72,9 @@ function varnames(::typeof(cons2prim), equations::IdealMhdMultiIonEquations1D)
7472
return prim
7573
end
7674

77-
# """
78-
# initial_condition_convergence_test(x, t, equations::IdealMhdMultiIonEquations1D)
79-
80-
# An Alfvén wave as smooth initial condition used for convergence tests.
81-
# """
82-
# function initial_condition_convergence_test(x, t, equations::IdealMhdMultiIonEquations1D)
83-
# # smooth Alfvén wave test from Derigs et al. FLASH (2016)
84-
# # domain must be set to [0, 1], γ = 5/3
85-
86-
# rho = 1.0
87-
# prim_rho = SVector{ncomponents(equations), real(equations)}(2^(i-1) * (1-2)/(1-2^ncomponents(equations)) * rho for i in eachcomponent(equations))
88-
# v1 = 0.0
89-
# si, co = sincos(2 * pi * x[1])
90-
# v2 = 0.1 * si
91-
# v3 = 0.1 * co
92-
# p = 0.1
93-
# B1 = 1.0
94-
# B2 = v2
95-
# B3 = v3
96-
# prim_other = SVector{7, real(equations)}(v1, v2, v3, p, B1, B2, B3)
97-
# return prim2cons(vcat(prim_other, prim_rho), equations)
98-
# end
75+
function default_analysis_integrals(::AbstractIdealGlmMhdMultiIonEquations)
76+
(entropy_timederivative,)
77+
end
9978

10079
"""
10180
initial_condition_weak_blast_wave(x, t, equations::IdealMhdMultiIonEquations1D)
@@ -137,8 +116,6 @@ function initial_condition_weak_blast_wave(x, t, equations::IdealMhdMultiIonEqua
137116
return prim2cons(SVector(prim), equations)
138117
end
139118

140-
# TODO: Add initial condition equilibrium
141-
142119
# Calculate 1D flux in for a single point
143120
@inline function flux(u, orientation::Integer, equations::IdealMhdMultiIonEquations1D)
144121
B1, B2, B3 = magnetic_field(u, equations)
@@ -176,36 +153,6 @@ end
176153
return SVector(f)
177154
end
178155

179-
"""
180-
Standard source terms of the multi-ion MHD equations
181-
"""
182-
function source_terms_lorentz(u, x, t, equations::IdealMhdMultiIonEquations1D)
183-
@unpack charge_to_mass = equations
184-
B1, B2, B3 = magnetic_field(u, equations)
185-
v1_plus, v2_plus, v3_plus, vk1_plus, vk2_plus, vk3_plus = charge_averaged_velocities(u,
186-
equations)
187-
188-
s = zero(MVector{nvariables(equations), eltype(u)})
189-
for k in eachcomponent(equations)
190-
rho, rho_v1, rho_v2, rho_v3, rho_e = get_component(k, u, equations)
191-
v1 = rho_v1 / rho
192-
v2 = rho_v2 / rho
193-
v3 = rho_v3 / rho
194-
v1_diff = v1_plus - v1
195-
v2_diff = v2_plus - v2
196-
v3_diff = v3_plus - v3
197-
r_rho = charge_to_mass[k] * rho
198-
s2 = r_rho * (v2_diff * B3 - v3_diff * B2)
199-
s3 = r_rho * (v3_diff * B1 - v1_diff * B3)
200-
s4 = r_rho * (v1_diff * B2 - v2_diff * B1)
201-
s5 = v1 * s2 + v2 * s3 + v3 * s4
202-
203-
set_component!(s, k, 0, s2, s3, s4, s5, equations)
204-
end
205-
206-
return SVector(s)
207-
end
208-
209156
"""
210157
Total entropy-conserving non-conservative two-point "flux"" as described in
211158
- Rueda-Ramírez et al. (2023)
@@ -630,71 +577,4 @@ Compute the fastest wave speed for ideal MHD equations: c_f, the fast magnetoaco
630577

631578
return c_f
632579
end
633-
634-
"""
635-
Routine to compute the charge-averaged velocities:
636-
* v*_plus: Charge-averaged velocity
637-
* vk*_plus: Contribution of each species to the charge-averaged velocity
638-
"""
639-
@inline function charge_averaged_velocities(u, equations::IdealMhdMultiIonEquations1D)
640-
total_electron_charge = zero(real(equations))
641-
642-
vk1_plus = zero(MVector{ncomponents(equations), eltype(u)})
643-
vk2_plus = zero(MVector{ncomponents(equations), eltype(u)})
644-
vk3_plus = zero(MVector{ncomponents(equations), eltype(u)})
645-
646-
for k in eachcomponent(equations)
647-
rho, rho_v1, rho_v2, rho_v3, _ = get_component(k, u,
648-
equations::IdealMhdMultiIonEquations1D)
649-
650-
total_electron_charge += rho * equations.charge_to_mass[k]
651-
vk1_plus[k] = rho_v1 * equations.charge_to_mass[k]
652-
vk2_plus[k] = rho_v2 * equations.charge_to_mass[k]
653-
vk3_plus[k] = rho_v3 * equations.charge_to_mass[k]
654-
end
655-
vk1_plus ./= total_electron_charge
656-
vk2_plus ./= total_electron_charge
657-
vk3_plus ./= total_electron_charge
658-
v1_plus = sum(vk1_plus)
659-
v2_plus = sum(vk2_plus)
660-
v3_plus = sum(vk3_plus)
661-
662-
return v1_plus, v2_plus, v3_plus, SVector(vk1_plus), SVector(vk2_plus),
663-
SVector(vk3_plus)
664-
end
665-
666-
"""
667-
Get the flow variables of component k
668-
"""
669-
@inline function get_component(k, u, equations::IdealMhdMultiIonEquations1D)
670-
# The first 3 entries of u contain the magnetic field. The following entries contain the density, momentum (3 entries), and energy of each component.
671-
return SVector(u[3 + (k - 1) * 5 + 1],
672-
u[3 + (k - 1) * 5 + 2],
673-
u[3 + (k - 1) * 5 + 3],
674-
u[3 + (k - 1) * 5 + 4],
675-
u[3 + (k - 1) * 5 + 5])
676-
end
677-
678-
"""
679-
Set the flow variables of component k
680-
"""
681-
@inline function set_component!(u, k, u1, u2, u3, u4, u5,
682-
equations::IdealMhdMultiIonEquations1D)
683-
# The first 3 entries of u contain the magnetic field. The following entries contain the density, momentum (3 entries), and energy of each component.
684-
u[3 + (k - 1) * 5 + 1] = u1
685-
u[3 + (k - 1) * 5 + 2] = u2
686-
u[3 + (k - 1) * 5 + 3] = u3
687-
u[3 + (k - 1) * 5 + 4] = u4
688-
u[3 + (k - 1) * 5 + 5] = u5
689-
end
690-
691-
magnetic_field(u, equations::IdealMhdMultiIonEquations1D) = SVector(u[1], u[2], u[3])
692-
693-
@inline function density(u, equations::IdealMhdMultiIonEquations1D)
694-
rho = zero(real(equations))
695-
for k in eachcomponent(equations)
696-
rho += u[3 + (k - 1) * 5 + 1]
697-
end
698-
return rho
699-
end
700580
end # @muladd

src/time_integration/methods_SSP.jl

-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ function solve!(integrator::SimpleIntegratorSSP)
186186
terminate!(integrator)
187187
end
188188

189-
modify_dt_for_tstops!(integrator)
190-
191189
@. integrator.r0 = integrator.u
192190
for stage in eachindex(alg.c)
193191
t_stage = integrator.t + integrator.dt * alg.c[stage]

test/test_tree_1d_mhdmultiion.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module TestExamples1DMHD
1+
module TestExamples1DMHDMultiIon
22

33
using Test
44
using Trixi

0 commit comments

Comments
 (0)