You are on page 1of 10

31/08/21

Climate Modelling
3rd year, SA Bachelor

Taylor’s expansion & Finite Differencing

Application of Taylor’s series to finite differencing


If a function u is defined by an array of points in a single
dimension à by Taylor series expansion, we get:

where h.o.t. stands for the higher-order terms.


Dividing throughout by Δx, we obtain:

If we introduce the notation O(Δx), means of the order of Δx, we get:

1
31/08/21

Forward & Backward Differencing

Neglecting the h.o.t. à

Forward finite differencing

Backward finite differencing

à first-order accuracy
à The truncation error is of the order of Δx, that is, O(Δx), which
corresponds to the largest term we neglected in the approximation

Centered Finite Differencing


Q1. What is the accuracy of the Centered Finite Differencing scheme?

à The truncation error is of the order of (Δx)2, that is, O(Δx)2


à Second order accuracy

2
31/08/21

Higher-order derivatives
Q2. Find a simple way to approximate

à The truncation error is of the order of (Δx)2, that is, O(Δx)2


5

Application of Taylor’s series to finite differencing

3
31/08/21

Fourth-Order Accurate Formulas

Q3. Find A, B, and C such that:

With the truncation error is of the order of (Δx)4

Fourth-Order Accurate Formulas


Q4. Prove that:

à 

à The truncation error is of the order of (Δx)4, that is, O(Δx)4

4
31/08/21

Second derivative
Q5. Find A, B, and C such that:

i.e. the terms of order (Δx)3, (Δx)4, and (Δx)5 are zero

Fourth-Order Accurate Formulas


Q6. Prove that:

à The truncation error is of the order of (Δx)4, that is, O(Δx)4

10

5
31/08/21

Second-order accurate Laplacian


§  Let’s start with Laplace’s equation
Where is the 2-D Laplacian operator in the Cartesian
coordinate system

Q7. Calculate the Laplacian of the following scalar fields

1.  f(x,y)= 3x3y2

2.  f(x,y)=(x2+y2)1/2

11

Second-order accurate Laplacian

§  The finite-difference analog of the second-order accurate


Laplacian

A 5-point diamond stencil


12

6
31/08/21

Second-order accurate Laplacian


For simplicity, assume that we have an even mesh, i.e. Δx=Δy=Δ

à second order accurate Laplacian

13
A 5-point diamond stencil

Second-order accurate Laplacian

A 5-point square stencil

14

7
31/08/21

Second-order accurate Laplacian

A 5-point square stencil


à The finite-difference expression for the second-order accurate
Laplacian represented by the 5-point square stencil

Q11. Which 5-point stencil is more accurate, and why?

5-point stencil with diamond configuration is slightly more accurate


than a 5-point square stencil ß distance from the center point (I,J) to
the other points is less in the diamond stencil (Δ) than the
corresponding distance in the square stencil (21/2Δ)
15

9-point stencil

à This formulation uses more


information around the central
point à can be locally more
accurate than the 5-point stencil
approximations

A 9-point stencil
16

8
31/08/21

Fourth-order accurate Laplacian

à The fourth-order accurate Laplacian

17

Fourth-order accurate Laplacian

à another fourth-order accurate Laplacian

18

9
phere, they mediate the condensation of water vapor that level, it is sometimes used
in the atmospheric branch of the hydrologic cycle, nate in lieu of height. In terms
they participate in and serve as sites for important level, situated at a height of a
chemical reactions, and they give rise to electrical sea level, is 31/08/21
roughly halfway
charge separation and a variety of atmospheric opti- atmosphere.
cal effects.
Density decreases with height
Practice#3 with Python as pressure. These vertical varia
1.3.4 Vertical structure
1. Vertical structure of the atmosphere density are much larger than the
To within a few percent, the density of air at sea level zontal and time variations. H
•  Write a program to calculate (approximately) the air density at
is 1.25 kg m . Pressure p and density " decrease
!3
different atmospheric levels by using forward, backward, define a standard atmosphere, w
nearly exponentially with height, i.e.,
centered difference methods, etc., given the pressure: horizontally and temporally av
the atmosphere as a function of
# H
p " p0e!z
(1.8) in Fig. 1.8. The nearly exponentia

of pressure and density can be i
where H=8000(m); g=9.8 m/s 2; p =1000.; Z=0., 1000., …9000.;
where H, the e-folding depth,0 is referred to as the that the observed vertical prof
dz=1000.
scale height and p0 is the pressure at some reference density on these semilog plo
•  Compare the obtained simulation results with the analytical
level, which is usually taken as sea level (z# 0). In straight lines. The reader is
results.
the lowest 100 km of the atmosphere, the scale height Exercise 1.14 at the end of this
•  Use a 4-order difference approximation to solve the problem
ranges roughly from 7 to 8 km. Dividing Eq. (1.8) by responding 10-folding depth for
p0 and taking the natural logarithms yields is !17 km.

p z Exercise 1.3 Assuming an e


ln "! (1.9)
p0 H and density dependence with H
the heights in the atmosphere
This relationship is useful for estimating the height of density is equal to 1 kg m!3 a
various pressure levels in the Earth’s atmosphere. which the pressure is equal to 1 h

Exercise 1.2 At approximately what height above


Practice#3 with Python
sea level zm does
half the mass of the atmosphere lie 160
above and the other half lie below? [Hint: Assume
2.  anf(x)=cos(x)+sin(2x); π≤x≤π
exponential pressure dependence with H # 8 km 140
Height above sea level (km)

•  compute the derivative f’(x) using:


and neglect the small vertical variation of g with 120
height.]
•  forward, backward, centered schemes 100

•  4Solution:
th-order accurate formula
Let pm be the pressure level that half
80
the mass of the atmosphere lies above and half lies
3.  below.
f(x,y)=(x +y2)1/2; 1≤x≤2; 1≤y≤2, dx=y=0.1
The 2pressure at the Earth’s surface is equal 60
to the weight (per unit area) of the overlying col-
•  compute the Laplacian of f using the different
umn of air. The same is true of the pressure at
40

schemes shown in the previous slides, &


any level in the atmosphere. Hence, pm # p0 /2 20
compare the accuracy with the analytical
where p0 is the global-mean sea-level pressure.
0
From Eq. (1.9)
solution (important for the final report) 10–8 10–7 10–6 10–5 10–4 10–3 10–2
Press
zm # !H ln 0.5 # H ln 2 20
Densi
Mean fr

Substituting H # 8 km, we obtain Fig. 1.8 Vertical profiles of pressure


in units of kg m!3, and mean free p
zm # 8 Km $ 0.693 ! 5.5 km U.S. Standard Atmosphere.
10

You might also like