You are on page 1of 17

NUMERICAL METHODS: FINITE DIFFERENCE APPROACH

Lecture-11
AMEEYA KUMAR NAYAK
DEPARTMENT OF MATHEMATICS

1
Contents

 Parabolic Equations in two dimensions


 Explicit Method
 Crank-Nicolson Method
 Example

2
Parabolic Equations in 2D:
Parabolic Equation in Two Dimensions:
A two-dimensional parabolic PDE is represented as:
𝜕𝑢 𝜕 2 𝑢 𝜕 2 𝑢
= + ; 0 ≤ 𝑥 ≤ 𝑎, 0 ≤ 𝑦 ≤ 𝑏; 𝑡 > 0 11.1
𝜕𝑡 𝜕𝑥 2 𝜕𝑦 2
An initial condition may be prescribed as : 𝑢 𝑥, 𝑦, 0 = 𝑔 𝑥, 𝑦 , 𝑡 = 0 (11.2)
Some kind of boundary conditions are prescribed on 𝑥 = 0, 𝑥 = 𝑎, 𝑦 = 0, 𝑦 = 𝑏.
Suppose Dirichlet conditions are prescribed on all these sides.
To solve the above problem,
 Subdivide the intervals 0 ≤ 𝑥 ≤ 𝑎 & [0 ≤ 𝑦 ≤ 𝑏] into M subintervals each
of width ∆𝑥 along x-axis and into N subintervals of width ∆𝑦 along y-axis
i.e., M∆𝑥 = 𝑎 & 𝑁∆𝑦 = 𝑏.

3
Parabolic Equations in 2D (Continue…):
 Denote the points of subdivision on x-axis by 𝑥𝑖 , 𝑖 = 0 1 𝑀 ; 𝑥0 = 0 & 𝑥𝑀 = 𝑎
and on y-axis by 𝑦𝑗 , 𝑗 = 0 1 𝑁 ; 𝑦0 = 0 & 𝑦𝑁 = 𝑏
 We shall compute the values of 𝑢(𝑥𝑖 , 𝑦𝑗 , 𝑡) ;
𝑖 = 1 1 𝑀 − 1; 𝑗 = 1 1 𝑁 − 1, for different t.
 Assume that values of u are known
at the 𝑘 𝑡ℎ time level, i.e., 𝑡 = 𝑘∆𝑡,
and we have to compute the values at
(𝑘 + 1)𝑡ℎ time level

Figure shows the subdivision of space


and time domain.

4
Parabolic Equations (Continue……):
Explicit Method: Discretize (11.1) at the mesh point (𝑖, 𝑗, 𝑘) approximating
the time derivative by forward difference and space derivative by central
difference.
𝜕𝑢 𝜕2𝑢 𝜕2𝑢
= +
𝜕𝑡 𝑖,𝑗,𝑘 𝜕𝑥 2 𝑖,𝑗,𝑘 𝜕𝑦 2 𝑖,𝑗,𝑘
𝑘+1 𝑘
𝑢𝑖,𝑗 − 𝑢𝑖,𝑗
+ 𝑂 ∆𝑡
Δ𝑡
𝑘 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1
= 2
+ 2
+ 𝑂 ∆𝑥 2 + 𝑂(∆𝑦 2 )
∆𝑥 ∆𝑦

Neglecting the truncation error, we get;

5
Parabolic Equations (Continue……):
𝑘 𝑘 𝑘 𝑘 𝑘 𝑘
𝑘+1 𝑘
𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1
𝑢𝑖,𝑗 = 𝑢𝑖,𝑗 + ∆𝑡 2
+ (11.3)
∆𝑥 ∆𝑦 2
𝑖 = 1 1 𝑀 − 1; 𝑗 = 1 1 𝑁 − 1
Formula (11.3) gives the value of (𝑘 + 1)𝑡ℎ time level explicitly in terms of the known
values at the (𝑘)𝑡ℎ time level.
1 1 1
The above scheme is stable only for ∆𝑡 + ≤ .
∆𝑥 2 ∆𝑦 2 2
If ∆𝑥 = ∆𝑦, then (11.3) can be written as
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘 ∆𝑡
𝑢𝑖,𝑗 = 𝑟 𝑢𝑖−1,𝑗 + 𝑢𝑖+1,𝑗 + 1 − 4𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖,𝑗−1 + 𝑢𝑖,𝑗+1 , 𝑟=
∆𝑥 2
(11.4)

6
Parabolic Equations (Continue……):

Crank-Nicolson Scheme:
1
Discretize (11.1) at the mesh point (𝑖, 𝑗, 𝑘 + ) approximating the time derivative
2
by central difference and space derivatives by the average of the second derivatives
at the 𝑘𝑡ℎ and (𝑘 + 1)𝑡ℎ level replacing by central difference i.e.,
𝜕𝑢 𝜕2𝑢 𝜕2𝑢
= +
𝜕𝑡 𝑖,𝑗,𝑘+
1 𝜕𝑥 2 𝜕𝑦 2 𝑖,𝑗,𝑘+
1
2 2

