Numerical Analysis by Dr. Anita Pal Assistant Professor Department of Mathematics National Institute of Technology Durgapur Durgapur-713209
Numerical Analysis by Dr. Anita Pal Assistant Professor Department of Mathematics National Institute of Technology Durgapur Durgapur-713209
Numerical Analysis by Dr. Anita Pal Assistant Professor Department of Mathematics National Institute of Technology Durgapur Durgapur-713209
by
Dr. Anita Pal
Assistant Professor
Department of Mathematics
National Institute of Technology Durgapur
Durgapur-713209
email: anita.buie@gmail.com
1
.
Chapter 9
Module No. 3
Elliptic PDE is one of the widely used PDEs. In this module, the finite difference
method is described to solve the elliptic PDEs.
The elliptic PDEs occur in many practical situations. The most simple elliptic PDEs
are Laplace and Poisson equations. The Laplace equation is ∇n u = 0 and Poisson
equation is ∇n u = g(r).
One physical example of such equations is stated below.
Let the function ρ represent the electric charge density in some open bounded set
Ω ⊂ Rd . If the permittivity ε is constant in Ω the distribution of the electric potential
ϕ in Ω is governed by the Poisson equation
−ε∆ϕ = ρ.
This equation does not have a unique solution, because if φ is a solution of this
equation, then the function φ + c, is also a solution, where c is any constant. To get a
solution, every elliptic equation should have a suitable boundary conditions.
Let us consider the two-dimensional Laplace equation
∂2u ∂2u
+ 2 = 0 within the region R (3.1)
∂x2 ∂y
and u = f (x, y) on the boundary C.
In this problem, both are space variables. Now, we approximate this PDE by the
central difference approximation. Then the finite difference approximation of the above
equation is
ui−1,j − 2ui,j + ui+1,j ui,j−1 − 2ui,j + ui,j+1
+ = 0. (3.2)
h2 k2
It is assumed that the length of the subintervals along x and y directions are equal,
i.e. h = k. Then the above equation becomes,
1
ui,j = [ui+1,j + ui−1,j + ui,j+1 + ui,j−1 ]. (3.3)
4
From this expression, it is seen that the value of ui,j is the average of the values of u
at the four meshes – north (i, j + 1), east (i + 1, j), south (i, j − 1) and west (i − 1, j).
1
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
y
6(i, j+1)
u
u e u
(i-1,j) (i,j) (i+1,j)
u - x
(i,j-1)
The known values (filled circles) and unknown (circle) are shown in Figure 3.1. This
formula is known as standard five-point formula.
It can be proved that the Laplace equation remains invariant when the coordinates
axes are rotated at an angle 450 .
Under this rotation, the equation (3.3) becomes
1
ui,j = [ui−1,j−1 + ui+1,j−1 + ui+1,j+1 + ui−1,j+1 ]. (3.4)
4
This is another formula to calculate ui,j and it is known as diagonal five-point
formula. The known and unknown meshes for this formula are shown in Figure 3.2.
y
6
u
(i-1,j+1)
u (i+1,j+1)
e
(i,j)
u u- x
(i-1,j-1) (i+1,j-1)
When the right hand side of the Laplace equation is nonzero, then this equation
is known as Poisson’s equation. The Poisson’s equation in two-dimension is in the
following form
Here, we also assumed that the mesh points in both x and y directions are uniform.
Using this assumption the central difference approximation of the equation (3.5) is
reduced to
1
ui,j = [ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − h2 gi,j ] where gi,j = g(xi , yj ). (3.6)
4
Let u = 0 along the boundary C and i, j = 0, 1, 2, 3, 4. Then u0,j = 0, u4,j = 0 for
j = 0, 1, 2, 3, 4 and ui,0 = 0, ui,4 = 0 for i = 0, 1, 2, 3, 4. The boundary values (filled
circles) are shown in Figure 3.3.
y
6 u=0
j=4 u u u u u
j=3 u e e e u
u1,3 u2,3 u3,3
u=0, j=2 u e e e u u=0
u1,2 u2,2 u3,2
j=1 u e e e u
u1,1 u2,1 u3,1
j=0 u u u u u- x
i=0 i=1 i=2 i=3 i=4
u=0
For a particular case, i.e. for i, j = 1, 2, 3 the equation (3.6) becomes a system of nine
equations with nine unknowns. These equations are written in matrix notation as
4 −1 0 −1 0 0 0 0 0 u1,1 −h2 g1,1
−1 4 −1 0 −1 0 0 0 0 u1,2 −h2 g1,2
0 −1 4 0 0 −1 0 0 0
u
−h 2g
1,3 1,3
−1 0 0 4 −1 0 −1 0 0 u2,1 −h2 g2,1
0 −1 0 −1 4 −1 0 −1 0 u2,2 = −h2 g2,2 (3.7)
0 0 −1 0 −1 4 0 0 −1 u −h2 g
2,3 2,3
0 0 0 −1 0 0 4 −1 0 u3,1 −h2 g3,1
0 0 0 0 −1 0 −1 4 −1 u −h2 g
3,2 3,2
0 0 0 0 0 −1 0 −1 4 u3,3 −h2 g3,3
3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
This indicates that the equation (3.6) is a system of N (where N is the number of
subintervals along x and y directions) equations. Note that the coefficient matrix is
symmetric, positive definite and sparse (many elements are 0). Since, the coefficient
matrix is sparse, so it is suggested to use iterative method rather than direct method
to solve the above system of equations. Commonly used iterative methods are Jacobi’s
method, Gauss-Seidel’s method, successive overrelaxation method, alternate direction
implicit method, etc.
Let us consider the Laplace’s equation uxx + uyy = 0. Let the region R be square
and it is divided into N × N small squares each of side h. The boundary values are
u0,j , uN,j , ui,0 , ui,N where i, j = 0, 1, 2, . . . , N , shown in Figure 3.4.
y
6 u1,4 u2,4 u3,4 u4,4
u0,4 u u u u u
u0,3 u e e e u u4,3
u1,3 u2,3 u3,3
u0,2 u e e e u u4,2
u1,2 u2,2 u3,2
u0,1 u e e e u u4,1
u1,1 u2,1 u3,1
u u u u u- x
u0,0 u1,0 u2,0 u3,0 u4,0
Figure 3.4: Known and unknown meshes for Laplace equation. Red meshes are cal-
culated by diagonal five-point formula and blue meshes are determined by standard
five-point formula
At first the diagonal five-point formula is used to compute the values of u according
to the order u2,2 , u1,3 , u3,3 , u1,1 and u3,1 (red meshes in the figure). That is,
1
u2,2 = (u0,0 + u4,4 + u0,4 + u4,0 )
4
1
u1,3 = (u0,2 + u2,4 + u0,4 + u2,2 )
4
4
......................................................................................
1
u3,3 = (u2,2 + u4,4 + u2,4 + u4,2 )
4
1
u1,1 = (u0,0 + u2,2 + u0,2 + u2,0 )
4
1
u3,1 = (u2,0 + u4,2 + u2,2 + u4,0 ).
4
In the second step, the remaining values, viz., u2,3 , u1,2 , u3,2 and u2,1 are evaluated
using standard five-point (blue meshes in the figure). Thus,
1
u2,3 = (u1,3 + u3,3 + u2,2 + u2,4 )
4
1
u1,2 = (u0,2 + u2,2 + u1,1 + u1,3 )
4
1
u3,2 = (u2,2 + u4,2 + u3,1 + u3,3 )
4
1
u2,1 = (u1,1 + u3,1 + u2,0 + u2,2 ).
4
Note that these are the first approximate values of u at different meshes. These values
can be updated by using any iterative methods mentioned earlier.
uxx + uyy = 0,
u(x, 0) = 0, u(0, y) = 0,
u(x, 1) = 5x, u(1, y) = 5y.
Find the first approximate values at the interior meshes by dividing the square region
into 4 × 4 squares.
Solution. For this problem, the region R is 0 ≤ x, y ≤ 1. Let h = k = 0.25 and
xi = ih, yj = jk, i, j = 0, 1, 2, 3, 4. The meshes are shown in Figure 3.5.
The values of u are calculated in two steps. In first step, the diagonal five-point
formula is used to find the values of u2,2 , u1,3 , u3,3 , u1,1 , u3,1 and in second step the
standard five-point formula is used to find the values of u2,3 , u1,2 , u3,2 , u2,1 .
The diagonal five-point formula is
1
ui,j = [ui−1,j−1 + ui+1,j−1 + ui+1,j+1 + ui−1,j+1 ]
4
5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
y
u1,4 u2,4 u3,4 u4,4
6 1.25
u 2.50
u 2.75 5.0
y=1.00, u0,4 =0 u u u u4,4 =5.0
y=0.00, u0,0 =0 u u u u u- x
0 0 0 0
u1,0 u2,0 u3,0 u4,0
x=0 x= 14 x= 12 x= 34 x=1
Figure 3.5: Meshes for Dirichlet’s problem
1 1
u2,3 = (u1,3 + u3,3 + u2,2 + u2,4 ) = (0.9375 + 2.8125 + 1.25 + 2.5) = 1.875
4 4
1 1
u1,2 = (u0,2 + u2,2 + u1,1 + u1,3 ) = (0 + 1.25 + 0.3125 + 0.9375) = 0.625
4 4
1 1
u3,2 = (u2,2 + u4,2 + u3,1 + u3,3 ) = (1.25 + 2.5 + 0.9375 + 2.8125) = 1.875
4 4
1 1
u2,1 = (u1,1 + u3,1 + u2,0 + u2,2 ) = (0.3125 + 0.9375 + 0 + 1.25) = 0.625.
4 4
6
......................................................................................
If the first approximate values of u are known, then these values can be updated by
applying any well known iterative method. Several iterative methods are available with
different rates of convergence, some of them are discussed below.
The standard five-point finite-difference formula for the Poisson’s equation (3.5) is
1
ui,j = (ui−1,j + ui+1,j + ui,j−1 + ui,j+1 − h2 gi,j ). (3.8)
4
(r)
Let ui,j be the rth iterative value of ui,j , r = 1, 2, . . ..
Jacobi’s method
The Jacobi’s iterative scheme to solve the system of equations (3.8) for the interior
meshes is
Gauss-Seidel’s method
In it well known (discussed in Chapter 5) that the latest updated values are used in
Gauss-Seidel’s method. The values of u along each row are computed systematically
from left to right. The iterative formula is
In this method, the iteration scheme is accelerated by introducing a scalar, called re-
(r+1) (r)
laxation factor. This acceleration is made by making corrections on [ui,j − ui,j ].
(r+1)
Suppose ui,j is the value obtained from any iteration method, such as Jacobi’s or
7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
Gauss-Seidel’s method. Then the updated value of ui,j at the (r + 1)th iteration is given
by
(r+1) (r+1) (r)
ui,j = wui,j + (1 − w)ui,j , (3.11)
Example 3.2 Solve the Laplace’s equation uxx + uyy = 0 defined within the square
region 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1 shown in Figure 3.6, by (a) Jacobi’s method, (b)
Gauss-Seidel’s method, and (c) Gauss-Seidel’s successive over-relaxation method.
u
12.4
e
u
12.4
e
u e
u
0 u e
u1,2
e
u2,2
e0
u
0 u e e e0
u
u1,1 u2,1
u u u u
0 0
Solution.
(a) Jacobi’s method
Let the initial values be u2,1 = u1,2 = u2,2 = u1,1 = 0 and h = k = 1/3.
The Jacobi’s iteration scheme is
8
......................................................................................
Therefore, u1,1 = 1.5500, u2,1 = 1.5500, u1,2 = 4.6500, u2,2 = 4.6500, correct up to
four decimal places.
(b) Gauss-Seidel’s method
Let u2,1 = u1,2 = u2,2 = u1,1 = 0 be the initial values. Also, h = k = 1/3.
9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
Hence, u1,1 = 1.55000, u2,1 = 1.55000, u1,2 = 4.65000, u2,2 = 4.65000, correct up to
five decimal places.
10
......................................................................................
Example 3.3 Solve the Poisson’s equation uxx + uyy = 5x2 y for the square region
0 ≤ x ≤ 1, 0 ≤ y ≤ 1 with h = 1/3 and the values of u on the boundary are every where
zero. Use (a) Gauss-Seidel’s method, and (b) Gauss-Seidel’s SOR method.
Solution. In this problem, g(x, y) = 5x2 y, h = k = 1/3 and the boundary conditions
are u0,0 = u1,0 = u2,0 = u3,0 = 0, u0,1 = u0,2 = u0,3 = 0,
u1,3 = u2,3 = u3,3 = 0, u3,1 = u3,2 = 0.
11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Partial Differential Equations: Elliptic
The solution obtained by SOR method is u1,1 = −0.02315, u2,1 = −0.04115, u1,2 =
−0.03086, u2,2 = −0.05916, correct up to five decimal places.
Note that the Gauss-Seidel’s iteration method needs 7 iterations whereas SOR method
takes only 6 iteration for w = 1.1.
13