Skip to main content
Sandbox Physics

Compressible flow · hyperbolic conservation laws

Shock Tube & Riemann Problem

Advance the one-dimensional Euler equations with an HLL finite-volume method while overlaying every cell against the exact Riemann solution. Tube density, the x–t wave diagram, four profiles, and conservation drift update together.

Interactive modelShock Tube & Riemann Problem
Normalized time0.00000.0000
Star pressure pp_*0.3031p00.3031\,p_0
Shock speed SsS_s1.752a01.752\,a_0
Density error L1L_10.00%0.00\,\%
Mass drift0.00%0.00\,\%
Energy drift0.00%0.00\,\%
Wave familyrarefaction · contact · shock

Physics tutorial

Shock tubes: how one initial jump becomes three wave families

BackgroundA shock tube begins with two uniform gases separated by a diaphragm. Removing it creates one discontinuity that self-organizes into a shock, contact discontinuity, and rarefaction fan, carrying compression, material identity, and smooth expansion in different ways.

Why it mattersGary Sod established these initial data as a canonical compressible-flow test in 1978. This Lab also uses the two-wave flux idea introduced by Harten, Lax, and van Leer in 1983, so every numerical cell can be compared with the exact self-similar Riemann solution.

Start with the essentials

Focus question
Why does one diaphragm jump generate a shock, a contact discontinuity, and a rarefaction fan at once?
One-sentence intuition
The one-dimensional Euler system has three characteristic speeds: uau-a, uu, and u+au+a. Different conserved quantities reorganize along those families, so one jump does not remain one wave.

Core mathematical model

One-dimensional Euler conservation law

t[ρρuE]+x[ρuρu2+pu(E+p)]=0\frac{\partial}{\partial t}\begin{bmatrix}\rho\\ \rho u\\ E\end{bmatrix}+\frac{\partial}{\partial x}\begin{bmatrix}\rho u\\ \rho u^2+p\\ u(E+p)\end{bmatrix}=0

The rows conserve mass, momentum, and total energy; the finite-volume method exchanges only interface fluxes.

Ideal-gas closure and sound speed

p=(γ1) ⁣(E12ρu2),a=γpρp=(\gamma-1)\!\left(E-\frac12\rho u^2\right),\qquad a=\sqrt{\frac{\gamma p}{\rho}}

The heat-capacity ratio closes the relation among energy, pressure, and sound speed and shifts all three wave families.

HLL two-wave numerical flux

FHLL=SRFLSLFR+SLSR(URUL)SRSLF_{\mathrm{HLL}}=\frac{S_R F_L-S_L F_R+S_LS_R(U_R-U_L)}{S_R-S_L}

When the bounding signal speeds straddle zero, HLL uses one averaged intermediate state. It remains conservative but spreads contacts more than the exact solution.

CFL-stable time step

ΔtCCFLΔxmaxi(ui+ai)\Delta t\le C_{\mathrm{CFL}}\frac{\Delta x}{\max_i\left(|u_i|+a_i\right)}

Each step keeps the fastest characteristic from crossing a full cell; refining the grid therefore shortens the time step automatically.

Common difficulties

A contact is not a weaker shock

Typical misconceptionDensity still jumps, so the middle line must be another small shock.

Better mental modelPressure and velocity remain continuous across a contact. Only density and material identity jump, and the contact travels with the star-region flow.

A smeared shock is not a physically thick shock

Typical misconceptionBecause the plotted front spans several cells, an inviscid physical shock has the same thickness.

Better mental modelThe Euler shock is a discontinuity. Its visible width here mainly records first-order HLL diffusion and finite resolution.

Run the experiment

  1. 01

    Reproduce the Sod benchmark

    Choose Sod benchmark, keep the exact overlay visible, and run until the solver pauses automatically.

    What to observe: A smooth rarefaction moves left, the contact advects through the middle, and the right shock leads; the numerical curves track the dashed exact solution.
  2. 02

    Increase the pressure ratio

    Switch to Strong shock, then increase the cell count while watching density error.

    What to observe: Shock speed and star pressure rise sharply. More cells narrow the front and reduce global error while forcing smaller time steps.
  3. 03

    Change the wave topology

    Compare Colliding flows with Symmetric expansion while the x–t diagram is visible.

    What to observe: Collision turns both outer waves into shocks, while separation creates two rarefaction fans; wave type follows star pressure relative to each initial pressure.