You are on page 1of 16

A Shallow Water Numerical Model v0.

1
Guillaume Riflet

November 20, 2006

Abstract
The shallow water equations are introduced and discretized in a
standard C-grid with a leapfrog, FCTS numerical scheme combined
with simple Asselin-Roberts filtering as presented in Kantha and Clayson [5].
Plain Dirichelet conditions were implemented at the boundaries. Sim-
ple testing were performed with a gaussian level elevation and with
wind forcing. The geostrophic equilibrium of a gaussian level elevation
is presented and an analytical solution of the steady-state is obtained.
Results show that Dirichelet boundary conditions reflect all surface
waves back inside the domain and multiple linear superpositions oc-
cur, eventually leading to instability.

1 The mathematical model


The shallow waters equations (SWE) describe the 2D barotropic mo-
tion of water masses. The system and its forcings are illustrated in
figure 1. The SWE are widely described throughout the literature; for
example, they are given in Kantha-Clayson[5] as
 ³ 2 ´
∂2u ∂η τw τb


∂Hu
+ ∂Huu
+ ∂Huv
− f Hv = νH ∂ u
+ − gH ∂x + ρu0 − ρu0
 ∂t ∂x ∂y ∂x
³ 2
2 ∂y 2
´
∂2v τvw τvb

∂Hv
∂t + ∂Hvu
∂x + ∂Hvv
∂y + f Hu = νH ∂ v
∂x 2 + ∂y 2 − gH ∂η
∂y + ρ0 − ρ0

 ∂η ∂Hu ∂Hv
∂t + ∂x + ∂y = 0
(1)
where H is the depth from the surface level to the bottom, u and v are
the zonal and meridional components of velocity, x, y and z are the
zonal, meridional and depth positions respectively. f = 1.01 × 10−4
rad/s is the Coriolis frequency at 42o of latitude, ν is the horizontal
turbulent viscosity, g = 9.8 m2 /s is the gravity acceleration, ρ0 = 1033
kg/m3 is the water mean density and eta is the water level relative to
rest. τub is the bottom stress zonal component, τuw is the wind stress
zonal component. The bottomstress [8] is given by
q
τub = ρ0 CD ub u2b + vb2
where CD is the bottom drag coefficient and ub and vb are the zonal
and meridional velocity bottom velocity components. The bottom drag

1
Figure 1: System depicted by the mathematical model. eta is the water
level from rest, d is the depth from rest, H is the depth from the water
level. The wind acts on the surface by forcing it, as well as the bed drags
on the bottom. The water column still has momentum in u, v, zonal and
meridional coordinates.

2
coefficient [6] is given by
µ ¶2
zD + z0
CD = k/ ln
z0

where zD is the distance to the bottom , z0 = 0.002 m is a typical


roughness length [6] and the Von Karman constant [6] is set to

k = 0.4.

The wind stress [8] is given by


q
τuw = ρa Ca u10 u210 + v10
2

where ρa = 1.25 kg/m3 is the air density, Ca is an air drag coefficient


whose values can be found in Pietrzak2002[8] and u10 and v10 is the
air speed at 10m height.

2 The mesh
The mesh in use is an Arakawa Staggered regular C-grid[1] as illus-
trated in figure 2. It is composed of three distinct cells: the U-cell,
the V-cell, and the T-cell, where are, respectively, at the centres the u,
the v and the η variables of equations 1. The C-grid provides better
precision for the non-linear advecting terms than the B-grid, however
it looses precision when evaluating the Coriolis term in equations 1 [1].
For simplicity, the mesh will have constant step-sizes ∆x and ∆y. The
indices i and j as shown in figure 2 and in figure 3 correspond to the
i-th zonal cell and the j-th meridional cell counted in the South-North
direction and in the West-East direction respectively.

3 The numerical scheme


For simplicity in the notation, the indices i and j will be omitted by
default. The spatial finite difference numerical scheme is the FCTS
described in [5]:
For the zonal momentum (U-Cell), the first-order spatial discretization
writes:
³ ´
∂Hu
= − (Huu)i+1/2 − (Huu) /∆x
∂t
³ ´ i−1/2
− (Huv)j+1/2 − (Huv)j−1/2 /∆y + f (Hv)
¡ ¢
+νH (ui−1 − 2ui + u¢i+1 ) /∆x2 + (uj−1 p
2
− 2uj + uj+1 ) /∆yp
¡
−gH ηi+1/2 − ηi−1/2 /∆x + ρρa0 Ca u10 u210 + v10 2 −C u
D b u2b + vb2
≡ Ru

