# Variable Depth Shallow Water Wave Equation

We consider here the problem of waves reflected by a region of variable depth in a finite region or in an otherwise uniform depth region assuming the equations of Shallow Depth (assuming the problem is linear). We consider slightly more general equations of motion so that the same method could be used for a variable density string.

## Equations

We begin with the shallow depth equation

$\rho(x)\partial_t^2 \zeta = \partial_x \left(h(x) \partial_x \zeta \right).$

subject to the initial conditions

$\zeta_{t=0} = \zeta_0(x)\,\,\,{\rm and}\,\,\, \partial_t\zeta_{t=0} = \partial_t\zeta_0(x)$

where $\zeta$ is the displacement, $\rho$ is the string density and $h(x)$ is the variable depth (note that we are unifying the variable density string and the wave equation in variable depth because the mathematical treatment is identical).

## Waves in a finite basin

We consider the problem of waves in a finite basin $-L\lt x\lt L$. At the edge of the basin the boundary conditions are

$\left.\partial_x \zeta\right|_{x=-L} = \left.\partial_x \zeta\right|_{x=L} =0$
.

We solve the equations by expanding in the modes for the basin which satisfy

$\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n \rho(x) \zeta_n ,$

normalised so that

$\int_{-L}^L \rho\zeta_n \zeta_m = \delta_{mn}.$

The solution is then given by

$\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_{-L}^L \rho(x)\zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )$
$+ \sum_{n=1} ^{\infty} \left(\int_{-L}^L \rho(x)\zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}$

where we have assumed that $\lambda_0 = 0$.

### Calculation of $\zeta_n$

We can calculate the eigenfunctions $\zeta_n$ by an expansion in the modes for the case of uniform depth. We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of

$J[\zeta] = \int_{-L}^L \frac{1}{2}\left\{ h(x)\left(\partial_x \zeta\right)^2 - \lambda \rho(x) \zeta^2 \right\}$

subject to the boundary conditions that the normal derivative vanishes (where $\lambda$ is the eigenvalue).

We expand the displacement in the eigenfunctions for constant depth $h=1$

$\zeta = \sum_{n=0}^{N} a_n \psi_n(x)$

where

$\psi_n = \frac{1}{\sqrt{L}} \cos( n \pi (\frac{1}{2L}x + \frac{1}{2})),\,\,n\ne 1$

$\psi_0 = \frac{1}{\sqrt{2L}},\,$

and substitute this expansion into the variational equation we obtain

$J[\vec{a}] = \int_{-L}^L \frac{1}{2}\left\{ h(x)\left( \sum_{n=0}^{N} a_n \partial_x \psi_n(x)\right)^2 - \lambda \rho(x) \left(\sum_{n=0}^{N} a_n \psi_n(x)\right)^2 \right\}$
$\frac{dJ}{da_m} = \int_{-L}^L \frac{1}{2}\left\{ h(x)2\partial_x \psi_m(x)\left( \sum_{n=0}^{N} a_n \partial_x \psi_n(x)\right) - \lambda \rho(x)2\psi_m(x)\left(\sum_{n=0}^{N} a_n \psi_n(x)\right) \right\} = 0$
$\int_{-L}^L \left\{ h(x)\partial_x \psi_m(x)\left( \sum_{n=0}^{N} a_n \partial_x \psi_n(x)\right) \right\} = \int_{-L}^L \left\{ \lambda \rho(x)\psi_m(x)\left(\sum_{n=0}^{N} a_n \psi_n(x)\right) \right\}$
$\sum_{n=0}^{N} a_n \int_{-L}^L \left\{ h(x)\partial_x \psi_n(x)\partial_x \psi_m(x)\right\} = \lambda \sum_{n=0}^{N} a_n \int_{-L}^L \left\{ \rho(x)\psi_n(x)\psi_m(x) \right\}$

this equation can be rewritten using matrices as

$\mathbf{K} \vec{a} = \lambda\mathbf{M} \vec{a}$

where the elements of the matrices K and M are

$\mathbf{K}_{mn} = \int_{-L}^L \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}$

and

$\mathbf{M}_{mn} = \int_{-L}^L \left\{\rho(x)\psi_n(x)\psi_m(x)\right\}$

### Matlab Code

Code to calculate the solution in a finite basin can be found here finite_basin_variable_h_and_rho.m

## Waves in an infinite basin

We assume that the density $\rho$ and the depth $h$ are constant and equal to one outside the region $-L\lt x\lt L$. We can therefore write the wave as

$u(x,t) = e^{-i k x} + R e^{i k x},\,\,x\lt -L$
$u(x,t) = Te^{-i k x},\,\,x\lt -L$

for waves incident from the right. To solve we use a solution to the problem on the interval $-L\lt x\lt L$ subject to arbitrary boundary conditions and match.

