Path: blob/main/examples/tree_1d_dgsem/elixir_euler_modified_sod.jl
5586 views
using OrdinaryDiffEqSSPRK1using Trixi23equations = CompressibleEulerEquations1D(1.4)45"""6initial_condition_modified_sod(x, t, equations::CompressibleEulerEquations1D)78Modified Sod shock tube problem, presented in Section 6.4 of Toro's book.9This problem consists of a left sonic rarefaction wave and is useful for testing whether numerical solutions10violate the entropy condition.11An entropy-satisfying solution should produce a smooth(!) rarefaction wave.1213## References14- Toro (2009).15Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction, 3rd Edition.16[DOI: 10.1007/b79761](https://doi.org/10.1007/b79761)1718- Lin, Chan (2014)19High order entropy stable discontinuous Galerkin spectral element methods through subcell limiting20[DOI: 10.1016/j.jcp.2023.112677](https://doi.org/10.1016/j.jcp.2023.112677)21"""22function initial_condition_modified_sod(x, t, ::CompressibleEulerEquations1D)23if x[1] < 0.324return prim2cons(SVector(1, 0.75, 1), equations)25else26return prim2cons(SVector(0.125, 0.0, 0.1), equations)27end28end29initial_condition = initial_condition_modified_sod3031# Using the weak form volume integral gives a wrong solution at the rarefaction wave!32#volume_integral = VolumeIntegralWeakForm()3334# The entropy-conservative flux-differencing volume integral recovers the rarefaction wave correctly!35volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha)3637solver = DGSEM(polydeg = 3, surface_flux = flux_hllc,38volume_integral = volume_integral)3940coordinates_min = 0.041coordinates_max = 1.04243mesh = TreeMesh(coordinates_min, coordinates_max,44initial_refinement_level = 6,45n_cells_max = 30_000,46periodicity = false)4748# Dirichlet boundary condition is only valid for considered time interval.49# If the rarefaction wave reaches the boundary, this condition is no longer valid!50boundary_conditions = (; x_neg = BoundaryConditionDirichlet(initial_condition),51x_pos = boundary_condition_do_nothing)5253semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,54boundary_conditions = boundary_conditions)5556tspan = (0.0, 0.2)57ode = semidiscretize(semi, tspan)5859summary_callback = SummaryCallback()60alive_callback = AliveCallback(alive_interval = 100)6162analysis_interval = 100063analysis_callback = AnalysisCallback(semi, interval = analysis_interval)6465callbacks = CallbackSet(summary_callback,66analysis_callback,67alive_callback)6869###############################################################################70# run the simulation7172# For weak form run: Need to enforce positivity explicitly! Not required for flux differencing volume integral.73#=74stage_limiter! = PositivityPreservingLimiterZhangShu(thresholds = (5.0e-6, 5.0e-6),75variables = (Trixi.density, pressure))7677ode_alg = SSPRK43(stage_limiter! = stage_limiter!)78=#79# Flux-differencing volume integral does not require positivity preservation for this test case.80ode_alg = SSPRK43()8182sol = solve(ode, ode_alg;83dt = 4e-4, adaptive = true,84ode_default_options()..., callback = callbacks);858687