Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/examples/tree_1d_dgsem/elixir_euler_modified_sod.jl
5586 views
1
using OrdinaryDiffEqSSPRK
2
using Trixi
3
4
equations = CompressibleEulerEquations1D(1.4)
5
6
"""
7
initial_condition_modified_sod(x, t, equations::CompressibleEulerEquations1D)
8
9
Modified Sod shock tube problem, presented in Section 6.4 of Toro's book.
10
This problem consists of a left sonic rarefaction wave and is useful for testing whether numerical solutions
11
violate the entropy condition.
12
An entropy-satisfying solution should produce a smooth(!) rarefaction wave.
13
14
## References
15
- Toro (2009).
16
Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction, 3rd Edition.
17
[DOI: 10.1007/b79761](https://doi.org/10.1007/b79761)
18
19
- Lin, Chan (2014)
20
High order entropy stable discontinuous Galerkin spectral element methods through subcell limiting
21
[DOI: 10.1016/j.jcp.2023.112677](https://doi.org/10.1016/j.jcp.2023.112677)
22
"""
23
function initial_condition_modified_sod(x, t, ::CompressibleEulerEquations1D)
24
if x[1] < 0.3
25
return prim2cons(SVector(1, 0.75, 1), equations)
26
else
27
return prim2cons(SVector(0.125, 0.0, 0.1), equations)
28
end
29
end
30
initial_condition = initial_condition_modified_sod
31
32
# Using the weak form volume integral gives a wrong solution at the rarefaction wave!
33
#volume_integral = VolumeIntegralWeakForm()
34
35
# The entropy-conservative flux-differencing volume integral recovers the rarefaction wave correctly!
36
volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)
37
38
solver = DGSEM(polydeg = 3, surface_flux = flux_hllc,
39
volume_integral = volume_integral)
40
41
coordinates_min = 0.0
42
coordinates_max = 1.0
43
44
mesh = TreeMesh(coordinates_min, coordinates_max,
45
initial_refinement_level = 6,
46
n_cells_max = 30_000,
47
periodicity = false)
48
49
# Dirichlet boundary condition is only valid for considered time interval.
50
# If the rarefaction wave reaches the boundary, this condition is no longer valid!
51
boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition),
52
x_pos = boundary_condition_do_nothing)
53
54
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
55
boundary_conditions = boundary_conditions)
56
57
tspan = (0.0, 0.2)
58
ode = semidiscretize(semi, tspan)
59
60
summary_callback = SummaryCallback()
61
alive_callback = AliveCallback(alive_interval = 100)
62
63
analysis_interval = 1000
64
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
65
66
callbacks = CallbackSet(summary_callback,
67
analysis_callback,
68
alive_callback)
69
70
###############################################################################
71
# run the simulation
72
73
# For weak form run: Need to enforce positivity explicitly! Not required for flux differencing volume integral.
74
#=
75
stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),
76
variables = (Trixi.density, pressure))
77
78
ode_alg = SSPRK43(stage_limiter! = stage_limiter!)
79
=#
80
# Flux-differencing volume integral does not require positivity preservation for this test case.
81
ode_alg = SSPRK43()
82
83
sol = solve(ode, ode_alg;
84
dt = 4e-4, adaptive = true,
85
ode_default_options()..., callback = callbacks);
86
87