3
Figure 2: Arakawa C staggered grid patterns. From left to right: the T-cell,
where η and H are evaluated at the centres, and u and v are evaluated at the
eastern, western faces and southern, northern faces respectively. The U-cell
where u is evaluated at the centre, η and H are evaluated at the eastern,
western faces, and v is evaluated at the corners. The V-cell, where v is eval-
uated at the centre, η and H are evaluated at the southern, northern faces,
and u is evaluated at the corners. The distance between two consecutive
cells of the same type is ∆x, zonally, and ∆y, meridionally. The indices i
and j correspond to the i-th zonal cell and the j-th meridional cell counted
in the South-North direction and in the West-East direction respectively.

4
where the halved indices correspond to fluxes at the U-cells’ faces.
Thus, the FCTS fluxes write:
2
(Huu)i+1/2 = H (ui+1 + u) /22 ,
2
(Huu)i−1/2 = Hi−1 (u + ui−1 ) /22 ,
(Huv)j+1/2 = 0.25 (Hi−1 + Hi + Hi−1,j+1 + Hi,j+1 ) (uj+1 + u) (vi−1,j+1 + vi,j+1 ) /22 ,
(Huv)j−1/2 = 0.25 (Hi−1 + Hi + Hi−1,j−1 + Hi,j−1 ) (u + uj−1 ) (vi−1 + v) /22 ,
f (Hv) = f (H + Hi−1 ) /2 (vi−1 + vi + vi−1,j+1 + vi,j+1 ) /4,
νH (ui−1 − 2ui + ui+1 ) = ν (H + Hi−1 ) /2 (ui−1 − 2ui + ui+1 ) ,
νH ¡(uj−1 − 2uj + uj+1
¢ ) = ν (H + Hi−1 ) /2 (uj−1 − 2uj + uj+1 ) ,
gH ηi+1/2 − ηi−1/2 = qg (H + Hi−1 ) (η − ηi−1 ) ,
p 2
CD u u + v = CD u u2 + (vi−1 + v + vi−1,j+1 + vi,j+1 ) .
2 2

p
Notice how the (Huu)j+1/2 , (Huv)j−1/2 , f (Hv) and CD u u2 + v 2
terms, loose significant precision over the other terms, due to their 4
terms averaging.
Hence, rewriting the full momentum FCTS spatial scheme we get:
³ ´
∂Hu 2 2
∂t = − H (ui+1 + u) /22 − Hi−1 (u + ui−1 ) /22 /∆x
µ ¶
0.25 (Hi−1 + Hi + Hi−1,j+1 + Hi,j+1 ) (uj+1 + u) (vi−1,j+1 + vi,j+1 ) /22
− /∆y
−0.25 (Hi−1 + Hi + Hi−1,j−1 + Hi,j−1 ) (u + uj−1 ) (vi−1 + v) /22
+f (H + Hi−1 ) /2 (vi−1 + vi + vi−1,j+1 + vi,j+1 ) /4
+ν (H + Hi−1 ) /2 (ui−1 − 2ui + ui+1 ) /∆x2
+ν (H + Hi−1 ) /2 (uj−1 − 2uj + uj+1 ) /∆y 2
−g (H + Hi−1 ) (η − ηi−1 ) /∆xq
p 2
+ ρρa0 Ca u10 u210 + v10
2 − C u u2 + (v
D i−1 + v + vi−1,j+1 + vi,j+1 )
≡ Ru
For the meridional spatial momentum scheme in the V-Cells, clever
symmetry one-to-one relations with zonal momentum scheme in the
U-cells are used:
• switch ∆x and ∆y: ∆x ↔ ∆y,
• switch i and j: i ↔ j,
• switch u and v: u ↔ v,
• switch signal of the Coriolis term: (+ ↔ −).
The finite-difference first-order numerical scheme for the waterlevel (T-
Cell) writes out:
³ ´ ³ ´
∂η
∂t = − (Hu)i+1/2 − (Hu)i−1/2 /∆x − (Hv)j+1/2 − (Hv)j−1/2 /∆y
≡ Rη,
and each face’s FCTS flux term writes down:
(Hu)i+1/2 = (H + Hi+1 ) /2 ui+1 ,
(Hu)i−1/2 = (Hi−1 + H) /2 u,
(Hv)j+1/2 = (H + Hj+1 ) /2 vj+1 ,
(Hv)j−1/2 = (Hj−1 + H) /2 v.

