Chapter Seven: Solution of Pdes. by Using Finite Difference Method 7.1 Partial Differential Equations
Chapter Seven: Solution of Pdes. by Using Finite Difference Method 7.1 Partial Differential Equations
Where
𝑘
𝛼2 =
𝜌𝜎
𝑘 = Conductivity
𝜎 = The specific heat
𝜌 = (Density) or mass per unit length (Kg/m)
Is a well-known example of the parabolic equation.
7.1.3 Hyperbolic Equation:
The one dimensional wave equation
𝜕2𝑢 2
𝜕2𝑢
=𝛼 . . … … . . … … … … … … … … … … … … … … … … … … … … … … … … … … … (7.8)
𝜕𝑡 2 𝜕𝑥 2
Where
𝑇
𝛼2 =
𝜇
𝑇 = Tension Force (N)
𝜇 = Mass per unit length (kg/m)
𝑖, 𝑗 + 1
𝑥 = 𝑖ℎ, 𝑖 = 1, 2, 3, … …
𝑘 ℎ
𝑦 = 𝑗𝑘, 𝑗 = 1, 2, 3, … …
The points of intersections of these lines as grid points, 𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
-2-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
𝜕𝑢 𝑢𝑖+1,𝑗 − 𝑢𝑖,𝑗
= 𝑢𝑥 = ⟹ {𝐹𝑜𝑟𝑤𝑎𝑟𝑑 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛}
𝜕𝑥 ℎ
𝜕𝑢 𝑢𝑖,𝑗 − 𝑢𝑖−1,𝑗
= 𝑢𝑥 = ⟹ {𝐵𝑎𝑐𝑘𝑤𝑎𝑟𝑑 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛}
𝜕𝑥 ℎ
𝜕𝑢 𝑢𝑖+1,𝑗 − 𝑢𝑖−1,𝑗
= 𝑢𝑥 = ⟹ {𝐶𝑒𝑛𝑡𝑟𝑎𝑙 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝑎𝑝𝑝𝑟𝑜𝑥𝑖𝑚𝑎𝑡𝑖𝑜𝑛}
𝜕𝑥 2ℎ
Where 𝑢𝑖,𝑗 = 𝑢𝑥,𝑦 = 𝑢𝑖ℎ,𝑗𝑘
The central difference approximations for the second derivative of 𝑢 are given by
𝜕2𝑢 𝑢𝑖+1,𝑗 − 2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
= 𝑢𝑥𝑥 =
𝜕𝑥 2 ℎ2
𝜕2𝑢 𝑢𝑖,𝑗+1 − 2 𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1
= 𝑢𝑦𝑦 =
𝜕𝑦 2 𝑘2
A formula similar to the formula (7.9) is sometimes used with convenience. It is given by
-3-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
1
𝑢𝑖,𝑗 = (𝑢𝑖+1,𝑗+1 + 𝑢𝑖+1,𝑗−1 + 𝑢𝑖−1,𝑗+1 + 𝑢𝑖−1,𝑗−1 ) … … … … … … … … . … … … … … (7.10)
4
This is known as diagonal five point formula and expresses the value of the function at the
diagonal points. It may be remarked here that although formula (7.10) is less accurate than
formula (7.9), it serves as a reasonably good approximation for obtaining grid values which are
needed as starting values in the iteration procedure. The finite difference analogue of this
formula is shown in figure (7.2) given below
ℎ
𝑖 − 1, 𝑗 + 1 𝑖 + 1, 𝑗 + 1
𝑖, 𝑗
𝑖 − 1, 𝑗 − 1 𝑖 + 1, 𝑗 − 1
It is now required to determine the values 𝑢𝑖 of 𝑢 at the internal mesh points when it is values 𝑏𝑗
on the boundary are known; see figure (7.3).
𝑏13 𝑏12 𝑏11 𝑏10 𝑏9
The initial value of 𝑢5 at the Centre is obtained by the
𝑢7 𝑢8 𝑢9
diagonal five point formula as 𝑏14 𝑏8
1 𝑏15 𝑢4 𝑢5 𝑢6
𝑢5 = (𝑏1 + 𝑏5 + 𝑏9 + 𝑏13 ) 𝑏7
4
𝑏16 𝑢1 𝑢2 𝑢3
With 𝑢5 known, 𝑢1 , 𝑢3 , 𝑢7 , and 𝑢9 are similarly calculated by 𝑏6
-4-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
Example 1: Solve the Laplace equation
𝜕2𝑢 𝜕2𝑢
+ =0
𝜕𝑥 2 𝜕𝑦 2
With the boundary conditions 𝑢(0, 𝑦) = 0, 𝑢(𝑥, 0) = 0, 𝑢(𝑥, 1) = 100𝑥, 𝑢(1, 𝑦) = 100𝑦.
Taking ℎ = (1⁄3).
Solution: 𝑦
1 100(1⁄3) 100(2⁄3)
𝑢22 = (𝑢32 + 𝑢12 + 𝑢23 + 𝑢21 )
4 𝑢24 𝑢34
𝑢44 100
0 𝑢14
1
= (𝑢32 + 0 + 𝑢23 + 0) … … … … . (1) 0 𝑢13 𝑢23 𝑢33
4 𝑢43 100(2⁄3)
1 0 𝑢12 𝑢22 𝑢32
𝑢42 100(1⁄3)
𝑢32 = (𝑢42 + 𝑢22 + 𝑢33 + 𝑢31 )
4
𝑥
1 100 𝑢11 𝑢21 𝑢31 𝑢41
= ( + 𝑢22 + 𝑢33 + 0) … … … . (2)
4 3 0 0 0 0
1
𝑢23 = (𝑢33 + 𝑢13 + 𝑢24 + 𝑢22 )
4
1 100
= (𝑢33 + 0 + + 𝑢22 ) … … … . (3)
4 3
1
𝑢33 = (𝑢43 + 𝑢23 + 𝑢34 + 𝑢32 )
4
1 2 × 100 2 × 100
= ( + 𝑢23 + + 𝑢32 ) … … … … (4)
4 3 3
Using Gauss-Seidel Iteration method
Iteration 1 2 3 4 5
𝑢22 0 4.167 Conti.
𝑢32 8.334 17.708
𝑢23 8.334 17.708
𝑢33 33.334 42.187
-5-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
-6-
𝑘
𝑢𝑖−1,𝑗 𝑢𝑖+1,𝑗
𝑢𝑖,𝑗
ℎ
Chapter Seven Solution of PDEs. by Using Finite Difference Method
The solution obtained from equation (7.12) is stable when
1 1
𝛼 < . For a particular case when 𝛼 = , equation (7.12)
2 2
𝜕2 𝑢
In the implicit scheme the space derivative of the parabolic equation, i.e. was replaced by
𝜕𝑥 2
arithmetic mean of its central difference approximation along the 𝑗th and (𝑗 + 1)th time row as
shown in figure (7.5). With this assumption the give parabolic equation is reduced to
𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗 (𝑢𝑖+1,𝑗 − 2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 ) + (𝑢𝑖+1,𝑗+1 − 2 𝑢𝑖,𝑗+1 + 𝑢𝑖−1,𝑗+1 )
=
𝑘 2ℎ2
Rearrangement above equation gives
Unknown values of 𝑢
−𝛼 𝑢𝑖+1,𝑗+1 + (2 + 2𝛼)𝑢𝑖,𝑗+1 − 𝛼 𝑢𝑖−1,𝑗+1 𝑢𝑖,𝑗+1 𝑢𝑖+1,𝑗+1
𝑢𝑖−1,𝑗+1
= 𝛼(𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 ) + (2 − 2𝛼) 𝑢𝑖,𝑗 … . . (7.14) Known values of 𝑢
𝑘
Where 𝑢𝑖−1,𝑗 𝑢𝑖+1,𝑗
𝑢𝑖,𝑗
𝑘 ℎ
𝛼=
ℎ2
It is obvious from equation (7.14) that the left side contains three unknown values of 𝑢 along
the (𝑗 + 1)th time row while the values on the right side are all known along the 𝑗th time row.
Equation (7.14) which is an implicit relation is known as Crank-Nicolson formula and is
convergent for all finite values of .
-7-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
2
𝜕𝑢 𝜕 𝑢
= , 0 ≤ 𝑥 ≤ 1, 𝑡 ≥ 0 … … … . . (1)
𝜕𝑡 𝜕𝑥 2
Under the condition that
𝑢(0, 𝑡) = 𝑢(1, 𝑡) = 0
1
𝑢(𝑥, 0) = 2𝑥 𝑓𝑜𝑟 0 ≤ 𝑥 ≤ … … … . . (2)
2
1
𝑢(𝑥, 0) = 2(1 − 𝑥) 𝑓𝑜𝑟 ≤𝑥≤1
2
Solve the above problem by using (a) an explicit method (b) Crank-Nicolson method
Solution:
(a) An explicit method
The finite difference analogue of equation (1) is given by
𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗 𝑢𝑖+1,𝑗 − 2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
= … … … … … … (3)
𝑘 ℎ2
Where
𝑥 = 𝑖ℎ, 𝑖 = 1, 2, 3, … …
𝑦 = 𝑗𝑘, 𝑗 = 1, 2, 3, … …
Equation (3) can be written as
𝑢𝑖,𝑗+1 = 𝛼(𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 ) + (1 − 2𝛼)𝑢𝑖,𝑗 … … … . . (4)
Where
𝑘
𝛼=
ℎ2
The schematic representation of equation (4) is shown in figure (7.6)
-8-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
Let ℎ = 0.1 , 𝑘 = 0.001 so that 𝛼 = 0.1. It is clear that the problem is symmetric with respect
to the line 𝑥 = 0.5. The values of equidistant from this line on the either side of it is are equal
1
and so we need the solution only for 0 ≤ 𝑥 ≤ .
2
1
𝑢𝑖,𝑗+1 = (𝑢 + 8 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 ) … … … . . (5)
10 𝑖+1,𝑗
For 𝑗 = 1
1 1
(a) Sub. 𝑖 = 2 in Eqn(5) 𝑢2,2 =
10
(𝑢3,1 + 8 𝑢2,1 + 𝑢1,1 ) = 10 (0.4 + 8 × 0.2 + 0) = 0.2
1 1
(b) Sub. 𝑖 = 3 in Eqn(5) 𝑢3,2 =
10
(𝑢4,1 + 8 𝑢3,1 + 𝑢2,1 ) = 10 (0.6 + 8 × 0.4 + 0.2) = 0.4
1 1
(c) Sub. 𝑖 = 4 in Eqn(5) 𝑢4,2 =
10
(𝑢5,1 + 8 𝑢4,1 + 𝑢3,1 ) = 10 (0.8 + 8 × 0.6 + 0.4) = 0.6
1 1
(d) Sub. 𝑖 = 5 in Eqn(5) 𝑢5,2 =
10
(𝑢6,1 + 8 𝑢5,1 + 𝑢4,1 ) = 10 (1 + 8 × 0.8 + 0.6) = 0.8
1 1
(e) Sub. 𝑖 = 6 in Eqn(5) 𝑢6,2 =
10
(𝑢7,1 + 8 𝑢6,1 + 𝑢5,1 ) = 10 (0.8 + 8 × 1 + 0.8) = 0.96
-9-
Chapter Seven Solution of PDEs. by Using Finite Difference Method
From symmetry can be find
𝑢11,2 = 𝑢1,2 = 0
Can repeat the same calculations method for 𝑗 = 2 and 𝑖 = 2,3, … … . ,10 etc.
The table (7.1) gives the values of 𝑢 for values of 𝑥 = [0, (0.1), 1 and various values of 𝑡.
Table (7.1)
- 10 -