A shock, a contact and a rarefaction
A tube of ideal gas (γ = 1.4) is split at x = 0.5. The left half holds (ρ, u, p) = (1, 0, 1), the right half (0.125, 0, 0.1). When the diaphragm goes, a rarefaction runs left and a contact and a shock run right. At t = 0.2 the shock sits at x = 0.8504.
The exact solution comes from OneSimulation's own exact Euler sampler. Every run is evaluated at the 400 cell centres. The page reports the L1 errors of density, velocity and pressure, the shock position error and the wall time.
The model, declared once
tube = Line(start=(0.0, 0.0, 0.0), end=(1.0, 0.0, 0.0))
gas = CompressibleEuler(
domain=tube.line, equation_of_state=IdealGasEquationOfState(gamma=gamma)
)
sod = Problem(
name="Sod shock tube",
geometry=tube,
physics=(gas,),
boundary_conditions=(
TransmissiveBoundary(boundary=tube.boundaries.all, physics=gas),
),
initial_conditions=(
InitialValue(gas.density, lambda x: np.where(x < 0.5, 1.0, 0.125)),
InitialValue(gas.momentum, 0.0),
InitialValue(gas.total_energy, lambda x: np.where(x < 0.5, 2.5, 0.25)),
),
)
None of this names a method. The method is the numerics argument of Simulation. Three of the 452 choices:
numerics = Numerics(
spatial=FiniteVolume(convection=HLLC(), reconstruction=MUSCL(), limiter=SuperbeeLimiter()),
time_integrator=TimeMethod("ssprk2"),
)
numerics = Numerics(
spatial=FiniteElement(element=DiscontinuousLagrange(2), convection=HLLC(),
limiter=DGPolynomialLimiter(slope_limiter=MinmodLimiter(),
invariant_domain=EulerInvariantDomain())),
linear_solver=SparseDirect(),
time_integrator=TimeMethod("ssprk2"),
)
numerics = Numerics(
spatial=FiniteVolume(convection=HLLC(), reconstruction=MUSCL(), limiter=MinmodLimiter()),
time_integrator=BDF(order=2),
nonlinear_solver=Newton(linear_solver=GMRES(preconditioner=ILU()),
jacobian="colored_finite_difference"),
)
result = Simulation(problem=sod, mesh=mesh, numerics=numerics).run(
start_time=0.0, end_time=0.2, time_step=2e-3)
Every spatial scheme with every Riemann solver
45 spatial schemes. Finite volumes with first-order, MUSCL and QUICK (seven limiters and the unlimited slope), ENO, WENO3, WENO5, WENO-Z and central WENO reconstructions. Finite elements (FEM): discontinuous Galerkin of degree 0 to 4, limited, unlimited or with a jump penalty; continuous Galerkin of degree 1 to 3 with graph viscosity, continuous interior penalty, volume interior penalty, SUPG, GLS or no stabilization. Finite differences: central, fourth-order and summation-by-parts stencils, with and without JST dissipation. Each is crossed with the Rusanov, HLL, HLLE and HLLC solvers and advanced with SSP-RK2 at the stable step.
| Spatial scheme | Riemann solver | L1 ρ | L1 u | L1 p | Shock | Time |
|---|---|---|---|---|---|---|
| FEM CG P2 + continuous interior penalty | HLLE | 8.66 × 10−4 | 1.69 × 10−3 | 6.97 × 10−4 | -0.45 | 22 s |
| FEM CG P2 + continuous interior penalty | HLL | 8.66 × 10−4 | 1.69 × 10−3 | 6.97 × 10−4 | -0.45 | 25 s |
| FEM CG P2 + continuous interior penalty | HLLC | 8.66 × 10−4 | 1.69 × 10−3 | 6.97 × 10−4 | -0.45 | 23 s |
| FEM CG P2 + continuous interior penalty | Rusanov | 8.66 × 10−4 | 1.69 × 10−3 | 6.97 × 10−4 | -0.45 | 23 s |
| FVM WENO5-Z | HLLC | 1.25 × 10−3 | 2.64 × 10−3 | 9.94 × 10−4 | +0.39 | 7 s |
| FVM WENO5-Z | HLLE | 1.26 × 10−3 | 2.61 × 10−3 | 9.67 × 10−4 | +0.38 | 7 s |
| FVM WENO5-Z | HLL | 1.26 × 10−3 | 2.61 × 10−3 | 9.67 × 10−4 | +0.38 | 7 s |
| FVM MUSCL + superbee | HLLC | 1.35 × 10−3 | 2.73 × 10−3 | 1.05 × 10−3 | +0.45 | 2 s |
| FVM WENO5 | HLLC | 1.40 × 10−3 | 2.74 × 10−3 | 1.06 × 10−3 | +0.42 | 5 s |
| FVM MUSCL + superbee | HLLE | 1.42 × 10−3 | 2.46 × 10−3 | 9.18 × 10−4 | +0.45 | 1 s |
| FVM MUSCL + superbee | HLL | 1.42 × 10−3 | 2.46 × 10−3 | 9.18 × 10−4 | +0.45 | 1 s |
| FVM WENO5 | HLLE | 1.43 × 10−3 | 2.75 × 10−3 | 1.05 × 10−3 | +0.42 | 5 s |
What the profiles look like

