PDEsNumerics 2 Student
PDEsNumerics 2 Student
PDEsNumerics 2 Student
October 4, 2018
Timetable
Week Chapters to read Videos to watch Class Assignment Deadline Prop-
before class before class Date ortion
2 1-3 1-4 Wed 10 Oct Code review 24 Oct 5%
Introduction and linear advection schemes
3 4-5 5.0-5.4, 6.0-6.1 Wed 17 Oct Draft report 7 Nov 5%
Analysis of Linear Advection Schemes and dispersion for feedback
6 6-7 7.0-7.5, 8.0-8.5 Wed 7 Nov Final 21 Nov 15%
More Advection Schemes and Wave equations code
7 Wed 14 Nov Final report 28 Nov 25%
2
Further Resources (Not essential reading)
Python
• “A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences” by
Johnny Wei-Bing Lin. http://www.johnny-lin.com/pyintro
• “Think Python. How to Think Like a Computer Scientist” by Allen B. Downey.
http://www.greenteapress.com/thinkpython/thinkpython.html
• http://www.python.org
• http://docs.python.org/tutorial/
• http://matplotlib.sourceforge.net/users/index.html
• http://software-carpentry.org/
• http://www.diveintopython.net/
• http://learnpythonthehardway.org/
• http://www.ibiblio.org/g2swap/byteofpython/read/
• “Making Use of Phython” by Rashi Gupta
• “Python Essential Reference” by David M. Beazley (Addison Wesley)
• “Learning Python” Mark Lutz (O’Reilly Media)
Numerical Methods
• Weller, H. Draft of chapter for “Mathematics for Planet Earth, a Primer”
http://www.met.reading.ac.uk/~sws02hs/teaching/
PDEsNumerics/WellerPrimer.pdf
• Wikipedia http://en.wikipedia.org
• Durran, D. R. Numerical methods for fluid dynamics (Springer).
3
4
Contents
1 The Navier Stokes Equations 10
1.1 The Potential Temperature Equation . . . . . . . . . . . . . . . . . . . . . . 11
1.2 Advection of Pollution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.1 Pure Linear Advection . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.2.2 Advection/Diffusion with Sources and Sinks . . . . . . . . . . . . . 13
1.3 The Momentum Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.1 Coriolis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.2 The Pressure Gradient Force . . . . . . . . . . . . . . . . . . . . . . 15
1.3.3 Gravitational Acceleration: A simulation of a dam break . . . . . . . 19
1.3.4 Diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.5 The Complete Navier Stokes Equations . . . . . . . . . . . . . . . . 22
3 Fourier Analysis 32
3.1 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.2 Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.3 Discrete Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5
8
Numerical Modelling of the Atmosphere and Ocean
Weather, ocean and climate forecasts predict the winds, temperature and pressure from the
Navier-Stokes equations:
10
1.1 The Potential Temperature Equation
Dθ ∂θ
= + u · ∇θ = Q + µθ ∇2 θ
Dt ∂t
Lagrangian Rate of change Advection Heat Diffusion
derivative at fixed point of θ source of θ
11
12
1.2.2 Advection/Diffusion with Sources and Sinks
DΨ ∂Ψ
= + u · ∇Ψ = S + µΨ ∇2 Ψ
Dt ∂t
Lagrangian Rate of change Advection Sources Diffusion
derivative at fixed point of Ψ and sinks of Ψ
13
1.3.1 Coriolis
Inertial Oscillations governed by part of the momentum equation:
∂u
Ω×u
= -2Ω
∂t
14
1.3.2 The Pressure Gradient Force
15
16
Geostrophic Balance: Pressure Gradients versus Coriolis
17
18
1.3.3 Gravitational Acceleration: A simulation of a dam break
19
20
1.3.4 Diffusion
Diffusion of quantity φ with diffusion Diffusion of a noisy profile
coefficient µφ in arbitrary spatial (zero gradient boundary conditions)
dimensions
0.7
∂φ
= µφ ∇2 φ 0.6
∂t
0.5
And in 1d:
0.4
∂φ ∂ 2φ
= µφ 2
φ
∂t ∂x 0.3
Discussion Questions:
• Which equations have a diffusion
coefficient?
• What causes diffusion?
• Is diffusion a large term of the equations
of atmospheric motion?
21
22
Chapter 2: Linear Finite Difference Schemes for Advection
In one spatial dimension, x, with constant wind, u, no diffusion and no sources or sinks, the
linear advection equation (eqn 1.1) for φ reduces to:
∂φ ∂φ
+u =0 or φt + uφx = 0 (2.1)
∂t ∂x
This equation has an analytic solution. If the initial condition is φ (x, 0) then the solution at
time t is φ (x,t) = φ (x − ut, 0).
Exercise:
Check that this is the analytic solution.
∂X ∂X ∂φ ∂φ ∂X
(Hint: define X = x − ut, calculate and and use the chain rule, = )
∂x ∂t ∂x ∂X ∂x
23
24
Questions
• Why did we go forwards in time?
(n+1)
In order to be able to re-arrange in order to create an equation for φ j based on values
that are all known from the previous time-step.
• Why did we go backwards in space? We will come back to this
• What order accuracy is FTBS in space and time? (ie, what is the order, n, such that the
error of the approximation is proportional to ∆xn or ∆t n )
• What influence will the errors have on the solution?...
25
φ j − φ j−1 ∆x 00
φ j0 = + φ j + O ∆x2 .
∆x 2
∆x 00
• The leading error term is φ . This tells us two things:
2
– The error is proportional to ∆x1 so the spatial derivative approximation is first-order
accurate.
– The error behaves like φ 00 which is the spatial term from the diffusion equation. Adding
this error to the advection equation makes the equation diffusive.
You will be writing code to solve the linear advection equation using FTBS in the
assignment. Is the solution diffusive in comparison to the analytic solution? Is the error
proportional to ∆x?
26
2.2 Centred in Time, Centred in Space (CTCS) and FTCS
∂φ ∂φ
To solve +u = 0 numerically:
∂t ∂x φ φ j−1 φ j
• Approximate ∂ φ /∂t at x j , tn by a centred φ j+1
(n−1) (n+1)
difference, using φ j and φ j :
(n) (n+1) (n−1)
∂φj φj −φj
=
∂t 2∆t
• Approximate ∂ φ /∂ x at x j , tn by a centred
(n)
∂φj
(n)
φ j+1 − φ j−1n x0 x1 x1 x j−1 x j x j+1 x
difference: = ∆x
∂x 2∆x
(n+1)
• Substituting these into eqn (2.1) and re-arrange to get φ j on the LHS and all other
terms on the RHS and substituting in the Courant number, c = u∆t/∆x gives CTCS:
(n+1) (n−1) (n) (n)
φj = φj − c φ j+1 − φ j−1 (2.4)
• This is a three-time-level formula (it involves values of φ at times tn−1 , tn and tn+1 . To
start the simulation, values of φ are needed at times t0 and t1 . However, only φ (x,t0 ) is
available. So another scheme (such as FTCS) must be used to obtain φ (1) = φ (x,t1 ):
(n+1) (n) c (n) (n)
FTCS: φ j = φ j − φ j+1 − φ j−1 (2.5)
2
27
28
2.3 Implicit and Explicit Schemes
Explicit Values at the next time-step are determined from values at the current (and previous)
time-steps. Straightforward.
Implicit Values at the next time-step are determined from values at the next time step!
• This leads to a set of simultaneous equations
• How do we solve a set of linear simultaneous equations?
- create a matrix equation and then solve using, eg Gaussian elimination
• How do we solve a set of non-linear simultaneous equations?
- multi-dimensional generalisation of Newton-Raphson method - hard and
expensive
• Easier to solve a linear equation implicitly rather than a non-linear equations
• Why would we want to use an implicit method at all?...
29
30
• Will these advection schemes approximate the continuous PDE given sufficient
resolution?
• Will we be able to take large time-steps?
31
0.0
0.5
32
Sum of First 4 Fourier Modes of a Periodic Function
1.0
Fourier Modes Original function
4 Sum of first 4 Fourier modes
0.5
2
0.0 0
2
0.5
4
1.0−π −π/2 π/2 π −π −π/2 π/2 π
0 0
x x
33
Exercise
Evaluate the Ak s in terms of the ak s and bk s.
35
36
Exercise
Check the formulae in equations (3.3) and (3.4) by defining your own function, f , at 2N + 1
equally space points in [0, 2π). Use these function values to calculate the Fourier
coefficients from equation (3.3) then plug them back into equation (3.4) to check that you
retrieve the same function values at the original points. Please contact me if you have
problems as there could be errors in equations (3.3) and (3.4).
37
what are:
(a) the Fourier coefficients (the ak and the bk )
(b) the Fourier modes (the sines and cosines)
(c) the wavenumbers (or frequencies) (the ks)
(d) the power of a given wavenumber (a2k + b2k )
2. How would you describe the operation:
Z π Z π
1 1
ak = f (x) cos(kx)dx , bk = f (x) sin(kx)dx
π −π π −π
(a Fourier transform)
3. Given a list of 2N + 1 equally spaced samples of a real valued, periodic function, fn , how
would you describe the following operation to convert this into a list of N + 1 values:
1 N
Ak = ∑ fn e−iπknx/N
N n=−N
(a discrete Fourier transform)
4. What is the wavelength of a wave described by sin 4x (2π/4)
39
30
• very smooth (only low
20
wavenumbers included)
10
• includes negative values
0
– “spectral ringing”
0 5 10 15 20
years
10-1
Observations
10-2
• dominant frequency at one year
power
10-3
10-4
(annual cycle)
10-5 • power at high frequencies (ie
10-6
daily variability)
10-1 100 101 102
Number per year
40
Time Series of the Nino 3 sea surface temperature (SST)
The SST in the Nino 3 region of the equatorial Pacific is a diagnostic of El Nino
30
raw
lines generated?
28
• Annual cycle is the
Fourier mode at 1 year
SST (deg C)
27
0.1
0.0001
varies slowly)
1e−05
• Power at 1-10 years (El Nino every 3-7
1e−06 years)
0.01 0.1 1 10
Frequency (per year)
41
10
-10
-20
-30
1950 1960 1970 1980 1990 2000 2010
... Fourier decompositions will be used to mathematically analyse the behaviour of the
numerical schemes...
42
Chapter 4: Numerical Analysis of Advection Schemes
4.1 Introduction: What is Numerical Analysis and why is it done
• Numerical analysis involves mathematically analysing numerical methods in order to
predict how they will behave when they are used.
• Numerical analysis is important because
– Model development by trial and error is very time consuming
– We cannot test our models for every possible situation. We need evidence that they will
work for all situations
– We gain insight into how numerical methods work and so how to design better ones
• This chapter describes various types of analysis that are done for advection schemes for
atmospheric models
43
44
Based on your knowledge of FTCS and based on the numerical solutions below, which of
properties 2-7 apply to the numerical solution of the linear advection equation using FTCS?
1.4 1.4
Initial conditions, mean = 0.5 Exact, mean = 0.5
1.2 1.2 Numerical after 20 time steps, mean = 0.5
1.0 1.0
0.8 0.8
0.6 0.6
φ
φ
0.4 0.4
0.2 0.2
0.0 0.0
0.20.0 0.2 0.4 0.6 0.8 1.0 0.20.0 0.2 0.4 0.6 0.8 1.0
x x
1.4 1.4
Exact, mean = 0.5 Exact, mean = 0.5
1.2 Numerical after 40 time steps, mean = 0.5 1.2 Numerical after 60 time steps, mean = 0.5
1.0 1.0
0.8 0.8
0.6 0.6
φ
0.4 0.4
0.2 0.2
0.0 0.0
0.20.0 0.2 0.4 0.6 0.8 1.0 0.20.0 0.2 0.4 0.6 0.8 1.0
x x
Consistent Yes Order of Accuracy 1st Stable No
Conservative Yes Bounded No Monotone No
45
How about when modifying all out of range values to be one or zero at every time-step?
1.4 1.4
Initial conditions, mean = 0.5 Exact, mean = 0.5
1.2 1.2 Numerical after 20 time steps, mean = 0.497688501049
1.0 1.0
0.8 0.8
0.6 0.6
φ
0.4 0.4
0.2 0.2
0.0 0.0
0.20.0 0.2 0.4 0.6 0.8 1.0 0.20.0 0.2 0.4 0.6 0.8 1.0
x x
1.4 1.4
Exact, mean = 0.5 Exact, mean = 0.5
1.2 Numerical after 40 time steps, mean = 0.497563296064 1.2 Numerical after 60 time steps, mean = 0.498957455923
1.0 1.0
0.8 0.8
0.6 0.6
φ
0.4 0.4
0.2 0.2
0.0 0.0
0.20.0 0.2 0.4 0.6 0.8 1.0 0.20.0 0.2 0.4 0.6 0.8 1.0
x x
Consistent Probably Order of Accuracy ? Stable Yes
Conservative No Bounded Yes Monotone No
46
4.3 Convergence and errors
If an analytic solution, f (x,t), to a PDE is known, then errors of a numerical solution,
φ (x,t), can be calculated as functions of space and time. Errors over space can be
summarised by integrating over space to calculate error norms:
∑ j ∆x|φ j − f (x j ) |
`1 (φ ) =
∑ j ∆x| f (x j ) |
q
2
∑ j ∆x (φ j − f (x j ))
`2 (φ ) = q
2
∑ j ∆x f (x j )
max |φ j − f (x j ) |
`∞ (φ ) = .
max | f (x j ) |
If a numerical scheme is described as nth order accurate, then these error metrics should
converge to zero at a rate proportional to ∆xn :
`i ∝ ∆xn .
47
48
4.5 Domain of Dependence
The domain of dependence of the solution of a PDE at position x and at time t is the set of
points at a previous time that influence the solution at position x and at time t.
Let us consider the 1D linear advection equation for dependent variable φ and advecting
velocity u:
φt + uφx = 0
0
0 2 4 6 8 10 12 x
49
n+1
n−1
n−2
x
j−3 j−2 j−1 j j+1
The numerical domain of dependence contains the physical domain of dependence when
0 ≤ c ≤ 1 so FTBS is unstable for c > 1 and c < 0. But we cannot say if FTBS is ever stable.
50
4.5.3 The Domain of Dependence of the CTCS Scheme
(n+1)
Draw the domain of dependence of φ j for CTCS.
t
n+1
n−1
n−2
x
j−3 j−2 j−1 j j+1
51
52
4.6.1 Von-Neumann Stability Analysis of FTBS
FTBS for linear advection is:
(n+1) (n) (n) (n)
φj = φ j − c φ j − φ j−1 (4.2)
= An eik j∆x :
(n)
Substitute in φ j
An+1 eik j∆x = An eik j∆x − cAn (eik j∆x − eik( j−1)∆x ) (4.3)
Cancel powers of An eik j∆x and rearrange to find A in terms of c and k∆x:
A = 1 − c(1 − e−ik∆x ) (4.4)
We need to find the magnitude of A so we need to write it down in real and imaginary form.
So substitute e−ik∆x = cos k∆x − i sin k∆x:
A = 1 − c(1 − cos k∆x) − ic sin k∆x (4.5)
and calculate |A|2 = AA∗ (A multiplied by its complex conjugate):
|A|2 = 1 − 2c(1 − cos k∆x) + c2 (1 − 2 cos k∆x + cos2 k∆x) + c2 sin2 k∆x
=⇒ |A|2 = 1 − 2c(1 − c)(1 − cos k∆x)
We need to find for what value of ∆t or c is |A| ≤ 1 in order to find when FTBS is stable:
|A| ≤ 1 ⇐⇒ |A|2 − 1 ≤ 0
⇐⇒ −2c(1 − c)(1 − cos k∆x) ≤ 0
⇐⇒ c(1 − c)(1 − cos k∆x) ≥ 0
53
We know that 1 − cos k∆x ≥ 0 for all k∆x so FTBS is stable when
c(1 − c) ≥ 0 ⇐⇒ 0 ≤ c ≤ 1.
u∆t
We have proved that FTBS is unstable if u < 0 or if > 1. We will now define:
∆x
Upwind scheme FTBS when u ≥ 0
FTFS when u < 0
The upwind scheme is first order accurate in space and time, conditionally stable and
damping.
4.6.2 What should A be for real linear advection?
For initial conditions consisting of a single Fourier mode: φ (x, 0) = Ak eikx , the solution at
time t is:
φ (x,t) = Ak eik(x−ut) .
This can be represented as a factor times eikx :
φ (x,t) = Ak e−ikut eikx
So if t = n∆t we have An = e−ikut = e−ikun∆t . Therefore A = e−iku∆t which has |A| = 1 and
so, under the influence of the linear advection equation, waves should not amplify or decay.
54
4.6.3 Von Neumann Stability Analysis of CTCS
The amplification factor, A, is found by substituting φ j = An eik j∆x into the equation for
(n)
CTCS:
(n+1) (n−1) (n) (n)
φj = φj − c φ j+1 − φ j−1 . (4.6)
This gives:
An+1 eik j∆x − An−1 eik j∆x + c(An eik( j+1)∆x − An eik( j−1)∆x ) = 0
=⇒ A2 + (2ic sin k∆x)A − 1 = 0
p
=⇒ A = −ic sin k∆x ± 1 − c2 sin2 k∆x
There are two cases to consider:
(i) |c| ≤ 1 =⇒ c2 sin2 k∆x ≤ 1
=⇒ |A|2 = 1 − c2 sin2 k∆x + c2 sin2 k∆x = 1
=⇒ The solution is stable and not damping
(ii) |c| > 1 =⇒ c2 sin2 k∆x > 1 for some k∆x
p
=⇒ |A|2 = (c sin k∆x ± c2 sin2 k∆x − 1)2
=⇒ At least one of the roots has |A| > 1. The solution is unstable
So CTCS is conditionally stable: it is stable for |c| ≤ 1
Regardless of c, there are always two possible values of A. This means that there will always
be two possible solutions; a realistic solution (the physical mode) and the un-realistic,
oscilating solution; the spurious computational mode. This will contaminate the solution
and behave in an un-realistic way.
55
4.7 Conservation
For a property, φ , advected with velocity, u: (φt + uφx = 0) we can show that the total mass
of φ is conserved. Define the total mass to be
Z 1
M= φ dx
0
and assume that φ has periodic boundary conditions so that φ (0,t) = φ (1,t) ∀t. Then:
Z 1 Z1 Z 1 Z 1
dM d dφ dφ
= φ dx = dx = − u dx = −u dφ = −u [φ ]10 = 0.
dt dt 0 0 dt 0 dx 0
since φ (0,t) = φ (1,t). Therefore M is conserved.
Is M conserved by a numerical scheme? Consider FTBS advection:
(n+1) (n) (n) (n)
φj = φ j − c φ j − φ j−1 .
56
4.7.1 Conservation of higher moments
We can show that the variance of φ is also conserved under linear advection. The variance is:
Z 1
V= φ 2 dx − M 2 .
0
Then we can calculate the rate of change of variance under linear advection, assuming that
Mt = 0:
Z 1 Z 1 Z 1 Z 1
dV dφ 2 dφ dφ 1
= dx = 2φ dx = − 2φ u dx = −2u φ dφ = −u φ 2 0 = 0.
dt 0 dt 0 dt 0 dx 0
Is V conserved by a numerical scheme? Consider FTBS advection:
(n+1) (n) (n) (n)
φj = φ j − c φ j − φ j−1 .
From this we can calculate V (n+1) as a function of V (n) (ignoring M for brevity):
nx nx
(n+1) 2 (n) 2
V (n+1) = ∑ ∆x φ j = ∆x ∑ φ j − c φ j − φ j−1
(n) (n)
j=1 j=1
nx nx nx nx
(n) 2 (n) 2
= ∆x ∑ φ j − 2c∆x ∑ φ j φ j + 2c∆x ∑ φ j φ j−1 + c2 ∆x ∑ φ j − φ j−1
(n) (n) (n) (n) (n)
j=1
The term multiplying 2c(1 − c) is always greater than zero and so the variance always
decreases when using FTBS.
57
58
Chapter 5: Waves, Dispersion and Dispersion Errors
Inaccurate dispersion of numerical methods is a common source of errors. Therefore we will
learn about dispersion and dispersion errors of numerical methods.
5.1 Some Background on Waves
A travelling wave can be described by the equation
60
How do variations in k and ω influence the wave and its propagation according to the
equation
y = a sin (kx − ωt)
Exercise:
Write down an expression for the wave length, λ , and the wave speed, u in terms of k and ω
λ = 2π/k, u = ω/k
61
5.2 Dispersion
Dispersion occurs when waves of different frequencies propagate at different speeds.
ω1 ω2
• u= = so wave of both wavelengths propagate at the same speed
k1 k2
• No dispersion occurs – the function does not change shape
62
ω1 ω2
• u1 = = 10 so the short wavelength waves are much slower than the long waves
k1 k2
• Dispersion occurs – the function changes shape
63
ω1 1 ω2
• u1 = = so the short wavelength waves travel more quickly
k1 3 k2
• Dispersion occurs – the function changes shape
64
For a function to propagate without changing shape, all of the Fourier modes must
propagate at the same speed:
This shows the propagation of a Gaussian and propagation of the first 9 Fourier modes.
65
66
5.3 Some Excellent Animations and Videos which demonstrate
Dispersion
• Some description and animations from Dr. Dan Russell, Grad. Prog. Acoustics, Penn
State:
http:
//www.acs.psu.edu/drussell/Demos/Dispersion/dispersion.html
• A video of the wake of a motor-boat from JNHeyman (41 seconds):
https://www.youtube.com/watch?v=lWi_KpBy8kU
• A video of ripples in a pond with descriptions of the dispersion (2:28)
https://www.youtube.com/watch?v=dESm6VjfSNs
67
68
5.5 Phase speed and dispersion errors of CTCS
The amplification factor of CTCS is
p
A = −ic sin k∆x ± 1 − c2 sin2 k∆x
where c = u∆t/∆x. Therefore we can find the phase-speeds of the numerical waves relative
to the analytic waves:
!
un 1 −1 c sin k∆x
= tan p
u uk∆t ± 1 − c2 sin2 k∆x
This can be simplified by substituting in u∆t = c∆x and sin α = c sin k∆x:
un α
=±
u ck∆x
There are two possible phase-speeds for each mode. These can be plotted against k∆x to find
out how waves propagate when advected by CTCS. A plot of un /u against k∆x (or ω = ku
against k) is called a dispersion relation. The dispersion relation for CTCS for c = 0.4:
1.0
0.5
0.0
un /u
0.5
The dispersion relation for CTCS for c = 0.4 plotted as ω against k∆x
1.5
numerical
1.0 true
0.5
0.0
ωn /u
0.5
1.0
70
5.6 Exercise
What can dispersion relations tell us about the behaviour of numerical methods? These are
the results of solving the linear advection equation using two finite volume methods. The
generic finite-volume method for linear advection in 1d for a uniform grid is define as:
(n+1) (n)
φj −φj φ j+1/2 − φ j−1/2
= −u
∆t ∆x
The two finite-volume methods are:
Lax-Wendroff Warming and Beam
1 1
φ j+1/2 = /2 (1 + c)φ j + /2 (1 − c)φ j+1 φ j+1/2 = 1/2 (3 − c)φ j − 1/2 (1 − c)φ j−1
Advection of a top-hat profile to the right using c = 0.2, 100 points
71
These are the dispersion relations for the two schemes. Which dispersion relation is related
to which scheme and why?
3.5
3.0 Scheme a
Scheme b
2.5 true
2.0
ω/u
1.5
1.0
0.5
0.00 π/4 π/2 3π/4 π
k ∆x
72
Chapter 6: Alternative Advection Schemes
Some problems we have encountered with advection schemes:
• First-order in space schemes are diffusive
• Second-order linear schemes suffer from dispersion errors which contaminate solutions
with grid-scale oscillations
• Explicit Eulerian schemes have time-step restrictions
73
74
6.1.1 Semi-Lagrangian Advection in One Dimension
CFL criterion: The domain of dependence of the numerical solution must contain the
domain of dependence of the original PDE.
• So to allow long time-steps, construct the numerical domain of dependence to contain the
xj
physical domain of dependence. t n+1
∂φ
• Recall the linear advection equation: ∂t + u ∂∂φx = 0
u
• and its analytic solution: φ (x,t) = φ (x − ut, 0)
• Semi-Lagrangian advection is defined from this:
φ (x j ,tn+1 ) = φ (x j − u∆t,tn ) = φ (x jd ,tn )
x jd = x j − u∆t is the departure point of point x j .
tn x jd
• So interpolate φ from known points onto x jd . xk x k+1 x
• First find k such that xk ≤ x jd ≤ xk+1 : (Use floor(x) meaning the integer below or at x)
k = floor((x j − u∆t)/∆x) = floor( j − c)
• Interpolate from xk−1 , xk , xk+1 , ... onto x jd (for example using cubic-Lagrange interpolation)
75
where volume V has surface S, dS is the outward pointing normal to surface S and
fi = φ u · dS is the flux over edge i.
Conservation: the finite volume method is conservative: however fi is calculated, the total
mass of φ is conserved because exactly what leaves one cell will enter another.
Finite volume is a family of methods. There are numerous approximations for estimating fi
from surrounding φ and u values.
77
78
6.4 Lax-Wendroff
We start with the finite volume method:
φj
(n+1) (n)
−φj φ j+1/2 − φ j−1/2 φ j+1
= −u .
∆t ∆x
For Lax-Wendroff, φ j+1/2 is calculated to be the
average value that passes through position x j+1/2 φj
between time-steps n and n + 1. So you could call it
(n+1/ )
φ j+1/ 2 . Therefore we need to calculate the average
2
value of φ between positions x j+1/2 and a distance
u∆t upstream of x j+1/2 . In order to calculate the xj x j+1 /2 x j+1
average, we assume that φ varies linearly between x j u∆t
and x j+1 . Then we can calculate φ at x j+1/2 − 1/2 u∆t .
(n+1/ )
This could be written φ j+1/ 2 = φ (n) x j+1/2 − 1/2 u∆t .
2
Exercise: Using the Courant number, c = u∆t/∆x, show that this gives:
(n+1/2 )
= 1/2 (1 + c)φ j + 1/2 (1 − c)φ j+1 (solution on blackboard notes)
(n) (n)
φ j+1/
2
Notes:
• Lax-Wendroff is second-order accurate in space and time.
• Lax-Wendroff is not monotonic or bounded
• Stable for |c| ≤ 1
79
80
6.5 Total Variation
• Linear, second-order advection schemes produce unbounded, unrealistic, grid-scale
oscillations. These can be measured by the total variation:
nx −1
TV = ∑ |φ j+1 − φ j |
j=0
Exercise: Calculate the total variation of these functions:
7 7 7
(a) (b) (c)
6 6 6
5 5 5
4 4 4
φ
φ
3 3 3
2 2 2
1 1 1
00 2 4 6 8 10 00 2 4 6 8 10 00 2 4 6 8 10
7 7 7
(d) (e) (f)
6 6 6
5 5 5
4 4 4
φ
φ
3 3 3
2 2 2
1 1 1
00 2 4 6 8 10 00 2 4 6 8 10 00 2 4 6 8 10
Question: Why is total variation used rather than boundedness to measure the generation of
spurious oscillations? ...Because spurious oscillations can be generated within the bounds of
the original function. Eg see function (e) above.
81
82
6.6.1 Limiter functions
The limiter function, Ψ, is based on the ratio of the upwind gradient to the local gradient:
φ j − φ j−1
r j+1/2 =
φ j+1 − φ j
for u > 0.
6.6.1.1 Exercise
Warming and Beam (WB) is not a TVD scheme but the flux,
φ j+1/2 = 1/2 (3 − c)φ j − 1/2 (1 − c)φ j−1 can be expressed in the form:
φ j+1/2 = Ψ j+1/2 φH + (1 − Ψ j+1/2 )φL
where φH is Lax-Wendroff (φH = 1/2 (1 + c)φ j + 1/2 (1 − c)φ j+1 ) and φL is backward in space
(φL = φ j ). If WB is expressed in this form, what is Ψ j+1/2 as a function of r j+1/2 ? (Hint,
equate the two forms for φ j+1/2 and then equate coefficients of either c0 or c1 )
φ j − φ j−1
⇒ Ψ j+1/2 = = r j+1/2
φ j+1 − φ j
83
Depth integrate the Navier-Stokes equations over orography to give the SWE:
Free surface
Du
= −2Ω × u − g∇(h + h0 ) + µu ∇2 u (7.1) u fluid
Dt depth, h
Dh
+ h∇ · u = 0 (7.2) h0
Dt
Solid surface
where
Exercise: Considering the meaning of the terms in the momentum equation in section 1.3,
what are the meaning of the terms of the momentum equation of the SWE?
85
5000 5100 5200 5300 5400 5500 5600 5700 5800 5900 6000
86
7.2 Processes Represented by the SWE
Which of these processes are represented by the SWE and which are only represented by the
full NS equations?
Horizontal advection SWE Acoustic waves NS
Vertical advection NS Coriolis SWE
Gravity waves SWE Diffusion SWE
Rossby waves SWE Heat transport NS
Adiabatic expansion NS Atmospheric convection NS
Geostrophic balance SWE Geostrophic turbulence SWE
87
88
7.2.1 Linearised SWE
In order to find analytic solutions and to analyse numerical methods, we linearise the SWE.
Assume:
• u = (u, v, 0)T is small
• 2Ω = (0, 0, f )T
• h = H + h0 where H is uniform in space and time and h0 is small
• the product of two small variables is ignored (even if one or both are inside a differential)
• h0 and µu are ignored
This gives the following equations for u,v and h0 expressed in terms of f (rather than Ω):
∂u ∂ h0
= fv−g (7.3)
∂t ∂x
∂v ∂ h0
= −fu−g (7.4)
∂t ∂y
∂ h0 ∂u ∂v
= −H + (7.5)
∂t ∂x ∂y
7.3 Analytic Solultion
Ignoring Coriolis, the linearised SWE have wave-like solutions – gravity waves. In 1d these
are: √
h0 = H eikx e±ikt gH (7.6)
p √
u = ± g/H H eikx e±ikt gH (7.7)
p
for any constant H. So waves
p with wavenumber k in space oscillate with frequency k gH
and the wave speed is ... gH (so gravity waves are non-dispersive).
89
90
7.4.1 Von-Neumann Stability Analysis
We can find the stability limits and dispersion relation for the numerical scheme given in
section 7.4 (1d A-grid FB) using von-Neumann stability analysis.
To calculate an amplification factor, A, for each wavenumber, k, we assume wave-like
solutions for h and u:
h j = H An eik j∆x
(n)
(7.10)
u j = U An eik j∆x
(n)
(7.11)
for some constants
√ H and U. Substituting these into (7.8) and (7.9) and defining the Courant
gH∆t
number c = leads to:
∆x
c2 ic p
A = 1 − sin2 k∆x ± sin k∆x 4 − c2 sin2 k∆x (7.12)
2 2
There are two solutions for A but this is correct because there are also two analytic solutions
to the equations (because of the ± in the analytic solution). For |c| ≤ 2 this gives |A|2 = 1
so the scheme is stable and undamping for sufficiently small time steps. However for |c| > 2
we have: 2
c2 2 c p
2 2
|A| = 1 − sin k∆x ± sin k∆x c2 sin k∆x − 4
2 2
p
which can be greater than 1 and so the scheme is unstable for |c| > 2 where c = gH∆t/∆x.
So this scheme is conditionally stable. Stable for c ≤ 2.
91
h0 u u=0
x x
Questions:
1. How do you expect the real solution of the linearised SWE to evolve?
High-frequency waves will be generated that propagate in both directions. The solution
will oscillate between having non-zero h0 and non-zero u.
93
D-grid E-grid
95
• The linearised SWE are solved numerically on Arakawa A, B and C grids, starting from
initial conditions consisting of zero velocity and zero h0 everywhere except a positive h0 in
one central grid-box
• The colours show h0 in the grid boxes. Red/yellow positive, blue negative, white zero
97