### Solution in Finite Interval of Variable Properties

Taking a separable solution gives the eigenvalue problem

$\partial_x \left( h(x) \partial_x\zeta \right) = -\omega^{2}\rho(x)\zeta \quad (1)$

Given boundary conditions $\zeta \mid_{-L} = a$ and $\zeta \mid_L = b$ we can take $\zeta = \zeta_p + u$ With $\zeta_p = \frac{(b-a)}{2L}x + \frac{b+a}{2}$ satisfying the boundary conditions and $u$ satisfying $u |_{-L} = u |_L = 0$

Substituting this form into (1) gives

$\partial_x(h(x)\partial_x \zeta_p)+\partial_x(h(x)\partial_xu) = -\omega^{2}\left(\zeta_p+u\right)$

Or, on rearranging

$\partial_x(h(x)\partial_xu)+\omega^{2}u = -\partial_x(h(x)\partial_x \zeta_p)-\omega^{2}\zeta_p = f(x)\quad (2)$

so
$f(x) = -\partial_x(h(x)\partial_x \zeta_p)-\omega^{2}\zeta_p = -\frac{(b-a)}{2L}\partial_xh(x) - \omega^2 \left(\frac{(b-a)}{2L}x + \frac{b+a}{2}\right)$

Now consider the homogenous Sturm-Liouville problem for u

$\partial_x(h(x)\partial_xu)+\lambda u = 0\quad u|_0=u|_1=0 \quad (3)$

By Sturm-Liouville theory this has an infinite set of eigenvalues $\lambda_k$ with corresponding eigenfunctions $u_k$. Also since $u_k|_0=u_k|_1=0\quad \forall k$ Each $u_k$ can be expanded as a fourier series in terms of sine functions.

$u_k = \sum_{n=1}^{\infty} a_{n,k} \psi_n$

where

$\psi_n = \sin\left(\frac{n\pi}{2}\left(\frac{x}{L} + 1\right)\right)$

Transforming (3) into the equivalent variational problem gives

$J[u] = \int_{-L}^{L}\,hu'^{2}-\lambda \rho u^{2} \, dx \quad (4)$

Substituting the fourier expansion for $u_k$ into (4):

