Solution (source code)

= Solution

For a steady inviscid <barotropic fluid> in a conservative <gravitational potential>, define $h(\rho)=\int dp/\rho$. Dotting the <Euler equation> with the <velocity> gives
$$
\mathbf u\cdot\nabla\left(\frac{u^2}{2}+h+\phi\right)=0.
$$
The <Bernoulli function> is therefore constant along a <streamline>. It balances <kinetic energy>, <pressure> work or <enthalpy>, and gravitational <potential energy> per unit <mass>. Different <streamlines> can have different constants; for an <irrotational flow>, the identity $\nabla H=\mathbf u\times(\nabla\times\mathbf u)$ makes the constant common throughout a connected region.

For an incompressible fluid, $h=p/\rho$ up to a constant, giving $u^2/2+p/\rho+\phi=C$. For a constant-entropy perfect-gas <streamline>, $h=\gamma p/[(\gamma-1)\rho]$. Together with <mass> conservation, this explains conversion of <enthalpy> into <kinetic energy> in a nozzle and the need to include <gravity> in an escaping wind. Viscous losses, heating and <entropy> production require their corresponding <energy> balance. Across an adiabatic shock the total <stagnation enthalpy> can still be conserved, but the upstream isentropic pressure-density law cannot simply be continued through the <entropy> jump.