an accumulation of energy at small scales [@graham_highly_2007].

Energy balance {#energybalancesec}
--------------

An exact energy balance can be easily derived for the SW model. The equation is useful to verify conservation in pseudospectral codes. By taking the dot product of Eq.  and $h \mathbf{u}$, setting ${\bf F} = 0$, and using Eq. , we obtain $$\begin{aligned}
    \frac{\partial }{\partial t} \left( \frac{h u^2}{2}  + g \frac{h^2}{2}
    \right) = &- {\boldsymbol{\nabla}}\cdot \left( \frac{h u^2}{2} \mathbf{u}  + g h^2 \mathbf{u}
    \right) \\
    &+ \nu \mathbf{u} \cdot [ {\boldsymbol{\nabla}}\cdot ( h {\boldsymbol{\nabla}}\mathbf{u}) ] .
\end{aligned}$$ Integrating in $x$ and $y$ over an area $A$ and taking periodic boundary conditions yields $$\label{balance}
    \frac{\mathrm{d} E}{\mathrm{d} t} = - 2 \nu Z,$$ where $$E = \frac{1}{A} \iint  \left( \frac{h u^2}{2} + g \frac{h^2}{2} \right)
    \mathrm{d} x \mathrm{d} y$$ is the mean total energy, and $$Z = \frac{1}{A} \iint  \frac{h \lvert {\boldsymbol{\nabla}}\mathbf{u}
    \rvert^2}{2}  \mathrm{d} x \mathrm{d} y$$ is a mean pseudo-enstrophy, such that $-2 \nu Z$ is the mean energy dissipation rate. As $h$ is always positive, the energy dissipation is always negative. The total energy is conserved when $\nu = 0$.

Now we can define $$U = \frac{1}{A} \iint \label{ec_cin} 
    \frac{h u^2}{2}\mathrm{d} x \mathrm{d} y$$ as the 