Solution (source code)

= Solution

Let $e=\rho u^2/2+p/(\gamma-1)$ be the total gas <energy density>, with $\gamma>1$. The one-dimensional continuity and momentum equations are
$$
\partial_t\rho+\partial_z(\rho u)=0,\qquad
\rho(\partial_tu+u\partial_zu)=-\partial_zp.
$$
Using continuity to put the momentum equation into conservative form gives
$$
\partial_t(\rho u)+\partial_z(\rho u^2+p)=0.
$$
The internal <energy density> $e_{\rm int}=p/(\gamma-1)$ satisfies
$$
\partial_te_{\rm int}+\partial_z(ue_{\rm int})=-p\partial_zu,
$$
by the adiabatic pressure equation. Multiplying the momentum equation by $u$ and using continuity gives
$$
\partial_t\left(\frac{\rho u^2}{2}\right)+\partial_z\left(\frac{\rho u^3}{2}\right)=-u\partial_zp.
$$
Adding these equations combines the pressure work into $-\partial_z(pu)$. The <conservation law> variables and <conservation law fluxes> are therefore
$$
\boxed{\mathbf U=\begin{pmatrix}\rho\\\rho u\\\rho u^2/2+p/(\gamma-1)\end{pmatrix},\qquad
\mathbf F=\begin{pmatrix}\rho u\\\rho u^2+p\\u\bigl(\rho u^2/2+\gamma p/(\gamma-1)\bigr)\end{pmatrix}.}
$$
The three rows express conservation of mass, momentum and total energy. Their integral <conservation laws> remain meaningful across a <shock wave>, where the differential pressure and velocity equations cannot be applied pointwise.