1 𝜕2𝑢 𝜕2𝑢 𝜕2𝑢 𝜕2𝑢


= + + + 2
2 𝜕𝑥 2 𝜕𝑦 2 𝑖,𝑗,𝑘
𝜕𝑥 2 𝜕𝑦 𝑖,𝑗,𝑘+1

7
Parabolic Equations (Continue……):
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢𝑖,𝑗 − 𝑢𝑖,𝑗 1 𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1
+ 𝑂 ∆𝑡 2 = +
Δ𝑡 2 ∆𝑥 2 ∆𝑦 2
𝑘+1 𝑘+1 𝑘+1 𝑘+1 𝑘+1 𝑘+1
1 𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1
+ 2
+ 2
+ 𝑂 ∆𝑥 2 + 𝑂(∆𝑦 2 )
2 ∆𝑥 ∆𝑦
Neglecting the truncation error, we can write the above equation as:
𝑘+1 𝑘+1 𝑘+1 𝑘+1 𝑘+1 𝑘+1
𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1 𝑘+1
−Δ𝑡 2
+ 2
+ 2𝑢𝑖,𝑗
∆𝑥 ∆𝑦
𝑘 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢𝑖−1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖+1,𝑗 𝑢𝑖,𝑗−1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗+1 𝑘
= Δ𝑡 2
+ 2
+ 2𝑢𝑖,𝑗 , (11.5)
∆𝑥 ∆𝑦
𝑖 = 1 1 𝑀 − 1; 𝑗 = 1 1 𝑁 − 1

8
Parabolic Equations (Continue……):

If ∆𝑥 = ∆𝑦, then (D) can be written as after putting 𝑟 = ∆𝑡/∆𝑥 2 ;

𝑘+1 𝑘+1 𝑘+1 𝑘+1 𝑘+1


−𝑟 𝑢𝑖−1,𝑗 + 𝑢𝑖+1,𝑗 + 2 1 + 2𝑟 𝑢𝑖,𝑗 − 𝑟 𝑢𝑖,𝑗−1 + 𝑢𝑖,𝑗+1
𝑘 𝑘 𝑘 𝑘 𝑘
= 𝑟 𝑢𝑖−1,𝑗 + 𝑢𝑖+1,𝑗 + 2 1 − 2𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖,𝑗−1 + 𝑢𝑖,𝑗+1 ; (11.6)

𝑖 = 1 1 𝑀 − 1; 𝑗 = 1 1 𝑁 − 1

At each time step we have to solve 𝑀 − 1 × (𝑁 − 1) equations, while the scheme is stable
1 1
for any value of ∆𝑡 + .
∆𝑥 2 ∆𝑦 2

9
Parabolic Equations (Continue……):
Example: Solve two-dimensional parabolic equation
𝜕𝑢 𝜕 2 𝑢 𝜕 2 𝑢
= 2 + 2 ; 0 ≤ 𝑥 ≤ 1.0, 0 ≤ 𝑦 ≤ 1.0; 𝑡 > 0
𝜕𝑡 𝜕𝑥 𝜕𝑦
with initial condition 𝑢 𝑥, 𝑦, 0 = 𝑥 + 𝑦, 𝑡 = 0 and boundary conditions are
imposed for 𝑡 > 0,
𝜕𝑢
(0, 𝑦, 𝑡) = 𝑢 & 𝑢 1, 𝑦, 𝑡 = 1;
𝜕𝑥
𝜕𝑢
𝑢 𝑥, 0, 𝑡 = 1 & (𝑥, 1, 𝑡) = −𝑢
𝜕𝑦
by Explicit method for only two time steps taking ∆𝑥 = ∆𝑦 = 0.25, & ∆𝑡 =
0.01 . Approximate the derivative boundary condition by forward and
backward differences as required.
10
Parabolic Equations (Continue……):
Solution: Given 2D parabolic equation as:
𝜕𝑢 𝜕 2 𝑢 𝜕 2 𝑢
= + ; 0 ≤ 𝑥 ≤ 1.0, 0 ≤ 𝑦 ≤ 1.0; 𝑡 > 0 (1)
𝜕𝑡 𝜕𝑥 2 𝜕𝑦 2 𝜕𝑢
= −𝑢
with initial condition 𝜕𝑦
𝑢 𝑥, 𝑦, 0 = 𝑥 + 𝑦, 𝑡 = 0
& boundary conditions are imposed for 𝑡 > 0,
𝜕𝑢 𝜕𝑢
(0, 𝑦, 𝑡) =𝑢 & 𝑢 1, 𝑦, 𝑡 = 1; =𝑢 𝑢=1
𝜕𝑥 𝜕𝑥
𝜕𝑢
𝑢 𝑥, 0, 𝑡 = 1 & (𝑥, 1, 𝑡) = −𝑢
𝜕𝑦
∆𝑦
∆𝑥 = ∆𝑦 = 0.25, & ∆𝑡 = 0.01
∆𝑥 𝑢=1

