Numerical Weather Prediction I / 4th Year/ Dept. Atm. Sci. Lecture (5) Dr.
Thaer Obaid Roomi
Lecture (5)
Explicit Method of Finite Difference
5.1 Introduction
In physics and mathematics, heat equation is a special case of diffusion equation and
is a partial differential equation (PDE). A very popular numerical method known as
finite difference methods (explicit and implicit schemes) is applied extensively for
solving heat equations successfully. Examples of Explicit schemes are Forward Time
and Centre Space (FTCS), Dufort and Frankel methods, whereas examples of
implicit schemes are Laasonen and Crank-Nicolson methods.
5.2 An Explicit Method of Solution
The explicit method of solution describe an unknown value at a certain grid point
depending on the known values at neighboring grid points. By using equations (4.11)
and (4.14) in the diffusion equation (which is of parabolic type), we get:
𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗 𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
= ,
𝑘 ℎ2
and this can be written as:
𝑢𝑖,𝑗+1 = 𝑢𝑖,𝑗 + 𝑟(𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 ) (5.1)
𝑘
where 𝑟 =
ℎ2
Hence, we can calculate u-values at the first time row depending on the boundary
and initial values at t=0 line. Then, similarly we can calculate the values at the
second time row depending on the values that was calculated for the first row, and
so on. This is called the explicit method.
Example: Consider a metal rod is heated for a long time in the center and keeping the
ends in contact with blocks of melting ice and that the initial temperature distribution
in non-dimensional form (unitless) is:
1
(𝑎) 𝑢 = 2𝑥, 0≤𝑥≤ ,
2
1
(𝑏) 𝑢 = 2(1 − 𝑥), ≤ 𝑥 ≤ 1.
2
𝜕𝑢 𝜕2 𝑢
In other words we are seeking a numerical solution of = which satisfies,
𝜕𝑡 𝜕𝑥 2
1. 𝑢 = 0 𝑤ℎ𝑒𝑛 𝑥 = 0 𝑎𝑛𝑑 1 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑡. (𝑡ℎ𝑒 𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛𝑠)
1 1
2. 𝑢 = 2𝑥 𝑓𝑜𝑟 0 ≤ 𝑥 ≤ , 𝑎𝑛𝑑 𝑢 = 2(1 − 𝑥) 𝑓𝑜𝑟 ≤𝑥≤1
2 2
𝑎𝑡 𝑡 = 0 ( 𝑡ℎ𝑒 𝑖𝑛𝑖𝑡𝑖𝑎𝑙 𝑐𝑜𝑛𝑑𝑖𝑡𝑖𝑜𝑛𝑠)
(1 - 4 )
Numerical Weather Prediction I / 4th Year/ Dept. Atm. Sci. Lecture (5) Dr. Thaer Obaid Roomi
For h=1/10 , the initial values and boundary values are as shown in in table
(5.1). The problem is symmetric with respect to x=1/2 , so we need the solution
1
only for 0 ≤ 𝑥 ≤ .
2
Table 5.1
X=0 0.1 0.2 0.3 0.4 0.5 0.6
x
j=0 0 0.2 0.4 0.6 0.8 1.0 0.8
j=1 0
j=2 0
j=3 0
j=4 0
j=4 t
j=3 ui,j+1
ui-1,j ui,j ui+1,j
j=2j
j=1 ui,j-1
k
=0
h x
𝑘 1
Take h=1/10, k=1/1000 so 𝑟 = = , equation (5.1) which is
ℎ2 10
𝑢𝑖,𝑗+1 = 𝑢𝑖,𝑗 + 𝑟(𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 )
becomes:
1
𝑢𝑖,𝑗+1 = (𝑢 − 8𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 ) (5.2)
10 𝑖−1,𝑗
For hand calculation, the “molecule” in Fig (5.2) can represent the relationship
among these four functional values
i,j+1
1
1/10 8/10 1/10
i-1,j i,j i+1,j
Fig. (5.2) Molecular representation
(2 - 4 )
Numerical Weather Prediction I / 4th Year/ Dept. Atm. Sci. Lecture (5) Dr. Thaer Obaid Roomi
The numbers in the circles (atoms) are the multiplicands the functional values at the
corresponding grid points.
The application of equation (5.2) on the data in Table (5.1) is shown in Table (5.2).
For example:
u5,1=1/10{0.8+(8×1)+0.8}=0.9600
u4,2=1/10{0.6+(8×0.8)+0.96}=0.7960
Table 5.2
i=0 i= 1 i= 2 i= 3 i =4 i= 5 i= 6
x=0 0.1 0.2 0.3 0.4 0.5 0.6
(j = 0) t=0.000 0 0.2000 0.4000 0.6000 0.8000 1.0000 0.8000
(j = 1) t=0.001 0 0.2000 0.4000 0.6000 0.8000 0.9600 0.8000
(j = 2) t=0.002 0 0.2000 0.4000 0.6000 0.7960 0.9280 0.7960
(j = 3) t=0.003 0 0.2000 0.4000 0.5996 0.7896 0.9016 0.7896
(j = 4) t=0.004 0 0.2000 0.4000 0.5986 0.7818 0.8792 0.7818
(j = 5) t=0.005 0 0.2000 0.3999 0.5971 0.7732 0.8597 0.7732
⁞
(j =10) t=0.010 0 0.1996 0.3968 0.5822 0.7281 0.7867 0.7281
⁞
(j=20) t=0.020 0 0.1938 0.3781 0.5373 0.6486 0.6891 0.6486
The analytical solution of the partial differential equation which fulfill the boundary
and initial conditions is:
∞
8 1 1
𝑢 = 2 ∑ 2 (𝑠𝑖𝑛 𝑛𝜋)(𝑠𝑖𝑛 𝑛𝜋𝑥)𝑒𝑥𝑝(−𝑛2 𝜋 2 𝑡)
𝜋 𝑛 2
𝑛=1
The comparison of this solution with the finite difference solution at x= 0.3,
shows that the finite difference solution of acceptable accuracy as in Table (5.3).
Table 5.3
Time step Finite – Analytical Difference Percentage error
difference solution (x=0.3)
Solution (x=0.3)
t=0.005 0.5971 0.5966 0.0005 0.08
t=0.01 0.5822 0.5799 0.0023 0.4
t=0.02 0.5373 0.5334 0.0039 0.7
t=0.10 0.2472 0.2444 0.0028 1.1
(3 - 4 )
Numerical Weather Prediction I / 4th Year/ Dept. Atm. Sci. Lecture (5) Dr. Thaer Obaid Roomi
5.2 Exercises
𝝏𝒖 𝝏𝟐 𝒖
Q1. For the following PDE: = 𝟐 , find the numerical solution at the grid points
𝝏𝒕 𝝏𝒙
in the first time row by using the explicit method. Consider the following
boundary conditions: u=4.56 at x=0 and u=1.56 at x=1 at t ≥ 0
u= 3(1.52 – x) for 0 ≤ 𝑥 ≤ 1 at t=0
knowing that h=2/10 , k=3/1000.
Then, suppose that u=0.668 (Numerical solution) and u=0.665 (Analytical
solution) calculate the difference and percentage error.
∂u ∂2 u
Q2. Consider the differential equation, = with the following boundary
∂t ∂x2
conditions: u=3x+1 for 0 ≤ 𝑥 ≤ 1.2 find the numerical solution at the grid
points in the first row (Take ∆𝑥 = ℎ = 3/10, ∆𝑡 = 𝑘 = 1/1000 )
(4 - 4 )