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