Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_tree_1d_mhd.jl
5582 views
1
module TestExamples1DMHD
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 "MHD" begin
11
#! format: noindent
12
13
@trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin
14
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
15
l2=[
16
1.440611823425164e-15,
17
1.1373567770134494e-14,
18
3.024482376149653e-15,
19
2.0553143516814395e-15,
20
3.9938347410210535e-14,
21
3.984545392098788e-16,
22
2.4782402104201577e-15,
23
1.551737464879987e-15
24
],
25
linf=[
26
1.9984014443252818e-15,
27
1.3405943022348765e-14,
28
3.3584246494910985e-15,
29
3.164135620181696e-15,
30
7.815970093361102e-14,
31
8.881784197001252e-16,
32
2.886579864025407e-15,
33
2.942091015256665e-15
34
],
35
initial_condition=initial_condition_constant,
36
tspan=(0.0, 1.0))
37
# Ensure that we do not have excessive memory allocations
38
# (e.g., from type instabilities)
39
@test_allocations(Trixi.rhs!, semi, sol, 1000)
40
end
41
42
@trixi_testset "elixir_mhd_alfven_wave.jl" begin
43
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
44
l2=[
45
1.0375628983659061e-5,
46
6.571144191446236e-7,
47
3.5833569836289104e-5,
48
3.583356983615859e-5,
49
5.084863194951084e-6,
50
1.1963224165731992e-16,
51
3.598916927583752e-5,
52
3.598916927594727e-5
53
],
54
linf=[
55
2.614095879338585e-5,
56
9.577266731216823e-7,
57
0.00012406198007461344,
58
0.00012406198007509917,
59
1.5066209528846741e-5,
60
2.220446049250313e-16,
61
0.00012658678753942054,
62
0.00012658678753908748
63
])
64
# Ensure that we do not have excessive memory allocations
65
# (e.g., from type instabilities)
66
@test_allocations(Trixi.rhs!, semi, sol, 1000)
67
end
68
69
@trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin
70
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
71
l2=[
72
1.4396053943470756e-5,
73
1.1211016739165248e-5,
74
3.577870687983967e-5,
75
3.577870687982181e-5,
76
1.967962220860377e-6,
77
1.1963224165731992e-16,
78
3.583562899483433e-5,
79
3.583562899486565e-5
80
],
81
linf=[
82
5.830577969345718e-5,
83
3.280495696370357e-5,
84
0.00012279619948236953,
85
0.00012279619948227238,
86
6.978806516122482e-6,
87
2.220446049250313e-16,
88
0.00012564003648959932,
89
0.00012564003648994626
90
],
91
volume_flux=flux_derigs_etal)
92
# Ensure that we do not have excessive memory allocations
93
# (e.g., from type instabilities)
94
@test_allocations(Trixi.rhs!, semi, sol, 1000)
95
end
96
97
@trixi_testset "elixir_mhd_alfven_wave.jl with flux_hllc" begin
98
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
99
l2=[
100
1.036850596986597e-5, 1.965192583650368e-6,
101
3.5882124656715505e-5, 3.5882124656638764e-5,
102
5.270975504780837e-6, 1.1963224165731992e-16,
103
3.595811808912869e-5, 3.5958118089159453e-5
104
],
105
linf=[
106
2.887280521446378e-5, 7.310580790352001e-6,
107
0.00012390046377899755, 0.00012390046377787345,
108
1.5102711136583125e-5, 2.220446049250313e-16,
109
0.0001261935452181312, 0.0001261935452182006
110
],
111
surface_flux=flux_hllc)
112
# Ensure that we do not have excessive memory allocations
113
# (e.g., from type instabilities)
114
@test_allocations(Trixi.rhs!, semi, sol, 1000)
115
end
116
117
@trixi_testset "elixir_mhd_ec.jl" begin
118
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"),
119
l2=[
120
0.05815183849746399,
121
0.08166807325621023,
122
0.054659228513541165,
123
0.054659228513541165,
124
0.15578125987042743,
125
4.130462730494e-17,
126
0.05465258887150046,
127
0.05465258887150046
128
],
129
linf=[
130
0.12165312668363826,
131
0.1901920742264952,
132
0.10059813883022554,
133
0.10059813883022554,
134
0.44079257431070706,
135
1.1102230246251565e-16,
136
0.10528911365809579,
137
0.10528911365809579
138
])
139
# Ensure that we do not have excessive memory allocations
140
# (e.g., from type instabilities)
141
@test_allocations(Trixi.rhs!, semi, sol, 1000)
142
end
143
144
@trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin
145
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"),
146
l2=[
147
0.17477712356961989,
148
0.19489623595086944,
149
0.3596546157640463,
150
0.0,
151
0.3723215736814466,
152
1.2060075775846403e-15,
153
0.36276754492568164,
154
0.0
155
],
156
linf=[
157
0.5797109945880677,
158
0.4372991899547103,
159
1.0906536287185835,
160
0.0,
161
1.0526758874956808,
162
5.995204332975845e-15,
163
1.5122922036932964,
164
0.0])
165
# Ensure that we do not have excessive memory allocations
166
# (e.g., from type instabilities)
167
@test_allocations(Trixi.rhs!, semi, sol, 1000)
168
end
169
170
@trixi_testset "elixir_mhd_briowu_shock_tube_mod_positivity.jl" begin
171
@test_trixi_include(joinpath(EXAMPLES_DIR,
172
"elixir_mhd_briowu_shock_tube_mod_positivity.jl"),
173
l2=[
174
0.17958200783518533,
175
0.21403217755031365,
176
0.3528008349880033,
177
0.0,
178
0.40156743941762096,
179
7.603990369710917e-14,
180
0.34299587882334953,
181
0.0
182
],
183
linf=[
184
0.5347779567211823,
185
0.4651105133406562,
186
0.9873266889381644,
187
0.0,
188
1.000540495846343,
189
8.615330671091215e-14,
190
1.4425998855617321,
191
0.0
192
])
193
# Ensure that we do not have excessive memory allocations
194
# (e.g., from type instabilities)
195
@test_allocations(Trixi.rhs!, semi, sol, 1000)
196
end
197
198
@trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin
199
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"),
200
l2=[
201
0.45700904847931145,
202
0.4792535936512035,
203
0.340651203521865,
204
0.4478034694296928,
205
0.9204708961093411,
206
1.3216517820475193e-16,
207
0.28897419402047725,
208
0.25521206483145126
209
],
210
linf=[
211
1.2185238171352286,
212
0.8913202384963431,
213
0.8488793580488431,
214
0.973083603686,
215
1.660723397705417,
216
2.220446049250313e-16,
217
0.6874726847741993,
218
0.65536978110274
219
])
220
# Ensure that we do not have excessive memory allocations
221
# (e.g., from type instabilities)
222
@test_allocations(Trixi.rhs!, semi, sol, 1000)
223
end
224
225
@trixi_testset "elixir_mhd_torrilhon_shock_tube.jl (HLLC)" begin
226
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"),
227
surface_flux=flux_hllc,
228
l2=[
229
0.4573799618744708, 0.4792633358230866, 0.34064852506872795,
230
0.4479668434955162, 0.9203891782415092,
231
1.3216517820475193e-16, 0.28887826520860815,
232
0.255281629265771
233
],
234
linf=[
235
1.2382842201671505, 0.8929169308132259, 0.871298623806198,
236
0.9822415614542821, 1.6726170732132717,
237
2.220446049250313e-16, 0.7016155888023747,
238
0.6556091522071984
239
])
240
# Ensure that we do not have excessive memory allocations
241
# (e.g., from type instabilities)
242
@test_allocations(Trixi.rhs!, semi, sol, 1000)
243
end
244
245
@trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin
246
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"),
247
l2=[
248
0.23469781891518154,
249
0.3916675299696121,
250
0.08245195301016353,
251
0.1745346945706147,
252
0.9606363432904367,
253
6.608258910237605e-17,
254
0.21542929107153735,
255
0.10705457908737925
256
],
257
linf=[
258
0.6447951791685409,
259
0.9461857095377463,
260
0.35074627554617605,
261
0.8515177411529542,
262
2.0770652030507053,
263
1.1102230246251565e-16,
264
0.49670855513788204,
265
0.24830199967863564
266
],
267
tspan=(0.0, 0.1))
268
# Ensure that we do not have excessive memory allocations
269
# (e.g., from type instabilities)
270
@test_allocations(Trixi.rhs!, semi, sol, 1000)
271
end
272
273
@trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin
274
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"),
275
l2=[
276
1.01126210e+00,
277
8.27157902e+00,
278
1.30882545e+00,
279
0.00000000e+00,
280
5.21930435e+01,
281
6.56538824e-16,
282
1.01022340e+00,
283
0.00000000e+00
284
],
285
linf=[
286
2.87172004e+00,
287
2.26438057e+01,
288
4.16672442e+00,
289
0.00000000e+00,
290
1.35152372e+02,
291
3.44169138e-15,
292
2.83556069e+00,
293
0.00000000e+00
294
],
295
tspan=(0.0, 0.2))
296
# Ensure that we do not have excessive memory allocations
297
# (e.g., from type instabilities)
298
@test_allocations(Trixi.rhs!, semi, sol, 1000)
299
end
300
301
@trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin
302
# Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below
303
trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"),
304
tspan = (0.0, 0.0))
305
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"),
306
l2=[
307
1.01539817e+00,
308
8.29625810e+00,
309
1.29548008e+00,
310
0.00000000e+00,
311
5.23565514e+01,
312
3.18641825e-16,
313
1.00485291e+00,
314
0.00000000e+00
315
],
316
linf=[
317
2.92876280e+00,
318
2.28341581e+01,
319
4.11643561e+00,
320
0.00000000e+00,
321
1.36966213e+02,
322
1.55431223e-15,
323
2.80548864e+00,
324
0.00000000e+00
325
],
326
initial_condition=initial_condition_shu_osher_shock_tube_flipped,
327
boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped),
328
tspan=(0.0, 0.2))
329
# Ensure that we do not have excessive memory allocations
330
# (e.g., from type instabilities)
331
@test_allocations(Trixi.rhs!, semi, sol, 1000)
332
end
333
end
334
335
end # module
336
337