Numerical Accuracy in Solutions of The Shallow-Water Equations
Numerical Accuracy in Solutions of The Shallow-Water Equations
in Solutions of the
Shallow-Water Equations
Master Thesis
Peterjan Broomans
Delft, February 2003
A few decades ago computational fluid dynamics (CFD) was in its infancy. Limitations on
memory and computation speed compelled CFD programmers to use single precision values,
which was adequate at that time. Through time the computation speed grew exponentially, and
prices of memory banks dropped. So, almost naturally the size and complexity of problems in
CFD have increased, but the computation precision has not.
It appears that for large simulations, up to 100.000 grid points or more, the acquired ac-
curacy is questionable. If in the (near) future increased computation speed would allow even
larger simulations, measures should be taken to ensure sufficiently accurate results. Increasing
the machine precision would achieve this aim. Furthermore, numerical adaptations might also
increase the accuracy. Row-scaling will for instance improve the results of the continuity equa-
tion at hardly any expense. Stricter and/or different stopping criteria for iterative processes will
surely increase the accuracy in several cases.
Several processes, like the turbulence model and the flooding and drying criteria, cause a
certain loss of accuracy, which is not always compensated by accuracy improvements. Much
could be gained if they were to be improved.
An addition to the complexity of CFD in the course of years is the transition from two-
dimensional to three-dimensional models. Unconditional stability of the scheme for the discre-
tised two-dimensional shallow-water equations seems to have become conditional in the three-
dimensional case. The numerical stability has become very much dependent on boundary con-
ditions.
i
Contents
Abstract i
Acknowledgment iv
List of symbols v
1 Introduction 1
2 Flow Model 3
2.1 Reynolds-Averaged Navier-Stokes Equations . . . . . . . . . . . . . . . . . . . . . 3
2.2 Three-Dimensional Shallow-Water Equations . . . . . . . . . . . . . . . . . . . . 4
2.3 Transformed Equations in σ-coordinates . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.5 Turbulence Closure Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 Stability Analysis 35
5.1 Stability of the Spatially Discretised Problem . . . . . . . . . . . . . . . . . . . . 35
5.2 Depth-Averaged Shallow-Water Equations . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Three-Dimensional Shallow-Water Equations . . . . . . . . . . . . . . . . . . . . 40
6 Test Cases 43
6.1 Definitions and Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.2 Test Case 1: Square Reservoir with Wind-Driven Flow . . . . . . . . . . . . . . . 45
6.3 Test Case 2: Reservoir with Island and Dams . . . . . . . . . . . . . . . . . . . . 46
ii
6.4 Test Case 3: Reservoir with Tidal Condition . . . . . . . . . . . . . . . . . . . . . 50
6.5 Test Case 4: Navigational Channel . . . . . . . . . . . . . . . . . . . . . . . . . . 56
6.6 Test Case 5: Long Narrow Reservoir . . . . . . . . . . . . . . . . . . . . . . . . . 58
6.7 Row Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.8 Stopping Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.9 Test Case 6: Westerschelde . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.10 Turbulence Closure Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.11 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.12 Truncation Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
7 Conclusions 71
8 Recommendations 74
Appendices
A Numerical Scheme 75
E Settings in Delft3D-FLOW 91
iii
Acknowledgment
This report is the result of my research at WL | Delft Hydraulics. I would like to thank Kees
Vuik and Jan Mooiman for their advise and input during this period. Furthermore, I want to
express my gratitude towards Prof.dr.ir. P. Wesseling, Arthur Mynett, Jan van Kester, Stef
Hummel, Rob Uittenbogaard and Herman Gerritsen for their help and input.
iv
List of symbols
v
symbol description unit
ρ density [kg/m3 ]
ρ spectral radius (of a matrix) [-]
ρ0 reference density [kg/m3 ]
ρc contraction factor [-]
σ transformed vertical coordinate [-]
τ time step [s]
τbx bed shear stress in x-direction [1/(ms)]
τby bed shear stress in y-direction [1/(ms)]
~τs wind stress [1/(ms)]
φ geophysical latitude [-]
Ω angular speed of the earth [1/s]
Ω rotation vector of the earth [1/s]
ω transformed vertical flow velocity component [m/s]
vi
Chapter 1
Introduction
The shallow-water equations describe the flow of water in rivers, lakes and shallow seas, like
the North Sea. The computer program Delft3D-FLOW can be used to compute a numerical
approximation of the solution of the shallow-water equations. The result of a Delft3D-FLOW
simulation can be used to solve the transport equations for some contaminant or to determine
whether dikes along a river need to be heightened. They are also much used to predict the flows
around and near yet unbuilt structures or possible adjustments to them in seas and rivers, like
for instance Flyland, the second ‘Maasvlakte’ or new harbours.
1
Natural water flow
?
Physical model
?
model uncertainties
Conceptual model
?
truncation errors
Numerical model
iteration errors, rounding errors
?
Solution
Figure 1.1: Uncertainties and errors in the various steps of the solution process.
cases will be set up, which show erroneous results. Analysis of these results will show or rule
out possible causes. If they have been discovered, possible solutions will be tested.
This report treats the complete solution process as shown in Figure 1.1. The derivation of
the shallow-water equations from the Navier-Stokes equations and the boundary conditions are
dealt with in the second chapter. The third chapter focuses on the staggered grid, the numerical
scheme and the procedure for solving the numerical equations. The fourth chapter contains
a discourse on analysis of rounding errors and iteration errors of the numerical schemes that
are used in Delft3D-FLOW. In the fifth chapter a stability analysis for the three-dimensional
shallow-water equations is carried out. The results of the analyses from chapter four and five are
performed on several test cases in chapter six, of which the conclusions and recommendations
are summarised in the chapters seven and eight.
2
Chapter 2
Flow Model
The Navier-Stokes equations are a general model which can be used to model water flows in
many applications. However, when considering a specific problem, such as shallow-water flows,
in which the horizontal scale is much larger than the vertical one the three-dimensional shallow-
water equations will suffice.
In this chapter we will derive the Reynolds-averaged Navier-Stokes equations describing
turbulent flows for which the length scale of the turbulence is much smaller than that of the
problem. From this we will derive the three-dimensional shallow-water equations under the
assumption that the pressure is hydrostatically distributed. These equations will be transformed
to so-called σ-coordinates, after which the boundary conditions and the turbulence modelling
will be discussed.
3
where the overbar represents time-averaged quantities. For instance ū is defined by
1 t+T
Z
ū(t) := u(τ )dτ.
T t
The period T should be larger than the turbulence time scale, but smaller than long periodic
effects such as the tide. The turbulent fluctuationsRare given by u0 , v 0 , w0 and p0 . Note that the
t+T 0
time-averages of these fluctuations are zero, i.e. T1 t u dτ = 0.
When substituting (2.2) into (2.1) and averaging the resulting equations over time the
Reynolds-averaged Navier-Stokes equations or simply Reynolds equations arise for turbulent
flows. They read
The correlations between fluctuating velocity components (u0 u0 , u0 v 0 , etc.) are unknown. These
correlations are responsible for a loss of momentum in the mean flow direction and therefore
appear to act as stresses on the fluid. They are called Reynolds stresses. These stresses are much
larger than the viscous stresses which have therefore been neglected.
Assumption 2 (Eddy viscosity concept or Boussinesq hypothesis). Reynolds stresses
like viscous stresses depend on the deformation of the mean flow. Thus, the Reynolds stresses
are modelled as
0 0
∂v̄ ∂ ū
u v = −νt + , (2.4)
∂x ∂y
where νt is the so-called eddy viscosity. This eddy viscosity is a priori unknown and a suitable
expression has to be constructed (see section 2.5).
4
where ζ = ζ(x, y, t) is the free surface level against the reference plane z = 0 and pa is the
atmospheric pressure. Substituting this result in the pressure term of (2.3a) and using Leibnitz’
integration rule, yields
Z ζ
1 ∂ p̄ ρg ∂ζ g ∂ρ 0 1 ∂pa
− =− − dz − .
ρ0 ∂x ρ0 ∂x ρ0 z ∂x ρ0 ∂x
The horizontal pressure gradient is described by differences of the water level ζ through the
barotropic term, the first term on the right-hand side, and by density differences in horizontal
direction through the baroclinic term, the second term. The last term on the right-hand side
describes the contribution of the atmospheric pressure. If we had taken ρ constant, (2.6) would
read p̄ = ρg(ζ − z) + pa and for the pressure term of (2.3a) we would have
1 ∂ p̄ ∂ζ 1 ∂pa
− = −g − .
ρ0 ∂x ∂x ρ0 ∂x
If we neglect the atmospheric pressure gradient, the horizontal pressure gradient will reduce to
the barotropic term.
When substituting equations (2.4) and (2.6) in equations (2.3a) and (2.3b), taking the density
constant, neglecting the atmospheric pressure gradient yields and dropping the overbar, we
obtain
∂u ∂u ∂u ∂u ∂ζ
+u +v +w = −g + fv
∂t ∂x ∂y ∂z ∂x
(2.7)
∂ H ∂u ∂ H ∂u ∂v ∂ V ∂u
+2 νt + νt + + νt
∂x ∂x ∂y ∂y ∂x ∂z ∂z
and
∂v ∂v ∂v ∂v ∂ζ
+u +v +w = −g − fu
∂t ∂x ∂y ∂z ∂y
(2.8)
∂ H ∂u ∂v ∂ H ∂v ∂ V ∂v
+ νt + +2 νt + νt ,
∂x ∂y ∂x ∂y ∂y ∂z ∂z
f = 2Ω sin φ
with Ω the angular speed of the earth and φ the latitude. The equations (2.7), (2.8) and the
incompressible continuity equation
∂u ∂v ∂w
+ + =0 (2.9)
∂x ∂y ∂z
are called the shallow-water equations. At this point we have a system of three equations (2.7)-
(2.9), three unknown velocity components, u(x, y, z, t), v(x, y, z, t) and w(x, y, z, t), and a free
boundary, i.e. the unknown free surface ζ(x, y, t). So, a fourth equation is needed to compute
the unknown variables.
To this end we integrate the continuity equation along the vertical axis, what results in
Z ζ Z ζ
∂u ∂v
w(x, y, ζ, t) − w(x, y, d, t) = − dz − dz, (2.10)
−d ∂x −d ∂y
5
where d = d(x, y) is the water depth below the reference plane z = 0. Morphological changes of
the bed due to the water flow are in general very small and they are therefore neglected. Thus
d is not dependent on the time. Equation (2.10) can be rewritten by using substitutions for w
at the bottom and the water surface. For z = ζ(x, y, t) we have
dζ ∂ζ ∂ζ ∂ζ
w= = +u +v . (2.11)
dt ∂t ∂x ∂y
A similar expression at the bottom reads
∂d ∂d
w = −u −v . (2.12)
∂x ∂y
Substituting (2.11) and (2.12) into (2.10) and using Leibnitz’ integration rule, yields
Z ζ Z ζ
∂ζ ∂ ∂
=− u dz − v dz. (2.13)
∂t ∂x −d ∂y −d
Rζ Rζ
If we define the depth-averaged velocities U and V by U := H1 −d u dz and V := H1 −d v dz,
where H = H(x, y, t) = ζ + d is the water depth, (2.13) reads
∂ζ ∂HU ∂HV
+ + = 0. (2.14)
∂t ∂x ∂y
6
The horizontal velocities u and v remain strictly horizontal after the transformation. Hence
ũ = u and ṽ = v. When we substitute equation (2.16) in equation (2.9), noting that H and ζ
are not dependent on σ, but ũ and ṽ are, and assuming that d is not time-dependent, we obtain
the continuity equation in transformed coordinates:
∂ζ ∂H ũ ∂H ṽ ∂ω
+ + + = 0. (2.17)
∂ t̃ ∂ x̃ ∂ ỹ ∂σ
Integrating equation (2.17) from the bottom to the surface and using Leibnitz’ integration rule,
yields
∂ζ ∂HU ∂HV
+ + = 0, (2.18)
∂ t̃ ∂ x̃ ∂ ỹ
R0 R0
where U and V are depth-averaged velocities defined by U = −1 ũ dσ and V = −1 ṽ dσ. Logi-
cally this equation is equal to (2.14) in the previous section, because they are integrated along
the vertical axis and therefore invariant under the σ-transformation. Note that the definitions
of U and V is equivalent to the definitions in the previous section.
After transformation of (2.7) and (2.8) to σ-coordinates the momentum equations in x- and
y-direction of the shallow-water equations arise. They read, dropping the tilde,
∂u ∂u ∂u ω ∂u 1 ∂p ∂σ ∂p 1 ∂ ∂u
+u +v + =− + + f v + Fx + 2 νtV (2.19)
∂t ∂x ∂y H ∂σ ρ0 ∂x ∂x ∂σ H ∂σ ∂σ
and
∂v ∂v ∂v ω ∂v 1 ∂p ∂σ ∂p 1 ∂ ∂v
+u +v + =− + − f u + Fy + 2 νtV . (2.20)
∂t ∂x ∂y H ∂σ ρ0 ∂y ∂y ∂σ H ∂σ ∂σ
Note that the density ρ is not taken constant. The terms Fx and Fy represent the horizontal
viscosity terms. They are given by
∂ ∂σ ∂ ∂ ∂σ ∂
Fx = + τxx + + τxy
∂x ∂x ∂σ ∂y ∂y ∂σ
and
∂ ∂σ ∂ ∂ ∂σ ∂
Fy = + τxy + + τyy ,
∂x ∂x ∂σ ∂y ∂y ∂σ
where the Reynolds stresses τxx , τxy and τyy satisfy
H ∂u ∂σ ∂u
τxx = 2νt +
∂x ∂x ∂σ
H ∂u ∂σ ∂u ∂v ∂σ ∂v
τxy = νt + + +
∂y ∂y ∂σ ∂x ∂x ∂σ
∂v ∂σ ∂v
τyy = 2νtH + .
∂y ∂y ∂σ
For large scale problems with coarse horizontal grids, i.e. when shear-stresses along the bound-
aries may be neglected, the forces Fx and Fy may be simplified. The horizontal eddy viscosity
νtH is assumed constant and the horizontal eddy viscosity terms are reduced to the Laplace
operator:
Fx = νtH 4u and Fy = νtH 4v (2.21)
7
∂2 ∂2
with 4 = ∂x 2 + ∂y 2 . After application of this simplification we allow the horizontal eddy viscosity
to vary in space.
Finally we will look at the horizontal pressure gradient in σ-coordinates, which can be
written as
∂p ∂σ ∂p ∂p 1 ∂ζ ∂H ∂p
+ = − +σ .
∂x ∂x ∂σ ∂x H ∂x ∂x ∂σ
Substituting the integrated hydrostatic pressure relation (2.15) results in
Z 0
∂pa ∂ 0 ∂ζ ∂H
+g H ρ dσ + gρ +σ .
∂x ∂x σ ∂x ∂x
This expression has been implemented in Delft3D-FLOW. If we take the density constant
and neglect the atmospheric pressure gradient, the horizontal pressure gradient reduces to the
∂ζ
barotropic term gρ ∂x as shown before in the previous section.
ω|σ=−1 = ω|σ=0 = 0.
By imposing these conditions we neglect evaporation, rainfall and exchange with the ground
water. At the sea bed the boundary conditions for the momentum equations are given by
νtV ∂u
1
= τbx (2.22)
H ∂σ σ=−1 ρ
and
νtV ∂v
1
= τby (2.23)
H ∂σ σ=−1 ρ
with τbx and τby the components of the bed shear stress in x- and y-direction, respectively.
Wind stresses are responsible for non-homogeneous boundary conditions for the momentum
equations at the free surface. They read
νtV ∂u
1
= |~τs | cos θ (2.24)
H ∂σ σ=0 ρ
and
νtV ∂v
1
= |~τs | sin θ (2.25)
H ∂σ σ=0 ρ
with |~τs | the wind stress and θ the angle between the wind stress vector and x-axis.
where ρa is the air density, U10 is the wind speed 10 metres above the water surface and Cd is
the wind drag coefficient, which depends on U10 .
8
This dependence is empirical and several implementations are possible, for example a linear
relation, a constant value for Cd or a combination of the two.
The conditions at the vertical boundary planes are divided in open and closed boundary condi-
tions. Closed boundaries are situated at the transition between land and water. Open boundaries
are virtual “water-water” boundaries. These open boundaries have been introduced in order to
limit the computational area.
At the closed boundaries the flow condition prohibiting flow through the boundary reads
u
n· = 0 ∀σ ∈ [−1, 0]
v (x,y)=(xb ,yb )
where (xb , yb ) is any point on the closed boundary and n consists of the first two components
of the outward normal of the vertical boundary plane in that point. The slip condition imposed
along the closed boundaries depends on the scale of the problem. In large scale problems the
tangential shear stresses along closed boundaries can be neglected (free slip condition). For
small scale problems this influence is not negligible and is taken into account through a partial
slip condition.
At open boundaries the water level, the velocity or the discharge should be prescribed. The
velocity at an open boundary is chosen perpendicular to that boundary for computational
reasons. For an open boundary one of the following three boundary conditions can be prescribed.
They are
where ζ is the free surface level (see page 4), U the depth-averaged normal velocity component
(see page 7) and Q the discharge through the boundary plane. For simplicity we have assumed
that the open boundary is perpendicular to the x-axis, so we only have to specify the velocity
component along the x-axis. We will speak of a left and a right open boundary, see Figure 2.1.
Closed Boundary
Closed Boundary
For the boundary conditions of the velocity and the discharge type a profile has to be
prescribed in the vertical direction. This profile can be uniform or logarithmic. Also a complete
3D-profile can be prescribed in which for various depths different conditions are specified.
If an outgoing wave at an open boundary is not prescribed exactly then that wave will
(partially) reflect at the boundary and propagate as a disturbance in the area. The boundary
9
conditions in (2.26) will in general cause wave
√ reflections. A weakly-reflective boundary condition
is based on the Riemann invariants U ± 2 gH. The boundary condition specified by the user
would then be p
U ± 2 gH = FR (t)
with ”+” for the left and ”−” for the right boundary. For numerical purposes it is convenient
to have a linearised boundary condition.
Assumption 5. For weakly-reflecting open boundary conditions the variations of the water level
ζ (with respect to the reference plane) are small in comparison with the water depth d.
To reduce the reflective properties of the water level and velocity boundary conditions in (2.26)
the time-derivative of the Riemann invariant is added. The new boundary conditions are
∂ p
ζ + αζ U ± 2 gH = Fζ (t),
∂t
∂ p
U + αU U ± 2 gH = FU (t)
∂t
for the water level and the velocity respectively. The reflection coefficients αζ and αU should be
chosen sufficiently small to damp short waves introduced by the initial conditions.
1. Constant coefficient.
2. Algebraic turbulence closure model.
3. k–L turbulence closure model.
4. k– turbulence closure model.
The first model is the simplest but also the most unrealistic as it will lead to a laminar flow.
The other models are based on the eddy viscosity concept of Kolmogorov and Prandtl. In this
10
concept the eddy viscosity is related to a characteristic length scale, L, and a characteristic
velocity scale, U. This relation reads
νtV ∼ L U.
The explicit form, also known as the Kolmogorov-Prandtl expression, is
√
νtV = c0µ lm k,
where c0µ is constant derived from the empirical constant cµ in the k– model, lm is the mixing
length and k is the turbulent kinetic energy. The last three models differ in their prescription
for lm and k.
In the algebraic model an expression is given for lm and k. For the mixing length one of the
most common choices is given by the Bakhmetev distribution which reads
r
z+d
lm = κ(z + d) 1 −
H
with κ the Von Kármán constant, κ ≈ 0.41. An algebraic expression for k depends on the
friction velocities or the velocity gradients.
In the k–L closure model the mixing length is analytically prescribed by lm = cD k 3/2 /,
where cD is a model coefficient, is the dissipation rate of turbulent kinetic energy and the
turbulent kinetic energy follows from a transport equation.
The k– closure model uses transport equations for both the turbulent kinetic energy k as
well as the dissipation rate of turbulent kinetic energy . These transport equations read
1 ∂ νtV ∂k
∂k ∂k ∂k ω ∂k
+u +v + = 2 + Pk + Bk − ,
∂t ∂x ∂y H ∂σ H ∂σ σk ∂σ
1 ∂ νtV ∂ 2
∂ ∂ ∂ ω ∂
+u +v + = 2 + P + B − c2 ,
∂t ∂x ∂y H ∂σ H ∂σ σ ∂σ k
where c2 is a model coefficient, σk and σ are the Prandtl-Schmidt numbers, Pk and P are the
production terms and Bk and Bk/ are the buoyancy terms. These equations can be solved with
appropriate initial and boundary conditions. Detailed descriptions of these models are beyond
the scope of this report. For more information we refer to Launder and Spalding (1972) and
Rodi (1985).
11
Chapter 3
The analytical solution of the shallow-water equations can only be calculated in a very small
number of cases, which however do not occur in nature. A numerical approximation is therefore
almost inevitable. In Delft3D-FLOW a finite difference scheme on a staggered grid is chosen
using an ADI solver in conjunction with a Gauss-Jacobi iteration. In the next sections these
numerical methods will be discussed.
12
equation,
∂2u ∂2u
∂u
=α + 2 , (3.2)
∂t ∂x2 ∂y
for example, would look like
up+1 p
m,n − um,n
= α(δx2 up+1 2 p+1
m,n + δy um,n )
∆t
with
p+1 p+1
δx2 up+1 p+1
m,n = (um−1,n − 2um,n + um+1,n )/∆x
2
and
δy2 up+1
m,n = (up+1
m,n−1 − 2up+1
m,n + up+1 2
m,n+1 )/∆y .
Solving this equation by Gaussian elimination would be too expensive due to fill-in. The alter-
nating direction implicit (ADI) schemes are a good alternative, because only tridiagonal matrix
equations have to be solved. The idea is to use implicit numerical approximations in one spatial
direction and explicit ones in the other spatial direction.
We will discuss one of the most common ADI schemes, the Peaceman-Rachford scheme, for
the two-dimensional heat equation. This ADI scheme uses a time step of ∆t/2 and the direction
in which implicit numerical approximations are used alternates. The scheme reads
p+ 1
um,n2 − upm,n p+ 1
= αδx2 um,n2 + αδy2 upm,n , (3.3a)
∆t/2
p+ 1
up+1
m,n − um,n
2
p+ 1
= αδx2 um,n2 + αδy2 up+1
m,n . (3.3b)
∆t/2
In equation (3.3a) the second derivative with respect to x is evaluated implicitly and the second
derivative with respect to y explicitly and vice versa in equation (3.3b). Note that both matrix
equations are tridiagonal. From now on we will refer to (3.3) as one iteration (in time), divided
into two stages.
Stability
For stability analysis we use a Von Neumann stability method. Let
where i is the imaginary unit, θx , θy ∈ [0, 2π] and G ∈ R, and substitute this expression in the
first stage, equation (3.3a). After cancelling several factors this results in
1 1 1 1
Gp+ 2 = Gp + rx Gp+ 2 [e−iθx ∆x − 2 + eiθx ∆x ] + ry Gp [e−iθy ∆y − 2 + eiθy ∆y ]
2 2
with rx = α∆t/∆x2 and ry = α∆t/∆y 2 . Further manipulation leads to the following relation
for the amplification factor G:
√ 1 + ry [cos βy − 1] 1 − 2ry sin2 12 βy
G= =
1 − rx [cos βx − 1] 1 + 2rx sin2 12 βx
with βx = θx ∆x and βy = θy ∆y. For the second stage the relation for the amplification factor
reads
√ 1 + rx [cos βx − 1] 1 − 2rx sin2 21 βx
G= = .
1 − ry [cos βy − 1] 1 + 2ry sin2 12 βy
13
Thus the amplification factor for the whole time step ∆t is
Since rx and ry are both positive and the sine terms are at most equal to one, the amplification
factor is always smaller than one. Hence this ADI scheme is unconditionally stable. Note that
each stage separately is conditionally stable with the conditions ry ≤ 1 and rx ≤ 1, respectively.
Consistency
Next we will discuss the consistency (accuracy) of the scheme. Therefore we rewrite the equations
(3.3a) and (3.3b) as
p+ 1
(1 − 21 ∆t α δx2 )um,n2 = (1 + 12 ∆t α δy2 )upm,n (3.4a)
p+ 12
(1 − 21 ∆t α δy2 )up+1 1 2
m,n = (1 + 2 ∆t α δx )um,n . (3.4b)
After multiplication of (3.4a) with (1 + 12 ∆t α δx2 ) the operators on the left-hand side are com-
mutable. Having done so we substitute (3.4b) in it, resulting in
up+1 p
m,n − um,n α δx2 p+1 p α δy2
= (u m,n + u m,n ) + (up+1 + upm,n )
∆t 2 ∆x2 2 ∆y 2 m,n
(3.6)
α∆t δx2 δy2
− (up+1 − upm,n )
4 ∆x2 ∆y 2 m,n
Using equation (3.2) on (3.7) (twice!) shows that the Peaceman-Rachford scheme is second order
accurate in ∆t, ∆x and ∆y. For more details on ADI schemes and the Peaceman-Rachford
scheme in particular we refer to Mitchell and Griffiths (1980).
14
The horizontal grid is the so-called Arakawa C grid, a staggered grid. This means that the
variables are arranged on the grid in a special way. The different variables are not calculated at
the same physical points in the horizontal plane. Figure 3.1 shows an example of the Arakawa
C grid.
4 - - - - -
6
6 d 6 d 6 d 6 d 6 d 6 Legend
n
3 - - - - - Computational boundary
Open boundary
6 d 6 d 6 d 6 d 6 d 6 Closed boundary
Water level grid point
2 - - - - - d Depth grid point
- u-velocity grid point
6 d 6 d 6 d 6 d 6 d 6 6 v-velocity grid point
1 - - - - -
6 d 6 d 6 d 6 d 6 d 6
0 - - - - -
0 1 2 3 4 5
m -
Figure 3.1: An example of the Arakawa C grid.
In general we will refer to the horizontal grid indices with m and n for the x- and y-direction,
respectively; and with M and N for their maximum values.
The open and closed boundaries in Figure 3.1 form the model boundary. Only points within
this boundary are calculated. For the open boundaries either the normal velocity component at
the boundary (e.g. at grid coordinates ( 12 , 2)) or the water level just outside the boundary (e.g.
at (0, 2)) should be prescribed.
In the vertical direction we define a number of layers, so-called σ-layers. The number of
layers is K. We will use index k to refer to the k th layer with k = 1 for the surface layer and
k = K for the bottom layer. The discretisation in σ-direction is not necessarily equidistant, so
the various layers may differ with respect to their thickness, ∆σk . Also in the vertical direction
a staggered grid is used. Figure 3.2 shows a single vertical grid cell for an arbitrary value of n.
k− 12
6
6 Legend
Computational cell boundary
∆σk k - - - u-velocity grid point
6 ω-velocity grid point
? k+ 1
2 6
m− 12 m m+ 12
The discretisations at the inner points is given term by term in Appendix A. Here we will give
the equations (3.1a-d) in approximated discrete form using symbols to represent derivatives.
15
The first stage reads
1
up+ 2 − up 1 1
ωp 1
+ up+ 2 S1x (up ) + v p+ 2 S1y (up ) + Hp Sσ (up+ 2 )
τ /2 (3.8a)
p+ 12 1
p+ 12
= −g S0x (ζ )+ 1
S (up+ 2 )
(H p )2 σσ
+ fv ,
p+ 12
v − vp 1 1
ωp 1
+ up S+x (v p+ 2 ) + v p S+y (v p+ 2 ) + Hp Sσ (v p+ 2 )
τ /2 (3.8b)
1
p p+ 21 1
= −g S0y (ζ ) + 2νtH [Sxx (v p+ 2 ) + Syy (v )] + 1
S (v p+ 2 )
(H p )2 σσ
− fu ,p
p+ 12
! !
ζ − ζp 1 p+ 21
∆σk vkp
X X
+ S0x H p+ 2 ∆σk uk + S0y Hp = 0, (3.8c)
τ /2
k k
p+ 1 p+ 1
ωk− 12 − ωk+ 12 1
ζ p+ 2 − ζ p 1 p+ 1
2 2
+ + S0x (H p+ 2 uk 2 ) + S0y (H p vkp ) = 0. (3.8d)
∆σk τ /2
The symbols S0x and S1x represent second order accurate central difference schemes of the first
derivatives with respect to x over respectively one and two grid cells. Thus
p p
S0x (ζ p ) = (ζm+ 1
,n
− ζm− 1
,n
)/∆x and S1x (up ) = (upm+1,n − upm−1,n )/2∆x. (3.9)
2 2
The second order accurate upwind schemes for the first derivatives are represented by S+x and
S+y . For instance
(
(3upm,n − 4upm−1,n + upm−2,n )/2∆x, if upm,n > 0,
S+x (up ) = (3.10)
(−3upm,n + 4upm+1,n − upm+2,n )/2∆x, if upm,n ≤ 0.
The symbols Sxx and Syy are defined at item 12. in the list of approximated terms in Ap-
pendix A. And the symbols Sσ and Sσσ represent the discretisations in items 8. (and 9.) and
14. respectively.
The second stage reads
1
up+1 − up+ 2 1 1
ω p+ 2
1
+ up+ 2 S+x (up+1 ) + v p+ 2 S+y (up+1 ) + p+ 1
Sσ (up+1 )
τ /2 H 2
(3.11a)
p+ 12 p+ 12
= −g S0x (ζ )+ 2νtH [Sxx (up+1 ) + Syy (u p+1
)] + 1
1 Sσσ (u p+1
) + fv ,
(H p+ 2 )2
1
v p+1 − v p+ 2 1 1 p+ 1
+ up+1 S1x (v p+ 2 ) + v p+1 S1y (v p+ 2 ) + ω p+21 Sσ (v p+1 )
τ /2 H 2 (3.11b)
p+1
= −g S0y (ζ ) + p+ 1 Sσσ (v ) − f up+1 ,
1 p+1
(H 2 )2
1
! !
ζ p+1 − ζ p+ 2 p+ 12
X p+ 21 p+1
X p+1
+ S0x H ∆σk uk + S0y H ∆σk vk = 0, (3.11c)
τ /2
k k
p+1 p+1
ωk− 1 − ω p+ 12
k+ 1 ζ p+1 − ζ 1 p+ 12
2 2
+ + S0x (H p+ 2 uk ) + S0y (H p+1 vkp+1 ) = 0. (3.11d)
∆σk τ /2
Note that due to the staggered grid (3.8a) and (3.11a) are calculated at (m+ 21 , n, k), (3.8b) and
(3.11b) at (m, n+ 21 , k), (3.8c) and (3.11c) at (m, n) and (3.8d) and (3.11d) at (m, n, k).
Further on in this report we will sometimes refer to the equations (3.8a) and (3.8b) as
the implicit and explicit momentum equation, respectively, because the water level ζ is taken
into account implicitly and explicitly, respectively. Equation (3.8c) will be referred to as the
continuity equation. For the equations (3.11a)-(3.11c) the terms are applied in the same manner.
16
3.4 Boundary Conditions
Careful treatment of the boundary conditions is essential in order to avoid unwanted numerical
phenomena, such as artificial boundary layers, unstable discretisations and numerical diffusion,
and to approximate the physical flow as well as possible. In this section we will start with the
closed boundary conditions, followed by those for the open boundaries and finally we will deal
with the boundary conditions at the bottom and the free surface. As an example the grid in
Figure 3.1 is used. So, the closed boundaries are parallel to the x-axis and the open boundaries
are parallel to the y-axis.
6 d 6 d 6
2 - -
6
6 d 6 d 6
n
1 - -
⇑ d ⇑ d ⇑
m-1 m m+1
Note that in the first case the approximation is zeroth order and in the second case it is first
∂v
order accurate. The horizontal advection term v ∂y at (m, 2 12 ) is also treated in a special way in
the first stage, when vm,2 1 > 0. The numerical approximation is
2
(
vm,2 1 (vm,2 1 − vm,1 1 )/∆y, if vm,2 1 > 0,
∂v
v ≈ 2 2 2 2
∂y m,2 1 vm,2 1 (−3vm,2 1 + 4vm,3 1 − vm,4 1 )/2∆y, if vm,2 1 ≤ 0.
2 2 2 2 2 2
17
In large scale problems the use of the free slip condition is allowed. For the horizontal advection
term v ∂u ∂u
∂y the free slip condition, ∂y = 0, and the impermeability condition, v = 0, support the
following approximations for the first stage:
∂u
v ≈0
∂y
and for the second stage:
(
0, if v̄m+ 1 ,1 > 0,
∂u
v ≈ 2
∂y m+ 1 ,1 v̄m+ 1 ,1 (−3um+ 1 ,1 + 4um+ 1 ,2 − um+ 1 ,3 )/2∆y, if v̄m+ 1 ,1 ≤ 0.
2 2 2 2 2 2
Note that the overbar on v indicates an averaged value as defined in item 6. in Appendix A. In
the second stage the numerical approximation at (m + 21 , 2) is replaced with:
(
v̄m+ 1 ,2 (um+ 1 ,2 − um+ 1 ,1 )/∆y, if v̄m+ 1 ,2 > 0,
∂u
v ≈ 2 2 2 2
∂y m+ 1 ,2 v̄m+ 1 ,2 (−3um+ 1 ,2 + 4um+ 1 ,3 − um+ 1 ,4 )/2∆y, if v̄m+ 1 ,2 ≤ 0.
2 2 2 2 2 2
2 2
∂ v
The second order derivatives, ν H ∂∂yu2 and ν H ∂y 2 , in the horizontal viscosity terms are approxi-
mated as follows near the closed the boundary:
(
2u 0 in the first stage,
∂
ν H 2 ≈ H 2
∂y m+ 1 ,1 νm+ 1 ,1 (um+ 1 ,2 − um+ 1 ,1 )/∆y in the second stage,
2 2 2 2
(
H 2 in the first stage,
∂2v νm,1 1 (vm, 1 − 2vm,1 1 + vm,2 1 )/∆y
ν H 2 ≈ 2 2 2 2
∂y m,1 1 0 in the second stage.
2
Note that in the second expression the velocity component at the closed boundary (vm, 1 ) is
2
explicitly taken into account, while this is avoided in the first expression. The second order
2 ∂2v
derivatives with respect to x, ν H ∂∂xu2 and ν H ∂x2 , are approximated with second order accurate
central difference schemes.
Boundary conditions on ζ at closed boundaries are only given if necessary. The derivative
of ζ with respect to x in equations (3.8a) and (3.11a) does not imply the need for a boundary
condition on ζ, because the closed boundaries are parallel to the x-axis. The derivative of ζ with
respect to y, however, in the horizontal momentum equation in y-direction requires a boundary
condition on ζ, but only in the second stage. It is obvious that the equations (3.11b) and (3.11c)
are coupled. To solve these equations (3.11b) is substituted in (3.11c) leading to a tridiagonal
system for ζ (see Section 3.5). Points near the closed boundary require data of points just
∂ζ
beyond the boundary. The boundary condition ∂y = 0 satisfies this need.
18
n+1 ⇒ - - n+1 - - -
⇑ d 6 d 6 d ⇑ d 6 d 6 d
n ⇒ - - n - - -
⇑ d 6 d 6 d ⇑ d 6 d 6 d
n-1 ⇒ - - n-1 - - -
0 1 2 0 1 2
m - m -
(a) (b)
Figure 3.4: The horizontal grid along an open boundary for a velocity boundary condition (a)
and for a water level boundary condition (b).
First we will discuss the velocity boundary condition. A velocity boundary condition can be a
complete two-dimensional velocity profile or it can consist of a condition on the depth-integrated
velocity along the border in combination with a vertical velocity profile. This vertical velocity
profile is usually a logarithmic or uniform profile.
At inner points the horizontal advection term u ∂u ∂x is approximated with a second order
central difference scheme in the first stage. Near an open velocity boundary as in Figure 3.4a
this approximation does not cause any problems, so it remains unchanged. In the second stage
this term is approximated as follows:
(
u1 1 ,n (u1 1 ,n − u 1 ,n )/∆x, if u1 1 ,n > 0,
∂u
u ≈ 2 2 2 2
∂x 1 1 ,n u 1
1 ,n (−3u 1
1 ,n + 4u 1
2 ,n − u 1
3 ,n )/2∆x, if u 1 1 ,n ≤ 0.
2 2 2 2 2 2
At open boundaries the tangential velocity component is assumed to be zero. This corresponds
with v0,n = 0 ∀n for both types of boundary condition in Figure 3.4. The numerical approxi-
∂v
mation of the horizontal advection term u ∂x near open velocity boundaries for the first stage
is: (
ū1,n+ 1 (v2,n+ 1 − v0,n+ 1 )/2∆x, if ū1,n+ 1 > 0,
∂v
u ≈ 2 2 2 2
∂x 1,n+ 1 0, if ū 1,n+ 1 ≤ 0
2 2
The numerical approximations of the horizontal viscosity terms do not need a special treatment
near open velocity boundaries and therefore they remain unchanged. For the same reasons as
near closed boundaries a boundary condition on ζ is only given when necessary. In the first
∂ζ
stage the boundary condition ∂x = 0 is used.
When a water level boundary condition is prescribed the numerical boundary is set along
the ζ grid points (see Figure 3.4b). The numerical approximations near the open boundary
of the various terms are different than with a velocity boundary condition. The numerical
approximation of the horizontal advection term u ∂u 1
∂x at ( 2 , n) is replaced with
(
0, if u 1 ,n > 0,
∂u
u ≈ 2
∂x 1 ,n u 1 (u 1
,n 1 ,n − u 1
,n )/∆x, if u 1
,n ≤ 0
2 2 2 2 2
19
∂v
for both stages. The horizontal advection term u ∂x is discretised near the open boundary
according to a second order central scheme in the first stage:
∂v
u ≈ ū1,n+ 1 (v2,n+ 1 − v0,n+ 1 )/2∆x.
∂x 1,n+ 1 2 2 2
2
For the second stage either a zeroth order approximation or second order upwind scheme is
used, depending on the flow direction of u. The approximation reads
(
0, if ū1,n+ 1 > 0,
∂v
u ≈ 2
∂x 1,n+ 1 ū 1,n+ 1 (−3v
1,n+ 1 + 4v
2,n+ 1 − v
3,n+ 1 )/2∆x, if ū 1,n+ 1 ≤ 0.
2 2 2 2 2 2
The horizontal viscosity operator for u, ν H ∆u, in the second stage is approximated as follows:
The horizontal viscosity terms for v in the first stage are not treated in a special way. In both
directions the second order difference schemes are used.
0 ⇒ ⇒
⇑ ⇑ ⇑ The arrow (⇑) indicates a
6 Dirichlet boundary condi-
1 - - ∆σ1 tion on the relative ver-
k tical velocity component.
6 6 6 ? The other arrow (⇒) in-
? 6 dicates a Neumann bound-
2 - - ∆σ2 ary condition on the hori-
zontal velocity component.
6 6 6 ?
m-1 m m+1
The Neumann boundary conditions for the wind stresses (see eqns. (2.24) and (2.25)) are only
applied to the vertical viscosity terms H12 ∂σ
∂ ∂u
(νtV ∂σ ) and H12 ∂σ ∂ ∂v
(νtV ∂σ ) and not to the vertical
ω ∂u ω ∂v
advection terms H ∂σ and H ∂σ . For the vertical advection terms at the surface first order upwind
schemes are used as numerical approximations. For the velocity component in x-direction, u, at
(m + 12 , n) this reads
ω ∂u u1 − u2
≈ ω̄1 1 .
H ∂σ k=1
2 (h1 + h2 )
In the numerical approximation of the vertical viscosity terms two first order derivatives are
subtracted (see list item 14 in Appendix A). Along the surface (when k = 1) one of these
20
derivatives equals the expression for wind stress, which accordingly replaces that derivative.
The vertical viscosity term for u at the surface becomes
" #
1 ∂ ∂u 1 |~
τ s | cos θ u 1 − u 2
νtV − ν1V1 1
≈ .
H 2 ∂σ ∂σ k=1 h1 ρ 2 (h
2 1 + h 2)
The boundary conditions at the bottom (eqns. (2.22) and (2.23)) are treated equivalently.
21
If the red/black pattern would be placed differently or if the main flow would be different, then
this matrix would also be different. However, it is not expected that the result of the iteration
would differ that much.
where 1 ∈ RK is the vector with only ones. The vector f p contains the remaining terms with
only explicit variables and boundary conditions on u. Due to the staggered grid the matrix C
(and hence also B) is not square. Performing a Gaussian elimination process on (3.12) leads to
1 1 p
up+ 2 + B 0 ζ p+ 2 = f 0 . (3.13)
This procedure does not cause any fill-in in the matrix B, due to the fact that the matrix A
consist of smaller tridiagonal matrices Ai . The depth-averaged form of this expression is needed
in the continuity equation (3.8c) and can easily be calculated by multiplying every row with the
respective relative layer thickness ∆σk and adding subsequent rows. This result in
1 1 p
U p+ 2 + B 00 ζ p+ 2 = f 00 (3.14)
Continuity Equation
The depth-integrated continuity equation (3.8c) describes the level of the water surface ζ in
the water column at coordinates (m, n) by calculating the net inflow in that column. This
guarantees conservation of mass. It is important for this calculation that the term HU is taken
either completely implicit or completely explicit (the same restriction applies to HV ). When
this is not the case the numerical approximation is not mass conservative. For flow calculations
this phenomenon is not so severe. However, when using non-mass-conservative calculated flow
data in transport equations for a pollutant, for instance, some of the pollutant may disappear
or appear. This is highly unwanted.
22
Equation (3.8c) is non-linear with respect to ζ, because both factors of HU are implicit. The
total water depth H equals ζ + d and U is given by (3.14). A way to deal with this problem is
1
to use an iterative scheme for ζ p+ 2 (Kester and Stelling, 1992). For this scheme the barotropic
1 1 1 1
term −g Sx (ζ p+ 2 ) in equation (3.8a) is multiplied by H p+ 2 ,i /H p+ 2 ,i+1 (with H p+ 2 ,0 := H p ).
With this modification the equations (3.8a) and (3.8c) read respectively
1
up+ 2 − up 1 1 1
+ up+ 2 Sx (up ) + v p+ 2 Sy (up ) + ω p Sσ (up+ 2 )
τ /2 (3.15a)
p+ 1
2 ,i
H p+ 12 ,i+1 p+ 12 p+ 12
= −g 1 Sx (ζ ) + Sσσ (u ) + fv ,
H p+ 2 ,i+1
1
! !
ζ p+ 2 ,i+1 − ζ p 1 p+ 12
∆σk vkp
X X
+ Sx H p+ 2 ,i+1 ∆σk uk + Sy Hp = 0, (3.15b)
τ /2
k k
where i denotes the current iterate. After the substitution of (3.15a) in (3.15b) as described
1
above, a linear tridiagonal iterative system for ζ p+ 2 arises, of which the result is substituted
in (3.15a). By default the number of iterations is set to two, what practically proves to be
sufficient.
Finally, the continuity equation (3.8d) can be solved by substitution of the previous com-
puted results. This equation is only used to derive the relative vertical velocity components,
ωm,n,k . Note that at a horizontal coordinate (m, n) there are K continuity equations for K − 1
unknown vertical velocity components. Therefore one of the equations is used for verification of
the calculations.
23
Chapter 4
When using a program like Delft3D-FLOW one would like to acquire the most accurate results
possible. However, computers can only calculate with a certain finite accuracy, the machine
precision. The cause of this finite accuracy is that after every floating point operation the result
is rounded, causing a small rounding error. Due to accumulation of these rounding errors the
final result is less accurate than the machine precision. Delft3D-FLOW calculates in single
precision, meaning that after a single floating point operation the result is rounded after the
seventh digit. To what extent do these rounding errors influence the accuracy of the solution?
This depends on the solution algorithm and the relation between the coefficients of the matrices
(the condition number). Truncation errors are not considered in this report, although they are
usually larger than rounding errors.
In this chapter we will start with the applied solution algorithms, the LU factorisation
(Gaussian elimination) and the red-black Gauss-Jacobi block iterative method. Condition num-
bers will be discussed next after which we arrive at the section on accuracy. Subsequently, we
will focus on the Gauss-Jacobi iterative method and possible stopping criteria. We end with a
short discourse on possible enhancements regarding the accuracy.
24
Error Analysis for General Matrices
We will analyse the LU factorisation if applied on a computer with machine precision µ. The fol-
lowing lemma gives an idea of how accurate the LU factorisation can be performed by providing
an upper bound for the “residue” of the decomposition: (L̂Û − A).
Lemma 4.1. Let A be a real n × n floating point matrix. If all pivots are nonzero, then the
calculated triangular matrices L̂ and Û satisfy
n o
L̂Û = A + H with |H| ≤ 2(n − 1)µ |A| + |L̂||Û | + O(µ2 ),
where H ≤ A means hij ≤ aij ∀i, j.
Proof. See Golub and Van Loan (1989, p. 105-6).
Solving the matrix equation using L and U is also subject to rounding errors as the next lemma
will show.
Lemma 4.2. Let L be a real lower triangular n × n floating point matrix. For the computed
solution ŷ of Ly = b we have
(L + F )ŷ = b with |F | ≤ nµ |L| + O(µ2 ).
Proof. See Forsythe and Moler (1967, p. 104-5).
Thus the computed solution ŷ satisfies a slightly perturbed system. For U x = ŷ a similar relation
holds. Combination of the Lemmas 4.1 and 4.2 provides an idea of the perturbed matrix equation
which is actually solved when using an LU factorisation or Gaussian elimination.
Theorem 4.1. Let L̂Û be the computed factorisation of the n×n floating point matrix A, ŷ the
computed solution of L̂y = b and x̂ the computed solution of Û x = ŷ. Then (A + E)x̂ = b with
n o
|E| ≤ 2nµ |A| + 2|L̂||Û | + O(µ2 ).
Pivoting
The previous analysis shows that we must avoid large entries in the computed triangular matri-
ces, L̂ and Û . One of the most basic methods to ensure small entries in L̂ is pivoting. Before we
discuss pivoting we first explain what a pivot is. Therefore we give a more detailed description
of the LU factorisation.
During the factorisation of the matrix A to a lower and an upper triangular matrix, A is actually
reduced to an upper triangular matrix U through Gaussian elimination. The information of the
“inverse” procedure to this reduction is stored in a lower triangular matrix L. After construction
of the first k − 1 columns of L and as many rows of U , the partially constructed L and U read
1 0 ... 0 0 ... 0 0
.. .. .. ..
l21 1 . . . .
.. .. ..
l31 l32
. 0 . .
. .. ..
. .
. 1 0 .
(k−1)
L = .. .. ,
l
k,1 . . . . . . . lk,k−1 1 . .
. .. .
.. lk+1,k−1 0 . 0 ..
. .. .. . .
..
. . . 1 0
ln1 ....... ln,k−1 0 ... 0 1
25
u11 u12 . . . . . . . . . . . . . u1,k ... u1n
. .. ..
0 u22 . .
. .
.. .. .. .. ..
. .
. 0 . .
.. ..
U (k−1) = . . uk−1,k−1 uk−1,k . . . uk−1,n .
.. (k−1) (k−1)
. 0 ak,k . . . ak,n
.. .. .. .. ..
. . . . .
(k−1) (k−1)
0 ........ 0 an,k . . . an,n
(k−1)
The entry ak,k is called the pivot. If the pivot is larger than all other entries in the same
(k−1)
column below the pivot (ai,k for k < i ≤ n) in absolute sense then their respective entries in
(k−1)
L (li,k for k < i ≤ n) will be at most one.
Pivoting is a technique to ensure small entries in L by interchanging rows (partial pivoting) or
rows and columns (complete pivoting). With partial pivoting we change two rows (if necessary)
such that the pivot is the largest entry compared to the entries in the same column below
(k−1)
the pivot. With complete pivoting we look for the largest entry in the submatrix Uk:n,k:n and
interchange two rows and two columns such that the pivot is the largest entry in the submatrix.
Both pivot strategies ensure small entries in L and complete pivoting has some minor advantages
with respect to the entries in U .
The main disadvantage of pivoting is that during the LU factorisation we must keep track
of all row and column interchanging. Moreover, if we have a tridiagonal matrix (or any other
sparse matrix) and we apply a pivoting strategy, we will loose the sparseness during the LU
factorisation, causing the need for more memory and computation time. Thus, we would rather
avoid pivoting at all and still have small entries in L. The following lemma will show that
pivoting is not always necessary.
Lemma 4.3. Let A be an n × n-matrix. If AT is diagonally dominant (thus if A is column
diagonally dominant) then A has an LU factorisation and |lij | ≤ 1.
Proof. See Golub and Van Loan (1989, p. 120).
26
where fl denotes that the result of the operation is rounded to the floating point format. For every
floating point operation the following relations hold: fl(a⊗b) = (a⊗b)(1+δ) and fl(a⊗b)(1+δ) =
(a ⊗ b) where |δ| ≤ µ (Forsythe and Moler, 1967, p. 90,97). For the equations in (4.1) this leads
to
b1
ŷ1 = ,
l1,1 (1 + δ1,1 )
−li,i−1 (1 + δi,i−1 )ŷi−1 + bi
ŷi = 0 ) for i = 2, .., n,
li,i (1 + δi,i )(1 + δi,i
0 is the round-off error due to the addition of b and the rest of the numerator. The
where δi,i i
division causes a round-off error which is represented by δi,i . These equations can be rewritten
to the following form
Theorem 4.2. Let L̂Û be the computed factorisation of the n × n tridiagonal floating point
matrix A, where AT is diagonally dominant, ŷ is the computed solution of L̂y = b and x̂ is the
computed solution of Û x = ŷ. Then (A + E)x̂ = b with
and thus
(L̂ + F )(Û + G)x̂ = (L̂Û + F Û + L̂G + F G)x̂ = b.
From Lemma 4.1 we have
n o
L̂Û = A + H with |H| ≤ 2(n − 1)µ |A| + |L̂||Û | + O(µ2 ).
So, by defining
E = H + F Û + L̂G + F G
and taking into account Lemma 4.3 we find (A + E)x̂ = b with
This upper bound will be used in determining an upper bound on the relative error for the
tridiagonal systems later on in this chapter. It cannot be used for iterative methods like the
Gauss-Jacobi scheme discussed in the Section 4.5.
27
4.2 Residue
The relative residue is defined by the ratio of the infinity norms of the residual vector to the
infinity norms of the right-hand side. So, if Ax = b is the matrix equation to be solved and the
residual vector is defined by r := Ax̂ − b, then the relative residue would be
where x̂ is the computed solution vector. Note that a small residue does not imply a small
relative error. However, there is a relation between the residue and the relative error as we will
see later on.
In order to calculate κ∞ (A) we determine kAk∞ and kA−1 k∞ separately. The first matrix norm
is rather easily computed since we have
n
X
kAk∞ = max |aij | ,
1≤i≤n
j=1
but only if the matrix elements are at our disposal. Within Delft3D-FLOW this is the case with
all matrices.
The second matrix norm however is more difficult because we do not know the inverse of
the matrix A. Before we proceed we will give a few definitions and lemmas.
Theorem 4.3. If A is an M -matrix, then kA−1 k∞ is equal to the infinity norm of the solution
y of Ay = d, where d is the all-one vector.
28
Proof. First of all, we note that A−1 exists, because A is an M -matrix. Following the definition
of matrix norms we have:
kA−1 xk∞
kA−1 k∞ = max = max kA−1 xk∞ . (4.2)
x6=0 kxk∞ kxk∞ =1
Because A is an M -matrix it follows that A−1 ≥ 0. This implies that the maximal value of the
right-hand side of (4.2) is assumed when x = (1, 1, ..., 1)T . This corresponds with the infinity
norm of the solution y of Ay = d where d = (1, 1, ..., 1)T .
In order to calculate the norms of the inverse matrices in Delft3D-FLOW we use the matrix
solvers that are already implemented to approach the solution of Ay = d where d = (1, 1, ..., 1)T .
It seems wrong to use the same matrix solvers to analyse their accuracy. However, we are mainly
interested in the order of the condition number rather than the exact figure.
4.4 Accuracy
We consider the relative error (and to some extent the error itself) of a solution to be the
most important quantity in an accuracy analysis. In this section we will construct an upper
bound for the relative error of a matrix equation Ax = b using an LU factorisation. Both the
implicit momentum equation and the continuity equation are solved using an LU factorisation.
Furthermore, we will give a general upper bound which is not dependent on the used matrix
solver. We will use this upper bound for all three matrix equations.
When using an LU factorisation we have observed (see Theorem 4.2) that for the computed
solution x̂ we have (A + E)x̂ = b with
Theorem 4.4. Let A and E be real n×n-matrices and b, f ∈ Rn with b 6= 0 such that
Ax = b,
(A + E)x̂ = b + f
with kEk ≤ δkAk and kf k ≤ δkbk. If δκ(A) = s < 1 then A + E is nonsingular and
kx − x̂k 2δ
≤ κ(A).
kxk 1−s
In our case f = 0 and we define δ := kEk/kAk. Applying Theorem 4.4 results in an upper
bound for the relative error for the implicit momentum equation and the continuity equation:
kx − x̂k 2kEkκ(A)
≤ . (4.3)
kxk kAk − kEkκ(A)
29
Note that we must have kEkκ(A) ≤ kAk. Practically this seems almost always to be the case.
For the explicit momentum equation we do not have an estimate or upper bound for the per-
turbation matrix E. Hence, we will derive a more general upper bound for the relative error in
the following lemma.
Lemma 4.6. Let A be a real n×n matrix, b ∈ Rn a vector and x̂ ∈ Rn the computed solution
of the matrix equation Ax = b. Then we have
kx − x̂k kAx̂ − bk
≤ κ(A) = κ(A)r,
kxk kbk
Proof. Define the residual vector by f := Ax̂ − b. Then the computed solution x̂ is the exact
solution of the matrix equation Ax̂ = b + f . Subtraction of both matrix equations leads to
A(x̂ − x) = f . Now we can write
( ( (
1 1
Ax = b, kbk ≤ kAkkxk, kxk ≤ kAk kbk ,
⇒ ⇒
A(x̂ − x) = f x̂ − x = A−1 f kx̂ − xk ≤ kA−1 kkf k.
kx − x̂k kAx̂ − bk
≤ κ(A) = κ(A)r.
kxk kbk
We can use this result for every numerical method. From the proof of Lemma 4.6 we can easily
derive the following relation.
Corollary 4.1. Let A be a real n×n matrix, b ∈ Rn a vector and x̂ ∈ Rn the computed solution
of the matrix equation Ax = b. Then we have
kx − x̂k
≤ 4µκ(A).
kxk
30
method. The matrix is given in Appendix B. The choice has been made to use a red-black block
Gauss-Jacobi iterative scheme as explained in Section 3.5.
Consider the matrix equation Ax = b with
D1 A12 . . . A1n
A21 D2 A2n
A= . .. .
. . .
. . .
An1 An2 . . . Dn
The matrices Di are not necessarily of the same size, however they are all square. We define
D := diag(D1 , D2 , ..., Dn ) and R := D − A. Now the block Gauss-Jacobi iterative scheme can
be written as
The term red-black refers to the order in which the elements of the vector xi+1 are computed
during step (2) as mentioned in Section 3.5 on page 21.
kAxn − bk
≤ r .
kbk
The main advantage of the original stopping criterion is that it requires little computation time,
especially when compared with the relative residue criterion. It is obvious that we would like to
have a reliable stopping criterion as well as little computation time.
In this respect the rate of convergence is an important property of the iteration process. Suppose
we want to solve a large-banded matrix equation Ax = b by means of an iterative scheme.
This scheme might look like Dxi+1 = Rxi + b with A = D − R. A single iteration satisfies
xi+1 = D−1 Rxi + D−1 b. Subtracting the same expression for the exact solution x leaves us
with x0 as the initial vector. So, the matrix B := D−1 R determines the rate of convergence.
Definition 4.3. Let B be the iteration matrix, B = D−1 R. Then kB i k is called the convergence
factor for i steps and Ri = kB i k1/i is called the average convergence factor (per step for i steps).
(See also Axelsson (1994, p. 163))
31
Usually B is not explicitly available, which makes it difficult to calculate the convergence
factor. It can be shown that the average convergence factor approaches the spectral radius of
the iteration matrix. Thus,
kB i k1/i → ρ(B), i → ∞.
However, also the spectral radius is not easily determined. Therefore we analyse a more easily
calculated quantity, namely the contraction factor, which is defined with the relation
kxi+1 − xi k
ρc (i) = . (4.5)
kxi − xi−1 k
The contraction factor is more or less constant during one iterative process. However, in practice
the first and sometimes the last contraction factor are relatively large, see Figure 4.1. The latter
might be large, because the result of the iteration process is very close to machine precision.
Figure 4.1: Two examples of the variation in the contraction factor during the iterative process.
To formulate an useful stopping criterion we need to know how large the iteration errors will
be. The following theorem will help us with that.
Theorem 4.5. Let B = D−1 R, kBk < 1, and xi be defined by (4.4). Then
kBk
kx − xi k ≤ kx − xi−1 k, i = 1, 2, ...
1 − kBk i
So, the original stopping criterion, kxi −xi−1 k ≤ it , has the following iteration error, if kBk < 1,
kBk
kx − xi k ≤ 1−kBk it .
In practice kBk is usually close to 1, which leads to a much smaller value for it than any
given δ. Also, if it is chosen equal to δ we run the risk of having a large iteration error. The
calculation of kBk is expensive and the exact solution x is unknown. Therefore we will use the
approximation ρc for the convergence factor. The iterative scheme in Delft3D-FLOW calculates
velocities, which are usually O(1) in the main flow direction. Thus we can estimate kxk with 1.
32
For the relative residue stopping criterion, kri k/kbk ≤ r , the iteration error is bounded by
the relation
kx − xi k = kA−1 ri k ≤ kA−1 k · kbk r ,
where ri := Axi − b is the residual vector. If we want a relative error kx − xi k/kxk ≤ δ, then
we have to choose
δkxk
r ≤ = δ/κeff (A).
kA−1 kkbk
So, for every order the effective condition number increases r must be chosen an order smaller.
Hence, a small (effective) condition number is preferred. The computation of kA−1 k is very
expensive, certainly in our case with a large-banded matrix. In a practical sense it is not very
useful to implement such a stopping criterion, unless an educated guess for kA−1 k would be
sufficient.
The original stopping criterion is less reliable because if the contraction factor is close to
one, the criterion might be met sooner than is tolerable. When the contraction factor is small
enough, then the original stopping criterion will suffice. Practically, it shows that for large
simulations (over 105 grid points) the contraction factor might approach one very close. In
these cases a different stopping criterion is desired. We will use the following stopping criterion
if the convergence factor exceeds 0.5:
where ρc is the advancing average contraction factor during an iteration cycle. In practical sense
we do not want the criterion to be such strict that it will never be met due to machine precision.
Therefore we also limit the right-hand side with 10 times the machine precision as a minimum.
In Section 6.8 we will examine the (relative) error, the number of iterations and computation
time for these three stopping criteria.
Of course the first idea is to use double precision (equivalent with sixteen significant digits) for
real values instead of single precision. A practical disadvantage is that the program has to be
adjusted for this. Furthermore, the computation time will increase and memory storage will be
twice as large. Table 4.1 shows that the residues are indeed about a factor 108 smaller. The
relative error is in case of an LU factorisation (continuity equation) proportional to the used
machine precision, but in case of an iterative solver (explicit momentum equation) it depends
on the stopping criterion.
Another possibility is to decrease the condition number κ(A). The test cases show rather
large condition numbers (between 104 and 106 ). One of the most probable causes for this is the
large difference in order between matrix entries on consecutive rows due to the implementation
of the open boundary conditions. While main diagonal entries may be as large as 105 for internal
points of the continuity equation, for open boundary points it is either 1 or −1. Addition of a
very small number to a very large number during elimination may cause very low accuracy. It
would thus be beneficial to have main diagonal entries which are all of the same order.
33
Table 4.1: Order of the relative residue computed in single and double precision for the continuity
equation (a) and the explicit momentum equation (b).
test case version test case version
precision precision
b01 c05 r11 b01 c05 r11
single 10 −6 10 −6 10−7 single 10 −7 10 −4 10−7
double 10 −15 10 −15 10−16 double 10 −9 10 −6 10−7
(a) (b)
The appropriate technique to realise this is called preconditioning, see Golub and Van Loan
(1989, p. 124-126). The idea is to multiply the matrix A (and also the vector b) with a matrix
P . The original matrix equation Ax = b then becomes P Ax = P b. It is obvious that the exact
solution is similar. If the matrix P is chosen close to the inverse of matrix A then the condition
number will decrease fairly much. However, the computation of such a matrix P would cause
round-off errors itself and cost valuable computation time.
One of the most time-efficient preconditioning methods is called row-scaling. Row-scaling
is the technique where every element on the same row including the right-hand side is divided
by a certain value. This value should be chosen such that the largest elements on every row
are of the same order. Thus the largest element on a row would be a suitable choice. Another
option would be to use kaTi k, where aTi is the ith row of A and k · k is an appropriate norm. All
possibilities have in common that the precondition matrix is diagonal.
If the matrix is diagonally dominant, which is the case most of the time for the continuity
equation and the explicit momentum equation in Delft3D-FLOW, then division by the main
diagonal element seems suitable. The precondition matrix is then defined by P −1 = diag(A).
The effect of row-scaling on the condition numbers of the continuity equation is enormous.
Some of the test cases show a decrease by factor 104 , see Table 4.2. The effect on the condition
numbers of both momentum equations is not so drastic, but in all cases they have improved.
Table 4.2: Order of the condition numbers with and without row-scaling for the continuity equation (a)
and the explicit momentum equation (b).
test case version test case version
row-scaling row-scaling
b01 c05 r11 b01 c05 r11
no 104 105 105 no 10 1 1
10 − 10 4 100
yes 101 101 102 yes 10 1 1
10 − 10 4 100
(a) (b)
34
Chapter 5
Stability Analysis
Early tests have shown unstable behaviour for some cases in the sense that results might increase
dramatically in one time step and diminish in the next (possibly due to variable/dependent ma-
trices). Some test cases react disproportionally to small changes in initial and/or boundary
conditions. Stelling (1984) performed a Von Neumann stability analysis on two possible dis-
cretisations of the depth-averaged shallow-water equations. We will repeat this analysis for the
discretisations as they are presently implemented in Delft3D-FLOW.
We start with a short discussion on the stability of the spatially discretised problem. In the
second section the stability analysis for the depth-averaged shallow-water equations is performed
and in the third section for the three-dimensional shallow-water equations. It appears that the
stability for the three-dimensional shallow-water equations is not unconditional.
35
The internal array structure of Delft3D-FLOW is not very suitable to compute the matrix B(w)
in that the three equations are computed in three different subroutines in which the explicit
terms are not stored. So, all the coefficients would have to be written out to file and read back
into memory. This procedure, the construction of the matrix B(w) and the calculation of the
maximal eigenvalue would take too long to carry out for several time steps. Therefore we refrain
from doing so.
It is however more easily done in a partial sense by dividing the matrix B(w) block form,
B11 (w) B12 (w) B13 (w)
B(w) = B21 (w) B22 (w) B23 (w) ,
B31 (w) B32 (w) B33 (w)
and only calculate the maximal eigenvalues for the diagonal blocks B11 (w), B22 (w) and B33 (w).
It appears that these maximal eigenvalues are situated around zero. Although this is not ade-
quate to qualify the discretised problem of the three-dimensional shallow-water equations (5.1)
as stable or unstable, it is not expected that it is unstable, since the time-integration method
is stable provided that the time step is small enough.
36
Note that there are two symbols, S0x and S1x , which represent the second order accurate central
difference schemes for the first derivative with respect to x due to the use of a staggered grid.
Due to the nonlinearity of the terms ∂Hu ∂Hv
∂x and ∂y in the continuity equation (H = d + ζ is not
considered constant at first) they cannot be used as such in the stability analysis. Therefore
they have been subjected to the product rule. For ∂Hu∂x this results in
∂Hu ∂u ∂H ∂u ∂(d¯ + ζ) ∂u ∂ζ
=H +u ≈ H̄ +U = H̄ +U ,
∂x ∂x ∂x ∂x ∂x ∂x ∂x
where in the approximation step the total water depth H in the first term, the advective current
u and the reference water depth d in the second term are considered constant. We will drop the
overbar on H as we have done already in (5.2) and (5.3). Boundary conditions are not taken
into account in a Von Neumann stability analysis.
We will prove unconditional stability for (5.2)-(5.3). Therefore we will look at solutions of
the form p p
ũmn û
p
ṽmn = v̂ p ei(α1 m∆x+α2 n∆y) , (5.5)
p
ζ̃mn ζ̂ p
where α1 , α2 ∈ R. The details of the substitution are given for some terms. Substitution of (5.5)
into U S1x (up ) gives
It is left to the reader to work out the substitutions for the other derivatives. Substitution of
(5.5) into the first equation of (5.2) and division by ei(α1 m∆x+α2 n∆y) leads to
2 p+ 1 i sin( 12 α1 ∆x) p+ 1
2 i sin(α1 ∆x) i sin(α2 ∆y)
û 2 + 1 g ζ̂ 2 = − U− V ûp .
τ 2 ∆x τ ∆x ∆y
37
τ
Substitution of (5.5) into all equations of (5.2) and (5.3) and multiplication by 2 gives
1
Aŵp+ 2 = B ŵp ,
1
(5.6)
C ŵp+1 = Dŵp+ 2
The solution ŵp+1 of (5.6) can now be written as ŵp+1 = Gŵp with G = C −1 DA−1 B, the
amplification matrix. Stability is proven if the largest eigenvalue of G in absolute sense is not
larger than 1. However, it is sufficient to show that kGp k2 is bounded ∀p.
Therefore we rewrite G as:
G = ΛΛ−1 C −1 ΛΛ−1 DΛΛ−1 A−1 ΛΛ−1 BΛΛ−1
= Λ(Λ−1 CΛ)−1 (Λ−1 DΛ)(Λ−1 AΛ)−1 (Λ−1 BΛ)Λ−1
= ΛC̃ −1 D̃Ã−1 B̃Λ−1
p
where Λ = diag(1, 1, H/g). Note that Ã, B̃, C̃ and D̃ are complex symmetric matrices. This
leads to the following relation for kGp k2 :
kGp k2 = kΛ(C̃ −1 D̃Ã−1 B̃)p Λ−1 k2
= kΛC̃ −1 · D̃Ã−1 · (B̃ C̃ −1 D̃Ã−1 )p−1 · B̃Λ−1 k2
≤ kΛC̃ −1 k2 · kD̃Ã−1 kp2 · kB̃ C̃ −1 kp−1
2 · kB̃Λ−1 k2 .
Stability is ensured if kD̃Ã−1 k2 and kB̃ C̃ −1 k2 are not larger than 1. Since both pairs of matrices
are equivalent we will only show that kB̃ C̃ −1 k2 ≤ 1. To prove this we write B̃ and C̃ in the
following partitioned form:
b̃ 0 c̃ 0
B̃ = , C̃ =
0 B̃d 0 C̃d
38
with
Lemma 5.1. Let A be a normal matrix (that means AAH = AH A) then AH A−1 is an unitary
matrix.
From Lemma 5.1 can be derived that C̃dH C̃d−1 is a unitary matrix. Thus
39
5.3 Three-Dimensional Shallow-Water Equations
The stability for the three-dimensional shallow-water equations will be analysed similarly to the
depth-averaged equations. The main difference is that now for every σ-layer separate horizontal
velocities are distinguished. Through the depth-integrated continuity equation ζmn depends on
umnk and vmnk ∀k, therefore umnk and vmnk are taken into account for every k separately. Thus
the system we will analyse in this section will comprise 2K momentum equations (two for every
σ-layer), where K is the number of σ-layers, and one depth-integrated continuity equation.
The continuity equations (3.8d) and (3.11d) are not taken into account, because the relative
vertical velocity ω is calculated “afterwards”. The vertical advective current ω varies in the
vertical direction, so we will model it as ω(k). Furthermore, viscosity will be taken into account,
the horizontal eddy viscosity as a frozen constant νtH and the vertical eddy viscosity, dependent
on the σ-layer, as νtV (k). The Coriolis forces are again neglected. Again the product rule has
been applied to two terms of the continuity equation.
Then the equations for (m, n) read for the first stage
p+ 21 p+ 12 1 νtV (k) p+ 1
St (uk ) + U S1x (upk ) + V S1y (upk ) + ωk
H Sσ (uk ) + g S0x (ζ p+ 2 ) − H2
Sσσ (uk 2 ) =0 ∀k,
p+ 12 p+ 12 p+ 12 ωk p+ 12
St (vk ) + U S+x (vk ) + V S+y (vk )+ H Sσ (vk )
(5.7)
p+ 12 p+ 12 νV p+ 1
+ g S0y (ζ p ) − 2νtH [Sxx (vk ) + Syy (vk )] − Ht2 Sσσ (vk 2 ) = 0 ∀k,
1 p+ 1 1
∆σk S0y (vkp ) + U S1x (ζ p+ 2 ) + V S1y (ζ p ) = 0
X X
St (ζ p+ 2 ) + H ∆σk S0x (uk 2 ) + H
k k
The symbols Sxx an Syy represent second order accurate central difference schemes of the
second derivative with respect to the x and y respectively. The symbols Sσ and Sσσ represent
the discretisations for the vertical advection term and vertical viscosity term respectively. They
are given by
p 2 ∆σk + ∆σk+1 p p ∆σk−1 + ∆σk p p
Sσ (uk ) = (u − uk ) + (u − uk+1 ) ,
∆σk−1 + 2∆σk + ∆σk+1 ∆σk−1 + ∆σk k−1 ∆σk + ∆σk+1 k
40
As done in the previous section we will look at solutions of the form:
p p
ũmn,1 û
ũp û1p
mn,2 2
.. .
..
.
ũp û p
mn,K
K
p p i(α1 m∆x+α2 n∆y)
= ŵp ei(α1 m∆x+α2 n∆y)
ṽmn,1 = v̂1 e
(5.10)
p p
ṽmn,2 v̂2
.. .
.
. .
p p
ṽ mn,K
v̂ K
p
ζ̃mn ζ̂ p
with α1 , α2 ∈ R. The size of the vectors ŵp and matrices A, B, C and D depends on the number
of σ-layers K. For our convenience we will set K to 3, so ŵp ∈ R7 and A, B, C, D ∈ R7×7 .
Substitution of (5.10) into the momentum equation for k = 2 of (5.7) leads to
p+ 21
− ûp2
û2 p p 2ω2 ∆σ2 + ∆σ3 p+ 12 p+ 1
1 + U D̂1x û2 + V D̂1y û2 + (û1 − û2 2 ) +
2τ
H(∆σ1 + 2∆σ2 + ∆σ3 ) ∆σ1 + ∆σ2
V p+ 12 p+ 12 p+ 12 p+ 12
∆σ1 + ∆σ2 p+ 2 1
p+ 1 1 ν (2) û − û2 û − û3
(û2 − û3 2 ) +g D̂0x ζ p+ 2 − t 2 1 1 −1 2 = 0.
∆σ2 + ∆σ3 H 2 (∆σ 1 + ∆σ 2 )∆σ 2 2 (∆σ 2 + ∆σ 3 )∆σ 2
For the top and the bottom layer the vertical viscosity terms and the vertical advective terms are
different as mentioned in Section 3.4. The boundary conditions at the free surface and the bottom
are used within the vertical viscosity terms and for the vertical advective terms upwind schemes
are used instead of central difference schemes. Implementation of these boundary conditions
causes a nonzero right-hand side. We will show that this right-hand side can be ignored in a
Von Neumann stability analysis.
The computed solution ŷ is the exact solution to a slightly perturbed system, namely
(
dŷ
dt − λŷ = g(t), (5.12)
ŷ(0) = y0 + 0 .
When performing a stability analysis we are interested whether the error = ŷ − y vanishes or
explodes. We can now construct an initial value problem for by subtracting (5.11) from (5.12).
This results in (
d
dt − λ = 0, (5.13)
(0) = 0 .
Note that this is only possible for linear differential equations. The system in (5.13) is the
homogeneous version of (5.11).
41
Thus substitution of (5.10) into the momentum equation for k = 1 of (5.7) gives
p+ 12
" p+ 1 p+ 1
#
û1 − ûp1 p p ω1 û1 2 − û2 2 1
where ŵ = [û1 , û2 , û3 , v̂1 , v̂2 , v̂3 , ζ̂]T . The matrices A, B, C and D are given in Appendix C.
Due to the asymmetric nature of these matrices the analogy with the stability analysis of
the depth-averaged shallow-water equations does not carry on. Therefore we will perform the
stability analysis per test case on the computer.
To this end we will set the values for the frozen quantities as best as possible according
to the test case and vary α1 between −π/∆x and π/∆x and α2 between −π/∆y and π/∆y.
For a certain number of pairs (α1 , α2 ) we will calculate the maximal absolute eigenvalue of the
amplification matrix G = C −1 DA−1 B. If any of these eigenvalues exceeds 1, then the problem
is unstable. The result of this analysis for a single problem/test case can be given in a contour
plot. Figure 5.2 shows the stability field of an unstable test case. The test case that was used is
’c02’, see Section 6.3.
It should be noted that in Delft3D-FLOW the vertical viscosity coefficient νtv cannot be set to
a certain value, because it is calculated by means of a turbulence model. So, it remains to be
seen if νtv will ever assume such a low value. However, the stability analysis shows that the time
integration scheme is not unconditionally stable.
42
Chapter 6
Test Cases
Several physical and numerical aspects of a shallow water flow problem (may) influence the
accuracy and stability of the numerical solution. Some of the physical aspects are bed topography
and boundary conditions. Numerical aspects are problem size, vertical σ-layer distribution, time
step, turbulence closure model and drying and flooding and most importantly the solution
algorithm.
In order to investigate their influence on the numerical accuracy and stability we have set
up various test cases. We start with small, simple ones and end with larger, more complex
cases. First we will examine a simple case to test the performance of Delft3D-FLOW in double
precision. The succeeding test cases will highlight influence of one or two aspects on the accuracy
and/or the stability. Finally, we use the eastern part of the Westerschelde as a test case to analyse
adjustments to Delft3D-FLOW on a large and actual case.
We are mainly interested in the accuracy of the result. We analyse the accuracy through calcu-
lation of the error and the relative error. The error is defined by kx − x̂k and the relative error
is defined by
kx − x̂k
. (6.1)
kxk
Furthermore, we distinguish (a) the (relative) error of the solution of a single linear matrix
equation (eg. one iteration of the continuity equation or the explicit momentum equation) and
(b) the (relative) error of the final result after a whole time step.
(a) The error and the relative error are not computable because we do not have the exact
solution x at our disposal. General estimates of these errors are not known, but upper
43
bounds on the relative error are. Small upper bounds guarantee high accuracy, but large
ones do not automatically signify low accuracy. A general upper bound of the relative error
is given in Lemma 4.6:
kx − x̂k kAx̂ − bk
≤ κ(A) = κ(A) r, (6.2)
kxk kbk
where r is the relative residue. This upper bound can be improved if we use the effective
condition number as done in Corollary 4.1 For the LU factorisation (applied on the conti-
nuity equation) of tridiagonal systems another upper bound can be constructed shown in
Equation (4.3):
kx − x̂k 2kEkκ(A)
≤ . (6.3)
kxk kAk − kEkκ(A)
For the continuity equation both upper bounds are computed and the smallest is always
presented. Averagely the upper bound in (6.2) is smaller than the one in (6.3), but usually
not more than a factor 10. Note that the above upper bounds only apply to linear systems.
We remind the reader that the numerical scheme of the continuity equation is in fact
non-linear. It is solved with an iterative scheme of which a single iteration is computed by
means of a LU factorisation (see last part of Section 3.5). The number of iterations is set a
priori to two. The upper bounds of the relative error we calculate are for single iterations.
Since the residues and upper bounds of the two iterations are more or less the same, we
only show results of the first iteration. Due to the non-linearity the matrix of the continuity
equation is updated for the second iteration.
(b) Compared to the results computed in single precision the results of the double precision
computation can be considered exact. So, we can actually calculate estimates for the ab-
solute and the relative error of the results computed in single precision. We will use the
results from the standard output of Delft3D-FLOW. Note that these results do not contain
the results of every half time step and every iteration. In this way we can only analyse the
accuracy of the complete system and not of single matrix equations.
We want to point out that these computed absolute and relative errors may be very poor
estimates, because slightly different matrix equations are solved for single and double pre-
cision due to differences in the solutions of the previous time step.
44
Table 6.1: Acquired accuracy
precision machine precision µ
single 6.0 · 10−8
double 1.1 · 10−16
We will analyse three stopping criteria for the iterative scheme, namely:
original The original stopping criterion: kxn − xn−1 k ≤ it , where it is set to 10−6 in Delft3D-
FLOW.
original with contraction factor If the advancing average contraction factor ρc (see Equa-
tion (4.5) and further) is smaller than 0.5, then the original stopping criterion is used.
Every time it is larger than 0.5 the following criterion must be met:
Delft3D-FLOW
We used version 3.10.10.00 of Delft3D-FLOW. The reason for this is, that it is the latest version
written completely in Fortran 77 code. The Fortran 77 compiler on the Sun-Sparc has the option
to read declarations of ‘reals’ as declarations of ‘doubles’, which is no longer available in the
compilers for Fortran 90. Most likely the SGI has a similar compiler option.
The settings we used in Delft3D-FLOW are included in Appendix E.
For the stability analysis we will use the characteristic numbers: CFL and cell-Péclet. The
cell-Péclet number is defined as
U ∆x
P := H , (6.7)
νt
where U is the characteristic advective current. For the CFL number we distinguish two defini-
tions, one for the velocity and one for the surface waves, respectively
√
Uτ gH τ
CFLU := and CFLζ := . (6.8)
∆x ∆x
45
Table 6.2 shows the difference in order of the relative residue and the relative error. For the
continuity equation this difference is about the same as the difference between single and double
precision. For the explicit momentum equation, however, the difference is much smaller. This is
due to stopping criterion for the Gauss-Jacobi iteration, which is for both machine precisions the
same. Note that when computing in double precision this criterion may be set more strict. The
contraction factor for this iteration is in both cases in the order of 10−3 . With single precision
Table 6.2: Order of the relative residue and the upper bound of the relative error and the number of
iterations for the Gauss-Jacobi iteration of test case 1 for different machine precisions.
continuity equation explicit momentum equation
precision
rel. residue rel. error rel. residue rel. error #iterations
single 10−7 10−7 10 −7 10 −7 2–3
double 10−15 10−15 −8
10 – 10 −11 −8
10 – 10 −11 2–3
this leads to a relative error of at most the order 10−7 with 2 or 3 iterations, but with double
precision the variation in the order of the residue and the relative error is a direct consequence
of the variation in the number of iterations.
If we consider the result computed in double precision as the exact solution, then we can
compute the (cumulative) error for the single precision result by simple subtraction as done in
Figure 6.1. We have repeated this with a smaller grid size (100 m) and a larger grid (6400 grid
points). It is clear that both solutions slowly diverge with respect to each other for 64 as well
as 6400 grid points. Note that this divergent behaviour only applies to problems with closed
Figure 6.1: Absolute error in ζ for single precision. The dotted lines are linear extrapolations.
boundaries (lakes for instance). From extrapolation of the graph in Figure 6.1 we can conclude
that differences in the order of centimetres will occur after 104 time steps for 6400 grid points.
When, however, open boundary conditions are imposed (seas, rivers and estuaries), it is
most likely that this difference does not grow.
The extra computation time for double precision is about 10 to 15 percent for the Sun Sparc.
46
finally, we will look at the differences between several computer architectures, viz. a Sun-Sparc,
an SGI and a PC.
In this test case (WL reference: ‘01-bakje’) a square reservoir (8 km by 8 km) with three
closed boundaries and one open boundary is simulated. A square island is situated in the centre
of the reservoir from which eight thin dams stretch out toward the boundaries, see Figure 6.2.
At the ‘lower’ boundary a tidal condition is defined, namely ζ(t) = 1 + cos(πt/720) with t in
minutes. The original version of this test case has only open boundaries at which homogeneous
boundary conditions (ζ = 0) are imposed except for the lower boundary at which the tidal
condition is defined. We will refer to this later on.
Figure 6.2: Vector field of the depth integrated velocity of test case 2.
The uniform water depth in this test case is 5 m. Along the vertical axis ten equidistant
σ-layers have been defined. The horizontal grid size in both directions is 1 km. Of this test case
several different versions have been simulated. The remaining specifications of these versions
are given in Table 6.3.
Grid refinement leads directly to increment of the problem size, numerically speaking. Grid
refinement has the advantage that it reduces the truncation error, which might be a reason to
carry out the refinement. However, it will have a negative effect on the accuracy of the computed
solution. Figure 6.3a shows a double logarithmic graph of the time-average upper bound for the
relative error of the continuity equation against the problem size, which is in this case the
number of grid points in x-direction multiplied with those in y-direction (thus nmax ×mmax in
Delft3D-FLOW).
If assumed that the relative error of the continuity equation is proportional to Knα , where K
is some constant. Then from Figure 6.3a can be derived that α ≈ 0.91 in case of the continuity
equation, so the upper bound for the relative error depends linearly on the problem size. For the
47
(a) (b)
Figure 6.3: The time-averaged upper bound for the relative error (a) and the time-averaged number of
iterations (b) when increasing the problem size (test case 2).
explicit momentum equation the accuracy remains rather high due to increment of the number
of iterations. For both equations the condition numbers of the matrices are fairly constant for
an increasing problem size. For the continuity equation the condition number is of O(104 ) and
for the explicit momentum equation of O(101 ).
We remind the reader that, besides the determination of an upper bound for the relative
error of the continuity equation, as done above and mentioned in Section 6.1 under (a), we can
also estimate the relative error in ζ as is explained under (b). In Figure 6.4 the relative error in
ζ has been plotted against the problem size.
(a) (b)
Figure 6.4: Time-averaged relative (a) and absolute error (b) in ζ when increasing the problem size (test
case 2).
The upper bound of the relative error (Figure 6.3a) is so large that it does not guarantee
that the calculated result is adequate for practical use. It is wanted that either a stricter upper
bound is constructed or the numerical scheme is improved, for instance through application of
48
a preconditioning method. We will use preconditioning later on in Section 6.7.
A decrease of the time step leads, just like refinement of the grid, to reduction of the
truncation error, but more importantly it increases the elements on the main diagonal of the
matrices. Direct consequences are smaller condition numbers and subsequently smaller upper
bounds on the relative error, see Figure 6.5.
(a) (b)
Figure 6.5: The time-averaged condition number (a) and the upper bound for the time-averaged relative
error (b) when decreasing the size of the time step (test case b01).
One of the problems is the difference in results when they have been computed on different
computer architectures. We have run test case b01 on three different computer machines (Sun
Sparc, SGI and PC). Figure 6.6 shows that the upper bounds for the relative error of the
continuity equation as well as the relative error in ζ are comparable. We see that the relative
error in ζ is only O(10−2 ) to O(10−4 ). The absolute error for a small problem (test case b01)
(a) (b)
Figure 6.6: The upper bounds on the relative error of the continuity equation (a) and the relative error
in ζ for different architectures (test case b01).
increases to millimetres and then slowly drops, see Figure 6.7a. For a larger problem (test case
49
b24) the absolute error increases rapidly to centimetres, then it slowly decreases to O(10−4 )
and remains fairly constant for all architectures. Also for larger problems the differences in error
between several architectures is negligible.
(a) (b)
Figure 6.7: The absolute error in ζ for test case b01 (a) and for test case b24 (b) for different architectures.
The original version of this test case has only Dirichlet boundary conditions on the water level
ζ and consequently Neumann homogeneous boundary conditions on the perpendicular flow ve-
locity component. The boundary conditions on ζ are homogeneous (ζ = 0) except for the ‘lower’
boundary which has a tidal boundary condition on ζ. Due to these unnatural imposed boundary
conditions high flow velocities occur near the corners where the tidal boundary condition change
into homogeneous boundary conditions.
This version shows unstable behaviour (Figure 6.8) when running the simulation with a
small difference (1 mm) in the initial water level. The differences in water level between the
non-perturbed and the perturbed simulation run up to metres. However, in time the simulation
stabilises and the differences drop below the magnitude of the perturbation. It is remarkable to
see that, when computing in double precision, this decrease arises sooner than when computing
in single precision. Also typical is that with a smaller time step the unstable behaviour still
occurs, but stabilises sooner (in simulation time) and quicker than with a larger time step.
Rounding errors seem to interfere with the spin-up time of the simulation. So, a preconditioning
method might lessen this interference, see Section 6.7.
Note that the absolute error in ζ is influenced by the tide. When the tide is high, the error
is a factor two to four higher than for low tide.
0.01, 0.1, 0.09, 0.08, 0.06, 0.05, 0.04, 0.03, 0.02, 0.02, 0.03, 0.04, 0.05, 0.06, 0.08, 0.09, 0.1, 0.01
50
(a) (b)
Figure 6.8: Absolute difference in ζ between a perturbed and an unperturbed problem with a time step
of 10 (a) and 5 minutes (b). The perturbation is 1 mm on the initial water level (‘original’ test case 2).
Compare with Figure 6.27.
for k = 1 to k = 20 respectively. This results in rather peculiar flow data at certain points in
time, see Figure 6.9. The vertical velocity component in this figure is scaled up by a factor of
approximately 1000. As a reference we added Figure 6.10 which shows an example of “normal”
flow data.
Figure 6.9: Cross-section of a peculiar flow profile at a certain time step. (PC Windows, time step 183)
The horizontal grid size is 1 km. The uniform water depth is 10 m. Wind is simulated in
western (left) direction with a constant speed of 10 m/s. Several versions of this test case have
been simulated. In Table 6.4 the specifications of the different versions are given. The time step
is set to 10 minutes.
This test case is used to test the influence of the σ-layer distribution. Furthermore the results
are compared when choosing different turbulence closure models.
We have tested stability for this test case also by disturbing the initial water level with 1
mm. Figure 6.11 shows unstable behaviour for the test case with a non-equidistant σ-layer
51
Figure 6.10: Cross-section of a normal flow profile. (PC Windows, time step 203)
distribution (c05) for single as well as double precision. For the test case with equidistant σ-
layer distribution (c02) a spin-up time of about 3500 minutes (roughly 2 days) is required
depending on the desired accuracy. This clearly shows that the kind of σ-layer distribution
determines the stability of the simulation.
(a) (b)
Figure 6.11: Absolute difference in ζ between a perturbed and an unperturbed problem for test case
c05 (a) and test case c02 (b). The perturbation is 1 mm on the initial water level.
52
Number of σ-layers
Another interesting quantity in this respect is the number of σ-layers. An increase of the number
of σ-layers would produce larger matrices for the explicit momentum equations, so we would
expect larger condition numbers and less accuracy. Remember that the continuity equation is
depth-integrated. So, the number of σ-layers is expected to have little effect on the condition
numbers of the continuity equation.
The Figures 6.12a through 6.13b are constructed with data from the test cases c01, c09,
c10, c02 and c12, all of which have an equidistant layer distribution representing 1, 5, 10, 20
and 50 layers, respectively. From them can be concluded that indeed the residue, the condition
number and the upper bound for the relative error for the continuity equation are constant
with respect to the number of σ-layers (when no row-scaling is applied). However, Figure 6.14a
shows a significant increase in the absolute error in ζ. We will come back to this later.
(a) (b)
Figure 6.12: The time-average relative residue (a) and the time-averaged condition number (b) for an
increasing number of σ-layers (test case 3).
Due to the ADI scheme the explicit momentum equation is being solved alternately in
the x- and y-direction. For this test case we have not averaged the data in both directions,
because they are rather different. From analysis of the data for the x-direction (dashed lines
in Figures 6.12 and 6.13) we conclude that the residue, the condition number and the upper
bound for the relative error increase exponentially with the number of σ-layers. This coincides
with the increase of the absolute error in the flow velocity component v, see Figure 6.14. The
number of iterations is however constant.
The graphs for the explicit momentum equation in y-direction (dotted lines in Figures 6.12
and 6.13) shows rather peculiar data. The flow in y-direction v is almost zero, as is expected
due to the given geometry. The explicit momentum equation is solved by means of an iterative
method with the stopping criterion which implies that in absolute sense the result must be
accurate in O(10−6 ). Thus, if v itself should be of O(10−7 ) for example, then the relative error
for v will explode. This also results in a large residue.
53
(a) (b)
Figure 6.13: The time-averaged upper bound for the relative error (a) and the time-averaged number
of iterations (b) for an increasing number of σ-layers (test case 3).
(a) (b)
Figure 6.14: Time-averaged absolute error in ζ (a) and in the flow velocity in y-direction v (b) for an
increasing number of layers (test case 3).
appear to be in error. Table 6.5 shows the results for these test cases. It is striking to see that,
Table 6.5: Time-averaged data on the explicit momentum equation in y-direction and the absolute error
in the water level ζ and in the flow velocity component v for test case c07 and c08.
explicit momentum equation absolute error
test case relative upper bound number of
ζ v
residue rel. error iterations
c07 10 −3 10 −2 3.3 10−4 10−4
c08 10−6 10−5 5.1 10−2 10−2
for these test cases, with two layers but even more with three layers, more iterations are needed
54
than with one, five or ten layers. Consequently, this results in a lower residue and a lower upper
bound for the relative error. Thus we would expect an improvement in the absolute error for
v, but it has in fact worsened. The absolute error is of O(10−2 ) for test case c08, while for test
case c01 (one layer) and test case c09 (five layers) it is of O(10−6 ) (see Figure 6.14b). Moreover,
even the absolute error in ζ is larger.
We remind the reader that for the criterion (absolute difference in v must be smaller than
−6
10 ) to be met for three σ-layers more iterations in y-direction are needed to solve the explicit
momentum equation in v than for five, ten or twenty σ-layers. This might be induced by a larger
value for v. This seems to be the case as we look at the flow profiles in the Figures 6.15 and
6.16. A regular flow profile is shown in Figure 6.17. Furthermore, the profiles are not similar.
For five layers and more these differences have not occurred.
Figure 6.15: Flow profile for the upper layer of test case c08 (three σ-layers) in single precision on time
step 568.
Figure 6.16: Flow profile for the upper layer of test case c08 (three σ-layers) in double precision on time
step 568.
Figure 6.17: Flow profile for the upper layer of test case c09 (five σ-layers) in single precision on time
step 568.
55
Application of row scaling does not show any improvement (no results shown). Thus both
machine precision and row scaling have no positive effect on the results for the test cases with
two or three σ-layers. This lets us to believe that the discretisations are not adequate or that
another process within the flow computation causes these results. If we simulate the test cases
with the k − L turbulence model instead of the k − turbulence model, the results can be
considered “normal” (see Figure 6.18). Also note that absolute errors when using the k − L
turbulence model are much smaller than with the k − turbulence model. Furthermore, the
dependence of the absolute errors on the number of σ-layers is much smaller.
(a) (b)
Figure 6.18: Time-averaged absolute error in ζ (a) and in the flow velocity in y-direction v (b) for
an increasing number of layers with the k − L turbulence closure model (test case 3). Compare with
Figure 6.14.
56
Figure 6.19: The bed topography of test case n02 (schematised Keeten-Volkerak).
(a) (b)
Figure 6.20: Upper bound for the relative error of the continuity equation (a) and the absolute error in
ζ for the schematised Keeten-Volkerak (test case n02).
Figure 6.21: The navigational channel meanders in the Benqué test case.
57
transition between deep and shallow water. Therefore we will look at different versions of this
test case, see Table 6.6.
Table 6.6: Specifications of the different versions of the Benqué test case.
test case version
specification
n03 n11 n12 n13 n14
navigational depth 13 m 20 m 25 m 30 m 35 m
ratio 1 : 43 1 : 21 1 : 16 1 : 12 1 : 10
A sudden increase in depth between two neighbouring grid points does not influence the
residue or the upper bound for the relative error of the continuity equation very much. Very
steep slopes (larger than 1:10) may cause a lower accuracy in ζ. For the explicit momentum
equation the angle of the slope has little to no effect on the residue, the condition number and
the upper bound for the relative error. These quantities are respectively of O(10−7 ), O(100 )
and O(10−7 ).
Figure 6.22: The time-averaged relative residue and the time-averaged upper bound for the relative
error of the continuity equation (Benqué test case).
58
Table 6.7: Specifications of the different versions of test case 5.
test case version
specification
l02 l52 l03 l04
reservoir size 10 km × 0.5 km 50 km × 0.5 km 100 km × 0.5 km 300 km × 0.5 km
grid size 100 × 5 500 × 5 1000 × 5 3000 × 5
(a) (b)
Figure 6.23: Upper bound for the relative error of the continuity equation (a) and the absolute error in
ζ for the schematised Keeten-Volkerak (test case n02).
Figure 6.24b shows that increasing the number of grid points in one direction up to 3000
causes the absolute error in ζ to increase up to millimetres. For large problems (above 400 grid
points in both directions) the absolute error is also in order of millimetres.
(a) (b)
Figure 6.24: Relative (a) and absolute error (b) in ζ for the Benqué test cases.
59
6.7 Row Scaling
As shown in Section 4.7 row scaling leads to a drastic reduction of the condition number of
the continuity equation. In this section we will analyse the influence of row scaling on two test
cases, viz. the test cases 2 and 3.
Test Case 2
According to Lemma 4.6 the upper bound for the relative error will also reduce (see Figure 6.25a)
so a higher accuracy can be guaranteed. The actual proof for the improvement of the solution
produced with row scaling is the reduction of the relative residue (see Figure 6.25b). However,
(a) (b)
Figure 6.25: The time-averaged upper bound for the relative error (a) and the time-averaged relative
residue (b) of the continuity equation when increasing the problem size for test case b01.
extrapolation of the the dotted line in Figure 6.25a still only ensures a relative error of the
continuity equation between 1% and 10% for problem sizes beyond 105 grid points (and 10
σ-layers). For the explicit momentum equation the improvement is by far not so drastic: the
condition number hardly decreases. This results in equivalent residues and upper bounds for
the relative error if no row scaling is applied.
If we analyse the graph of the relative and absolute error in ζ, when row scaling is applied, we
would expect a reduction with respect to the error, when row scaling is not applied. Figure 6.26
shows, however, otherwise. The errors are comparable to those in Figure 6.4.
In Section 6.3 on page 50 we briefly discussed the original version of this test case which has
open and not closed boundaries. The absolute difference in ζ for this test case was unacceptably
high for a considerable period of the simulation time. This period reduced when decreasing the
time step or compute in double precision. The implementation of row scaling also leads to a
reduction of this time period, especially in the case of single precision computation and a time
step of ten minutes (see Figure 6.27a).
Test Case 3
For test case 3 more or less the same results arise when row scaling is applied. Again the upper
bound on the relative error decreases (see Figure 6.28a), which leads to more accurate results.
This is confirmed by a decrease in the relative residue (see Figure 6.28b). In contrary with
60
(a) (b)
Figure 6.26: The time-averaged relative error (a) and the absolute error (b) in the water level ζ when
increasing the problem size for test case 2. Compare with Figure 6.4.
(a) (b)
Figure 6.27: Absolute difference in ζ between a perturbed and an unperturbed problem with a time
step of 10 (a) and 5 minutes (b). The perturbation is 1 mm on the initial water level and row scaling is
applied. Compare with Figure 6.8c and Figure 6.8a, respectively.
test case 2, also the explicit momentum equation shows considerable improvement due to row
scaling.
But also for this test case the absolute errors in the water level ζ and the flow velocity
component v do not show any improvement if row scaling is applied. Possible reasons for this
are most likely other processes which play a role in the numerical computation. However, if we
choose a different turbulence closure model, the k − L turbulence model instead of the k −
turbulence model, row scaling still does not influence the absolute errors in ζ and v. The results
acquired with the k − L turbulence model has absolute errors for the equations as well as for
the variables ζ and v in O(10−6 ), which is just above the machine precision. So, row scaling (or
any other adjustment for that matter) is naturally not able to improve the accuracy.
61
(a) (b)
Figure 6.28: The time-averaged upper bound (a) and the time-averaged relative residue (b) for an
increasing number of σ-layers when row scaling is applied. Compare with Figures 6.13a and 6.12a,
respectively.
(a) (b)
Figure 6.29: Time-averaged absolute error in ζ (a) and in the flow velocity in y-direction v (b) for an
increasing number of layers when row scaling is applied. Compare with Figure 6.14.
62
Figure 6.30: Time-averaged contraction factor for the explicit momentum equation when increasing the
problem size (test case b01). The dotted line is an extrapolation of the graph.
machine precision and row scaling, seem to have far less influence on the contraction factor.
We have tested the three different stopping criteria mentioned in Section 6.1 on test case
3 with a varying number of equidistant σ-layers. In Figure 6.31 the relative residues for the
explicit momentum equation is plotted for the x as well as the y-direction. We remind the
reader that the residual criterion is met if the residue is smaller 10−4 . This is confirmed by
the graphs. The critical value for the residual criterion is fairly high, but in single precision
not all test cases could converge any further. The other two stopping criteria show comparable
(a) (b)
Figure 6.31: Time-averaged relative residue for the explicit momentum equations in x-direction (a) and
in y-direction for an increasing number of σ-layers and different stopping criteria (test case 3).
residues. The iterative process with original stopping criterion only needs one iteration for the
explicit momentum equation in y-direction, but in combination with the contraction factor at
least two iterations are required. Hence, the difference in Figure 6.31b.
The different stopping criteria have little effect on the absolute error in ζ and v (see Fig-
ure 6.32).
63
(a) (b)
Figure 6.32: Time-averaged absolute error in ζ (a) and in the flow velocity in y-direction v (b) for an
increasing number of layers and different stopping criteria (test case 3).
Table 6.8: Time-averaged data on the continuity equation and the explicit momentum equation for the
Westerschelde test case.
continuity equation explicit momentum equation
precision;
relative condition upper bound relative condition upper bound
row scaling
residue number rel. error residue number rel. error
single; no 10 −7 10 5 10−2 10 −7 10 0 10−7
double; yes 10−16 102 10−14 10−7 100 10−7
64
Figure 6.33: Bed topography of the Westerschelde.
Figure 6.34 shows a large error for both quantities. Furthermore, the absolute error in the
water level corresponds with the frequency of the tidal condition. We have seen this before in
Figure 6.8.
(a) (b)
Figure 6.34: The absolute error in ζ (a) and in the flow velocity in y-direction v (b) for the Westerschelde.
The first 1520 time steps are not shown.
But the tide does not explain the large absolute error in ζ. In Figure 6.35 the absolute error
at a certain time step is plotted for the whole area. It is clear that the large error is very local
and is most likely not due to cumulation of rounding errors. The peaks in the absolute error
occur in very shallow areas (water depth is around 10 cm). This means that only small changes
65
Figure 6.35: The absolute error in ζ for the Westerschelde at time step 3020.
to the water level will cause recession. Further inspection of the ‘right’ high peak in Figure 6.36a
shows that this occurs. The recession and flooding criteria in Delft3D-FLOW are set at certain
water depths (ζ + d). So, small changes in the water level ζ can cause an area to recede or
flood. In our case the water level in grid point (174, 115) remains dry when computed in double
precision, but it is flooded in single precision from a certain point in time.
(a) (b)
Figure 6.36: The water level ζ at grid point (174, 115) (a) and the absolute error in ζ taking into the
water depth (b) for the Westerschelde.
Figure 6.36 shows that the absolute error in ζ in the deeper areas is O(10−3 ).
66
(a) (b)
Figure 6.37: The relative residue (a) and the upper bound for the relative error (b) of the explicit
momentum equation for test case b21.
is the largest. From this we conclude that the use of the k − turbulence model leads to less
accurate results than the other models with the exception of the constant value model.
(a) (b)
Figure 6.38: The absolute error in the water level ζ (a) and the flow velocity component u (b) for test
case b21.
67
6.11 Stability
In Chapter 5 we proved unconditional numerical stability of the two-dimensional shallow-water
equations. The consequence is that small errors in simulations in Delft3D-FLOW with a sin-
gle σ-layer will dim. During the attempt to perform a similar stability analysis on the three-
dimensional shallow-water equations complex matrix equations arose, which complicated the
analytical approach. For that reason the amplification matrix (and its largest eigenvalue) of the
complex equations is computed by means of a Matlab program, see Appendix D.
Early runs showed that for all the two-dimensional cases the largest eigenvalue of the am-
plification matrix is one, affirming the unconditional stability. But for some three-dimensional
cases larger eigenvalues were not uncommon. We will first discuss the input parameters for the
Matlab program and then show how they influence the largest eigenvalue.
The Matlab program uses a linearised version of the three-dimensional shallow-water equations.
So, as opposed to Delft3D-FLOW it also requires input data with respect to the total water
depth, the flow velocity profiles in the vertical for both directions, the relative vertical velocity,
ω, and the vertical eddy viscosity. The latter two need to be given for every layer separately.
The fact that the Matlab program requires more input data than Delft3D-FLOW makes the
program less useful for an a priori stability check of a simulation. However, it does allow us to
check the stability for more unusual situations.
We have used the flow results of test case c05, which shows unstable behaviour in Figure 6.11,
and test case c02 to set up the necessary input data. The resulting largest eigenvalues are 1.0104
and 1.0065, respectively. According to the Matlab program both test cases would be unstable.
It should be noted that the program does not give the answer to the question when a simulation
will be stable or not. Though it can be used as an comparative tool to see, what changes or
differences makes a simulation more stable or just less stable.
We have tested several “unnatural” settings on the Matlab program to gain some insight re-
garding the influence of the input data on the stability.
Flow velocity profiles An uniform horizontal velocity profile in the vertical direction results
in a stable system. The slightest variation in the profile makes it unstable. Furthermore,
a larger horizontal velocity results in a less stable or more unstable system. This can be
compared with the cell-Péclet number, see Equation (6.7). A larger cell-Péclet number
results in a less stable system
Relative vertical velocity The relative vertical velocity ω is set at most in O(10−4 ). If we
neglect the vertical advective term by setting ω = 0, the stability is hardly influenced.
Vertical eddy viscosity Computation of the vertical eddy viscosity can cause inaccurate re-
sults. Setting this parameter to zero in the Matlab program improves the stability. If
we would set both the vertical eddy viscosity and the relative vertical velocity to zero,
then the system would be stable according to the Matlab program. Setting all “verti-
cal” terms to zero actually reduces the three-dimensional shallow-water equations to the
two-dimensional case, of which we already know that it is unconditionally stable.
Number of σ-layers Increasing the number of σ-layers reduces the stability of the program.
From the previous remarks it should be noted that the vertical dimension is the cause of possible
instabilities and unstable behaviour. The vertical eddy viscosity and the vertical profile for the
horizontal velocities are the main contributors to these phenomena.
68
Stabilising the system for the various test cases is of course the next concern. Decreasing the
time step for the test cases c02 and c05 has a positive effect on the stability, but does not
seem to be sufficient, see Table 6.9. When increasing the horizontal eddy viscosity coefficient
sufficiently, a stable system arises according to the analysis. Table 6.9 shows the minimal values
which guarantee stability for three test cases. It appears that values for the cell-Péclet number
between 15 and 25 “guarantee” numerical stability. The Courant numbers do not seem to matter
in this respect.
It can be concluded that the Von Neumann stability analysis does not correspond one on
one with results from Delft3D-FLOW. However, it does confirm for instance that test case c05
is less stable than test case c02. Also an increase in stability is shown when decreasing the time
step or increasing the horizontal eddy viscosity coefficient.
x − x1 = K( 13 ∆x)2 . (6.10)
3 ∆x
x1 − x∆x = 98 K∆x2 ,
3 ∆x
leading to
x1 − x∆x
3 ∆x
K= 8 2
. (6.11)
9 ∆x
Substitution of (6.11) into (6.9) and (6.10) gives the truncation errors.
69
For the test cases b01 and b21 we have calculated the truncation error using the results of
test case b24 as a comparison, see Figure 6.39. It shows that a finer grid hardly contributes to
a more accurate result. We also conclude that for a simulation with 10 σ-layers up to 600 grid
points the truncation error is at best in O(10−3 ).
(a) (b)
Figure 6.39: The maximal (a) and the mean truncation error (b) in the spatial directions for test case
b01 and b21.
70
Chapter 7
Conclusions
In this report we have discussed the complete process from Navier-Stokes equations to the
solution of the three-dimensional shallow-water equations. Residues, condition numbers and
upper bounds for the relative errors of separate matrix equations have been computed as well
as estimates of the absolute and the relative error of final results.
We will first summarise the conclusions from analyses of the test cases which have been
performed without row scaling
Machine Precision
• For a small problem (100 grid points) the results between single and double precision
match very well. However, they do diverge in time (Figure 6.1) for a closed boundary
problem. After 100.000 time steps this difference may be in the order of millimetres.
• The residues and upper bounds for the relative error for double precision is about eight
orders of magnitude smaller.
• The increase in computation time for double precision with respect to single precision on
the Sun-Sparc is on average 13%.
Architecture
• Different computer architectures (Sun-Sparc, SGI, PC-Windows) produce very similar
results in single precision for a simple test case. The accuracy for the different architectures
is also very similar. In both cases the PC produces slightly better results than the Sun-
Sparc and the SGI.
Problem size
• The upper bound on the relative error for a standard test case is too high to guarantee
reliable results. Furthermore, the upper bound increases linearly with the problem size.
• The number of iterations for explicit momentum equation increases linearly with the
number of grid points in x- and y-direction.
• The condition number of the continuity equation does not depend on the problem size.
• The absolute error in the results of Delft3D-FLOW increases slowly with the number of
grid points in the horizontal plane.
71
Layer distribution
• The condition number and the upper bound for the relative error of the continuity equation
are not dependent on the number of σ-layers.
• The condition number and subsequently the upper bound for the relative error of the
explicit momentum equation increase exponentially with the number of σ-layers.
• The absolute error in the results of Delft3D-FLOW range from O(10−6 ) for one σ-layer
to O(10−2 ) for fifty σ-layers.
Bed topography
• Increasing slopes in the bed topography results in a slightly higher condition number and
therefore slightly less accuracy.
Stopping criteria
• The residual stopping criterion may either improve or worsen the relative residue compared
to the original stopping criterion. This is due to the fact that the critical value for the
residual criterion is set too high to ensure improvement of the computed result. This high
critical value is not set higher, because then it is not met for test case due to the limited
machine precision.
• The contraction factors are small enough for nearly all test cases to ensure convergence.
However, for large problem sizes the contraction factor can increase close to one. A small
adjustment, related to the contraction factor, to the original stopping criterion can still
ensure convergence.
Stability
• The numerical scheme implemented in Delft3D-FLOW for the two-dimensional shallow-
water equations is unconditionally stable. The numerical scheme for the three-dimensional
shallow-water equations is not. Stability highly depends on the vertical profile for the
horizontal flow velocities, the vertical eddy viscosity and the relative vertical velocity.
72
Row scaling
• Row scaling has a tremendous effect on the condition number and subsequently on the
upper bound of the relative error of the continuity equation. The difference is, depending
on the problem, between 2 and 5 orders of magnitude. The acquired upper bounds for
the relative errors are in many cases so low that they guarantee small relative errors.
The upper bounds range from O(10−7 ) to O(10−3 ) for the continuity equation and from
O(10−7 ) to O(10−6 ) for the explicit momentum equation.
• The condition number of the continuity equation does depend on the problem size when
row scaling is applied.
73
Chapter 8
Recommendations
With regard to the conclusions in the previous chapter, we recommend the following actions to
be taken or considered.
• The acquired accuracy is not in every case acceptable. Thus measures should be taken.
We strongly suggest to switch over from single to double precision.
• Other stopping criteria for the Gauss-Jacobi iteration are possible. In combination with
the contraction factor the original stopping criterion can still be used. This is a simple
adjustment and the extra computation time is negligible.
• Small rounding errors and high accuracy alone still do not guarantee good results. The
truncation errors are supposedly larger than rounding errors and iteration errors. We
recommend that these truncation errors are estimated and measures should be taken if
they appear to be too large. To this end implementation of higher order numerical schemes,
grid refinement and reduction of the time step are possibilities.
• The most common used k − turbulence model produces in general less accurate results
than the other turbulence models. This ‘problem’ is already known and new ideas (e.g.
k − τ turbulence model) are still developing.
74
Appendix A
Numerical Scheme
The numerical approximations will be given for both stages and if necessary due to the staggered
grid averaged quantities are introduced. At the inner points of the grid each term of the equations
(3.1a-d) is approximated as follows:
∂u
1. Discretisation of at (m+ 12 , n, k)
∂t
1
stage 1: (up+ 2 − up )/ 12 τ
1
stage 2: (up+1 − up+ 2 )/ 12 τ
∂v ∂u
2. Discretisation of at (m, n+ 12 , k) is equivalent to the discretisation of .
∂t ∂t
∂ζ ∂u
3. Discretisation of at (m, n) is equivalent to the discretisation of .
∂t ∂t
∂u
4. Horizontal advection term u at (m+ 12 , n, k)
∂x
p+ 1
stage 1: um+21 ,n (upm+1 1 ,n − upm− 1 ,n )/2∆x
2 2 2
1
p+ p+ 1
u 21 (3u 1 − 4up+11 + up+1 1 )/2∆x,
p+1
if um+21 ,n > 0
m+ ,n m+ ,n m− ,n m−1 ,n
stage 2: p+ 1
2 2
p+
2 2
1
2
In the first stage the derivative is treated in an explicit way and approximated with a central
difference scheme; in the second stage it is approximated with an implicit upwind scheme.
∂v
5. Horizontal advection term v at (m, n+ 12 , k)
∂y
p+ 21 p+ 12 p+ 12
v p
1 (3v 1 − 4v 1 + v )/2∆y, p
if vm,n+ 1 > 0
m,n+ 2 m,n+ 2 m,n− 2 m,n−1 21
stage 1: p+ 21
p+ 21 1
p+ 2
2
p p
v
m,n+ 1
(−3vm,n+ 1 + 4vm,n+1 1 − vm,n+2 1 )/2∆y, if vm,n+ 1 ≤ 0
2 2 2 2 2
p+1 p+ 21 p+ 21
stage 2: vm,n+ 1 (v
m,n+1 1
− vm,n− 1 )/2∆y
2 2 2
In the first stage the derivative is approximated with an implicit upwind scheme; in the
second stage it is treated in an explicit way and approximated with a central difference
scheme.
75
∂u
6. Horizontal advection term v at (m+ 21 , n, k)
∂y
p+ 1
stage 1: v̄m+21 ,n (upm+ 1 ,n+1 − upm+ 1 ,n−1 )/2∆y
21 2 2
p+ 2 p+1 p+1 p+ 1
v̄ 1 (3u 1 − 4u 1
m+ ,n m+ ,n m+ ,n−1
+ up+1
m+ 1 ,n−2
)/2∆y, if v̄m+21 ,n > 0
stage 2: p+ 1
2 2 2 2
p+ 1
2
p+ 21 p+ 21 p+ 12 p+ 12 p+ 12 1
where v̄ m+ 21 ,n
= 14 (vm,n+ 1 + vm+1,n+ 1 + vm,n− 1 + vm+1,n− 1 ), the averaged value for v p+ 2 at
2 2 2 2
(m+ 12 , n, k).
∂v
7. Horizontal advection term u at (m, n+ 21 , k)
∂x
p+ 12 p+ 12 p+ 12
ūp
1 (3v 1 − 4v 1 + v )/2∆x, if ūpm,n+ 1 > 0
m,n+ 2 m,n+ 2 m−1,n+ 2 m−2,n+ 12
stage 1: p+ 12 p+ 12 p+ 12
2
ūp
p
(−3vm,n+ 1 + 4vm+1,n+ 1 − vm+2,n+ 1 )/2∆x, if ūm,n+ 1 ≤ 0
m,n+ 1 2 2 2 2 2
p+ 21 p+ 12
stage 2: ūp+1 1 (v
m,n+ 2 m+1,n+ 12
− vm−1,n+ 1 )/2∆x
2
where ūpm,n+ 1 = 1 p
4 (um+ 1 ,n + upm+ 1 ,n+1 + upm− 1 ,n + upm− 1 ,n+1 ), the averaged value for up at
2 2 2 2 2
(m, n+ 12 , k).
ω ∂u
8. Vertical advection term at (m+ 12 , n, k)
H ∂σ
p p
ω̄kp hk +hk+1 p+ 12 p+ 12 hpk−1 +hpk p+ 1 p+ 1
stage 1: 1 p p 1 p hp +hp
uk−1 − uk + hpk +hpk+1
uk 2 − uk+12
2 hk−1 +hk + 2 hk+1 k−1 k
"
p+ 1 p+ 1 p+ 1 1
#
p+ 1 2 p+ 2
2 hk +hk+12 hk−12 +hk
ω̄k
stage 2: 1 p+ 21 p+ 1 1 p+ 1 p+ 1
up+1
k−1 − up+1
k + p+ 1 p+ 1
up+1
k − up+1
k+1
2 + 1 hp+ 2 hk−12 +hk 2 2 +hk+12
2 hk−1 +hk 2 k+1 hk
where
p
ω̄kp = ω̄m+ 1
,n,k
p
= 14 (ωm,n,k− 1 + ω
p
m,n,k+ 1
p
+ ωm+1,n,k− 1 + ω
p
m+1,n,k+ 1
),
2 2 2 2 2
the averaged value of ω p at (m+ 12 , n, k), and hpm+ 1 ,n,k is defined as ∆σk H̄m+
p
1
,n
with
2 2
p 1 p p
H̄m+ 1
,n
= 2 (ζm,n + ζm+1,n + dm+ 1 ,n− 1 + dm+ 1 ,n+ 1 ),
2 2 2 2 2
∂ζ
10. Barotropic term −g at (m+ 12 , n, k)
∂x
p+ 21 p+ 12
stage 1: −g ζm+1,n − ζm,n /∆x
76
stage 2: the same expression as in the first stage.
Note that in the first stage the expression is implicit and it is explicit in the second stage.
∂ζ
11. Barotropic term −g at (m, n+ 12 , k)
∂y
p p
stage 1: −g ζm,n+1 − ζm,n /∆y
p+1 p+1
stage 2: −g ζm,n+1 − ζm,n /∆y
Note that in the first stage the expression is explicit and it is implicit in the second stage.
2
∂ u ∂2u
H
12. Horizontal viscosity term νt + 2 at (m+ 12 , n, k)
∂x2 ∂y
stage 1: 0
H p+1 p+1
stage 2: 2νt Sxx (um+ 1 ,n ) + Syy (um+ 1 ,n )
2 2
with
Sxx (up+1
m+ 1 ,n
) = (up+1
m− 1 ,n
− 2up+1
m+ 1 ,n
+ up+1
m+1 1 ,n
)/∆x2 ,
2 2 2 2
Syy (up+1
m+ 12 ,n
) = (up+1
m+ 21 ,n−1
− 2up+1
m+ 12 ,n
+ up+1
m+ 12 ,n+1
)/∆y 2 .
In the first stage this term is neglected, while in the second stage it is computed for the whole
time step (thus twice as large).
2
∂2v
H ∂ v
13. Horizontal viscosity term νt + at (m, n+ 12 , k)
∂x2 ∂y 2
H p+ 21 p+ 12
stage 1: 2νt Sxx (vm,n+ 1 ) + Syy (vm,n+ 1 )
2 2
stage 2: 0
1 ∂ V ∂u
14. Vertical viscosity term 2 νt at (m+ 21 , n, k)
H ∂σ ∂σ
"
p+ 1 1 p+ 1 1
#
1 u 2 −up+ 2 u 2 −up+ 2
stage 1: ν V 1 k−1p k p − νk+ V k k+1
hpk k− 2 12 (hk−1 +hk )
1 1 p p
2 2 (hk +hk+1 )
1 V up+1 −u p+1
u p+1
−u p+1
stage 2: νk− 1 k−1 1
k − ν V 1 k 1 k+1 1
p+ 12 p+ 2 p+ 1 k+ 2 1 p+ p+
2 1 h +h 2 hk 2 +hk+12
hk 2 k−1 k 2
The vertical eddy viscosity νtV is calculated or determined through one of the turbulence clo-
sure models. This is done in an explicit way. In both stages only the flow velocity component
is taken implicitly.
1 ∂ V ∂v
15. Vertical viscosity term 2 νt at (m, n+ 12 , k) is discretised in a similar manner as
H ∂σ ∂σ
1 ∂ V ∂u
νt .
H 2 ∂σ ∂σ
16. Coriolis term f v at (m+ 12 , n, k)
p+ 1
stage 1: f v̄m+21 ,n
2
77
stage 2: the same expression as in the first stage.
Note that in the first stage the expression is implicit and it is explicit in the second stage.
stage 2: −f ūp+1
m,n+ 12
Note that in the first stage the expression is explicit and it is implicit in the second stage.
∂HU
18. at (m, n)
∂x
P p+ 12 p+ 21 p+ 21 p+ 12
stage 1: k ∆σk H̄m+ 1 ,n,k um+ 1 ,n,k − H̄m− 1 ,n,k um− 1 ,n,k /∆x
2 2 2 2
∂Hu
20. at (m, n, k)
∂x
p+ 21 p+ 12 p+ 12 p+ 12
stage 1: H̄m+ 1 ,n,k um+ 1 ,n,k − H̄m− 1 ,n,k um− 1 ,n,k /∆x
2 2 2 2
∂ω
22. at (m, n, k)
∂σ
p+ 21 p+ 12
stage 1: ωk− 1 − ωk+ 1 /∆σk
2 2
p+1 p+1
stage 2: ωk− 1 − ωk+ 1 /∆σk
2 2
78
Appendix B
The construction of the matrix of the explicit momentum equation (3.8b) is discussed in Sec-
tion 3.5. Generally, this matrix equation is of the form Av = b, where A ∈ RM N K×M N K is given
on the next page and v ∈ RM N K is the solution vector for the unknown velocity component
v. The vector v is arranged in respectively the vertical and the horizontal (first in y- then in
x-direction) directions.
The submatrix Ti ∈ RK×K is a tridiagonal matrix with the coefficients (if i = (m − 1)N + n)
(jy)
for vm,n,k ∀k. The submatrix Di,i+j ∈ RK×K is a diagonal matrix with the coefficients for
(jx)
vm,n+j,k ∀k with i = (m − 1)N + n and j ∈ {−2, −1, 1, 2}. The submatrix Di,i+j·N ∈ RK×K is a
diagonal matrix with the coefficients for vm+j,n,k ∀k with i = (m−1)N +n and j ∈ {−2, −1, 1, 2}.
Note that D(−2x) , D(−2y) , D(2y) and D(2x) can have zeros on the diagonal due to the second
order upwind schemes.
79
(1y) (2y) (1x) (2x)
T1 D12 D13 Ø ... Ø D1,N +1 Ø ... Ø D1,2N +1 Ø
(−1y) (1y) (2y) (1x) (2x)
D21 T2 D23 D24 Ø ... Ø D2,N +2 Ø ... Ø D2,2N +2 Ø
(−2y) (−1y) (1y) (2y) (1x) (2x) ..
D31 D32 T3 D34 D35 Ø ... Ø D3,N +3 Ø ... Ø D3,2N +3 .
(−2y) (−1y) (1y) (2y) (1x)
..
Ø D42 D43 T4 D45 D46 Ø ... Ø D4,N +4 Ø ... Ø .
.. (−2y) (−1y) (1y) (2y) (1x) ..
. Ø D53 D54 T5 D56 D57 Ø ... Ø D5,N +5 Ø ... .
.. .. .. .. .. .. .. .. .. ..
Ø . . . . . . . . . .
(−1x) (−2y) (−1y) (1y) (2y) 1x
DN +1,1 Ø ... Ø DN +1,N −1 DN +1,N TN +1 DN +1,N +2 DN +1,N +3 Ø ... Ø DN +1,2N +1 Ø
80
(−1x) (−2y) (−1y) (1y) (2y) ..
Ø DN +2,2 Ø ... Ø DN +2,N DN +2,N +1 TN +2 DN +2,N +3 DN +2,N +4 Ø ... Ø .
.. (−1x) (−2y) (−1y) (1y) (2y) ..
. Ø DN +3,3 Ø ... Ø DN +3,N +1 DN +3,N +2 TN +3 DN +3,N +4 DN +3,N +5 Ø ... .
.. .. .. .. .. .. .. .. .. ..
. . . . . . . . . .
Ø
(−2x) (−1x) (−2y) (−1y) (1y) (2y)
D2N +1,1 Ø ... Ø D2N +1,N +1 Ø ... Ø D2N +1,2N −1 D2N +1,2N T2N +1 D2N +1,2N +2 D2N +1,2N +3 Ø
(−2x) (−1x) (−2y) (−1y) (1y) ..
Ø D2N +2,2 Ø ... Ø D2N +2,N +2 Ø ... Ø D2N +2,2N D2N +2,2N +1 T2N +2 D2N +2,2N +3 .
(−2x) (−1x) (−2y) (−1y)
..
Ø D2N +3,3 Ø ... Ø D2N +3,N +3 Ø ... Ø D2N +3,2N +1 D2N +3,2N +2 T2N +3 .
.. .. .. .. .. .. .. .. .. ..
. . . . . . . . . .
Appendix C
with α1 , α2 ∈ R, then for K = 3 (i.e. three σ-layers) the matrix form reads
1
Aŵp+ 2 = B ŵp ,
1
C ŵp+1 = Dŵp+ 2 .
where the vector ŵp = (ûp1 , ûp2 , ûp3 , v̂1p , v̂2p , v̂3p , ζ̂ p )T . These equations represent the system (5.7)-
(5.8), respectively. The matrices A and C contain the coefficients of all the implicit terms for
respectively the first and second stage. The matrices B and D contain those of all the explicit
terms.
Consider the derivatives in vertical direction, Sσ (upk ) and Sσσ (upk ), in (5.9). They are included
in the matrix form as
Sσ (ũpk ) = D̂σl (k) · ûpk−1 + D̂σm (k) · ûpk + D̂σu (k) · ûpk+1 ei(α1 m∆x+α2 n∆y)
and
Sσσ (ũpk ) = D̂σσ
l
(k) · ûpk−1 + D̂σσ
m
(k) · ûpk + D̂σσ
u
(k) · ûpk+1 ei(α1 m∆x+α2 n∆y) ,
turning up in three (two at bottom and surface boundaries) matrix entries. At the end of this
appendix the symbols D̂σl (k), D̂σl (k), etc. are explained. Derivatives in the horizontal direction
81
however are still contained in one matrix entry of, e.g.
with
ν V (1) m ν V (1) u
1+ τ2 ωH1 D̂σm (1)− τ2 tH 2 D̂σσ (1) τ2 ωH1 D̂σu (1)− τ2 tH 2 D̂σσ (1) 0
V V V
τ νt (2) l τ νt (2) m τ νt (2) u
τω l τ ω2 m τ ω2 u
A11 2 H D̂σ (2)− 2 H 2 D̂σσ (2) 1+ 2 H D̂σ (2)− 2 H 2 D̂σσ (2)
= 2 H D̂σ (2)− 2 H 2 D̂σσ (2)
2 ,
V
τ ω3 l τ νt (3) l νtV (3) m
0 2 H D̂σ (3)− 2 H 2 D̂σσ (3) 1+ τ2 ωH3 D̂σm (3)− τ2 H 2 D̂σσ (3)
T
a31 = ( τ2 ∆σ1 H D̂0x , τ τ
2 ∆σ2 H D̂0x , 2 ∆σ3 H D̂0x ) ,
a33 = 1 + τ2 U D̂1x ,
B11 Ø 0T
1− τ2 U D̂1x − τ2 V D̂1y
0 0
B11 = 0 1− τ2 U D̂1x − τ2 V D̂1y 0 ,
τ τ
0 0 1− 2 U D̂1x − 2 V D̂1y
82
b23 = − τ2 g D̂0y · (1, 1, 1)T ,
b33 = 1 − τ2 V D̂1y .
The matrix C which is given below is comparable with/to the matrix A. The ADI scheme is
responsible for the fact that in C the submatrices A11 and A22 are interchanged, because the
discretisations which are used on ûk ∀k in one half time step are exactly the same as the ones
used on v̂k ∀k in the other half time step. So, we have
A22 Ø 0
C = Ø A11 c23 (C.3)
0 T
c32 c33
with
c23 = τ2 g D̂0y · (1, 1, 1)T ,
T
c32 = ( τ2 ∆σ1 H D̂0y , τ τ
2 ∆σ2 H D̂0y , 2 ∆σ3 H D̂0y ) ,
c33 = 1 + τ2 V D̂1y ,
and
I3 Ø d13
D = Ø B11 0 (C.4)
dT31 0 d33
with
d13 = − τ2 g D̂0x · (1, 1, 1)T ,
d33 = 1 − τ2 U D̂1x .
The symbols D̂xx and D̂yy in the horizontal viscosity terms −τ νtH D̂xx and −τ νtH D̂yy represent
second order accurate second derivatives in respectively the x- and y-direction. Thus
The vertical derivatives are represented by D̂σl , D̂σm and D̂σu for the vertical advective terms
l , D̂ m and D̂ u for the vertical viscosity terms. For the top layer (k = 1) the advective
and D̂σσ σσ σσ
terms are represented by
1 1
D̂σm (1) = 1 and D̂σu (1) = − 1 ,
2 (∆σ1 + ∆σ2 ) 2 (∆σ1 + ∆σ2 )
83
and for the other layers by
2 ∆σk + ∆σk+1
D̂σl (k) = · , 0 < k < K,
∆σk−1 + 2∆σk + ∆σk+1 ∆σk−1 + ∆σk
m 2 ∆σk + ∆σk+1 ∆σk−1 + ∆σk
D̂σ (k) = − + , 0 < k < K,
∆σk−1 + 2∆σk + ∆σk+1 ∆σk−1 + ∆σk ∆σk + ∆σk+1
2 ∆σk−1 + ∆σk
D̂σu (k) = − · , 0 < k < K.
∆σk−1 + 2∆σk + ∆σk+1 ∆σk + ∆σk+1
For the top layer (k = 1) the vertical viscosity terms are represented by
m 1 u 1
D̂σσ (1) = − 1 and D̂σσ (1) = 1 ,
2 (∆σ1 + ∆σ2 )∆σ1 2 (∆σ1 + ∆σ2 )∆σ1
l 1 m 1
D̂σσ (K) = 1 and D̂σσ (K) = − 1 ,
2 (∆σK−1 + ∆σK )∆σK 2 (∆σK−1 + ∆σK )∆σK
l 1
D̂σσ (k) = 1 , 0 < k < K,
2 (∆σk−1 + ∆σk )∆σk
!
m 1 1
D̂σσ (k) =− 1 + 1 , 0 < k < K,
2 (∆σk−1 + ∆σk )∆σk 2 (∆σk + ∆σk+1 )∆σk
u 1
D̂σσ (k) = 1 , 0 < k < K.
2 (∆σk + ∆σk+1 )∆σk
84
Appendix D
The stability of the three-dimensional shallow-water equations for various cases has been tested
by means of Matlab. Below follows the listing of the Matlab program. For clarity the comments
in this program are included.
function [lev] = stabilitySWE(deltasigma,H,U,V,omega,nutH,nutV,...
delta_x,delta_y,tau,resolution)
% Stability.m calculates the largest eigenvalue in absolute sense
% of the amplification matrix for the discrete three-dimensional
% shallow-water equations. This is performed using a Von Neumann
% stability analysis (or Fourier analysis).
% A stability field is plotted on the plane where alpha1 varies
% between -pi/delta_x and pi/delta_x. For alpha2 similar bounds
% hold.
%
% SYNTAX: STABILITYSWE(deltasigma, H, U, V, omega, nutH, nutV,...
% nutV, delta_x, delta_y, tau, resolution)
%
% deltasigma is a row containing the vertical layer distribution.
% H is the total water depth in metres.
% U is s row containing the advective horizontal velocities in
% x-direction in metres/second for every sigma-layer.
% V is s row containing the advective horizontal velocities in
% y-direction in metres/second for every sigma-layer.
% omega is vertical velocity in the top layer. omega is zero at the
% bottom. The interpolation is linear.
% nutH is the constant horizontal eddy viscosity in
% metres^2/second.
% nutV is the vertical eddy viscosity in the middle of the depth
% in metres^2/second. nutV is zero at the top and at the bottom.
% The interpolation is done with a sine function.
% tau is the time step in minutes.
% delta_x is the grid size in x-direction in metres.
% delta_y is the grid size in y-direction in metres.
% resolution is an integer determining how many points in x- as
% well as y-direction of the ’stability field’ are going to be
% calculated. Higer resolution means longer calculation time, but
% better restults. Range: 10 (quick and dirty) to 30 (accurate).
%
% OUPUT: [lev] = STABILITYSWE(...);
%
% lev is the largest eigenvalue of the amplification matrix.
85
%
% RESTRICTIONS
%
% This function can only be used with rectilinear grids and con-
% stant horizontal eddy viscosity.
% Salt, pollutants, temperature, flooding and drying and structures
% are not considered.
%
% REMARKS
%
% Boundary conditions are not considered in a Fourier analysis as
% such, because right-hand sides are not necessary for a Fourier
% analysis.
% The values in deltasigma should add up to one.
% deltasigma, U and V should be of the same sizes.
%
% EXAMPLE
%
% deltasigma = 0.1*ones(1,10);
% H = 10;
% U_top = 1.2; U_bottom = 0.5;
% U = (1-log(0.1+0.9*(1-cumsum(deltasigma)))/log(0.1))*(U_top-U_bottom)...
% + U_bottom;
% V = 0.2*ones(size(deltasigma));
% omega = 1e-4; nutH = 1; nutV = 2e-2;
% delta_x = 1000; delta_y = 1000; tau = 5;
% [lev] = STABILITYSWE(deltasigma,H,U,V,omega,nutH,nutV,...
% delta_x,delta_y,tau,20);
% CHECK INPUT
86
error(’ERROR: Resolution is too small! Must be at least 4.’); end;
% INITIALISATION
% --- construct arrays for the vertical eddy viscosity (nutV) and
% the vertical velocity (omega) if more than one layer is
% defined.
if (kmax > 1)
nutV = nutV*sin(cumsum(deltasigma)*pi);
omega = omega*(1 - cumsum(deltasigma)); % linear increase of omega
%omega = omega*sin(cumsum(deltasigma)*pi); % sine curve for omega
else
nutV = 0;
omega = 0;
end;
%
% PRINT DATA TO SCREEN
%
fprintf(’Time step: tau = %5.1f s\n’,tau);
fprintf(’Grid size: Delta_x = %5d m\n’,delta_x);
fprintf(’ Delta_y = %5d m\n’,delta_y);
fprintf(’Water depth: H = %5.2f m\n’,H);
fprintf(’Advective currents: U = %5.2f m/s\n’,U_di);
fprintf(’ V = %5.2f m/s\n’,V_di);
fprintf(’Number of layers: %5d \n’,kmax);
fprintf(’Vertical velocity, eddy viscosity, layer distribution, velocity profiles\n’);
fprintf(’ omega nutV layers U V \n’);
fprintf(’ %12.3e %12.3e %6.4f %6.3f %6.3f \n’,...
[omega; nutV; deltasigma; U; V]);
fprintf(’Viscosity: nutH = %5.2f m^2/s\n\n’,nutH);
fprintf(’ CFL = %5.2f \n’,CFL);
fprintf(’ Resolution = %5d \n\n’,resolution);
%
% MATRIX CONSTRUCTION AND CALCULATION OF LARGEST EIGENVALUE OF G
%
% --- define index ranges
indexrange = [0:resolution];
range1 = 2*pi/(delta_x)*(indexrange/resolution-0.5);
range2 = 2*pi/(delta_y)*(indexrange/resolution-0.5);
% --- initialise matrices
p = 2*kmax+1;
87
A = zeros(p);
B = A; C = A; D = A;
for index1=indexrange
alpha1 = range1(index1+1);
for index2=indexrange
alpha2 = range2(index2+1);
88
B(k,k) = 2/tau - U(k)*D_1x - V(k)*D_1y;
D(k,k) = 2/tau;
D(k,p) = -g*D_0x;
D(p,k) = -deltasigma(k)*H*D_0x;
end;
for k=kmax+1:2*kmax
A(k,k) = 2/tau + U(k-kmax)*D_ux(k-kmax) +...
V(k-kmax)*D_uy(k-kmax) + D_mds(k-kmax) - 2*nutH*(D_xx+D_yy);
if (k>kmax+1) A(k,k-1) = D_lds(k-kmax); end;
if (k<2*kmax) A(k,k+1) = D_uds(k-kmax); end;
B(k,k) = 2/tau;
B(k,p) = -g*D_0y;
B(p,k) = -deltasigma(k-kmax)*H*D_0y;
A = tau/2*A;
B = tau/2*B;
C = tau/2*C;
D = tau/2*D;
G = (inv(C)*D)*(inv(A)*B);
end;
end;
89
colormap([0 0 0]);
set(gca, ’fontsize’,16,’fontname’,’Times New Roman’);
title(strcat(’Stability Field. LEV=’,num2str(lev,9)));
clabel(c,h,’fontsize’,14,’labelspacing’,300);
xlabel(’\alpha_1’,’fontsize’,16,’fontname’,’Times New Roman’);
ylabel(’\alpha_2’,’fontsize’,16,’fontname’,’Times New Roman’);
set(gcf, ’position’, [1 29 1152 768]);
90
Appendix E
Settings in Delft3D-FLOW
Physical parameters
The geometry is different for every test case. The domain and boundary conditions are treated
in the text. The initial conditions on the flow velocity components is hard-coded set to zero.
The water level on simulation start must be given by the user. In our test cases this is always
an uniform condition. Furthermore, we have used, unless mentioned otherwise:
• a horizontal eddy viscosity of 1 m2 /s,
• the k − turbulence model with no background value,
• the Chezy bottom roughness formula specified by a constant (65 in both directions),
• no partial slip conditions.
Table E.1 shows the values of the relevant physical constants.
Numerical parameters
For the time step several values have been used. They are mentioned in the text. By default the
maximum criterion has been used for the drying and flooding mechanism. The threshold depth
is set at 0.10 m.
91
Output parameters
By default we let Delft3D-FLOW write out all calculated variables for every time step.
92
Bibliography
AIAA, Guide for the verification and validation of computational fluid dynamics simulations,
AIAA Guide G-077-1998 (Reston, VA, 1998).
Bijvelds, M., Numerical modelling of estuarine flow over steep topography, Ph.D. thesis, Delft
University of Technology (Delft, 2001).
Forsythe, G.E. and Moler, C.B., Computer Solution of Linear Algebraic Systems (Englewood
Cliffs, NJ: Prentice-Hall, 1967).
Golub, G.H. and Van Loan, C.F., Matrix Computations, 2nd edn. (Baltimore: John Hopkins,
1989).
Jin, X.-Y., Quasi-three-dimensional numerical modelling of flow and dispersion in shallow water ,
Ph.D. thesis, Delft University of Technology (Delft, 1993).
Kester, J.A.Th.M. van and Stelling, G.S., ’Versnellen van TRISULA-3D’, Delft Hydraulics Re-
port Z81, WL | Delft Hydraulics (1992).
Launder, B.E. and Spalding, D., Lectures in mathematical models of turbulence (New York:
Academic Press, 1972).
Mitchell, A.R. and Griffiths, D.F., The Finite Difference Method in Partial Differential Equa-
tions, pp. 59–70, 148–154 (New York: John Wiley, 1980).
Oberkampf, W.L. and Blottner, F.G., ’Issues in computational fluid dynamics code verification
and validation’, AIAA Journal , vol. 36, 687–695 (1998).
Phillips, N.G., ’A coordinate system having some special advantages for numerical forecasting’,
Journal of Meteorology, vol. 14, 184–185 (1957).
Rodi, W., ’Calculation of stably stratified shear-layer flows with a buoyancy-extended k- tur-
bulence model’, in Hunt, J.C.R. ed., Turbulence and diffusion in stable environments, pp.
111–140 (Oxford: Clarendon, 1985).
Stelling, G.S., On the construction of computational methods for shallow water flow problems,
Ph.D. thesis, Delft University of Technology (Delft, 1984).
Uittenbogaard, R.E., Van Kester, J.A.Th.M. and Stelling, G.S., ’Implementation of three tur-
bulence models in TRISULA for rectangular horizontal grids’, Delft Hydraulics Report Z162,
WL | Delft Hydraulics (Delft, 1992).
93
Wesseling, P., Principles of Computational Fluid Dynamics, Springer Series in Computational
Mathematics, Vol.29 (Heidelberg: Springer, 2000).
94