Maths 5
Maths 5
u 2 u
2
k
=c , i.e., ut = c u xx where c =
2 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
Consider step sizes x = h, t = k , substitute c 2 = 1 . Then the One Dimensional heat equation
a
is
u 1 2u
=
t a x 2
u xx = aut .
The explicit formula to solve this equation is
ui +1, j + ui −1, j
ui , j +1 = which is called Bender Schmidt recurrence relation
2
ah 2
This is valid only when = , i.e., k =
1
2 2
Value of u at a = average of the values at d and e .
Example 1
u 2u
Solve = subject to u(x,0) = sin x, 0 x 1, u(0, t ) = u(1, t ) = 0 , using Bender Schmidt
t x 2
method.
Solution
From the give equation, we get a = 1 . Here 0 x 1 Let us take h = 0.2 . Then
ah 2 1(0.2)
2
k= = = 0.02
2 2
k 0.02 1
= = =
ah 2
(0.2)2 2
The first row, first column and last column are filled up using the given conditions. The
ui +1, j + ui −1, j
remaining rows are filled using Bender Schmidt formula: ui , j +1 =
2
u(x,0) = sin x, 0 x 1, u(0, t ) = u(1, t ) = 0
ah 2 2(1)
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 + ui −1, j
remaining rows are filled using Bender Schmidt Formula: ui , j +1 =
2
u(x,0) = x(4 − 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
Sub = 1
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
Practice problem
1. Solve
2 u u
x 2
t
( 2
)
= given u (0, t ) = u (5, t ) = 0, u (x,0) = x 25 − x . Find u in the range taking h=1
2
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(1 + 1)ui , j+1 = −ui+1, j − ui−1, j + 2(1 − 1)ui , j
ui , j +1 =
1
(ui−1, j +1 + ui+1, j +1 + ui−1, j + ui+1, j )
4
1
𝑢(𝑥, 0) = 𝑢(0, 𝑡) = 0and𝑢(1, 𝑡) = 100𝑡. Compute u for one step in t direction taking h = .
4
Solution:
2
1 1
Here a=16, h = k = ah2 = 16 = 1
4 4
k 1
= 2 = 2
=1
ah 1
16
4
ui , j +1 =
1
(ui−1, j +1 + ui+1, j +1 + ui−1, j + ui+1, j )
4
Initial Condition 𝑢(𝑥, 0) = 0, Boundary Condition 𝑢(0, 𝑡) = 0and𝑢(1, 𝑡) = 100𝑡
0 0.25 0.5 0.75 1
j i
0 0 0 0 0 0
1 0 u1 u2 u3 100
u1 =
1
(0 + 0 + 0 + u2 )
4
u
u1 = 2
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
(u2 + 0 + 0 + 100 )
4
u + 100
u3 = 2
4
4u3 = u2 + 100
u2 − 4u3 = −100 .................(3)
Solving (1), (2) and (3), we get
u1=1.7857, u2=7.1429, u3=26.7857
k 1
= = =1
ah2 1
2
16
4
ui , j +1 =
1
(ui−1, j +1 + ui+1, j +1 + ui−1, j + ui+1, 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 + u2 )
4
u2
u1 =
4
u 41 − u2 = 0 .................(1)
u2 =
1
(u1 + 0 + 0 + u3 )
4
u + u3
u2 = 1
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
1 2 1
u6 = u5 + + u 2 +
4 16 16
1 3
u 6 = u5 + 0.0045 +
4 16
4u6 = u5 + 0.1920
−u5 + 4u6 = 0.1920 .................(6)
1
k 1
Here a=1, Given h = 0.5 = 2 = 8 2 =
ah 1(0.5) 2
1
=
since 2 we cannot use simplified formula
I. C 𝑢(𝑥, 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.3333(0)
8
u1 = 0.0208
(ii) h = 1 and k = 1 .
4 8
1
k 8
Here a=1, Given h = 0.25 = 2 = =2
1(0.25)
2
ah
=2
since we cannot use simplified formula
ui , j +1 =
1
(ui+1, j +1 + ui−1, j +1 + ui+1, j + ui−1, j ) + 1 ui , j
3 3
0 0 0 0 0 0
1/8 0 u1 u2 u3 1/8
u1 =
1
(0 + 0 + 0 + u2 ) + 1 (0)
3 3
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 = u2 + −u2 + 3u3 = 0.125
8
Solving (1) , (2) and (3)
When u t (x,0) = 0 , the second row of the table is got using the formula
ui−1,0 + ui+1,0
ui ,1 =
2
For working convenience, we will consider the downward direction
to be the positive t - direction
2u 2 2u
=a 2
t 2 x
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
ui +1, j + ui −1, j
ui, j +1 = ui −1, j + ui +1, j − ui, j −1
u(0, t ) = u(5, 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 up to 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:
B. C u(0, t ) = u(5, t ) = 0
I. C
ut (x,0) = 0, u(x,0) = x 2 (5 − x),
ui , j +1 =
1
2
ui +1, j + ui −1, j
ui, j +1 = ui −1, j + ui +1, j − ui, 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 2u
=a 2
t 2 x
Given utt − u xx = 0
Here a2=1 , a=1 given h = 0.25
ui , j +1 =
1
2
ui +1, j + ui −1, j
ui, j +1 = ui −1, j + ui +1, j − ui, j −1
Practice problem
Laplace equation (Two dimensional heat equation in steady state)
Laplace equation in two dimensions is given by
2u 2u
+ = 0 or u xx + u yy = 0 or 2 u = 0
x 2 y 2
2u 2u
Consider the equation + = 0 . Replace the partial derivatives by the corresponding
x 2 y 2
difference quotients
i.e., ui , j = 1 (ui +1, j + ui −1, 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, ui , j = 1 (ui −1, j −1 + ui −1, j +1 + ui +1, j +1 + ui +1, 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
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
initial values, we use SFPF: ui , j = 1 (ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ) and
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
2. Solve u xx + u yy = 0 over the square mesh of side 4 units, satisfying the following boundary
conditions:
(i) u (0, y ) = 0 for 0 y 4
(ii ) u (4, y ) = 12 + y for 0 y 4
(iii ) u (x,0) = 3x for 0 x 4
(iv ) u (x,4) = x 2 for 0 x 4
Answer:
Let u1 , u 2 , u3 ,........u9 be the required values of u at the internal grid points. To obtain the
initial values, we use SFPF: ui , j = 1 (ui +1, j + ui −1, j + ui , j +1 + ui , j −1 ) and
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 = (6 + 14 + 12 + 6) = 9.5 (DFPF)
1
4
u2 = (4 + 10 + 6 + 2.50 ) = 5.625 (SFPF)
1
4
u4 = (2.5 + 6 + 3 + 0) = 2.875 (SFPF)
1
4
u6 = (10 + 14 + 9.5 + 6) = 9.875 (SFPF)
1
4
u8 = (6 + 3 + 6 + 9.5) = 6.125 (SFPF)
1
4
1 4 9 16
0 u1 u2 u3 15
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
0 u4 u5 u6 14
2.875 6 9.875
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
0 u7 u8 u9 13
3 6.125 9.5
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
0 3 6 9 12
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) u4 = 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.13 1.57
1.29 1.65
1.33 1.67
1.34 1.67
1.34 1.67
1 u3 u4 2
1.25 0.5
1.57 1.13
1.65 1.29
1.67 1.33
1.67 1.34
1.67 1.34
2 1
C 2 1 D
Hence the solution u1 = u4 = 1.334 and u2 = u3 = 1.667
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
1
𝑢2 = 4 (0.5 + 0.5 + 2 + 4) = 2.25 (𝑆𝐹𝑃𝐹) ⇒ 𝑢3 = 2.25
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
Hence the solution u1 = 2 , u2 = u3 = 3 and u4 = 4
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
x y
to 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 .
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 .
2
(
1. Solve the Poisson equation u = −10 x + y + 10 over the square mesh with sides
2 2
)
𝑥 = 0, 𝑦 = 0, 𝑥 = 3, 𝑦 = 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 = u 4
(
h 2 f (ih, jh ) = −10 i 2 + j 2 + 10 )
(
u i −1, j + u i +1, j + u i , j +1 + u i , j −1 − 4u i , j = −10 i 2 + j 2 + 10 ……….(1) )
Apply equation (1) at the grid points A, B, C
At A, i = 1, j = 2
(
u i −1, j + u i +1, j + u i , j +1 + u i , j −1 − 4u i , 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
(
u i −1, j + u i +1, j + u i , j +1 + u i , j −1 − 4u i , j = −10 i 2 + j 2 + 10 )
(
u1, 2 + u3, 2 + u2,3 + u2,1 − 4u2, 2 = −10 2 2 + 22 + 10 )
u1 + 0 + 0 + u4 − 4u2 = −180
2u1 − 4u2 = −180 u1 = u4
..............(2)
At C, i = 1, j = 1
(
u i −1, j + u i +1, j + u i , j +1 + u i , j −1 − 4u i , 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 u = 8x y for a square mesh given u=0 on the boundary, by dividing the square into
2 2 2
(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 ,
h =1
u1 + u3 + 0 + u5 − 4u2 = 0
2u1 − 4u2 + u5 = 0 u1 = u3
............(1)
At B, i = 1, j = 1
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
********************************************************************************