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
2055 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
let
42
t = sol.t[end]
43
u_ode = sol.u[end]
44
du_ode = similar(u_ode)
45
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
46
end
47
end
48
49
@trixi_testset "elixir_eulermulti_es.jl" begin
50
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"),
51
l2=[
52
0.1522380497572071,
53
0.43830846465313206,
54
0.03907262116499431,
55
0.07814524232998862
56
],
57
linf=[
58
0.24939193075537294,
59
0.7139395740052739,
60
0.06324208768391237,
61
0.12648417536782475
62
])
63
# Ensure that we do not have excessive memory allocations
64
# (e.g., from type instabilities)
65
let
66
t = sol.t[end]
67
u_ode = sol.u[end]
68
du_ode = similar(u_ode)
69
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
70
end
71
end
72
73
@trixi_testset "elixir_eulermulti_convergence_ec.jl" begin
74
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"),
75
l2=[
76
8.575236038539227e-5,
77
0.00016387804318585358,
78
1.9412699303977585e-5,
79
3.882539860795517e-5
80
],
81
linf=[
82
0.00030593277277124464,
83
0.0006244803933350696,
84
7.253121435135679e-5,
85
0.00014506242870271358
86
])
87
# Ensure that we do not have excessive memory allocations
88
# (e.g., from type instabilities)
89
let
90
t = sol.t[end]
91
u_ode = sol.u[end]
92
du_ode = similar(u_ode)
93
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
94
end
95
end
96
97
@trixi_testset "elixir_eulermulti_convergence_es.jl" begin
98
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),
99
l2=[1.8983933794407234e-5, 6.207744299844731e-5,
100
1.5466205761868047e-6, 3.0932411523736094e-6,
101
6.186482304747219e-6, 1.2372964609494437e-5],
102
linf=[0.00012014372605895218, 0.0003313207215800418,
103
6.50836791016296e-6, 1.301673582032592e-5,
104
2.603347164065184e-5, 5.206694328130368e-5])
105
# Ensure that we do not have excessive memory allocations
106
# (e.g., from type instabilities)
107
let
108
t = sol.t[end]
109
u_ode = sol.u[end]
110
du_ode = similar(u_ode)
111
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
112
end
113
end
114
115
@trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin
116
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"),
117
l2=[1.888450477353845e-5, 5.4910600482795386e-5,
118
9.426737161533622e-7, 1.8853474323067245e-6,
119
3.770694864613449e-6, 7.541389729226898e-6],
120
linf=[0.00011622351152063004, 0.0003079221967086099,
121
3.2177423254231563e-6, 6.435484650846313e-6,
122
1.2870969301692625e-5, 2.574193860338525e-5],
123
volume_flux=flux_chandrashekar)
124
# Ensure that we do not have excessive memory allocations
125
# (e.g., from type instabilities)
126
let
127
t = sol.t[end]
128
u_ode = sol.u[end]
129
du_ode = similar(u_ode)
130
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
131
end
132
end
133
134
@trixi_testset "elixir_eulermulti_two_interacting_blast_waves.jl" begin
135
@test_trixi_include(joinpath(EXAMPLES_DIR,
136
"elixir_eulermulti_two_interacting_blast_waves.jl"),
137
l2=[1.288867611915533, 82.71335258388848, 0.00350680272313187,
138
0.013698784353152794,
139
0.019179518517518084],
140
linf=[29.6413044707026, 1322.5844802186496, 0.09191919374782143,
141
0.31092970966717925,
142
0.4417989757182038],
143
tspan=(0.0, 0.0001))
144
# Ensure that we do not have excessive memory allocations
145
# (e.g., from type instabilities)
146
let
147
t = sol.t[end]
148
u_ode = sol.u[end]
149
du_ode = similar(u_ode)
150
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
151
end
152
end
153
end
154
155
end # module
156
157