5
Thus, the full waterlevel FCTS numerical scheme is:
∂η
∂t = − ((H + Hi+1 ) /2 ui+1 − (Hi−1 + H) /2 u) /∆x
− ((H + Hj+1 ) /2 vj+1 − (Hj−1 + H) /2 v) /∆y
≡ Rη.

The time scheme used is the Leapfrog as described in [5]:

η l+1 = η l−1 + 2∆t {Rη} ,


H l+1 =¡η l+1 +¡ d,l−1 ¢ ¢ ¡ ¢
l+1 l−1 l−1 l+1
u = ¡u ¡ H + Hi−1 ¢ + 4∆t {Ru}¢ /¡ H l+1 + Hi−1 ¢ ,
l−1 l+1
v l+1 = v l−1 H l−1 + Hi−1 + 4∆t {Rv} / H l+1 + Hi−1 .
Notice how the leapfrog time scheme obliges two initial conditions at t0
and at t1 . Hence, in order to avoid mode decoupling, a Robert-Asselin
filter for u, v, η at each integration time-step is used, as suggested
by [5]:
¡ ¢
P l = P l + γ P l−1 − 2P l + P l+1 ,
where γ is a parameter set to 0.1 [5]. The Robert-Asselin provides
a good coupling between the two initial conditions, at the expense of
some loss in precision.
The stability criterion is the CFL criterion described in Kantha-Clayson
2000 [5]: µ µ ¶¶
p 1 1
max 2∆t gH + 2 < 1.0
x2 y
Note that for stability reasons, in the momentum equations, the friction
terms are evaluated at time l − 1.

4 Boundary conditions
Currently, only Dirichelet conditions are implemented at the bound-
aries. Indeed, if the T-cells domain has M × N nodes then the U-
cells have M × (N + 1) nodes and the V-cells have (M + 1) × N
nodes. η is calculated within {2, ..., (M − 1)} × {2, ..., (N − 1)}
and u and v are calculated within {2, ..., (M − 1)} × {2, ..., N } and
{2, ..., M } × {2, ..., (N − 1)}.

5 Results
5.1 Gaussian level initial condition
In a 20×20 grid points basin with 10 m depth, 10 m spatial increments
and 0.1 s time increments, we dropped a gaussian water level elevation
of 0.2 meters according to
1 (x−x0 )2 +(y−y0 )2
η(x, y) = √ e− 2σ 2 (2)
σ 2π

6
Figure 3: Detailed mesh emphasizing the boundaries. Composite of T, U and
V-cells, the mesh illustrates the zone of integration of each type of cell: the
blue rectangle contains the T-cells computed nodes, the thin green rectangle
contains the U-cells computed nodes, the thin red rectangle contains the V-
cells computed nodes. The thick green and red rectangles, however, delimit
respectively the faces of the U and V-cells computed nodes.

7
Figure 4: Water level elevation test-run. 2D model initial condition with
Dirichelet conditions at the boundary.

with (x0 , y0 ) = (Lx /2, Ly /2) and σ = 1. The Dirichelet conditions set
the velocity and water level to null at the boundary, thus forcing the
surface waves to bounce back from the boundary, as seen in the figures
[4-12].

5.1.1 Energy
The kinetic energy, KE is given by [4]
Z Z
1 ¡ ¢
KE = ρgH u2 + v 2 dA;
2
the perturbation potential energy, P P E is given [4]
Z Z
1
PPE = ρgη 2 dA;
2
and the total energy is the sum T E = KE + P P E. Figure 13 shows
the evolution of the total, kinetic and potential energy of the gaussian
elevation test case in inviscid, fritctionless conditions. The energy de-
cay is strictly due to numerical diffusion, as the Dirichelet boundary
conditions allow no energy flux through. The FCTS scheme is widely
reknown for its high numerical diffusivity.

5.2 Wind forcing


For a fetch of 10 kilometers with 5 m/s near-surface winds in a 2
m depth basin, the typical maximum water level elevation reached is
15 − 20 cm high [3]. In (14) is shown a fully developed surface velocity
field field when such a forcing is applied along the y coordinate.

8
Figure 5: Water level elevation test-run for t = 0.7 s.

Figure 6: Water level elevation test-run for t = 1.4 s.

9
Figure 7: Water level elevation test-run for t = 2.1 s.

Figure 8: Water level elevation test-run for t = 2.8 s.

10
Figure 9: Water level elevation test-run for t = 3.5 s.

Figure 10: Water level elevation test-run for t = 4.2 s.

11
Figure 11: Water level elevation test-run for t = 4.9 s.

Figure 12: Water level elevation test-run for t = 40 s.

12
6 Energy vs time
x 10
3
Total energy
Kinetic energy
Potential energy

