Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_tree_1d_eulermulti.jl
5582 views
1
module TestExamples1DEulerMulti
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "tree_1d_dgsem")
9
10
@testset "Compressible Euler Multicomponent" begin
11
@trixi_testset "Testing entropy2cons and cons2entropy" begin
12
using ForwardDiff
13
using Trixi: Trixi, CompressibleEulerMulticomponentEquations1D, cons2entropy,
14
entropy2cons, SVector
15
gammas = (1.3272378792562836, 1.5269959187969864, 1.8362285750521512,
16
1.0409061360276926, 1.4652015053812224, 1.3626493264184423)
17
gas_constants = (1.817636851910076, 6.760820475922636, 5.588953939749113,
18
6.31574782981543, 3.362932038038397, 3.212779569399733)
19
equations = CompressibleEulerMulticomponentEquations1D(gammas = SVector{length(gammas)}(gammas...),
20
gas_constants = SVector{length(gas_constants)}(gas_constants...))
21
u = [-1.4632513788889214, 0.9908786980927811, 0.2909066990257628,
22
0.6256623915420473, 0.4905882754313441, 0.14481800501749112,
23
1.0333532872771651, 0.6805599818745411]
24
w = cons2entropy(u, equations)
25
# test that the entropy variables match the gradients of the total entropy
26
@test w ForwardDiff.gradient(u -> Trixi.total_entropy(u, equations), u)
27
# test that `entropy2cons` is the inverse of `cons2entropy`
28
@test entropy2cons(w, equations) u
29
end
30
31
@trixi_testset "elixir_eulermulti_ec.jl" begin
32
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"),
33
l2=[0.15330089521538684, 0.4417674632047301,
34
0.016888510510282385, 0.03377702102056477,
35
0.06755404204112954],
36
linf=[0.29130548795961864, 0.8847009003152357,
37
0.034686525099975274, 0.06937305019995055,
38
0.1387461003999011])
39
# Ensure that we do not have excessive memory allocations
40
# (e.g., from type instabilities)
41
@test_allocations(Trixi.rhs!, semi, sol, 1000)
42
end
43
44
@trixi_testset "elixir_eulermulti_es.jl" begin
45
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"),
46
l2=[
47
0.1522380497572071,
48
0.43830846465313206,
49
0.03907262116499431,
50
0.07814524232998862
51
],
52
linf=[
53
0.24939193075537294,
54
0.7139395740052739,
55
0.06324208768391237,
56
0.12648417536782475
57
])
58
# Ensure that we do not have excessive memory allocations
59
# (e.g., from type instabilities)
60
@test_allocations(Trixi.rhs!, semi, sol, 1000)
61
end
62
63
@trixi_testset "elixir_eulermulti_convergence_ec.jl" begin
64
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"),
65
l2=[
66
8.575236038539227e-5,
67
0.00016387804318585358,
68
1.9412699303977585e-5,
69
3.882539860795517e-5
70
],
71
linf=[
72
0.00030593277277124464,
73
0.0006244803933350696,
74
7.253121435135679e-5,
75
0.00014506242870271358
76
])
77
# Ensure that we do not have excessive memory allocations
78
# (e.g., from type instabilities)
79
@test_allocations(Trixi.rhs!, semi, sol, 1000)
80
end
81
82
@trixi_testset "elixir_eulermulti_convergence_es.jl" begin
83
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),
84
l2=[1.8983933794407234e-5, 6.207744299844731e-5,
85
1.5466205761868047e-6, 3.0932411523736094e-6,
86
6.186482304747219e-6, 1.2372964609494437e-5],
87
linf=[0.00012014372605895218, 0.0003313207215800418,
88
6.50836791016296e-6, 1.301673582032592e-5,
89
2.603347164065184e-5, 5.206694328130368e-5])
90
# Ensure that we do not have excessive memory allocations
91
# (e.g., from type instabilities)
92
@test_allocations(Trixi.rhs!, semi, sol, 1000)
93
end
94
95
@trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin
96
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),
97
l2=[1.888450477353845e-5, 5.4910600482795386e-5,
98
9.426737161533622e-7, 1.8853474323067245e-6,
99
3.770694864613449e-6, 7.541389729226898e-6],
100
linf=[0.00011622351152063004, 0.0003079221967086099,
101
3.2177423254231563e-6, 6.435484650846313e-6,
102
1.2870969301692625e-5, 2.574193860338525e-5],
103
volume_flux=flux_chandrashekar)
104
# Ensure that we do not have excessive memory allocations
105
# (e.g., from type instabilities)
106
@test_allocations(Trixi.rhs!, semi, sol, 1000)
107
end
108
109
@trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin
110
@test_trixi_include(joinpath(EXAMPLES_DIR,
111
"elixir_eulermulti_two_interacting_blast_waves.jl"),
112
l2=[1.288867611915533, 82.71335258388848, 0.00350680272313187,
113
0.013698784353152794,
114
0.019179518517518084],
115
linf=[29.6413044707026, 1322.5844802186496, 0.09191919374782143,
116
0.31092970966717925,
117
0.4417989757182038],
118
tspan=(0.0, 0.0001))
119
# Ensure that we do not have excessive memory allocations
120
# (e.g., from type instabilities)
121
@test_allocations(Trixi.rhs!, semi, sol, 1000)
122
end
123
end
124
125
end # module
126
127