Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_paper_self_gravitating_gas_dynamics.jl
5582 views
1
module TestPaperSelfgravitatingGasDynamics
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
# Start with a clean environment: remove Trixi.jl output directory if it exists
9
outdir = "out"
10
isdir(outdir) && rm(outdir, recursive = true)
11
12
EXAMPLES_DIR = joinpath(examples_dir(), "paper_self_gravitating_gas_dynamics")
13
14
# Numerical examples from the Euler-gravity paper
15
@testset "paper_self_gravitating_gas_dynamics" begin
16
#! format: noindent
17
18
@trixi_testset "elixir_euler_convergence.jl" begin
19
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"),
20
l2=[
21
0.0001740977055972079,
22
0.0003369355182519592,
23
0.0003369355182518708,
24
0.0006099171220334989
25
],
26
linf=[
27
0.001079347149189669,
28
0.0018836938381321389,
29
0.001883693838132583,
30
0.003971575376718217
31
])
32
# Ensure that we do not have excessive memory allocations
33
# (e.g., from type instabilities)
34
@test_allocations(Trixi.rhs!, semi, sol, 1000)
35
end
36
37
@trixi_testset "elixir_euler_convergence.jl with polydeg=4" begin
38
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"),
39
l2=[
40
1.7187201161597772e-5,
41
2.678065111772951e-5,
42
2.678065111783027e-5,
43
4.952504160091526e-5
44
],
45
linf=[
46
0.0001501749544159381,
47
0.00016549482504535362,
48
0.00016549482504601976,
49
0.0004372960291432193
50
],
51
polydeg=4)
52
# Ensure that we do not have excessive memory allocations
53
# (e.g., from type instabilities)
54
@test_allocations(Trixi.rhs!, semi, sol, 1000)
55
end
56
57
@trixi_testset "elixir_hypdiff_convergence.jl" begin
58
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"),
59
l2=[
60
0.003154024896093942,
61
0.012394432074951856,
62
0.02185973823794725
63
],
64
linf=[
65
0.01731850928579215,
66
0.07843510773347553,
67
0.11242300176349201
68
])
69
# Ensure that we do not have excessive memory allocations
70
# (e.g., from type instabilities)
71
@test_allocations(Trixi.rhs!, semi, sol, 1000)
72
end
73
74
@trixi_testset "elixir_hypdiff_convergence.jl with polydeg=4" begin
75
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"),
76
l2=[
77
0.0002511283012128458,
78
0.0008808243846610255,
79
0.0016313343228567005
80
],
81
linf=[
82
0.0017290715087938668,
83
0.003129184465704738,
84
0.01000728849316701
85
],
86
polydeg=4)
87
# Ensure that we do not have excessive memory allocations
88
# (e.g., from type instabilities)
89
@test_allocations(Trixi.rhs!, semi, sol, 1000)
90
end
91
92
@trixi_testset "elixir_eulergravity_convergence.jl" begin
93
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"),
94
l2=[
95
0.00024871265138964204,
96
0.0003370077102132591,
97
0.0003370077102131964,
98
0.0007231525513793697
99
],
100
linf=[
101
0.0015813032944647087,
102
0.0020494288423820173,
103
0.0020494288423824614,
104
0.004793821195083758
105
],
106
tspan=(0.0, 0.1))
107
# Ensure that we do not have excessive memory allocations
108
# (e.g., from type instabilities)
109
@test_allocations(Trixi.rhs!, semi, sol, 1000)
110
end
111
112
@trixi_testset "elixir_eulergravity_convergence.jl with polydeg=4" begin
113
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"),
114
l2=[
115
1.9537712148648045e-5,
116
2.7564396197947587e-5,
117
2.7564396197967635e-5,
118
5.688838772067586e-5
119
],
120
linf=[
121
0.00012335710672761735,
122
0.00020086268350816283,
123
0.00020086268350727465,
124
0.0004962155455632278
125
],
126
tspan=(0.0, 0.1), polydeg=4)
127
# Ensure that we do not have excessive memory allocations
128
# (e.g., from type instabilities)
129
@test_allocations(Trixi.rhs!, semi, sol, 1000)
130
end
131
132
@trixi_testset "elixir_eulergravity_convergence.jl with 1st order RK3S*" begin
133
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"),
134
l2=[
135
0.00024871265138959434,
136
0.000337007710281087,
137
0.0003370077102811394,
138
0.0007231525515231289
139
],
140
linf=[
141
0.0015813032941613958,
142
0.002049428843978518,
143
0.0020494288439798503,
144
0.004793821198143977
145
],
146
tspan=(0.0, 0.1),
147
timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!)
148
# Ensure that we do not have excessive memory allocations
149
# (e.g., from type instabilities)
150
@test_allocations(Trixi.rhs!, semi, sol, 1000)
151
end
152
153
@trixi_testset "elixir_eulergravity_convergence.jl with 3rd order RK3S*" begin
154
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"),
155
l2=[
156
0.0002487126513894034,
157
0.00033700771023049785,
158
0.00033700771023048245,
159
0.0007231525514158737
160
],
161
linf=[
162
0.0015813032943847727,
163
0.002049428842844314,
164
0.0020494288428452023,
165
0.004793821195971937
166
],
167
tspan=(0.0, 0.1),
168
timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!)
169
# Ensure that we do not have excessive memory allocations
170
# (e.g., from type instabilities)
171
@test_allocations(Trixi.rhs!, semi, sol, 1000)
172
end
173
174
@trixi_testset "elixir_eulergravity_jeans_instability.jl" begin
175
@test_trixi_include(joinpath(EXAMPLES_DIR,
176
"elixir_eulergravity_jeans_instability.jl"),
177
l2=[
178
10733.28239179182,
179
13356.0533511341,
180
1.6722844879795038e-6,
181
26833.19833691448
182
],
183
linf=[
184
15193.794080890715,
185
18880.45819785685,
186
6.809726988008751e-6,
187
37971.74113135785
188
],
189
tspan=(0.0, 0.1),
190
atol=4.0e-6)
191
# Ensure that we do not have excessive memory allocations
192
# (e.g., from type instabilities)
193
@test_allocations(Trixi.rhs!, semi, sol, 1000)
194
end
195
196
@trixi_testset "elixir_eulergravity_jeans_instability.jl with RK3S*" begin
197
@test_trixi_include(joinpath(EXAMPLES_DIR,
198
"elixir_eulergravity_jeans_instability.jl"),
199
l2=[
200
10734.653995035567,
201
13357.709699808021,
202
1.911011743371934e-6,
203
26836.62734552835
204
],
205
linf=[
206
15195.73481107317,
207
18882.799120551972,
208
7.867948710816926e-6,
209
37976.592992473394
210
],
211
tspan=(0.0, 0.1),
212
atol=4.0e-6, # the background field is reatively large, so this corresponds to our usual atol
213
parameters=ParametersEulerGravity(background_density = 1.5e7,
214
gravitational_constant = 6.674e-8,
215
cfl = 2.4,
216
resid_tol = 1.0e-4,
217
n_iterations_max = 1000,
218
timestep_gravity = timestep_gravity_erk52_3Sstar!))
219
# Ensure that we do not have excessive memory allocations
220
# (e.g., from type instabilities)
221
@test_allocations(Trixi.rhs!, semi, sol, 1000)
222
end
223
224
@trixi_testset "Printing" begin
225
@test_trixi_include(joinpath(EXAMPLES_DIR,
226
"elixir_eulergravity_jeans_instability.jl"),
227
tspan=(0.0, 1.0e-5),
228
parameters=ParametersEulerGravity(background_density = 1.5e7,
229
gravitational_constant = 6.674e-8,
230
cfl = 2.4,
231
resid_tol = 1.0e-4,
232
n_iterations_max = 1000,
233
timestep_gravity = timestep_gravity_erk52_3Sstar!))
234
235
show(stdout, parameters)
236
show(stdout, semi)
237
show(stdout, semi_euler.boundary_conditions)
238
show(stdout, TrivialCallback())
239
show(stdout, equations_euler)
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_eulergravity_sedov_blast_wave.jl" begin
246
@test_trixi_include(joinpath(EXAMPLES_DIR,
247
"elixir_eulergravity_sedov_blast_wave.jl"),
248
l2=[
249
0.046315994852653024,
250
0.0650818006233669,
251
0.06508180062336677,
252
0.4896707211656037
253
],
254
linf=[
255
2.3874843337593776,
256
4.07876384374792,
257
4.07876384374792,
258
16.23914384809855
259
],
260
tspan=(0.0, 0.05))
261
# Ensure that we do not have excessive memory allocations
262
# (e.g., from type instabilities)
263
@test_allocations(Trixi.rhs!, semi, sol, 1000)
264
end
265
266
@trixi_testset "elixir_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin
267
@test_trixi_include(joinpath(EXAMPLES_DIR,
268
"elixir_eulergravity_sedov_blast_wave.jl"),
269
l2=[
270
0.00289222135995042,
271
0.013724813590853825,
272
0.013724813590853832,
273
0.05822904710548214
274
],
275
linf=[
276
0.26361780693997594,
277
1.3908873830688688,
278
1.3908873830688688,
279
4.066701303607613
280
],
281
tspan=(0.0, 0.005), initial_refinement_level=8,
282
amr_callback=TrivialCallback())
283
# Ensure that we do not have excessive memory allocations
284
# (e.g., from type instabilities)
285
@test_allocations(Trixi.rhs!, semi, sol, 1000)
286
end
287
end
288
289
# Clean up afterwards: delete Trixi.jl output directory
290
@test_nowarn rm(outdir, recursive = true)
291
292
end #module
293
294