PDE Numerical Solutions Guide
PDE Numerical Solutions Guide
Finite difference techniques for the solution of two dimensional Laplace’s and Poisson’s
equations on rectangular domain–Solution of one dimensional heat equation using Bender
Schmidt and Crank Nicholson difference schemes –Solution of one dimensional wave
equation by explicit scheme.
Note:
It is possible for an equation to be of more than one type depending on the values of the
coefficients.
For example, the equation y u xx+ uyy = 0
A = y, B = 0, C = 1
B2 – 4AC = -4y
Problems
1. Classify the partial differential equation
uxx- 2 uxy + uyy = 0
Solution:
A = 1, B = -2 , C = 1
B2 – 4AC = (-2)2 – 4(1)(1) = 0
So, given partial differential equation is Parabolic.
Solution:
A = 1, B = -4
B2 – 4AC = (-4)2 – 4(1)(0) = 16
So, given partial differential equation is Hyperbolic.
Parabolic equation
One dimensional heat equation
The one dimensional heat equation models the flow of heat in a rod that is insulated along the
sides so that there is no loss of heat. The temperature u in the rod depends on two variables - x
(position on the rod, i.e., distance from the origin) and t (time). The general one dimensional
heat equation is
u 2 u
2
k
c , i.e., u t c 2 u xx where c 2 is the thermal diffusivity of the material of the
t x 2
rod, k is the thermal conductivity, is the density and is the specific heat capacity of the
material of the rod.
To solve this equation, we need 3 conditions – 2 boundary conditions and 1 initial condition.
Numerical solution of one dimensional heat equation
1. Explicit method – Bender Schmidt method
2. Implicit method – Crank Nicholson method
u 1 2u
t a x 2
u xx aut .
Example 1
u 2 u
Solve subject to ux,0 sin x, 0 x 1, u0, t u1, t 0 , using Bender Schmidt
t x 2
method.
u xx aut u(x,t)
Solution
From the give equation, we get a 1 . Here 0 x 1 Let us take h 0.2 . Then
ah 2 10.2
2
k 0.02
2 2
k 0.02 1
ah 2
0.22 2
The first row, first column and last column are filled up using the given conditions. The
ui 1, j u i 1, j
remaining rows are filled using Bender Schmidt formula : u i , j 1
2
ux,0 sin x, 0 x 1, u0, t u1, t 0
2. Solve u xx 2ut , given u0, t 0, u4, t 0, ux,0 x4 x assuming h k 1 . Find the
values of u upto t=5 by Bender-Schmidt method.
Solution
From the give equation, we get a 2 . Given h 1 . Then
ah 2 21
2
k 1
2 2
k 1
2
ah 2
The first row, first column and last column are filled up using the given conditions. The
ui 1, j u i 1, j
remaining rows are filled using Bender Schmidt formula : u i , j 1
2
ux,0 x4 x gives the values of the first row.
i
j 0 1 2 3 4
0 0 3 4 3 0
1 0 2 3 2 0
2 0 1.5 2 1.5 0
3 0 1 1.5 1 0
4 0 0.75 1 0.75 0
Solution:
From the give equation, we get a 1 . Given h k 1 . Then
k 1
2
1
ah 2
Sub 1
ui , j 1 ui 1, j ui , j ui 1, j
The first row, first column and last column are filled up using the given conditions. The
remaining rows are filled using Bender Schmidt formula : ui , j 1 ui 1, j ui , j ui 1, j
i
j 0 1 2 3 4
0 0 3 4 3 0
1 0 1 2 1 0
2 0 1 0 1 0
3 0 -1 2 -1 0
4 0 3 -4 3 0
5 0 -7 10 -7 0
Note:Here 1 , so we cannot use Bender Schmidt formula. We have to use explicit formula even
1
though we do not have 0 .
2
Practice problem
2 u u
1. Solve given u0, t u5, t 0, ux,0 x 2 25 x 2 . Find u in the range taking h=1
x 2
t
and upto t 3 using Bender-Schmidt formula.
u1 u3 u7 u9 3 and u2 u4 u6 u8 2
Crank-Nicholson method
In the one-dimensional heat equation u xx aut , we replace u xx by the average of the values of
the difference quotient at i, j and i, j 1 , and replace u t by its difference quotient to obtain
general Crank-Nicholson scheme:
ui 1, j 1 ui 1, j 1 2 1ui , j 1 ui 1, j ui 1, j 2 1ui , j where
k
ah 2
u i , j 1
1
ui1, j 1 ui1, j 1 ui1, j ui1, j
4
u ( x,0) u (0, t ) 0 and u (1, t ) 100 t . Compute u for one step in t direction taking h 1 .
4
Solution:
2
1 1
Here a=16 , h k ah 2 16 1
4 4
k 1
1
ah 2 1
2
16
4
u i , j 1
1
ui1, j 1 ui1, j 1 ui1, j ui1, j
4
Initial Condition u( x,0) 0,
0 0 0 0 0 0
1 0 u1 u2 u3 100
u1
1
0 0 0 u2
4
u2
u1
4
4u1 u2
4u1 u2 0 .................(1)
u2
1
u1 0 0 u3
4
u1 u3
u2
4
4u2 u1 u3
u1 4u2 u3 0 .................(2)
u3
1
u 2 0 0 100
4
u2 100
u3
4
4u3 u2 100
16
4
u i , j 1
1
ui1, j 1 ui1, j 1 ui1, j ui1, j
4
0 0 0 0 0 0
1/16 0 u1 u2 u3 1/16
2/16 0 u4 u5 u6 2/16
u1
1
0 0 0 u 2
4
u2
u1
4
u41 u2 0 .................(1)
u2
1
u1 0 0 u3
4
u1 u3
u2
4
u1 4u2 u3 0 .................(2)
1 1
u3 u 2 0 0
4 16
1
4u3 u2
16
1 .................(3)
u2 4u3
16 Solving (1), (2) and (3) we get
u4
1
0 0 u 2 u5
4
u 2 4u 4 u5 0
0.0045 4u 4 u5 0
.....................(4)
4u 4 u5 0.0045
4u 4 u5 0.0045
u5
1
u 4 u6 u1 u3
4
1 2 1
u6 u5 u 2
4 16 16
1 3
u 6 u 5 0.0045
4 16
4u6 u5 0.1920
u 2 u
3. Using Crank-Nicholson method, solve , subject to
t x 2
u ( x,0) 0, u (0, t ) 0 and u (1, t ) t taking (i) h 0.5 and k 1 (ii) h 1 and k 1 .
8 4 8
Solution:
1
(i) h 0.5 and k
8
1
k 1
Here a=1 , Given h 0.5 2 8 2
ah 10.5 2
1
since 2 we cannot use simplified formula
ui 1, j 1 ui 1, j 1 2 1ui , j 1 ui 1, j ui 1, j 2 1ui , j
1
sub 2
0.5ui 1, j 1 0.5ui 1, j 1 20.5 1ui , j 1 0.5ui 1, j 0.5ui 1, j 20.5 1ui , j
0.5
ui1, j 1 ui1, j 1 ui1, j ui1, j 1 ui , j ui , j 1
3 3
0.1667ui 1, j 1 ui 1, j 1 ui 1, j ui 1, j 0.3333ui , j ui , j 1
I. C u(x,0) 0
0 0.5 1
t x
0 0 0 0
1/8 0 u1 1/8
1
u1 0.1667 0 0 0 0.33330
8
u1 0.0208
1 1
(ii) h and k .
4 8
1
k 8
Here a=1 , Given h 0.25 2 2
10.25
2
ah
2
since we cannot use simplified formula
ui 1, j 1 ui 1, j 1 2 1ui , j 1 ui 1, j ui 1, j 2 1ui , j
2
sub
2ui 1, j 1 2ui 1, j 1 22 1ui , j 1 2ui 1, j 2ui 1, j 22 1ui , j
2ui 1, j 1 2ui 1, j 1 6ui , j 1 2ui 1, j 2ui 1, j 2ui , j
1
ui1, j 1 ui1, j 1 ui1, j ui1, j 1 ui , j ui , j 1
3 3
1
ui1, j 1 ui1, j 1 ui1, j ui1, j 1 ui , j ui , j 1
3 3
ui , j 1
1
ui1, j 1 ui1, j 1 ui1, j ui1, j 1 ui , j
3 3
0 0.25 0.5 0.75 1
t x
0 0 0 0 0 0
1/8 0 u1 u2 u3 1/8
u1
1
0 0 0 u 2 1 0
3 3
3u1 u2 0 .................(1)
u2
1
0 0 u1 u3 1 0
3 3
3u 2 u1 u3 u1 3u 2 u3 0 .................(2)
1 1 1
u3 0 0 u 2 0
3 8 3
1 .................(3)
3u3 u 2 u 2 3u3 0.125
8
Solving (1) , (2) and (3)
u1 0.0060 , u2 0.0179 , u3 0.0476
2u 2 u
2
c
t 2 x 2
h
When k , the explicit formula to solve one dimensional wave equation is
a
u i , j 1 u i 1, j u i 1, j u i , j 1 .
When ut x,0 0 , the second row of the table is got using the formula
ui 1,0 ui1,0
ui ,1
2
For working convenience, we will consider the downward direction
to be the positive t - direction
Value of u at E = Value of u at B + Value of u at D - Value of u at A
2l
Note: Period of vibration = where l is the length of the string
a
l
Half period of vibration =
a
2u 2 u
2
a
t 2 x 2
1. Solve 25u xx u tt 0 for u at the pivotal positions, given
2 x for 0 x 2.5
u 0, t u 5, t 0, ut x,0 0, u x,0 for one half period of vibration.
10 2 x for 2.5 x 5
Solution:
Given 25u xx u tt 0
ui , j 1
1
2
u i 1, j ui 1, j
u i , j 1 u i 1, j u i 1, j u i , j 1
u0, t u5, t 0,
B. C
2 x for 0 x 2.5
ut x,0 0, u x,0
I. C 10 2 x for 2.5 x 5
0 1 2 3 4 5
t x
0 0 2 4 4 2 0
0.2 0 2 3 3 2 0
0.4 0 0+3-2=1 2+3-4=1 3+2-4=1 3+0-2=1 0
0.6 0 0+1-2=-1 1+1-3=-1 1+1-3=-1 1+0-2=-1 0
0.8 0 0+(-1)-1=-2 -1+(-1)-1=-3 -1+(-1)-1=-3 -1+0-1=-2 0
1.0 0 0+(-3)-(-1)=-2 -2+(-3)-(-1)=-4 -3+(-2)-(-1)=-4 -3+0-(-1)=-2 0
2. Evaluate the pivoted values of the following equation taking h=1and upto one half of the
period of the oscillation 16u xx utt 0 , u 0, t u 5, t 0, ut x,0 0, u x,0 x 2 5 x ,
Solution:
Given 16u xx utt 0
l 5
One half period of vibration = 1.25 sec
a 4
B. C u0, t u5, t 0
ut x,0 0, u x,0 x 2 5 x ,
I. C
For wave equation
ui , j 1
1
2
u i 1, j ui 1, j
u i , j 1 u i 1, j u i 1, j u i , j 1
0 1 2 3 4 5
t x
0 0 4 12 18 16 0
0.25 0 6 11 14 9 0
0.5 0 7 8 2 -2 0
0.75 0 2 -2 -8 -7 0
1 0 -9 -14 -11 -6 0
1.25 0 -16 -18 -12 -4 0
2u 2 u
2
a
t 2 x 2
Given utt u xx 0
ux,0 ut 0, t 0
I. C
For wave equation
ui , j 1
1
2
u i 1, j ui 1, j
u i , j 1 u i 1, j u i 1, j u i , j 1
2u 2u
2 0 or u xx u yy 0 or 2 u 0
x 2
y
2u 2u
Consider the equation 0 . Replace the partial derivatives by the corresponding
x 2 y 2
difference quotients
u i 1, j 2u i , j u i 1, j u i , j 1 2u i , j u i , j 1
0
h2 k2
If we consider a square mesh, i.e., h k , then we have
u i 1, j u i 1, j u i , j 1 u i , j 1 4u i , j 0
i.e., u i , j
1
ui1, j ui1, j ui, j 1 ui, j 1 . This is called standard five point formula
4
The value of u at any interior grid point is the average of the values of u at the 4 grid points
near it.
We may also consider the value of u as the average of the values of u at the 4 nearest
diagonal points:
i.e, u i , j
1
ui1, j 1 ui1, j 1 ui1, j 1 ui1, j 1 . This is called diagonal five point formula
4
Standard five point formula (SFPF) is preferred to diagonal five point formula (DFPF) since
the error in DFPF is four times the error in SFPF.
Solution of Laplace equation by Liebmann’s iteration process
4. Now we have the initial values of u at all the internal grid points.
5. We iterate in the order u1 , u 2 , u3 ,........ u9 using SFPF, always using the latest available
values. This is called Liebmann’s iteration process.
Note: Using SFPF at the nine interior grid points, we can form 9 equations in the 9
unknowns u1 , u 2 , u3 ,........ u9 and solve them using Gauss-Seidal method.
2u 2u
1. Solve the elliptic equation 0 for the following square mesh with boundary
x 2 y 2
values as shown, using Liebmann’s iteration procedure.
Solution:
Let u1 , u 2 , u3 ,........ u9 be the required values of u at the internal grid points. To obtain the
DFPF: u i , j
1
ui1, j 1 ui1, j 1 ui1, j 1 ui1, j 1
4
Rough values
u5
1
0 17.0 21.0 12.1 12.5 SFPF
4
u1
1
0 12.5 17.0 0 7.4 DFPF
4
u3
1
12.5 18.6 17.0 1.0 17.3 DFPF
4
u7
1
12.5 0 0 12.1 6.2 DFPF
4
u9
1
12.5 9.0 12.1 21.0 13.7 DFPF
4
u2
1
17.0 12.5 7.4 17.3 13.6 SFPF
4
u4
1
7.4 6.2 0 12.5 6.5 SFPF
4
u6
1
12.5 21.0 17.3 13.7 16.1 SFPF
4
u8
1
12.5 12.1 6.2 13.7 11.1 SFPF
4
11.1 17.0 19.7 18.6
0 u1 u2 u3
7.4 13.6 17.3
7.8 13.7 17.9
7.9 13.7 17.9
7.9 13.7 17.9
0 u4 u5 u6 21.9
6.5 12.5 16.1
6.6 11.9 16.1
6.6 11.9 16.3
6.6 11.9 16.3
0 u7 u8 u9 21.0
6.2 11.1 13.7
6.6 11.1 14.3
6.6 11.2 14.3
6.6 11.2 14.3
0 17.0
Let u1 , u 2 , u3 ,........ u9 be the required values of u at the internal grid points. To obtain the
DFPF: u i , j
1
ui1, j 1 ui1, j 1 ui1, j 1 ui1, j 1
4
Rough values:
u5
1
4 14 6 0 6 SFPF
4
u1
1
0 6 4 0 2.50 DFPF
4
u3
1
4 16 14 6 10 DFPF
4
u7
1
0 6 0 6 3 DFPF
4
u9
1
6 14 12 6 9.5 DFPF
4
u2
1
4 10 6 2.50 5.625 SFPF
4
u4
1
2.5 6 3 0 2.875 SFPF
4
u6
1
10 14 9.5 6 9.875 SFPF
4
u8
1
6 3 6 9.5 6.125 SFPF
4
1 4 9 16
0 2.5 5.625 10
2.375 5.594 9.867
2.360 5.590 9.866
2.363 5.586 9.855
2.364 5.588 9.866
2.365 5.589 9.866
2.366 5.589 9.866
2.366 5.589 9.866
u1 u2 u3
0 2.875 6 9.875 15
2.844 6.132 9.875
2.871 6.123 9.874
2.863 6.122 9.874
2.864 6.124 9.875
2.865 6.124 9.866
2.866 6.125 9.866
2.866 6.125 9.866
u4 u5 u6
0 3 6.125 9.5 14
2.992 6.156 9.508
3.007 6.160 9.508
3.008 6.160 9.509
3.008 6.160 9.509
3.009 6.160 9.509
3.009 6.160 9.509
3.009 6.160 9.509
u7 u8 u9
0 13
0 3 6 9 12
u1 2.37 , u2 5.59 , u3 9.87 , u4 2.87
Hence the solution is u5 6.13 , u6 9.87 . u7 3.01 , u8 6.16 , u9 9.51
3. Solve u xx u yy 0 correct to two decimal places, at the nodal points of the following square
grid,
using the boundary values indicated.
A 1 2 B
u1 u2
1 2
u3 u4
2 1
C 2 1 D
Solution:
The given problem is symmetric about diagonal AD and BC
That is u1=u4 and u2=u3. Therefore we need to find only two values u1 and u2.
Assume u2=0 , u3=0 (since u2=u3)
Rough values
u1
1
1 1 0 0 0.5 SFPF u 4 0.5
4
u2
1
0.5 0.5 2 2 1.25 SFPF u3 1.25
4
A 1 2 B
u1 u2
0.5 1.25
1.125 1.563
1.282 1.641
1.321 1.661
1.331 1.666
1.333 1.667
1.334 1.667
1.334 1.667
1 u3 u4 2
1.25 0.5
1.563 1.125
1.641 1.282
1.661 1.321
1.666 1.331
1.667 1.333
1.667 1.334
1.667 1.334
2 1
C 2 1 D
4. Solve u xx u yy 0 correct to two decimal places, at the nodal points of the following square grid,
u1 u2
1 4
u3 u4
2 5
C 4 5 D
Solution:
The given problem is symmetric about diagonal AD
That is u2=u3. Therefore we need to find only two values u1 , u2 and u4 .
Assume u2=0 , u3=0 (since u2=u3)
Rough values
u1
1
1 1 0 0 0.5 SFPF
4
u2
1
0.5 0.5 2 4 2.25 SFPF u3 2.25
4
u4
1
0 0 5 5 2.5 SFPF u3 2.5
4
A 1 2 B
0.5 2.25
1.63 2.53
1.77 2.89
1.95 2.98
1.99 3
2 3
u1 u2
1 2.25 2.5 2
2.53 3.77
2.89 3.95
2.98 3.99
3 4
3 4
u3 u4
2 1
C 2 1 D
Practice problems
1. Solve u xx u yy 0 for the following square mesh with boundary values as shown below:
Poisson equation
The second order partial differential equation
2u 2u
u f x, y or 2 2 f x, y is called Poisson equation. When f x, y 0 , it reduces to
2
x y
Laplace equation.
Numerical solution of Poisson equation
Consider a square region, with the values of u (temperature) given at the grid points on the
boundary. We wish to solve Poisson equation with the given boundary conditions and obtain the
values of u at the interior grid points.
2u 2u
Consider the equation f x, y . Replace the partial derivatives by the
x 2 y 2
corresponding difference quotients and put x ih, y jh .
u i 1, j 2u i , j u i 1, j u i , j 1 2u i , j u i , j 1
f ih, jh
h2 h2
Apply equation (1) at each interior mesh point and get a system of linear equations in
u1 , u 2 , u3 ,........ Solve these equations to get the required values of u .
1. Solve the Poisson equation 2 u 10 x 2 y 2 10 over the square mesh with sides
x 0, y 0, x 3, y 3 with u 0 on the boundary, and mesh length 1 unit.
Answer:
y
0 0 0 0
0 (A)u1 (B)u2 0
(1,2) (2,2)
0 u3 u4 0
(C)(1,1) (D)(2,1)
0 x
0 0 0
The given PDE and boundary conditions are symmetrical about the line x y .
Hence the interior values of u are also symmetrical about the line x y .
Hence u1 u4
ui 1, j ui 1, j ui , j 1 ui , j 1 4ui , j 10 i 2 j 2 10
u0, 2 u2, 2 u1,3 u1,1 4u1, 2 10 12 22 10
0 u2 0 u3 4u1 150
4u1 u2 u3 150
..............(1)
At B, i 2, j 2
ui 1, j ui 1, j ui , j 1 ui , j 1 4ui , j 10 i 2 j 2 10
u1, 2 u3, 2 u2,3 u2,1 4u2, 2 10 22 22 10
u1 0 0 u4 4u2 180
ui 1, j ui 1, j ui , j 1 ui , j 1 4ui , j 10 i 2 j 2 10
u0,1 u2,1 u1, 2 u1,0 4u1,1 10 12 12 10
0 u4 u1 0 4u3 120
u1 75 , u2 82.5 , u3 67.5 , u4 75 u1 u4
2. Solve 2 u 8 x 2 y 2 for a square mesh given u=0 on the boundary, by dividing the square into
16 sub- squares of length 1 unit.
0 0 0 y 0 0
(0,1) (1,1)
0 u1 u2(A) u3(B) 0
(0,0)
0 u4 u5(C) u6 0
x
0 u7 u8 u9 0
0 0
0 0 0
Take the coordinate system with origin at the centre of the square. Since the PDE and
boundary conditions are symmetrical about x, y axes and y=x
From figure u1 u7 , u2 u8 , u3 u9 , u1 u3 , u4 u6 , u7 u9 ,
u2 u4 , u3 u7 , u6 u8 , u1 u9 , u2 u6 , u4 u8 ,
ui 1, j ui 1, j ui , j 1 ui , j 1 4ui , j h 2 f ih, jh at each grid point, where f x, y 8x 2 y 2 and
h 1
h 2 f ih , jh 8ij
u1 u3 0 u5 4u2 0
2u1 4u2 u5 0 u1 u3
............(1)
At B, i 1, j 1
u2 0 0 u4 4u1 8
u2 u4 4u1 8
2u2 4u1 8 u2 u4
2u1 u2 4
.............(2)
At C, i 0, j 0
u4 u6 u2 u8 4u5 0
4u2 4u5 0 u2 u4 u6 u8
u2 u5 0
u2 u5
...............(3)
Sub (3) in (1)
2u1 4u2 u5 0
2u1 4u2 u2 0
2u1 3u2 0
...............(4)
Solving (2) and (4) we get
u1 3 , u2 2
u1 u3 u7 u9 3 and u2 u4 u6 u8 2
********************************************************************************