Ideal magnetohydrodynamic energy conservation (source code)

= Ideal magnetohydrodynamic energy conservation
{title2=$\partial_t\mathcal E+\nabla\cdot\mathbf F=0$}

For a fixed <Newtonian gravitational potential>, total <energy density> is $\mathcal E=\rho(u^2/2+\Phi)+p/(\gamma-1)+B^2/(2\mu_0)$. Its flux combines advected kinetic/potential energy, <specific enthalpy> and the <Poynting vector>. Dotting the <ideal magnetohydrodynamic momentum equation> with <velocity>, adding the adiabatic <internal energy> equation and the <magnetic energy> equation cancels the magnetic work. The <pressure> terms combine into $-\nabla\cdot(p\mathbf u)$, proving the conservation law. A time-dependent imposed potential instead contributes $\rho\partial_t\Phi$.