A Burgers shock
Fast fluid runs into slow fluid and piles up into a shock, the simplest model of a traffic jam or a breaking wave. The shock must move at exactly the speed conservation dictates.

The cell values on 200 cells from \(t=0\) to \(0.6\), with the exact step dashed.
The problem
The inviscid Burgers equation with a jump from 1 to 0:
\[u_t + \left(\tfrac12 u^2\right)_x = 0,\qquad u(x,0)=\begin{cases}1 & x<0.2\\ 0 & x>0.2\end{cases}\]
The Rankine–Hugoniot condition moves the shock at \((1+0)/2\), so it sits at \(x_0+t/2\).
The jNO code
The flux in conservation form, (ui * ui / 2).d(x, ...), is what moves the shock at the right speed. The march is
explicit SSPRK3, and cfl= chooses the substeps of every step from the spectral radius of the operator:
prob = jno.fvm(
[
ui.t + (ui * ui / 2).d(x, scheme=jno.fv(limiter="minmod")),
u(xl) - 1.0,
u(xi) - (1.0 - jno.np.tanh(1e4 * (xi - 0.2))) / 2,
]
)
traj = np.asarray(prob.solve(time=jno.solve.erk("ssprk3", cfl=0.5)))
Result
The shock is at \(x_0+t/2\) to within one cell, and with the TVD limiter the solution stays within \([0,1]\).
Full script
The whole script, as it runs in the tests
"""An inviscid Burgers shock, marched explicitly with ``jno.solve.erk``.
u_t + (u^2/2)_x = 0, u = 1 for x < 0.2, 0 beyond: a shock moving at (1 + 0)/2.
Conservation form ``(ui*ui/2).d(x, ...)`` puts the shock where the Rankine-Hugoniot condition says;
SSPRK3 with a minmod limiter keeps it sharp and monotone, and ``cfl=`` chooses the substeps from the
spectral radius of the first-order operator at every step.
"""
import jax
jax.config.update("jax_enable_x64", True)
import numpy as np
import jno
run = jno.setup(__file__)
T = 0.6
d = jno.Path(0.0, 0.0).line_to(1.0, 0.0).curve(size=0.005).domain(time=(0.0, T, 101))
x, t = d.variable("interior", split=True)[:2]
xl = d.variable("left", split=True)[0]
xi = d.variable("initial", split=True)[0]
u = d.unknown()
ui = u.bind(x=x, t=t)
prob = jno.fvm(
[
ui.t + (ui * ui / 2).d(x, scheme=jno.fv(limiter="minmod")),
u(xl) - 1.0,
u(xi) - (1.0 - jno.np.tanh(1e4 * (xi - 0.2))) / 2,
]
)
traj = np.asarray(prob.solve(time=jno.solve.erk("ssprk3", cfl=0.5)))
c = prob.centroids[:, 0]
front = c[np.argmin(np.abs(traj[-1] - 0.5))]
print(f"shock at x = {front:.3f} (Rankine-Hugoniot: {0.2 + 0.5 * T:.3f}); range [{traj.min():.3f}, {traj.max():.3f}]")
assert abs(front - (0.2 + 0.5 * T)) < 0.01