Every time integrator
29 time integrators. 30 explicit runs at the stable step and 31 implicit runs at Δt = 2 × 10−3, a CFL number of about 1.4 that no explicit method could take. All with HLLC fluxes.
See matrix 2 in the carousel at the top.
Every nonlinear and linear solver
Backward Euler on MUSCL-minmod-HLLC, Δt = 2 × 10−3. 30 solver pairs converged to the same discrete solution. Their density errors differ by a relative 2.8 × 10−7 at most. Wall time ranges from 6 s (quasi-Newton, sparse LU) to 17 s (quasi-Newton, GMRES + ILU).
See matrix 3 in the carousel at the top.
The same gas as particles
Smoothed-particle hydrodynamics solves the same problem without a mesh: 800 particles in a periodic box, 400 of them in [0, 1], the same resolution as the 400 cells. Every time integrator of the grid matrix is passed to the particle solver unchanged, with three choices of Monaghan's artificial viscosity. 85 of 87 combinations ran as declared; the most accurate is theta = 0.75 with Monaghan α = 0.5, β = 1, mean density error 4.67 × 10−3.
See matrix 4 in the carousel at the top.
400 against 200 cells
| Combination | 200 cells | 400 cells | Ratio | Shock, 200 | Shock, 400 |
|---|---|---|---|---|---|
| FVM first order, Rusanov | 1.83 × 10−2 | 1.20 × 10−2 | 1.53 | +4.19 | +2.20 |
| FVM first order, HLLC | 1.33 × 10−2 | 8.44 × 10−3 | 1.58 | +4.72 | +2.45 |
| FVM MUSCL + minmod, HLLC | 4.56 × 10−3 | 2.55 × 10−3 | 1.79 | +1.73 | +0.94 |
| FVM MUSCL + superbee, HLLC | 2.52 × 10−3 | 1.35 × 10−3 | 1.87 | +0.51 | +0.45 |
| FVM WENO5, HLLC | 2.63 × 10−3 | 1.40 × 10−3 | 1.88 | +0.78 | +0.42 |
| FEM DG P2 + minmod + invariant domain, HLLC | 4.54 × 10−3 | 2.54 × 10−3 | 1.79 | +1.66 | +0.90 |
| FEM CG P1 + graph viscosity, HLLC | 1.84 × 10−2 | 1.20 × 10−2 | 1.53 | +4.01 | +2.12 |
| FDM WENO5 flux splitting, Lax-Friedrichs splitting | 3.46 × 10−3 | 1.80 × 10−3 | 1.92 | +1.05 | +0.57 |
Schemes that must fail at a shock, and their stabilized counterparts
A linear scheme of higher than first order oscillates at a discontinuity (Godunov's theorem). On Sod's problem that drives density or pressure negative, and OneSimulation reports it instead of clipping the state. Each such scheme is shown hatched in the matrices, with the result of its stabilized counterpart behind the hatching: exactly one ingredient is added, or, for time integrators that are not A-stable and for the fixed-point iteration, the step is reduced to one they are stable for. Of the 373 declared runs, 297 ran directly and 76 are shown stabilized.
| Declared scheme | Why it fails | Stabilized counterpart | Runs |
|---|---|---|---|
| Adams-Moulton 4 | Euler state has non-positive pressure | Adams-Moulton 4 at Δt = 5.0e-04 | 1 |
| BDF4 (Gear) | Euler state has non-positive pressure | BDF4 (Gear) at Δt = 5.0e-04 | 1 |
| BDF5 (Gear) | Euler state has non-positive pressure | BDF5 (Gear) at Δt = 5.0e-04 | 1 |
| BDF6 (Gear) | Euler state has non-positive pressure | BDF6 (Gear) at Δt = 5.0e-04 | 2 |
| FDM central, 2nd order | Euler state has non-positive pressure | central differences + Jameson-Schmidt-Turkel artificial dissipation | 4 |
| FDM polynomial, 4th order | Euler state has non-positive pressure | 4th-order differences + Jameson-Schmidt-Turkel artificial dissipation | 4 |
| FDM summation by parts, order 2 | Euler state has non-positive pressure | SBP order 2 with SAT boundary flux + Jameson-Schmidt-Turkel artificial dissipation | 4 |
| FDM summation by parts, order 4 | Euler state has non-positive pressure | SBP order 4 with SAT boundary flux + Jameson-Schmidt-Turkel artificial dissipation | 4 |
| FEM CG P1 + GLS | Euler state has non-positive pressure | CG P1 + invariant-domain graph viscosity instead of GLS | 4 |
| FEM CG P1 + SUPG | Euler state has non-positive pressure | CG P1 + invariant-domain graph viscosity instead of SUPG | 4 |
| FEM CG P1 Galerkin | Euler state has non-positive pressure | FEM CG P1 + invariant-domain graph viscosity | 4 |
| FEM CG P2 Galerkin | Euler state has non-positive pressure | FEM CG P2 + invariant-domain graph viscosity (positive Bernstein basis) | 4 |
| FEM CG P3 Galerkin | Euler state has non-positive pressure | FEM CG P3 + invariant-domain graph viscosity (positive Bernstein basis) | 4 |
| FEM DG P1 + jump penalty | Euler state has non-positive pressure | DG P1 + Euler invariant-domain scaling instead of the jump penalty | 4 |
| FEM DG P1, unlimited | Euler state has non-positive density | FEM DG P1 + Euler invariant-domain scaling (no slope limiter) | 3 |
| FEM DG P1, unlimited | Euler state has non-positive pressure | FEM DG P1 + Euler invariant-domain scaling (no slope limiter) | 1 |
| FEM DG P2, unlimited | Euler state has non-positive pressure | FEM DG P2 + Euler invariant-domain scaling (no slope limiter) | 4 |
| FEM DG P3, unlimited | Euler state has non-positive pressure | FEM DG P3 + Euler invariant-domain scaling (no slope limiter) | 4 |
| FEM DG P4, unlimited | Euler state has non-positive pressure | FEM DG P4 + Euler invariant-domain scaling (no slope limiter) | 4 |
| FVM MUSCL, unlimited | Euler state has non-positive density | MUSCL unlimited + invariant-domain positivity limiter at the faces | 4 |
| FVM QUICK | Euler state has non-positive pressure | QUICK + invariant-domain positivity limiter at the faces | 4 |
| fixed point | Euler state has non-positive pressure | fixed point at Δt = 2.5e-04 | 1 |
| fixed point + Aitken | partitioned coupling did not converge within maximum_iterations | fixed point + Aitken at Δt = 2.5e-04 | 1 |
| leapfrog | Euler state has non-positive pressure | leapfrog + Robert-Asselin-Williams filter (ν = 0.2, α = 0.53; first order), safety factor 0.15 | 3 |
| leapfrog | unfiltered leapfrog has no stable region on the negative real axis, so the damping of SPH artificial viscosity grows its computational mode for every step size; select leapfrog_raw, or switch the artificial viscosity off | leapfrog + Robert-Asselin-Williams filter (ν = 0.2, α = 0.53) | 2 |
Methods that do not apply to this problem
A few methods in OneSimulation are not in the matrix because the Euler system lacks what they are built for.
| Method | Built for |
|---|---|
| Conjugate gradients, algebraic multigrid | Symmetric positive definite operators |
| Runge-Kutta-Chebyshev and -Legendre super-steps | Parabolic (diffusive) operators |
| Staggered Verlet | Second-order systems (structural dynamics, particles with forces) |
| IMEX splitting | Problems with a stiff and a non-stiff part |
| Local time stepping | Steady states |
| Hydrostatic reconstruction | Shallow water over topography |
| Scharfetter-Gummel flux | Drift-diffusion (semiconductors, plasmas) |
| Scalar upwind and central fluxes | Scalar transport; for the Euler system the library asks for a Riemann solver instead |
Reproduce the run
The notebook declares the model once and runs the whole matrix in one loop. All wall times on this page were measured with the compiled OneSimulation runtime (machine code, the package customers install) on an Apple Silicon laptop; the 452 runs took 43 minutes in total. Lower cells for a quick look. Activate the Python environment described in the STEP tutorial first.
The earlier Poisson comparison on a 3D cube shows the same idea for an elliptic problem.