2.5

2
E(J)

1.5

0.5

0
0 10 20 30 40 50 60
t(s)

Figure 13: Gaussian elevation test-case energy time evolution in inviscid,


frictionless conditions during a t = 60 s run.

Figure 14: Fully developed surface velocities and water level when forcing
with a 5 m/s wind along the y-coordinate.

13
5.3 Geostrophic equilibrium
The steady-state solution where the Coriolis force balances the pressure
gradient in a constant depth domain writes
(
∂η
f Hvg = gH ∂x
(3)
f Hug = −gH ∂η ∂y

Now, is this solution compatible with the continuity equation? If we


apply the first derivatives along y and x to the first and second differ-
ential equation respectively, and assuming that the Coriolis frequency
is constant throughout the domain, we get:
 ³ ∂η ´
( ∂Hv  ∂Hvg g ∂H ∂η ∂ ∂x
g ∂η  = + H
∂y = f ∂x
g
∂y f ∂y ∂x
µ ∂y ¶ .
∂Hug g ∂η ⇒ ∂ ∂η
∂x = − f ∂y
 ∂Hu g ∂H ∂η
 ∂x = − f ∂x ∂y + H ∂x
g ∂y

Since H(x, y, t) = d + η(x, y, t) then, using the continuity equation,

∂Hug ∂Hvg ∂η
+ =0 ⇒ =0
∂x ∂y ∂t
is obtained. This shows that the constraints yield a well-posed prob-
lem and a steady state solution. The system is then said to be in
geostrophic equilibrium and ug and vg are the geostrophic velocity
components. Plus, (3) yield analytical solution. Indeed, if we use the
gaussian elevation for η given in (2) then
(
∂η x−x0
∂x = − σ 2 η
∂η y−y0
∂y = − σ 2 η

Now (3) is solvable yielding


(  2 2
g x−x0
vg = f σ 2 η  v = g x−x0 √1 e− (x−x0 ) 2σ+(y−y
2
0)
g f σ 2 σ 2π
⇔ . (4)
ug = − fg y−y
2 2
σ2 η  u = − g y−y0 √1 e− (x−x0 ) 2σ+(y−y
0 0)
2
g f σ 2 σ 2π

The geostrophic velocity field given in (4) may apply to T-cells. Thus
simple linear interpolation is required when applying it to U-cells and
V-cells. In (15) is plotted the analytical solution of the steady state
problem.

6 Conclusions
Here lies the shallow-water equations numerical model as described in
Kantha-Clayson [5] with the same numerical scheme. It currently only
has the Dirichelet boundary conditions. This means that all surface
waves bounce back at the boundary and and give rise to a cascade of
multiple linear superpositions leading to a path of unavoidable numer-
ical instability. The commonly used solution is to radiate the level at

14
Figure 15: Initial condition in geostrophic balance at t = 0 s.

the boundaries [7], [9]. Further work involves implementing Neumann


conditions at the boundaries, variable coriolis force, variable bottom
topography, cyclic boundary conditions besides radiating level and mo-
mentum. Ultimately, using flow relaxation schemes at the boundaries
is considered [9], [8], as well as developing the recent works of Blayo [2].

References
[1] Arakawa, A. Computational design for long-term numerical in-
tegration of the equations of fluid motion: two-dimensional incom-
pressible flow. Part i. 119–143.
[2] Blayo, E., and Debreu, L. Revisiting open boundary conditions
from the point of view of characteristic variables. Ocean Modelling
9 (2005), 231–252.
[3] Brito, D. Titulo do trabalho do david. work in progress, 2006.
[4] Gill, A. E. Atmosphere-ocean dynamics. International Geo-
physics Series (1982), xv, 662 p–xv, 662 p.
[5] Kantha, L. H., and Clayson, C. A. Numerical models of
oceans and oceanic processes. 1168–1168.
[6] Leitão, P. C. Integração de escalas e de processos na mod-
elação do ambiente marinho. Environmental Engineering Depart-
ment (2002).
[7] Orlanski, I. A simple boundary condition for unbounded hyper-
bolic flows. Journal of Computational Physics 21 (1976), 251–269.
[8] Pietrzak, J., Jakobson, J. B., Burchard, H., Ja-
cob Vested, H., and Petersen, O. A three-dimensional hy-

15
drostatic model for coastal and ocean modelling using a generalised
topography following co-ordinate system. 173–205.
[9] Shchepetkin, A. F. A method for computing horizontal pressure-
gradient force in an oceanic model with a nonaligned vertical co-
ordinate. 3090–3090.

16