You are on page 1of 13

7.

Numerical Solution of Partial Differential Equation


The PDEs serve as models for elliptic, parabolic, and hyperbolic. For example,
the Laplace equation is a representative example of an elliptic type of PDE, and so
forth.
Note:
u  2u
ux  , u xx  2
x x
u  2u
uy  , u yy  2
y y
 2u
u xy 
x y

A PDE is called quasilinear if it is linear in the highest derivatives. Hence a


second-order quasilinear PDE in two independent variables x, y is of the form;

au xx  2bu xy  cu yy  F  x , y ,u ,u x ,u y 
u is the dependent variable. This equation is said to be of;

Elliptic type if ac  b 2  0 (example: Laplace equation)


Parabolic type if ac  b 2  0 (example: heat equation
Hyperbolic type if ac  b 2  0 (example: wave equation)

7.1 Solution of 2-D Laplace Equation;


 2u  u xx  u yy  0

To obtain methods of numerical solution. we replace the partial derivatives by


corresponding difference quotients, as follows. By the Taylor formula,
h2 h3
u ( x  h , y )  u ( x , y )  hu x ( x , y )  u xx ( x , y )  u xxx ( x , y )   (1)
2 6
2
h h3
u ( x  h , y )  u ( x , y )  hu x ( x , y )  u xx ( x , y )  u xxx ( x , y )   (2)
2 6
39
Subtract Eq.(2) from Eq.(1), neglect terms in h3, h4, ...,

1 1
u x ( x, y ) 
2h
 u ( x  h , y )  u ( x  h, y )   u x i, j 
2h
 ui1, j  ui1, j 
Similarly

1 1
u y ( x, y ) 
2k
 u ( x, y  k )  u ( x, y  k )   uy
i, j

2k
 ui, j 1  ui , j 1 

(x,y+k)
i, j+1

k k

h h h h
(x−h,y) (x+h,y)
(x,y) i−1, j i, j i+1, j

k k

i, j−1
(x,y−k)

To obtain second derivative, adding eq.(1) and eq.(2);


1
u xx ( x , y )  u ( x  h , y )  2u ( x , y )  u ( x  h , y )
h2
1
u xx  u i 1, j  2u i , j  u i 1, j  (4)
i,j
h2 
Similarly

1
u yy ( x , y )  u ( x  k , y )  2u ( x , y )  u ( x  k , y )
k2
1
u yy  ui , j 1  2ui , j  ui , j 1  (5)
i, j k2 
Substitute eqs. (4) &(5) into Laplace equation;

40
1 1
u
2  i 1, j
 2u i , j  u i 1, j   2 u i , j 1  2u i , j  u i , j 1   0
h k
* If h = k
u i 1, j  u i 1, j  u i , j 1  u i , j 1  4u i , j  0

u i 1, j  u i 1, j  u i , j 1  u i , j 1
u i , j 
4
Note:

i, j+1  1 
k   (Called Stencil, pattern,
1 4 1 molecule, or star)
h
i-1, j i+1, j  
i, j
 1 

i, j-1

Laplace equation can be rewritten the in stencil form as:

 1 
 
1 4 1 u  0
 
 1 
Example:
The four sides of a square plate of side 12 cm made of homogeneous material are
kept at constant temperature 0 ºC and 100 ºC as shown figure. Using a grid mesh of 4
cm. Find the (steady state) temperature at the mesh point.

y
0ºC 1,3 2,3
0,3 3,3
12

0,2 1,2 2,2 3,2


100ºC
R 100ºC
0,1 2,1 3,1
1,1

0 x 0,0 1,0 2,0 3,0


100ºC 12

Grid and mesh points


Given Problem
41
Solution:
The equations for 2-D in steady state as;
 2u  u xx  u yy  0

Consider the mesh points;


h=k=4
4u i , j  u i 1, j  u i 1, j  u i , j 1  u i , j 1

Boundary Condition
u1,0  u 2,0  100 0C
u1,3  u 2,3  0 oC

u 0,1  u 0,1  100 0C


u 3,1  u 3,2  100 oC

At point (1,1)

4u1,1  u 2,1  u 0,1  u1,2  u1,0  4u1,1  u 2,1  100  u1,2  100

4u1,1  u 2,1  u1,2  200 (1)


At point (2,1)

4u 2,1  u 3,1  u1,1  u 2,2  u 2,0  4u 2,1  100  u1,1  u 2,2  100

4u 2,1  u1,1  u 2,2  200 (2)


At point (1,2)

4u1,2  u 2,2  u 0,2  u1,3  u1,1  4u1,2  u 2,2  100  0  u1,1

4u1,2  u 2,2  u1,1  100 (3)


At point (2,2)

4u 2,2  u 3,2  u1,2  u 2,3  u 2,1  4u 2,2  100  u1,2  0  u 2,1

4u 2,2  u1,2  u 2,1  100 (4)


Solving Eqs. (1), (2), (3), and (4) to find the interior point u1,1 ,u 2,1 , u1,2 , and u 22

42
From eqs. (1) and (4)

u11  u22  25 (5)


From eqs.(2) and (3):
u21  u12  25 (6)

Substitute eq. (6) in eq (1):

4u11  2u12  225 (7)


Extract u 22 from eqs.(5) and substitute in (2):
4u12  2u11  75 (8)

From eqs. (7) and (8): u12  375 / 6  62.5  u11  350 / 4  87.5

So far: u21  62.5  25  87.5, u22  87.5  25  62.5

Example: Find the temperature distribution for the following plate.

y
0ºC 1,3 3,2
0,3 3,3
12

0,2 1,2 2,2 3,2


100ºC
R 100ºC
0,1 2,1 3,1
1,1

0 x 0,0 1,0 2,0 3,0


12
uy = 0
1,-1 2,-1
Given Problem
Grid and mesh points
To find the temperature at isolation side

u1,1  u1,1
uy  0  u1,1  u1,1 ...(a )
1,0 2k
u2,1  u2,1
uy  0  u2,1  u2,1 ...(b)
2,0 2k

At point (1,0)
4u1,0  u 2,0  u 0,0  u1,1  u1, 1  4u1,0  u 2,0  100  u1,1  u1,1

43
4u1,0  u 2,0  2u1,1  100 (1)

At point (2,0)
4u 2,0  u 3,0  u1,0  u 2,1  u 2,1  4u 2,0  100  u1,0  u 2,1  u 2, 1
4u 2,0  u1,0  2u 2,1  100 (2)
The other points same the above example
At point (1,1)

4u1,1  u2,1  u0,1  u1,2  u1,0  4u1,1  u2,1  100  u1,2  u1,0

4u1,1  u 2,1  u1,2  u1,0  100 (3)


At point (2,1)

4u2,1  u3,1  u1,1  u2,2  u2,0  4u 2,1  100  u1,1  u2,2  u2,0

4u2,1  u1,1  u2,2  u2,0  100 (4)


At point (1,2)

4u1,2  u 2,2  u 0,2  u1,3  u1,1  4u1,2  u 2,2  100  0  u1,1

4u1,2  u 2,2  u1,1  100 (5)


At point (2,2)

4u 2,2  u 3,2  u1,2  u 2,3  u 2,1  4u 2,2  100  u1,2  0  u 2,1

4u 2,2  u1,2  u 2,1  100 (6)

44
7.2 Solution of Parabolic Equation (1-D Diffuse equation)
In this section we explain the numerical solution of the prototype of parabolic
equation, the one dimensional heat equation;
1
ut  u xx (1)

 m2 
x : space 0  x  L , t :time t 0  : thermal diffusivity  
 s 
The initial condition u ( x ,0)  f  x  (given) and boundary condition at x=0 and x =

L for all t  0 . Using x  h , t  k


u i , j 1  u i , j
ut i ,j
 Forward difference (a)
k
1
u xx  u i 1, j  2u i , j  u i 1, j 
i,j
h2  (b)
Subs. above Eqs. (a) & (b) in Eq.(1);
1 1
u i , j 1  u i , j   2 u i 1, j  2u i , j  u i 1, j 
k h
k
u i , j 1  2 u i 1, j  2u i , j  u i 1, j   u i , j
h
k  2 k 
u i , j 1  2 u i 1, j  u i 1, j    1  2 u i , j
h  h 
u i , j 1  1  2r u i , j  r u i 1, j  u i 1, j 

k
where r 
h2

45
i, j+1

t k

....

....
h
i-1, j i, j i+1, j
0,3 3,2 j=3
1,3 3,3

u at x  0 0,2 1,2 2,2 3,2 j=2 u at x  L


0,1 j=1
1,1 2,1 3,1
k
h  1 
0,0 x  
i=1 i=2 i=3 ....  
r 1  2r  r 

u at t  0
Initial condition
Figure; stencil for Four Points
Figure; Grid and mesh points

N. B. For convergence and stability of explicit method is the condition;

1 k 1
r  2

2 h 2
2
h
k  time step
2

46
Ex. A bar is initially at 100 ºC, it's ends are attached to a constant temperature body
at 0 ºC. Find the temperature distribution assuming  = 0.1, Take x=h=0.25.

Sol. If h= 0.25 and  = 0.1

The condition for stability is;


0 ºC 100 ºC 0 ºC
k 1 h 2
   k 
h2 2 2

....

....
....
0.252
k  k  0.3125
2  0.1 0,3 4,3
1,3 3,2 3,3
Take k  0.25
0,2 1,2 2,2 3,2 4,2
k 0.1 0.25
r 2
  0.4
h 0.252 0,1
1,1 3,1 4,1
2,1
t k
h
x 0,0
1,0
u i , j 1  1  2r u i , j  r u i 1, j  u i 1, j  2,0 3,0 4,0

* Boundary conditions Figure; Grid and mesh points

At x = 0 u 0,1  u 0,2  u 0,3  ...  u 0, j  0


i, j+1
At x = L u 4,1  u 4,2  u 4,3  ...  u 4, j  0

* Initial conditions At t = 0 i-1, j i, j i+1, j

u1,0  u 2,0  u 3,0  ...  u i ,0  100

Compute the other points using the above formula

At t = 0.25, j =1

u1,1  0.2u1,0  0.4 u2,0  u0,0   0.2 100  0.4 100  0   60


u2,1  0.2u2,0  0.4 u3,0  u1,0   0.2  100  0.4 100  100   100
u3,1  0.2u3,0  0.4 u4,0  u2,0   0.2  100  0.4(0  100)  60

47
At t = 0.5, j =2

u2,1  0.2u1,1  0.4 u2,1  u0,1   0.2  60  0.4 100  0   52


u2,2  0.2u2,1  0.4 u3,1  u1,1   0.2  100  0.4  60  60   68
u3,2  0.2u3,1  0.4 u4,1  u2,1   0.2  60  0.4(0  100)  52

At t = 0.75, j = 3

H.W. Complete the other points

Continue the procedure for until the steady state condition that is not change the
value of u at increase the time t.

7.3 Solution of Hyperbolic Equation (1-D Wave equation)


In this section we explain the numerical solution of the prototype of hyperbolic
equation, the one dimensional wave equation;
1
u tt  u xx
c2 (1)
m 
x : space 0  x  L , t :time t 0 c : speed  
s 

Initial displacement u ( x ,0)  f  x  (Given)

Initial velocity u t ( x ,0)  v  x  (Given)

boundary condition u (0,t )  u ( L , t )  0


Using x  h , t  k
1
u xx  u i 1, j  2u i , j  u i 1, j 
i,j
h2  (a)
1
utt  u i , j 1  2u i , j  u i , j 1  (b)
i,j
k2
Subs. above Eqs. (a) & (b) in Eq.(1);
1 1
2
u
2  i , j 1
 2u i , j  u i , j 1   2 u i 1, j  2u i , j  u i 1, j 
c k h

48
c 2k 2
u i , j 1  2 u i 1, j  2u i , j  u i 1, j   2u i , j  u i , j 1
h

u i , j 1  2(1  r 2 )u i , j  r 2 u i 1, j  u i 1, j   u i , j 1

ck
where r 
h

i, j+1

k
h
t i-1, j i, j i+1, j
....

.... i, j-1
0,3 j=3
1,3 3,2 3,3

0,2 1,2 2,2 3,2 j=2

0,1 j=1
1,1 2,1 3,1  1 
k  2 
t =0
h
r 2 1  r 2  r2
0,0 1,0 2,0 3,0 .... x  
 1 
1,-1 2,-1 3,-1

Figure; stencil for five Points


Figure; Grid and mesh points

* The condition for convergence and stability of the solution;

ck h
1  r   0
2
 r 1 
h
 1 k 
c

At initial velocity v(x) given (At t = 0 , j = 0)

u i ,0  u i ,1
v  x i   ut i ,0
 Using Backward difference
k

u i ,1  u i ,0  kv  x i 

49
Example:

For the string shown, find the motion using x = 0.25, speed c = 1 m/s.
L=1
2 0.25  x  0.75
v x   
0 otherwise 1 f(x)

Sol. h = x = 0.25
0,3 1,3 3,2 3,3
h
r  1  k 
c 0,2 1,2 2,2 3,2
k  0.25  take k  0.2
0,1
ck 1*0.2 1,1 2,1 3,1
r   0.8 k
h 0.25 t =0
h
0,0 1,0 2,0 3,0 4,0
r 2  0.64
1,-1 2,-1 3,-1
u i , j 1  2(1  r 2 )u i , j  r 2 u i 1, j  u i 1, j   u i , j 1
Figure; Grid and mesh points
u i , j 1  0.72u i , j  0.64 u i 1, j  u i 1, j   u i , j 1

* Boundary conditions;

u 0,0  u 0,1  u 0,2  u 0,3  ......  0


u 4,0  u 4,1  u 4,2  u 4,3  ......  0

At t = 0 , j = 0

Initial conditions:

u i ,0  f  ih  Note: Some time the function


f(x) given as; f(x)= sin x
u1,0  f  0.25  0.5
u 2,0  f  0.5  1
u 3,0  f  0.75  0.5

50
u i ,1  u i ,0  kv  ih 
u1,1  u1,0  kv  0.25  0.5  0.2 * 2  0.1
u 2,1  u 2,0  kv  0.5  1  0.2 * 2  0.6
u 3,1  u 3,0  kv  0.75  0.5  0.2 * 2  0.1

u1,1  0.72u1,0  0.64  u2,0  u0,0   u1,1  0.72  0.5  0.64(1  0)  0.1  0.9
u2,1  0.72u2,0  0.64  u3,0  u1,0   u2,1  0.72  1  0.64  0.5  0.5   0.6  0.76
u3,1  0.72u3,0  0.64  u4,0  u2,0   u3,1  0.72  0.5  0.64  0  1  0.1  0.9

At t = 0.2, j =2

u1,2  0.72u1,1  0.64  u2,1  u0,1   u1,0  0.72  0.9  0.64(0.76  0)  0.5  0.6344
u2,2  0.72u2,1  0.64  u3,1  u1,1   u2,0  0.72  0.76  0.64  0.9  0.9   1  0.6992
u3,2  0.72u3,1  0.64  u4,1  u2,1   u3,0  0.72  0.9  0.64  0  0.76   0.5  0.6344

At t = 0.4, j = 3

51

You might also like