11
Parabolic Equations (Continue……):
For ∆𝑥 = ∆𝑦, then the explicit method is can be written as
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘 ∆𝑡
𝑢𝑖,𝑗 = 𝑟 𝑢𝑖−1,𝑗 + 𝑢𝑖+1,𝑗 + 1 − 4𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖,𝑗−1 + 𝑢𝑖,𝑗+1 , 𝑟=
∆𝑥 2
∆𝑡 0.01
Here 𝑟 = = = 0.16, we get
∆𝑥 2 0.25 2
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢𝑖,𝑗 = 0.16 𝑢𝑖−1,𝑗 + 𝑢𝑖+1,𝑗 + 0.36 𝑢𝑖,𝑗 + 0.16 𝑢𝑖,𝑗−1 + 𝑢𝑖,𝑗+1 (2)
𝑖 = 1,2,3,4, ; 𝑗 = 1,2,3,
For 𝑖 = 0, using forward difference for boundary condition, we have
𝑘+1 𝑘+1
𝑢1,𝑗 −𝑢0,𝑗 𝑘+1 𝑘+1 𝑘+1
= 𝑢0,𝑗 i.e., 𝑢0,𝑗 = 0.8 𝑢1,𝑗 (3)
∆𝑥
For j = 4, using backward difference for boundary condition, we have
𝑘+1 𝑘+1
𝑢i,4 −𝑢i,3 𝑘+1 𝑘+1 𝑘+1
= −𝑢𝑖,4 i.e., 𝑢i,4 = (0.8)𝑢i,3 (4)
∆𝑥

12
Parabolic Equations (Continue……):
𝑘+1 𝑘+1
𝑢4,𝑗 = 1 = 𝑢i,0 ; for all time steps; 𝑖, 𝑗 = 0,1,2,3,4
Using the initial condition 𝑢 𝑥, 𝑦, 0 = 𝑥 + 𝑦, 𝑡 = 0; we get:

𝑡=0 𝑖 0 1 2 3 4
𝑗 𝑦 𝑥 0.0 0.25 0.50 0.75 1.0

4 1.0 1.0 1.25 1.5 1.75 2.0


3 0.75 0.75 1.0 1.25 1.5 1.75
2 0.50 0.50 0.75 1.0 1.25 1.50
1 0.25 0.25 0.50 0.75 1.0 1.25
0 0.0 0.0 0.25 0.50 0.75 1.0

13
Parabolic Equations (Continue……):

For 𝑖 = 1
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢1,𝑗 = 0.16 𝑢0,𝑗 + 𝑢2,𝑗 + 0.36 𝑢1,𝑗 + 0.16 𝑢1,𝑗−1 + 𝑢1,𝑗+1
For 𝑖 = 2
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢2,𝑗 = 0.16 𝑢1,𝑗 + 𝑢3,𝑗 + 0.36 𝑢2,𝑗 + 0.16 𝑢2,𝑗−1 + 𝑢2,𝑗+1
For 𝑖 = 3
𝑘+1 𝑘 𝑘 𝑘 𝑘 𝑘
𝑢3,𝑗 = 0.16 𝑢2,𝑗 + 𝑢4,𝑗 + 0.36 𝑢3,𝑗 + 0.16 𝑢3,𝑗−1 + 𝑢3,𝑗+1

Solving the above equation for each 𝑗 = 1,2,3 along with eq. (3) & (4) we get the
required solution as following:

14
Parabolic Equations (Continue……):
𝑘+1 𝑘+1
𝑢4,𝑗 = 1 = 𝑢i,0 ; for all time steps; 𝑖, 𝑗 = 0,1,2,3,4
Using the previous values at 𝑡 = 0; we get the solution for next time step as:

𝑡 = 0.01 𝑖 0 1 2 3 4
𝑗 𝑦 𝑥 0.0 0.25 0.50 0.75 1.0

4 1.0 0.64 0.8 1.0 1.2 1.0


3 0.75 0.8 1.0 1.25 1.5 1.0
2 0.50 0.6 0.75 1.0 1.25 1.0
1 0.25 0.4 0.5 0.75 1.0 1.0
0 0.0 1.0 1.0 1.0 1.0 1.0

15
Parabolic Equations (Continue……):
Using the previous values at 𝑡 = 0.01; we get the solution for next time step as:
𝑡 = 0.02 𝑖 0 1 2 3 4
𝑗 𝑦 𝑥 0.0 0.25 0.50 0.75 1.0

4 1.0 0.59904 0.7488 0.936 1.0336 1.0


3 0.75 0.7488 0.936 1.17 1.292 1.0
2 0.50 0.6128 0.766 1.0 1.17 1.0
1 0.25 0.5152 0.644 0.83 1.0 1.0
0 0.0 1.0 1.0 1.0 1.0 1.0

16
17

You might also like