Solution (source code)

= Solution

Take a dense lower layer and write $g'=g(\rho_1-\rho_0)/\rho_0>0$. In the <Boussinesq approximation> the fractional density difference is small; use the reference density in inertia and retain the difference in <buoyancy>. The one-layer model additionally treats the ambient as much deeper, with negligible distributed horizontal inertia away from the head. The <shallow water> approximation requires depth small relative to the horizontal variation length, small vertical accelerations, nearly <hydrostatic pressure>, and an approximately depth-uniform horizontal <velocity>. Neglect mixing, <viscosity>, bed friction and rotation. A slowly varying rectangular channel allows cross-sectional averages without large lateral separation.

A slice of width $b(x)$ contains volume $bh\,dx$. Its outgoing <volume flux> is $bhu$, so <volume conservation> gives $(bh)_t+(bhu)_x=0$. The integrated hydrostatic excess <pressure> is $\rho_0g'bh^2/2$. Pressure on the sloping side walls contributes $\rho_0g'h^2b'/2$ to the longitudinal force. The conservative <momentum> equation is therefore
$$
(bhu)_t+\left[bhu^2+\frac12g'bh^2\right]_x=\frac12g'h^2b'.
$$
Use the volume equation to simplify it. The resulting <shallow water equations> are
$$
\boxed{h_t+uh_x+hu_x=-hu\frac{b'}b,\qquad u_t+uu_x+g'h_x=0.}
$$
Omitting the wall force would incorrectly introduce a width term into the material acceleration equation.

For $(h,u)$ the principal matrix is $\begin{pmatrix}u&h\\g'&u\end{pmatrix}$. Its <eigenvalues> are $u\pm c$, where $c=\sqrt{g'h}$. For $h>0$ they are real and distinct, so the system is strictly <hyperbolic>. It degenerates at a dry front. From the volume equation, $c_t+uc_x+(c/2)u_x=-(cu/2)b'/b$. Combine this with the momentum equation to obtain the <variable-width shallow-water characteristics>:
$$
\boxed{\frac{dx_\pm}{dt}=u\pm c,\qquad
\frac{d}{dt}(u\pm2c)\bigg|_{x_\pm(t)}=\mp cu\frac{b'}b.}
$$
In a constant-width channel $u\pm2c$ are <Riemann invariants> along the corresponding <characteristic curves>; with varying width they satisfy compatibility equations with a source term.