The 3D version of this nozzle solves the steady isentropic + Rankine-Hugoniot equations algebraically and jumps straight to the answer. This 2D version is a genuinely different computation: it time-marches the unsteady quasi-1D Euler equations on a finite-volume grid until the flow relaxes to a steady state on its own — the shock is not placed by a root-finder, it emerges from real conservation.
∂(ρA)/∂t + ∂(ρuA)/∂x = 0
∂(ρuA)/∂t + ∂((ρu²+p)A)/∂x = p·dA/dx
∂(EA)/∂t + ∂(u(E+p)A)/∂x = 0
flux at each cell face: Rusanov (local Lax-Friedrichs) —
F* = ½(F_L+F_R) − ½·max(|u|+a)·(Q_R−Q_L)
- Mass, momentum and energy are updated explicitly every timestep from the fluxes crossing each cell's faces — the same finite-volume idea used in real CFD codes, just first-order and 1D for speed.
- The scheme captures the shock itself — no separate shock-fitting logic. Numerical diffusion smears it over a few cells, which is exactly why real CFD codes report shock strength via a resolution-independent invariant (stagnation-pressure loss) rather than reading two adjacent cells.
- Because the field only relaxes (never resets) when you move a slider, dragging back pressure or area ratio here drives a real transient: watch the shock actually slide to its new position over several seconds instead of teleporting.
- Inlet: fixed reservoir p₀,ρ₀ with the Mach number extrapolated from the interior (standard subsonic-inflow characteristic treatment). Outlet: static pressure fixed to your back-pressure target when the exit is subsonic, fully extrapolated when it runs supersonic.
Real-world relevance: this is literally how rocket-nozzle and supersonic-inlet CFD works — an explicit time-marching solver relaxing a variable-area duct to steady state, the same approach (MacCormack/Godunov-family schemes on the quasi-1D Euler equations) used since the 1970s to design real nozzles before wind-tunnel testing.