Solution (source code)

= Solution

For one-dimensional <compressible flow>, define the total energy density
$$
E=\frac{p}{\gamma-1}+\frac12\rho u_x^2.
$$
The conservative mass, momentum, and energy equations are
$$
\boxed{\partial_t\rho+\partial_x(\rho u_x)=0},
$$
$$
\boxed{\partial_t(\rho u_x)+\partial_x(\rho u_x^2+p)=0},
$$
$$
\boxed{\partial_tE+\partial_x[(E+p)u_x]=0}.
$$
A monatomic nonrelativistic perfect gas has $\gamma=5/3$, an ultrarelativistic gas or radiation-dominated fluid has $\gamma=4/3$, and a rotationally active diatomic gas has $\gamma=7/5$.