Skip to content

Commit

Permalink
Updated tests of the multi-ion MHD equations after bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amrueda committed Nov 7, 2023
1 parent db51600 commit 84966be
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 234 deletions.
56 changes: 56 additions & 0 deletions examples/tree_2d_dgsem/elixir_mhdmultiion_es.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the ideal MHD equations
equations = IdealMhdMultiIonEquations2D(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 = (-2.0, -2.0)
coordinates_max = (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_standard)

###############################################################################
# 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(dt = 0.1, # 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
158 changes: 0 additions & 158 deletions examples/tree_2d_dgsem/elixir_mhdmultiion_rotor.jl

This file was deleted.

174 changes: 125 additions & 49 deletions test/test_tree_1d_mhdmultiion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,134 @@ include("test_trixi.jl")
EXAMPLES_DIR = joinpath(pathof(Trixi) |> dirname |> dirname, "examples", "tree_1d_dgsem")

@testset "MHD Multi-ion" begin
@trixi_testset "elixir_mhdmultiion_ec_onespecies.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec_onespecies.jl"),
l2=[4.13046273e-17, 5.47627735e-02, 5.47627735e-02,
5.85364902e-02, 8.15735949e-02,
5.46480229e-02, 5.46480229e-02, 1.54430906e-01],
linf=[1.11022302e-16, 9.62277600e-02, 9.62277600e-02,
1.07398441e-01, 1.85851486e-01,
9.41669606e-02, 9.41669606e-02, 4.10966135e-01])
end
#! format: noindent

@trixi_testset "elixir_mhdmultiion_ec.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec.jl"),
l2=[4.13046273e-17, 4.41300832e-02, 4.08698259e-02,
1.45921842e-02, 1.46195334e-01,
1.46189460e-01, 1.47069647e-01, 1.15948953e-01,
4.17156345e-02, 2.95429888e-01,
2.91864340e-01, 2.90281705e-01, 1.91712252e-01],
linf=[1.11022302e-16, 8.23475323e-02, 8.20044181e-02,
5.26482770e-02, 2.36978475e-01,
1.78890885e-01, 1.83844973e-01, 3.69223717e-01,
9.49715344e-02, 4.04059325e-01,
3.53727376e-01, 3.43908646e-01, 3.72557303e-01])
end
@trixi_testset "elixir_mhdmultiion_ec_onespecies.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec_onespecies.jl"),
l2=[
4.1304627304940003e-17,
5.4681492967955873e-02,
5.4681492967955873e-02,
5.8034794143785734e-02,
8.1686107656040716e-02,
5.4627972898756594e-02,
5.4627972898756594e-02,
1.5559804954845133e-01,
],
linf=[
1.1102230246251565e-16,
1.0756082592909055e-01,
1.0756082592909055e-01,
1.1699453974473184e-01,
1.8782944777819507e-01,
9.8288863211692001e-02,
9.8288863211692001e-02,
4.3538944922452361e-01,
])
end

@trixi_testset "elixir_mhdmultiion_es.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_es.jl"),
l2=[4.13046273e-17, 4.34692117e-02, 4.01800240e-02,
1.39798040e-02, 1.45588748e-01,
1.46145114e-01, 1.47018561e-01, 1.07728669e-01,
4.13841438e-02, 2.95261011e-01,
2.91827041e-01, 2.90260310e-01, 1.90243105e-01],
linf=[1.11022302e-16, 7.89266630e-02, 7.79256051e-02,
4.76391824e-02, 2.07007992e-01,
1.79314301e-01, 1.84325683e-01, 3.47578503e-01,
9.30059101e-02, 3.81670634e-01,
3.53221946e-01, 3.43511206e-01, 3.75916013e-01])
end
@trixi_testset "elixir_mhdmultiion_ec.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec.jl"),
l2=[
4.1304627304940003e-17,
4.3626365427359211e-02,
4.3597997802536363e-02,
2.3507245682869861e-02,
4.6610769145871714e-02,
1.4848843852905394e-02,
1.7839683917849288e-02,
1.3457845268573115e-01,
3.8214585380506302e-02,
5.2755332770791419e-02,
3.3071810251645600e-02,
3.0160701292947324e-02,
8.5619654328485756e-02,
],
linf=[
1.1102230246251565e-16,
9.1215410389221874e-02,
9.1205447402732065e-02,
7.1152999945483464e-02,
1.2176089138259275e-01,
3.2242944708070438e-02,
3.8890545935514498e-02,
3.4213021755787931e-01,
8.5324175333816754e-02,
1.0941185893660356e-01,
6.7106846800977699e-02,
6.0449563579190013e-02,
1.8998760735672127e-01,
])
end

@trixi_testset "elixir_mhdmultiion_es_shock_capturing.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_mhdmultiion_es_shock_capturing.jl"),
l2=[4.13046273e-17, 4.34327035e-02, 4.01429579e-02,
1.39648331e-02, 1.45589699e-01,
1.46145036e-01, 1.47013130e-01, 1.07647870e-01,
4.13842626e-02, 2.95252636e-01,
2.91824474e-01, 2.90263048e-01, 1.90199794e-01],
linf=[1.11022302e-16, 7.86144728e-02, 7.75970804e-02,
4.75320603e-02, 2.07019087e-01,
1.79245486e-01, 1.84254005e-01, 3.47166288e-01,
9.16953877e-02, 3.81637525e-01,
3.53188856e-01, 3.43474263e-01, 3.75932899e-01])
end
@trixi_testset "elixir_mhdmultiion_es.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_es.jl"),
l2=[
4.1304627304940003e-17,
4.2553038586026444e-02,
4.2527236533326879e-02,
2.3251091453701061e-02,
4.4654486530370789e-02,
1.4619805774071728e-02,
1.7643391664085059e-02,
1.2712914702892930e-01,
3.8469247812943669e-02,
5.2336025462555114e-02,
3.2727028006044219e-02,
2.9776912791966450e-02,
8.4012739159795263e-02,
],
linf=[
1.1102230246251565e-16,
8.2210559138160888e-02,
8.2218565022087908e-02,
6.5729098364666283e-02,
1.1094270689375808e-01,
2.4700103166055636e-02,
3.2091406020875547e-02,
3.1521158925312243e-01,
8.5168856942823057e-02,
1.0770235761746386e-01,
5.1134001263296432e-02,
4.3948680822294889e-02,
1.6265858425106705e-01,
])
end

@trixi_testset "elixir_mhdmultiion_es_shock_capturing.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_mhdmultiion_es_shock_capturing.jl"),
l2=[
4.1304627304940003e-17,
4.2551420656608052e-02,
4.2525625623064091e-02,
2.3250220525587818e-02,
4.4653027389729920e-02,
1.4619390203068858e-02,
1.7642992953968012e-02,
1.2712366369768024e-01,
3.8467995219616406e-02,
5.2334692216684658e-02,
3.2726030774880857e-02,
2.9775868343442317e-02,
8.4007321361367848e-02,
],
linf=[
1.1102230246251565e-16,
8.2196712187582066e-02,
8.2204692538675128e-02,
6.5725380494179808e-02,
1.1093829329448765e-01,
2.4696553126525956e-02,
3.2087364118652505e-02,
3.1519746333592513e-01,
8.5161488531380058e-02,
1.0769856292976031e-01,
5.1128616588110090e-02,
4.3943599376482068e-02,
1.6265341537651956e-01,
])
end
end

end # module
Loading

0 comments on commit 84966be

Please sign in to comment.