$J = \int_{-L}^{L}\,h\left(\sum_{n=1}^{\infty} a_{n} \psi_n'\right)^{2}-\lambda \rho \left(\sum_{n=1}^{\infty} a_{n} \psi_n\right)^{2} \, dx \quad$

Since $u_k$ minimises J, we require $\frac{\partial J}{\partial a_{n}}=0 \quad \forall n$

$\frac{\partial J}{\partial a_{m}}=\int_{-L}^{L}\left\{2h\psi_m'\sum_{n=1}^{\infty} a_{n}\psi_n'-2\lambda\rho \psi_m \sum_{n=1}^{\infty} a_{n} \psi_n\right\}dx=0$

$\implies \int_{-L}^{L}2h\psi_m'\sum_{n=1}^{\infty} a_{n}\psi_n'dx= \int_{-L}^{L}2\lambda\rho \psi_m \sum_{n=1}^{\infty} a_{n} \psi_ndx$

$\implies \sum_{n=1}^{\infty}a_{n}\int_{-L}^{L}h\psi_m'\psi_n'dx= \lambda\sum_{n=1}^{\infty}a_{n}\int_{-L}^{L}\rho \psi_m \psi_ndx$

By defining a vector $\textbf{a} = \left(a_{n}\right)$ and matrices $K_{(n,m)} = \int_{-L}^{L}h(x)\psi_m'(x)\psi_n'(x)dx$ and $M_{(n,m)} = \int_{-L}^{L}\rho(x)\psi_m(x)\psi_n(x)dx$ we have the linear system $K\textbf{a} = \lambda M\textbf{a}$ which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors $\textbf{a}$ representing coefficient vectors of the fourier expansions of eigenfunctions.

If we now construct $u(x,\omega) = \sum_{k=1}^{\infty} b_k u_k$ and substitute this into equation (2) we get

$\sum_{k=1}^{\infty} (\partial_x(h(x)\partial_x u_k) + \omega^{2}\rho u_k)b_k = f(x)$
$\implies \sum_{k=1}^{\infty} (-\lambda_k\rho u_k + \omega^{2}\rho u_k)b_k = f(x)$
$\implies \sum_{k=1}^{\infty} (\omega^{2}-\lambda_k) b_k \rho u_k = f(x) \quad (5)$

And defining the RHS of equation (5) as $f(x)$, a known function, we can retrieve the coefficients $b_k$ by integrating against $u_k$

$b_k = \frac{\int_{-L}^{L}\,f u_k\,dx}{(\omega^{2}-\lambda_k) \int_{-L}^{L}\, \rho u_{k}^{2}\,dx}$

The coefficients $c_n$ of the fourier expansion of u are just $\sum_{k=1}^{\infty}a_{n,k}b_{k}$ with $a_{n.k}$ being the $n$th coefficient of the $k$th eigenfunction of the Sturm-Liouville problem.

So

$\zeta(x,\omega)=\frac{(b-a)}{2L}x + \frac{b+a}{2}+\sum_{n=1}^{\infty}c_{n} \sin\left(\frac{n\pi}{2}\left(\frac{x}{L} + 1\right)\right), \quad (6)$

with $\zeta |_{-L}=a \quad \zeta |_{L}=b$ and, given $a$ and $b$ explicitly differentiating $\zeta$ gives $\partial_x \zeta |_{-L}$ and $\partial_x \zeta |_L$.

### Matching at $\pm L$

We choose a basis of the solution space for any particular $\omega$ to be $\{\zeta_1,\,\zeta_2\}$, where $\zeta_1$ is the solution to the BVP(a=1,b=0) and $\zeta_1$ is the solution to the BVP(a=0,b=1). The functions $\zeta_1$ and $\zeta_2$ can be calculated for any $\omega$ from (6).

The aim here is to construct a matrix S such that, given $a$ and $b$

$S \begin{pmatrix} \zeta |_{-L} \\ \zeta |_L \end{pmatrix}=\begin{pmatrix} \partial_x \zeta |_{-L} \\ \partial_x \zeta |_L \end{pmatrix}$

Taking $a=1,\,b=0$ to give $\zeta_1$ shows that the first column of S must be $\begin{pmatrix} \partial_x \zeta_1 |_{-L} \\ \partial_x \zeta_1 |_L \end{pmatrix}$ and likewise taking $a=0,\,b=1$ to give $\zeta_2$ shows the second column must be $\begin{pmatrix} \partial_x \zeta_2 |_{-L} \\ \partial_x \zeta_2 |_L \end{pmatrix}$. So S is given by

$\begin{pmatrix} \partial_x \zeta_1 |_{-L} \, \partial_x \zeta_2 |_{-L} \\ \partial_x \zeta_1 |_L \, \partial_x \zeta_2 |_L \end{pmatrix}$

Now for the area of constant depth on the left hand side there is a potential of the form $e^{i\omega x}$ which, creates reflected and transmitted potentials from the variable depth area of the form $Re^{-i\omega x}$ and $Te^{i\omega x}$ respectively where the magnitudes of $R$ and $T$ are unknown. We can calculate that the boundary conditions for $\zeta$ must be

$\zeta |_{-L} = e^{-i\omega L}+Re^{i\omega L}, \quad \zeta |_L = Te^{i\omega L}, \quad \partial_x \zeta |_{-L} = i\omega e^{-i\omega L}-i\omega Re^{i\omega L}, \quad \partial_x \zeta |_L = i\omega Te^{i\omega L}$

$\begin{pmatrix} i\omega e^{-i\omega L}-i\omega Re^{i\omega L} \\ i\omega Te^{i\omega L} \end{pmatrix} = S\begin{pmatrix} e^{-i\omega L}+Re^{i\omega L} \\ Te^{i\omega L} \end{pmatrix}$

Knowing S these boundary conditions can be solved for $R$ and $T$, which in turn gives actual numerical boundary conditions to the original problem($a_+=e^{-i\omega L}+Re^{i\omega L}$ and $b_+=Te^{i\omega L}$). Taking a linear combination of the solutions already calculated ($a_+\zeta_1(x,\omega) + b_+\zeta_2(x,\omega)$) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a generalised eigenfunction potential for the whole real axis which we denote as $\zeta_+(x,\omega)$.

Independent generalised eigenfunctons (which we denote as $\zeta_-(x,\omega)$)can be found by considering the potential $e^{-i\omega x}$ on the right hand region of constant depth. The corresponding reflected and transmitted potentials from the variable depth area are of the form $Re^{i\omega x}$ and $Te^{-i\omega x}$ respectively. Again knowing S we can solve for R and T and hence find the numerical boundary conditions ($a_-=Te^{i\omega L}$ and $b_-=e^{-i\omega L}+Re^{i\omega L}$).

We come out with:

$\zeta_+(x,\omega) = \left\{ \begin{matrix} {e^{i\omega x}+Re^{-i\omega x}, \quad \mbox{ for } x\lt -L} \\ {a_+\zeta_1(x,\omega) + b_+\zeta_2(x,\omega),\quad \mbox{ for } -L\leq x \leq L} \\ {Te^{i\omega x}, \quad \mbox{ for } x\gt L} \end{matrix} \right.$

where R and T are found by solving:

$\begin{pmatrix} (S_{11} + i\omega)e^{i\omega L} & S_{12}e^{i\omega L} \\ S_{21}e^{i\omega L} & (S_{22}-i\omega)e^{i\omega L} \end{pmatrix} \begin{pmatrix}R\\T\end{pmatrix} = \begin{pmatrix} (i\omega - S_{11}) e^{-i\omega L} \\ -S_{21}e^{-i\omega L} \end{pmatrix}$

and $a_+=e^{-i\omega L}+Re^{i\omega L}$ and $b_+=Te^{i\omega L}$

Note that the values of R and T for $\zeta_-$ are different from those for $\zeta_+$ (although they are related through some identities). For $\zeta_-$ we have:

$\zeta_-(x,\omega) = \left\{ \begin{matrix} {Te^{-i\omega x}, \quad \mbox{ for } x\lt -L} \\ {a_-\zeta_1(x,\omega) + b_-\zeta_2(x,\omega),\quad \mbox{ for } -L\leq x \leq L} \\ {e^{-i\omega x}+Re^{i\omega x}, \quad \mbox{ for } x\gt L} \end{matrix} \right.$

where R and T are found by solving:

$\begin{pmatrix} S_{12}e^{i\omega L} & (S_{11}+i\omega)e^{i\omega L} \\ (S_{22}-i\omega)e^{i\omega L} & S_{21}e^{i\omega L}\end{pmatrix} \begin{pmatrix}R\\T\end{pmatrix} = \begin{pmatrix} S_{12}e^{-i\omega L} \\ -(i\omega + S_{21})e^{-i\omega L} \end{pmatrix}$

Note a_+, b_+, a_- and b_- are found frm their corresponding R and T values.

### Generalised Eigenfunction Expansion

Now we have the generalised eigenfunctions $\zeta_+(x,\omega)$ and $\zeta_-(x,\omega)$, which have the orthogonality relationships:

$\int_{-\infty}^{\infty}\zeta_+(x,\omega)\zeta_-(x,\omega')\mathrm{d}x= 0 \qquad (7)$
$\int_{-\infty}^{\infty}\zeta_+(x,\omega)\zeta_+(x,\omega')\mathrm{d}x= 2 \pi \delta(\omega-\omega') \qquad (8)$
$\int_{-\infty}^{\infty}\zeta_-(x,\omega)\zeta_-(x,\omega')\mathrm{d}x= 2 \pi \delta(\omega-\omega') \qquad (9)$

For any particular $\omega$ the general solution to the differential equation can be written as:

$\zeta(x,t,\omega) = \cos(\omega t)\left(c_1(\omega)\zeta_+(x,\omega)+d_1(\omega)\zeta_-(x,\omega)\right) + \frac{\sin(\omega t)}{\omega}\left(c_2(\omega)\zeta_+(x,\omega)+d_2(\omega)\zeta_-(x,\omega)\right)$

The general solution to the PDE is therefore:

$\zeta(x,t) = \int_{0}^{\infty} \zeta(x,t,\omega) \mathrm{d} \omega$
$\implies \zeta(x,t) = \int_{0}^{\infty} \left\{ \cos(\omega t)\left(c_1(\omega)\zeta_+(x,\omega)+d_1(\omega)\zeta_-(x,\omega)\right) + \frac{\sin(\omega t)}{\omega}\left(c_2(\omega)\zeta_+(x,\omega)+d_2(\omega)\zeta_-(x,\omega)\right) \right\} \mathrm{d} \omega \qquad (10)$

Giving the initial conditions:

$F(x) = \zeta(x,0) = \int_{0}^{\infty} \left\{ c_1(\omega)\zeta_+(x,\omega)+d_1(\omega)\zeta_-(x,\omega) \right\} \mathrm{d} \omega$
$G(x) = \partial_t \zeta(x,0) = \int_{0}^{\infty} \left\{ c_2(\omega)\zeta_+(x,\omega)+d_2(\omega)\zeta_-(x,\omega) \right\} \mathrm{d} \omega$

Using identities (7),(8) and (9) we can show:

$c_1(\omega) = \frac{1}{2\pi}\langle F(x), \zeta_+(x,\omega) \rangle$
$d_1(\omega) = \frac{1}{2\pi}\langle F(x), \zeta_-(x,\omega) \rangle$
$c_2(\omega) = \frac{1}{2\pi}\langle G(x), \zeta_+(x,\omega) \rangle$
$d_2(\omega) = \frac{1}{2\pi}\langle G(x), \zeta_-(x,\omega) \rangle$

Which we can use in combination with (10) to solve the IVP.

### Matlab Code

Code to calculate the solution in a infinite basin can be found here infinite_basin_variable_h_and_rho.m