COMPARISON OF NUMERICAL SOLUTION OF ELLIPTIC PDE USING FDM AND FEM
S. Karunanithi #1and S.Jeevitha#2
#1, #2, Department of Mathematics, Government Thirumagal Mills College, Gudiyattam – 632 602, Tamil Nadu, India
Abstract: In this paper numerical techniques have been used to solve two dimensional steady heat flow problem with initial and Dirichlet boundary conditions in a rectangular domain .The methods used are used for the purpose of numerical solution viz, Finite difference method and finite element methods. The implementation of the solution is done using Microsoft Office Excel or work sheet. The numerical solutions obtained by these two methods are also compared graphically.
Keywords: Dirichlet Boundary conditions, Finite Difference Method, Finite Element Method, Poisson Equation and Laplace equation.
Corresponding Author: S.Karunanithi
1. INTRODUCTION:
Partial differential equations arise in formulation of problems involving functions of several variables such as the propagation of sound or heat, electro statics, electro dynamics, fluid flow, and elasticity, etc. Partial differential equations arise when a dependent variable depends on two or more independent variables. Usually analytic solutions for these differential equations are difficult to compute and hence alternative methods are used .Numerical methods are widely used to solve partial differential equations within the given domain together with boundary conditions. In general the domain is divided into finite number of elements or the domain is made discretization into small triangles or rectangles.
The values of the dependent variable at the nodes or grid points of these triangles are computed. This paper includes the following sections. Section 2 presents formulation of two dimensional Laplace and Poisson equation with Dirichlet Boundary conditions. Section 3presents finite difference method for solving Laplace and Poisson Equations using spread sheet. Section 4 finite element method for solving Laplace and Poisson equation Section 5 Comparison of numerical solutions obtained in section3 and 4. Section 6The paper ends with conclusions.
2. PROBLEM FORMULATION:
2.1 Laplace equation:
A simple case of steady state heat equation conduction in a rectangular domain shown in Fig.1 may be defined by two dimensional Laplace equations:
2 2
2
2 2 0
u u
u x y
(1)
For x
0,a , y
0,b with a b 3IJST
Where u x y
, is the steady state temperature distribution in the domain.The Dirichlet boundary conditions are
0, 0u y , u a y
,
0 ;u x
, 0 0, u x b
, 100
The region R is divided into finite number of rectangular elements .Every node and every side of the rectangular must be common with adjacent elements except for sides on the boundaries. The nodes and elements are both numbered as shown in Fig.2.
Fig.2: Rectangular elements with nodes are numbered.
2.2 Poisson equation:
The Poisson equation is given by 2u2 2u2 f x y
,x y
or u f x y
,
(2) Here the Laplace operator denotes2 2
2 2
x y
.Equation is the elliptic second order linear partial differential equation. In the dependent variable u x y
,
is a function of its arguments and depends on the independent variables x and y.The function is known as a10 11
7 6
R
0 a=3
0 0
b=3
100
Fig.1: Rectangular region R with boundary conditions
15 14 13
16
100
0
X Y
Y
X 12
8 9
5 0
1 2 3 4
_________________________
IJST
source function. For the purpose of numerical solution of the Poisson equation we consider a plane region defined byR
x y, : 0 x 1and 0 y 1
. We will also impose Dirichlet boundary conditions for the dependent variable u x y
,
on the region R defined as
0, 0, , 0 0,
,1 0, 1, 0
u y u x
u x u y
(3)
The region R together with the Dirichlet boundary conditions (3) is illustrated in figure 3.
The x-variable increases along the positive horizontal axis while the y-variable increases along the positive vertical axis.
Y
u0 u0
u0 X Figure .3: Rectangular region R with boundary conditions
The nodes and the sides in and on the region R can be classified in to two groups ,viz.
interior and exterior .The interior nodes and sides lie inside the region R while the exterior nodes and sides lie on the boundary of the regionR.Further all the interior nodes and sides are common to adjacent rectangular elements. Of course this fact is exempted for the exterior nodes and sides. The nodes of the region R are numbered and shown in figure 4.
1 2 3 4 5 X Figure 4: Rectangular elements with node numbers.
17 18 19
12 13 14
7 8 9
0 u
R
22 23 24 25
6 11 16 21 Y
IJST
Here our problem is to find numerical values of the function u x y
,
at the interior node points of the region R provided that the Poisson equation (2) and the Dirichlet conditions (3) given in are satisfied.3. Finite Difference Method:
The finite difference method (FDM) is conceptually simple. The finite difference techniques are based on the replacement of differential equations with approximately equivalent finite difference equations. Whenever solving differential equations analytically is not easy then the differential equations are replaced by corresponding finite difference equations and those will be solved. Further, the differential equations provide exact values while the difference equations provide approximate values for the variables. Approximation of the solution relates to the number of grids given region is divided into. More are the grids and better is the approximation.
1. Divide the solution region into a grid of nodes of points. Grid points are typically arranged in a rectangular array of nodes.
2. Approximate the given differential equation by equivalent finite difference equations that relate the solutions to the grid points.
3. Solve the difference equations subjected to the prescribed boundary and /or initial conditions.
To find the solution of the function u x y
,
on the region R , we divide the region into equal rectangles or meshes. The region has prescribed potentials along its boundaries. Let the location of an interior grid point be identified by a pair of integers i, j , where i and j represent the position along the horizontal and vertical directions, respectively. For a grid having equal horizontal and vertical step sizes, the potential is given by finite difference equation:
,
1, 1, , 1 , 1
1
i j 4 i j i j i j i j
u u u u u (3)
The equations are formulated for all the free nodes leading to a system of linear algebraic equations. This system of equations may be solved by a variety of methods. In this paper the Gauss-Seidel method is implemented in a spreadsheet to solve this system of equations. The Gauss-Seidel method is a relatively simple iterative method for solving systems such as those encountered in the finite difference formulation. For Poisson equation the potential equation contains value of the specific value of the function f x y
,
1. For agrid having equal and horizontal and vertical step sizes the potential is given
by ,
1, 1, , 1 , 1 2 .
1
i j 4 i j i j i j i j i j
u u u u u h f , i j, 2, 3, 4 .
rectangular grid of the free nodes to illustrate the finite difference method.
There are 4 potentials at interior grid points that are determined for Laplace equation and 9 potentials at interior node for Poisson equation are shown in the figure 5(a) and (b) respectively .
_________________________
IJST
(a) (b)
Figure 5: The region R showing prescribed potentials at the boundaries and Table.1.Gauss-Seidel iterations to illustrate the FDM for Laplace equation
10 11
7 6
17 18 19
12 13 14
7 8 9
Iteration 6 7 10 11
1 0.0 0.0 0.0 0.0
2 0.0 0.0 25.0 25.0
3 6.3 6.3 31.3 31.3
4 9.4 9.4 34.4 34.4
5 10.9 10.9 35.9 35.9
6 11.7 11.7 36.7 36.7
7 12.1 12.1 37.1 37.1
8 12.3 12.3 37.3 37.3
9 12.4 12.4 37.4 37.4
10 12.5 12.5 37.5 37.5
Iteratio ns
Node numbers
7 8 9 12 13 14 17 18 19
1 0 0 0 0 0 0 0 0 0
2 -0.0156 -0.0195 -0.0205 -0.0195 -0.0254 -0.0271 -0.0205 -0.0271 -0.0292 3 -0.0254 -0.0334 -0.0308 -0.0334 -0.0459 -0.0421 -0.0308 -0.0421 -0.0367 4 -0.0323 -0.0429 -0.0369 -0.0429 -0.0581 -0.0485 -0.0369 -0.0485 -0.0399 5 -0.0371 -0.0486 -0.0399 -0.0486 -0.0642 -0.0516 -0.0399 -0.0516 -0.0414 6 -0.0399 -0.0516 -0.0414 -0.0516 -0.0673 -0.0532 -0.0414 -0.0532 -0.0422 7 -0.0414 -0.0532 -0.0422 -0.0532 -0.0688 -0.0539 -0.0422 -0.0539 -0.0426 8 -0.0422 -0.0539 -0.0426 -0.0539 -0.0695 -0.0543 -0.0426 -0.0543 -0.0428
100 Y
0 0
0
0
0
0
0
Y
X X
Table .2. Gauss-Seidel iterations to illustrate the FDM for Poisson equation
IJST
4. Finite Element Method:
The finite element method is a technique for solving PDEs. Finite element methods are essentially methods for finding approximate solutions of partial differential equations defined in a finite region or domain. Finite element method involves the following steps involves the following steps:
i. Divide the domain in to a finite number of elements.
ii. Drive the weak formulation corresponding to the given problem
iii. Calculate the stiffness matrix and load vector for each element in the domain.
Calculate global stiffness matrix and assemble. Calculate global load vector and assemble.
iv. Solve the resulting system of algebraic linear equations subject to the satisfaction of the boundary conditions.
For Laplace equation, the region is divided into 18 equal triangular elements as indicated in the Fig for Laplace equation. The elements are identified by encircled numbers1 through 18.In this discretization there are 16 global nodes numbered 1 through 16 as indicated in the Figure 6.
1 2 3 4
Figure .6: The region R showing prescribed potentials at the boundaries and triangular grid of the free nodes to illustrate the finite element method
For Poisson equation the given domain R is divided into 32 congruent right angled and isosceles triangles. The nodes of the triangles are represented using unenclosed numbers.
These unenclosed numbers are called global node numbers. Similarly, the triangles are represented by en-rectangle numbers. These enclosed numbers are called element numbers.
The en-rectangle number is a number that is enclosed by a rectangle. These details are shown in the figure 7.
10 -0.0428 -0.0545 -0.0429 -0.0545 -0.0701 -0.0546 -0.0429 -0.0546 -0.0429 11 -0.0429 -0.0546 -0.0429 -0.0546 -0.0702 -0.0546 -0.0429 -0.0546 -0.0429 12 -0.0429 -0.0546 -0.0429 -0.0546 -0.0703 -0.0547 -0.0429 -0.0547 -0.0430 13 -0.0429 -0.0547 -0.0430 -0.0547 -0.0703 -0.0547 -0.0430 -0.0547 -0.0430 14 -0.0430 -0.0547 -0.0430 -0.0547 -0.0703 -0.0547 -0.0430 -0.0547 -0.0430 15 -0.0430 -0.0547 -0.0430 -0.0547 -0.0703 -0.0547 -0.0430 -0.0547 -0.0430
16
9 10 11
8 7 6
Y
5
1 2
3 4
5 6 7
8 9
10
11 1
12 14
100
18
15 17 16
13
X
0 0
13 14
15
_________________________
IJST
Figure 7: Division of domain R into isosceles triangle and right angled triangles The stiffness matrix for each element is calculated using the formula
1 4
e
ij i j i j
C PP Q Q
A
,where i j, 1, 2, 3 (4) and Pi,P and ,j Q Q for elements i j e that are computed.
2 3 3 2
1
A 2 P Q P Q (5)
For Laplace equation the stiffness matrix for each element is calculated and is the assembled from the element coefficient matrix. Since there are 16 X 16 matrix. The assembled global coefficient matrix is shown in Matrix table 3.
Table:3 showing global coefficient matrix of Laplace equation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 -0.5 0 0 0 0 0 -0.5 0 0 0 0 0 0 0 0
2 -0.5 2 -0.5 0 0 0 -1 0 0 0 0 0 0 0 0 0
3 0 -0.5 2 -0.5 0 -1 0 0 0 0 0 0 0 0 0 0
4 0 0 -0.5 1 -0.5 0 0 0 0 0 0 0 0 0 0 0
5 0 0 0 -0.5 2 -1 0 0 0 0 0 -0.5 0 0 0 0
6 0 0 -1 0 -1 4 -1 0 0 0 -1 0 0 0 0 0
7 0 -1 0 0 0 -1 4 -1 0 -1 0 0 0 0 0 0
8 -0.5 0 0 0 0 0 -1 2 -0.5 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 -0.5 2 -1 0 0 0 0 0 -0.5
10 0 0 0 0 0 0 -1 0 -1 4 -1 0 0 0 -1 0
11 0 0 0 0 0 -1 0 0 0 -1 4 -1 0 -1 0 0
17 18 19
12 13 14
7 8 9
21
16
11
26
25 27
28
29
30 32
31
17
18 20
19 21
22 24
23
16
10 9
12
11 13
14 16
15
2 1
3 4
6 5
8 7
22 23 24 25
1 2 3 4
IJST
13 0 0 0 0 0 0 0 0 0 0 0 -0.5 1 -0.5 0 0
14 0 0 0 0 0 0 0 0 0 0 -1 0 -0.5 2 -0.5 0
15 0 0 0 0 0 0 0 0 0 -1 0 0 0 -0.5 2 -0.5
16 0 0 0 0 0 0 0 0 -0.5 0 0 0 0 0 -0.5 1
For Poisson equation, there are 32 global matrices gives the assembled global matrix of 25 X 25 matrix. The assembled global matrix is shown in the table 4.
Table.4: showing assembled global matrix of Poisson equation Global Node Numbers
GLOBAL NODE NUMBERS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
1 -1 0.5 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0.5 -2 0.5 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0.5 -2 0.5 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 0 0 0.5 -2 0.5 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0.5 -1 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 0.5 0 0 0 0 -2 1 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
9 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0.5 0 0 0 1 -2 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0.5 0 0 0 0 -2 1 0 0 0 0.5 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0 0 0
13 0 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0 0
14 0 0 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0 0.5 0 0 0 1 -2 0 0 0 0 0.5 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0.5 0 0 0 0 -2 1 0 0 0 0.5 0 0 0 0
17 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0 0
18 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0 0
19 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 -4 1 0 0 0 1 0
20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 0 0 1 -2 0 0 0 0 0.5
21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 0 0 0 -1 0.5 0 0 0
22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0.5 -2 0.5 0 0
23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0.5 -2 0.5 0
24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0.5 -2 0.5
25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0 0 0 0.5 -1
Defining the vector potential u andf u , where the subscripts f and p refers to nodes with p free (unknown) potentials and prescribed potentials respectively, the global coefficient matrix
is then partitioned accordingly and unknown potentials are obtained from
1
f ff fp p
u c c u
(6)
The implementation of equation (6) has been broken down into three parts:
1) Computation of the inverse of the cf f matrix (this has been labeled A1Cff1
2) Computation of an intermediate vector b C ufp p and 3) Computation of vector of potential at free nodes uf A b1
Table 5. Reduced assembled global vector and corresponding load vector of Laplace equation Global
Node Numbers
Global Node Numbers Global node Numbers
Load vector
6 7 10 11
6 4 -1 0 -1 6 0
7 -1 4 -1 0 7 0
10 0 -1 4 -1 10 100
11 -1 0 -1 4 11 100
_________________________
IJST
Table 6. Reduced assembled global vector and corresponding load vector of Poisson equation
Global Node Numbers
Global Node Numbers (Matrix of
free nodes Cff ) Global Node
Numbers
Load Vector 7 8 9 12 13 14 17 18 19
7 -4 1 0 1 0 0 0 0 0 7 0.0417
8 1 -4 1 0 1 0 0 0 0 8 0.0833
9 0 1 -4 0 0 1 0 0 0 9 0.0417
12 1 0 0 -4 1 0 1 0 0 12 0.0833
13 0 1 0 1 -4 1 0 1 0 13 0.0417
14 0 0 1 0 1 -4 0 0 1 14 0.0833
17 0 0 0 1 0 0 -4 1 0 17 0.0417
18 0 0 0 0 1 0 1 -4 1 18 0.0833
19 0 0 0 0 0 1 0 1 -4 19 0.0417
Finally the vector potentials at free nodes are calculated using equation (6) and the values are tabulated as shown in table 7 and 8 for Laplace and Poisson equation respectively.
Table 7. Load vector with global node numbers Global Node Numbers Load Vector
6 12.5
7 12.5
10 37.5
11 37.5
Table 8: Load vector corresponding with global node numbers Global Node
Numbers Load Vector
7 -0.0391
8 -0.0573
9 -0.0391
12 -0.0573
13 -0.0677
14 -0.0573
17 -0.0391
18 -0.0573
19 -0.0391
5. Comparison of numerical solution by FDM and FEM:
As indicated in the Table 9 and 10 the potentials at the free nodes computed by FDM, FEM numerical solutions compared fairly well. The better agreement should be obtained between the all numerical solution results by using a rectangular grid for difference
IJST
Table .9:Comparison between Numerical solution by FDM and FEM of Laplace equation
Node Numerical solution by FDM
Numerical Solution by FEM
6 12.5 12.5
7 12.5 12.5
10 37.5 37.5
11 37.5 37.5
Table .10: Comparison between numerical solution by FDM and FEM solution of Poisson equation
Graphical comparison between numerical solution by FDM and FEM:
Figure 8: Graphical comparison between Numerical Solution by FDM and FEM Nodes Finite Difference
Solution
Finite Element Solution
7 -0.0430 -0.0391
8 -0.0547 -0.0573
9 -0.0430 -0.0391
12 -0.0547 -0.0573
13 -0.0703 -0.0677
14 -0.0547 -0.0573
17 -0.0430 -0.0391
18 -0.0547 -0.0573
19 -0.0430 -0.0391
_________________________
IJST
Figure 9: Graphical comparison between Numerical solution by FDM and FEM 6. Conclusion:
Many fundamental ideas and techniques in finite difference and finite element methods have resemblance, and in some simple cases they coincide. we have introduced numerical methods for solving Laplace and Poisson equations in two dimensions with Dirichlet boundary conditions respectively. In both cases the finite difference method is somewhat complex in comparison with that of the finite element method. Boundary conditions which are expressed using differential equations are difficult to handle using finite difference method, but the finite element method alleviates all difficulties appears in finite difference method.
References:
[1] Alfio Quarteroni, “Numerical models for differential problems”, (2nd edition), Springer- Verlag, Italia, 2014
[2] Parag V. Patil and Dr. J.S.V.R. Krishna Prasad, “Numerical solution for two dimensional Laplace equation with Dirichlet boundary conditions, Volume 6, Issue 4 (May - June 2013), pp.66-75.
[3]Benyam Mebrate and Puranchandra Rao koya, “Numerical solution of a two dimensional Poisson equation with Dirichlet boundary conditions, volume 3, No.6, 2015, pp.297-304.
[4] M. N. O. Sadiku, “Elements of Electromagnetics (New York: Oxford University Press, 4th edition, 2006)
[5] M. Kumar and P. Kumar, “A Finite Element Approach for Finding Positive Solutions of Semilinear Elliptic Dirichlet Problems,” Numerical Methods for Partial differential
Equations, Vol. 25, No. 5, 2009, pp. 1119-1128.