Solution (source code)

= Solution

The magnetic energy is
$$
E_B=\int_V\frac{B^2}{2\mu_0}\,dV.
$$
Using the ideal-MHD induction equation and integrating the identity $\mathbf B\mathbin\cdot\nabla\times(\mathbf u\times\mathbf B)$ by parts gives
$$
\frac{dE_B}{dt}
=\frac1{\mu_0}\int_S[(\mathbf u\times\mathbf B)\times\mathbf B]
\mathbin\cdot d\mathbf S
-\int_V\mathbf u\mathbin\cdot(\mathbf j\times\mathbf B)\,dV.
$$
The volume term vanishes for a <force-free magnetic field>, leaving
$$
\boxed{\frac{dE_B}{dt}
=\frac1{\mu_0}\int_S[(\mathbf u\times\mathbf B)\times\mathbf B]
\mathbin\cdot d\mathbf S}.
$$