November 2026 · Politecnico di Milano
Atmosphere and Ocean Dynamics — Lecture 5
Prof. Dr. Pedro da Silva Peixoto
Applied Mathematics
Instituto de Matemática e Estatística
Universidade de São Paulo
Visiting Professor at MOX Lab
Politecnico di Milano
Previous knowledge
Accuracy and stability of a grid model, from one ODE to the shallow water equations
(Durran 2010, Ch. 1–4; Döös et al. 2022)

Richardson’s grid over Europe. Richardson (1922), public domain
But: with balanced data, could he have gone on, step after step?
A forecast by numbers needs a grid, a time step, and a scheme that does not blow up
(Richardson 1922; Lynch 1999) · Grid: archive.org/details/weatherpredictio00richrich
\[\frac{d\mathbf{q}}{dt} = \mathbf{F}(\mathbf{q})\]
\(\mathbf q\): all the grid values \(q_j\); \(\mathbf F\): their tendencies, from the differences of neighbours
Two questions for every scheme: how accurate is a difference, and is a time step stable?
(Durran 2010, sec. 1.3, sec. 3.3.1; Döös et al. 2022)
Expand \(q\) around \(x_j\), one grid step ahead:
\[q_{j+1} = q_j + \Delta x\, q'_j + \frac{\Delta x^2}{2}\,q''_j + \frac{\Delta x^3}{6}\,q'''_j + \dots\]
and one step behind:
\[q_{j-1} = q_j - \Delta x\, q'_j + \frac{\Delta x^2}{2}\,q''_j - \frac{\Delta x^3}{6}\,q'''_j + \dots\]
Question: which combination of \(q_{j-1}, q_j, q_{j+1}\) best gives \(q'_j\)?
On a grid we only know values; derivatives must be built from them
(Durran 2010, sec. 1.3.1, sec. 3.1)
Solve the first expansion for \(q'_j\):
\[\frac{q_{j+1} - q_j}{\Delta x} = q'_j + {\color{#1f5ccc}\underbrace{\frac{\Delta x}{2}\,q''_j + \dots}_{\text{truncation error}}}\]
Truncation error: what the difference leaves out of the Taylor series
[Durran (2010), §3.1; §3.3.2, eq. 3.39]
Subtract the two expansions: the even terms cancel,
\[\frac{q_{j+1} - q_{j-1}}{2\Delta x} = q'_j + {\color{#1f5ccc}\frac{\Delta x^2}{6}\,q'''_j} + \dots\]
But: accurate at one instant is not enough. Do the errors grow when we step in time?
Order: the error falls like \(\Delta x^p\); centred differences are second order (\(p = 2\))
[Durran (2010), §3.1; §3.3.2, eq. 3.39; Döös et al. (2022)]
\[\frac{d\psi}{dt} = \lambda\psi = i\omega\psi, \qquad \psi = \psi_0\,e^{i\omega t}\]
\(\psi\): the amplitude of one mode; \(\omega\): its frequency, here \(\pm ck\); \(|\psi|\) stays constant
Every linear wave is one oscillation, \(d\psi/dt = i\omega\psi\): test a time scheme on it
(Durran 2010, sec. 2.2; Cushman-Roisin and Beckers 2011, sec. 2.7)
One step of a time scheme multiplies the mode by a number, the amplification factor \(A\):
\[\psi^{n+1} = A\,\psi^n, \qquad \psi^n = A^n\psi^0\]
\(\psi^n\): the amplitude at the time \(t^n = n\Delta t\). Exact: \(A = e^{i\omega\Delta t}\), on the unit circle
A scheme for waves is judged by its \(A\) on \(d\psi/dt = i\omega\psi\): size (amplitude) and angle (phase)
(Durran 2010, sec. 2.2; Cushman-Roisin and Beckers 2011, sec. 2.7)
Forward Euler: the slope at the start of the step,
\[\psi^{n+1} = \psi^n + \Delta t\,(i\omega\psi^n)\]
\[A = 1 + i\omega\Delta t, \qquad {\color{#1f5ccc}|A| = \sqrt{1 + \omega^2\Delta t^2} > 1}\]
Forward Euler is unconditionally unstable for waves
(Durran 2010, sec. 2.2; Cushman-Roisin and Beckers 2011, sec. 2.6)
Backward Euler, the slope at the end (implicit):
\[\begin{aligned}&\psi^{n+1} = \psi^n + \Delta t\,(i\omega\psi^{n+1})\\ &\Rightarrow\; A = \frac{1}{1 - i\omega\Delta t}, \quad {\color{#1f5ccc}|A| < 1}\end{aligned}\]
Trapezoidal (Crank–Nicolson), the average of both:
\[\begin{aligned}&\psi^{n+1} = \psi^n + \frac{\Delta t}{2}\,i\omega\,(\psi^n + \psi^{n+1})\\ &\Rightarrow\; A = \frac{1 + i\omega\Delta t/2}{1 - i\omega\Delta t/2}, \quad {\color{#1f5ccc}|A| = 1}\end{aligned}\]
Damped, or neutral but slow; both implicit: a system to solve each step
Implicit schemes are stable for any \(\Delta t\), at the price of a linear system per step
(Durran 2010, sec. 2.2.3)
Leapfrog (Richardson’s step-over), centred in time:
\[\psi^{n+1} = \psi^{n-1} + 2\Delta t\,(i\omega\psi^n)\]
Try \(\psi^n = A^n\psi^0\): two roots,
\[\begin{gathered}A^2 - 2i\omega\Delta t\,A - 1 = 0\\ \Rightarrow\; A = i\omega\Delta t \pm \sqrt{1 - \omega^2\Delta t^2}\end{gathered}\]
Leapfrog: explicit, neutral, second order, but with a spurious second solution
(Durran 2010, sec. 2.4; Lynch 1999)
Step \(\Delta t = 1.5\) h at Milan (\(f\Delta t = 0.56\)): the velocity should go once round the circle
Same equation, same step: the scheme decides whether the current grows, dies or keeps its size
(Cushman-Roisin and Beckers 2011, secs. 2.6–2.9; Durran 2010, sec. 2.2)
Leapfrog + Robert–Asselin ran most weather and climate models for decades
(Robert 1966; Asselin 1972; Durran 2010, sec. 2.4.2)
Runge–Kutta: several slopes (stages) within one step; one time level, so no computational mode. The RK3 of Wicker and Skamarock (2002), for \(d\psi/dt = F(\psi)\):
\[\psi^* = \psi^n + \tfrac{\Delta t}{3}F(\psi^n),\quad \psi^{**} = \psi^n + \tfrac{\Delta t}{2}F(\psi^*),\] \[\psi^{n+1} = \psi^n + \Delta t\,F(\psi^{**})\]
On \(F = \lambda\psi\), with \(z = \lambda\Delta t\): \(\;A_{\mathrm{RK3}} = 1 + z + \dfrac{z^2}{2} + \dfrac{z^3}{6}\) (RK4 adds \(z^4/24\))
Explicit schemes for waves are stable only for \(|\omega\,\Delta t|\) below a limit of order one
(Durran 2010, sec. 2.3; Wicker and Skamarock 2002; Skamarock et al. 2012)
Exercise 1 — Forward Euler on the inertial oscillation. With \(w = u + iv\) the inertial oscillation \(du/dt = fv\), \(dv/dt = -fu\) is \(dw/dt = -ifw\). (a) One forward-Euler step multiplies \(w\) by a number \(A\): find \(A\) and \(|A|\). (b) At Milan (\(f = 1.04\times10^{-4}\,\mathrm{s^{-1}}\)) with \(\Delta t = 1\) h: by how much has the speed \(|w|\) grown after one inertial period, \(2\pi/f \approx 16.8\) h?
(c) To hand in: friction, and leapfrog. (i) Add a linear friction (drag) with rate \(r = 1/(1\ \text{day})\): \(dw/dt = -(if + r)\,w\). Find \(|A|\) for forward Euler. Can friction save it? For which \(\Delta t\) does the speed stop growing at Milan? (ii) Without friction, leapfrog: \(w^{n+1} = w^{n-1} - 2if\Delta t\,w^n\) (try \(w^n = A^n\)). What is the longest step at Milan that does not blow up? Which scheme would you use for the inertial currents of an ocean model, and why?
In notebook 05a (exercises 3 and 4): open in Colab · download
(Cushman-Roisin and Beckers 2011, secs. 2.6–2.7)
Friction does not save forward Euler on waves; a neutral scheme does
(Cushman-Roisin and Beckers 2011, secs. 2.6–2.9; Durran 2010, sec. 2.2)
Notebook 05a (open in Colab · download): time schemes on one ordinary differential equation, on a computer.
Stability regions of Euler and the Runge–Kutta schemes; leapfrog on the imaginary axis
Predict, run, explain: write down what you expect before each run
One equation, many schemes: accuracy and stability measured on a computer
(Durran 2010, Ch. 2; Wicker and Skamarock 2002)
But: so far time only. A whole field moving across the grid: how do space and time errors meet?
Accuracy (order) and stability (\(|A| \le 1\)) are different properties: check both
(Durran 2010, secs. 2.1–2.3)
A tracer \(q\) (humidity, salt) carried at constant speed \(c > 0\):
\[\frac{\partial q}{\partial t} + c\,\frac{\partial q}{\partial x} = 0, \qquad q(x,t) = q_0(x - ct)\]
With the Courant number \(C = c\,\Delta t/\Delta x\):
But: why does FTCS, centred and consistent, blow up?
Same equation, same step: smearing (upwind), wiggles (centred) or explosion (FTCS)
(Durran 2010, sec. 3.4; Lax and Wendroff 1960; FTCS: Kalnay 2003)
On a periodic grid any field is a sum of modes \(e^{ikx}\), \(\;k\Delta x \in [-\pi, \pi]\). A linear scheme with constant coefficients only multiplies each mode:
\[q_j^n = A^n\,e^{\,i k j\Delta x}\]
\(k\): wavenumber; \(A\): amplification factor of the mode
Put it in the scheme, divide by \(A^n e^{ikj\Delta x}\): an equation for \(A(k\Delta x)\). Stable if \(|A| \le 1\) for every \(k\).
Von Neumann analysis: the amplification factor of each Fourier mode
(Durran 2010, sec. 3.2.2; Charney et al. 1950)
Upwind, with \(\theta = k\Delta x\):
\[A\,e^{ikj\Delta x} = e^{ikj\Delta x} - C\left(e^{ikj\Delta x} - e^{ik(j-1)\Delta x}\right)\]
\[A = 1 - C + C\,e^{-i\theta}\]
Upwind: stable if the flow crosses at most one cell per step, \(C = c\Delta t/\Delta x \le 1\)
(Durran 2010, sec. 3.2.2)
FTCS, with \(\theta = k\Delta x\):
\[A = 1 - iC\sin\theta, \qquad {\color{#1f5ccc}|A|^2 = 1 + C^2\sin^2\theta > 1}\]
Consistent is not enough: FTCS approximates the equation and still blows up
(Durran 2010, secs. 3.2.2, 3.4.4)
Method of lines: the space difference has eigenvalues \(\lambda(\theta)\); the scheme is stable if every \(\lambda\Delta t\) lies in the time scheme’s stability region.
The time-stepping picture and von Neumann’s are the same picture
(Durran 2010, sec. 2.2.4)
The solution at \((x_j, t^n)\) comes from \(x_j - ct^n\). An explicit scheme only sees the grid points in its stencil cone. If the true source lies outside, no choice of weights can converge.
CFL condition: the numerical domain of dependence must contain the true one (\(C \le 1\) here)
(Courant et al. 1928; Durran 2010, sec. 3.2.3; Lynch 2008)
Theorem (Lax and Richtmyer 1956). For a well-posed linear initial-value problem and a consistent linear finite-difference scheme, stability is necessary and sufficient for convergence. A stable scheme accurate of order \((p, q)\) converges with error \(O(\Delta t^p) + O(\Delta x^q)\).
For a consistent scheme, stable \(\Leftrightarrow\) convergent: the reason we spend so long on \(|A|\)
(Lax and Richtmyer 1956; Durran 2010, sec. 3.2)
Notebook 05b (open in Colab · download): advection in 1D, the CFL condition and von Neumann’s analysis, on a computer.
One revolution with \(C = 0.5\): upwind, leapfrog, Lax–Wendroff (left); FTCS blows up (right)
Predict, run, explain: which scheme keeps the height of the bump after one revolution?
Same equation, same step: the scheme decides between smearing, wiggles and explosion
(Durran 2010, secs. 3.2–3.4; Wicker and Skamarock 2002)
Taylor-expand the upwind scheme in \(\Delta t\) and \(\Delta x\): it solves, to second order, the modified equation
\[\frac{\partial q}{\partial t} + c\,\frac{\partial q}{\partial x} = {\color{#1f5ccc}\frac{c\,\Delta x}{2}\,(1 - C)}\,\frac{\partial^2 q}{\partial x^2}\]
Centred schemes (leapfrog, Lax–Wendroff) keep the amplitude better but leave wiggles: their error term is a third derivative, \(\partial^3 q/\partial x^3\): dispersion, waves of different lengths moving at different speeds.
But: which waves are slow, and how slow?
Upwind smooths (numerical diffusion); centred schemes keep amplitude but disperse
(Durran 2010, secs. 3.3.2, 3.4.2)
Centred difference, a mode \(e^{i(kx - \omega t)}\):
\[\omega = \frac{c\,\sin(k\Delta x)}{\Delta x}, \qquad \frac{c^*}{c} = \frac{\sin(k\Delta x)}{k\Delta x}\]
\(c^* = \omega/k\): the phase speed on the grid; exact in time
Grids are slow for short waves: resolve a feature with many points (8–10 per wavelength)
(Durran 2010, sec. 3.3.1; Randall 2011)
Linear gravity waves (height \(h = H + \eta\)): each equation needs the other variable’s derivative,
\[\partial_t h + H\,\partial_x u = 0, \qquad \partial_t u + g\,\partial_x h = 0\]
But: does it matter where they live?
Staggering puts each derivative where it is needed, at the shortest distance
(Mesinger and Arakawa 1976; Durran 2010, sec. 4.1.2)
A: \(\omega = \dfrac{c}{\Delta x}\sin(k\Delta x)\) \(\quad\) C: \(\omega = \dfrac{2c}{\Delta x}\sin\dfrac{k\Delta x}{2}\)
A grid: the \(2\Delta x\) wave feels no force and stays, as noise; on the C grid it feels the largest
(Mesinger and Arakawa 1976; Randall 2011)
The solver behind the shallow water waves and the adjustment:
Is it stable? Fastest wave: the checkerboard, \(\omega_{\max} = 2c/\Delta x\) (1D), \(2\sqrt{2}\,c/\Delta x\) (2D). So \(\omega_{\max}\Delta t = 1\) and \(1.41\), inside RK4’s \(2\sqrt{2} = 2.83\): stable, with a margin of 2 to 3
A grid, a difference, a time scheme and a step: each choice can now be checked on paper
(Durran 2010, secs. 2.2.4, 4.1.2; Randall 1994)
Notebook 05c (open in Colab · download): the shallow water solver opened, in 1D, to run, to test and to break.
A narrow bump on the A grid (top) and the C grid (bottom)
At home. Predict, run, explain: write down what you expect before each run
The black box in 1D: a grid, a difference, a time scheme and a step
(Wicker and Skamarock 2002; Randall 1994)
Exercise 2 — Why 1950 worked and 1922 did not. Compute the Courant number \(C = c\,\Delta t/\Delta x\) of Richardson’s forecast (grid about 200 km, leapfrog step \(\Delta t = 3\) h) and of the ENIAC forecast (\(\Delta x = 736\) km, \(\Delta t = 3\) h) for a wind of 20 m/s, a jet of 50 m/s and gravity waves at 300 m/s. Which signals could each scheme follow? Why could the ENIAC ignore the gravity waves?
(c) To hand in: an ocean model. A model with \(\Delta x = 10\) km over an ocean 4000 m deep: what is the longest explicit time step allowed by the surface gravity waves (\(c = \sqrt{gH}\), take \(C \le 1\))? And by currents of 1 m/s? How many steps per day does each need? What would you do?
In notebook 05b (exercise 1): open in Colab · download

The ENIAC at Aberdeen. U.S. Army photo, public domain
(Lynch 1999; Charney et al. 1950) · Photo: commons.wikimedia.org: Glen Beck and Betty Snyder program the ENIAC
The fastest wave sets the explicit time step: filter it, split it, or treat it implicitly
(Lynch 1999; Charney et al. 1950)
Notebooks 05a (open in Colab · download), 05b (open in Colab · download) and 05c (open in Colab · download): exercise 1 comes back in 05a, exercise 2 in 05b.
Richardson’s method was the right one, his time step was not: the fastest wave sets \(\Delta t\)
Reading: (Durran 2010, Ch. 2–4; Cushman-Roisin and Beckers 2011, secs. 2.6–2.9; Döös et al. 2022)