Showing the energy is conserved in the shallow water equations The shallow water equations are:
\begin{align}
\frac{Dv_x}{Dt}-fv_y&=-g\frac{\partial h}{\partial x}\\
\frac{Dv_y}{Dt}-fv_x&=-g\frac{\partial h}{\partial y}\\
\frac{D(h-h_b)}{Dt}&=-(h-h_b)(\frac{\partial v_x}{\partial x}+\frac{\partial v_y}{\partial y})
\end{align}
Where $\mathbf{v}=(v_x(x,y,t),v_y(x,y,t))$, $f$ and $h_b$ are functions of $x$ and $y$ and $h$ is a function of $x,y$ and $t$.
I want to show that the energy is a conserved quantity, I know energy takes the form
$$E=\frac{1}{2}(h-h_b)(v_x^2+v_y^2)+\frac{1}{2}gh^2$$
I've seen that
$$\frac{\partial E}{\partial t}+\nabla\cdot F=0$$
With $F$ being the energy flux.
My question is how do i show this?
I've tried taking the material derivative of $E$ and working through and that gets me that
$$\mathbf{v}\nabla\cdot E=\nabla\cdot F$$
I can't find a way to have the divergence of something on the RHS.
The only other thing i can think to do is guess the form of $F$ which since it is a energy flux it should be similar to $\mathbf{v}E$.
 A: Note that with $q = v_x$ or $q = v_y$ we have
$$\tag{1}q \frac{Dq}{Dt} = q \frac{\partial q}{\partial t} + qv_x \frac{\partial q}{\partial x} + qv_y \frac{\partial q}{\partial y}= \frac{\partial }{\partial t}\left(\frac{1}{2}q^2   \right) + v_x \frac{\partial }{\partial x}\left(\frac{1}{2}q^2\right)+  v_y \frac{\partial }{\partial y}\left(\frac{1}{2}q^2\right)$$
Multiplying each of the first two shallow water equations by $v_x$ and $v_y$, respectively, and using (1) we get
$$\tag{2}\frac{\partial }{\partial t}\left(\frac{1}{2}v_x^2   \right) = fv_xv_y+ v_x \frac{\partial }{\partial x}\left(\frac{1}{2}v_x^2\right)+  v_y \frac{\partial }{\partial y}\left(\frac{1}{2}v_x^2\right)- g v_x \frac{\partial h}{\partial x},$$
$$\tag{3}\frac{\partial }{\partial t}\left(\frac{1}{2}v_y^2   \right) = fv_xv_y+ v_x \frac{\partial }{\partial x}\left(\frac{1}{2}v_y^2\right)+  v_y \frac{\partial }{\partial y}\left(\frac{1}{2}v_y^2\right)- gv_y \frac{\partial h}{\partial y}$$
Define $K = \frac{1}{2}(v_x^2 + v_y^2)$ and add (2) and (3) to obtain
$$\tag{4}\frac{\partial K}{\partial t} = 2fv_xv_y + v_x\frac{\partial K}{\partial  x}+  v_y \frac{\partial K}{\partial y}- g v_x \frac{\partial h}{\partial x}- g v_y \frac{\partial h}{\partial y}$$
The third shallow water equation can be rewritten as
$$\tag{5} \frac{\partial h}{\partial t} = \frac{\partial}{\partial t}(h-h_b) = -v_x \frac{\partial }{\partial x}(h-h_b) - v_y \frac{\partial }{\partial y}(h-h_b) -(h-h_b) \frac{\partial v_x}{\partial x}- (h-h_b) \frac{\partial v_y}{\partial y}\\=-\frac{\partial }{\partial x}[(h-h_b) v_x] - \frac{\partial }{\partial y}[(h-h_b) v_y]$$
SInce $E = (h-h_b)K + \frac{1}{2}gh^2$, we have
$$\tag{6} \frac{\partial E}{\partial t} = (h-h_b)\frac{\partial K}{\partial t} + K \frac{\partial }{\partial t}(h- h_b)+gh \frac{\partial h}{\partial t}$$
Multiplying (4) by $(h-b)$ and (5) by $K$, yields
$$\tag{7}(h-h_b)\frac{\partial K}{\partial t} = 2fv_xv_y(h-h_b)+  (h-h_b)v_x\frac{\partial K}{\partial  x}+  (h-h_b)v_y \frac{\partial K}{\partial y} - g(h-h_b) v_x \frac{\partial h}{\partial x}- g v_y(h-h_b) \frac{\partial h}{\partial y},$$
$$\tag{8} K\frac{\partial }{\partial t}(h- h_b)= -K\frac{\partial }{\partial x}[(h-h_b) v_x] - K\frac{\partial }{\partial y}[(h-h_b) v_y]$$
Adding (7) and (8), we get
$$\tag{9}(h-h_b)\frac{\partial K}{\partial t} + K \frac{\partial }{\partial t}(h- h_b) = 2fv_xv_y(h- h_b) - \frac{\partial}{\partial x} [(h-h_b)Kv_x] -  \frac{\partial}{\partial y} [(h-h_b)Kv_x] - g(h-h_b) v_x \frac{\partial h}{\partial x}- g v_y(h-h_b) \frac{\partial h}{\partial y},$$
Using (5) we get
$$\tag{10}gh\frac{\partial h}{\partial t} = -gh\frac{\partial }{\partial x}[(h-h_b) v_x] - gh\frac{\partial }{\partial y}[(h-h_b) v_y] \\= -\frac{\partial }{\partial x}[gh(h-h_b) v_x] - \frac{\partial }{\partial y}[gh(h-h_b) v_y] + g(h-h_b)v_x\frac{\partial h }{\partial x}+ g(h-h_b)v_y\frac{\partial h }{\partial y}  $$
Substituting with (9) and (10) back into (6) yields
$$\frac{\partial E}{\partial t} = 2fv_xv_y(h- h_b) - \frac{\partial}{\partial x} [(h-h_b)Kv_x] -  \frac{\partial}{\partial y} [(h-h_b)Kv_x] - g(h-h_b) v_x \frac{\partial h}{\partial x}- g v_y(h-h_b) \frac{\partial h}{\partial y}-\frac{\partial }{\partial x}[gh(h-h_b) v_x] - \frac{\partial }{\partial y}[gh(h-h_b) v_y] + g(h-h_b)v_x\frac{\partial h }{\partial x}+ g(h-h_b)v_y\frac{\partial h }{\partial y}$$
The fourth, fifth , eighth and ninth terms on the RHS cancel, and we obtain
$$\frac{\partial E}{\partial t} + \nabla \cdot \mathbf{F} = fv_xv_y(h-h_b),$$
where
$$\nabla \cdot \mathbf{F} = \nabla \cdot [(h-h_b)(K +gh) \mathbf{v}]$$
