You are on page 1of 36

SE301:Numerical Methods

Topic 9
Partial Differential Equations
Dr. Samir Al-Amer
Term 071

SE301_Topic9 (c)Al-Amer 2005 ١

Lect 27: Partial Differential Equations

S Partial Differential Equations (PDE)


S What is a PDE
S Examples of Important PDE
S Classification of PDE

SE301_Topic9 (c)Al-Amer 2005 ٢

١
813

Partial Differential Equations


A partial differential equation (PDE) is an
equation that involves an unknown function
and its partial derivatives.
Examples :
∂ 2 u ( x, t )
∂ u ( x, t )
=
∂x 2 ∂t
PDE involves two or more independent variables
(in the example x and t are independent variables)
SE301_Topic9 (c)Al-Amer 2005 ٣

Notation

∂ 2 u ( x, t )
u xx =
∂x 2
∂ 2 u ( x, t )
u xt =
∂x ∂t
order of the PDE = order of the highest order derivative

SE301_Topic9 (c)Al-Amer 2005 ٤

٢
813

Linear PDE
Classification
A PDE is linear if it is linear in the unknown
function and its derivatives
Example of linear PDE :
2 u xx + 1 u xt + 3 utt + 4 u x + cos(2t ) = 0
2 u xx + −3 ut + 4 u x = 0
Examples of Nonlinear PDE
2 u xx + (u xt ) + 3 utt = 0
2

u xx + 2 u xt + 3 ut = 0
2 u xx + 2 u xt ut + 3 ut = 0
SE301_Topic9 (c)Al-Amer 2005 ٥

Representing the solution of PDE


(two independent variables)
S Three main ways to represent the solution
T ( x1 , t1 ) T=5.2

t1 T=3.5

x1
Different curves are Three dimensional The axis represent
used for different plot of the function the independent
values of one of the T(x,t) variables. The value
independent
of the function is
variable
displayed at grid
points
SE301_Topic9 (c)Al-Amer 2005 ٦

٣
Heat Equation Different curve is
used for each
value of t

ice ice Temperature Temperature at


x different x at t=0
Thin metal rod insulated
everywhere except at the
edges. At t =0 the rod is
placed in ice

∂ 2 T ( x, t ) ∂ T ( x , t ) Position x
− =0
∂x 2 ∂t Temperature at
T (0, t ) = T (1, t ) = 0 different x at t=h

T ( x, o) = sin(π x)

SE301_Topic9 (c)Al-Amer 2005 ٧

Heat Equation
Temperature
T(x,t) Time t
ice ice
T ( x1 , t1 )
x
∂ 2 T ( x, t ) ∂ T ( x , t )
− =0 t1
∂x 2 ∂t
T (0, t ) = T (1, t ) = 0
x1 Position x
T ( x,0) = sin(π x)

SE301_Topic9 (c)Al-Amer 2005 ٨

٤
814

Linear Second Order PDE


Classification
A second order linear PDE (2 - indepent variables)
A u xx + B u xy + C u yy + D = 0,
D is a function of x, y, u x , u y
is classfied based on (B 2 − 4 AC) as follows :
B 2 − 4 AC = 0 Parabolic
B 2 − 4 AC > 0 Hyperbolic
B 2 − 4 AC < 0 Elliptic
SE301_Topic9 (c)Al-Amer 2005 ٩

Linear Second Order PDE


Examples ( Classification)
∂ 2 T ( x, t ) ∂ T ( x, t )
Heat Equation k − =0
∂x 2 ∂t
A = k , B = 0, C = 0 ⇒ B 2 − 4 AC = 0
⇒ Heat Equation is Parabolic
______________________________________
∂ 2 u ( x , t ) ∂ 2 u ( x, t )
Wave Equation − =0
∂x 2 ∂t 2
A = 1, B = 0, C = −1 ⇒ B 2 − 4 AC > 0
⇒ Wave Equation is Hyperbolic
SE301_Topic9 (c)Al-Amer 2005 ١٠

٥
Classification of PDE
Linear Second order PDE are important set of
equations that are used to model many systems
in many different fields of science and
engineering.

Classification is important because


Q Each category relates to specific engineering problems
Q Different approaches are used to solve these categories

SE301_Topic9 (c)Al-Amer 2005 ١١

Examples of PDE
PDE are used to model many systems in
many different fields of science and
engineering.
Important Examples:
Q Wave Equation
Q Heat Equation
Q Laplace Equation
Q Biharmonic Equation

SE301_Topic9 (c)Al-Amer 2005 ١٢

٦
Heat Equation
∂ 2 u ( x, y , z , t ) ∂ 2 u ( x, y , z , t ) ∂ 2 u ( x, y , z , t ) ∂ u ( x, y , z , t )
+ + =
∂x 2
∂y 2
∂z 2 ∂t

The function u(x,y,z,t) is used to represent


the temperature at time t in a physical body
at a point with coordinates (x,y,z) .

SE301_Topic9 (c)Al-Amer 2005 ١٣

Simpler Heat Equation


∂ 2 u ( x, t ) ∂ u ( x, t )
=
∂x 2 ∂t
x

u(x,t) is used to represent the temperature


at time t at the point x of the thin rod.

SE301_Topic9 (c)Al-Amer 2005 ١٤

٧
Wave Equation
∂ 2 u ( x, y , z , t ) ∂ 2 u ( x, y , z , t ) ∂ 2 u ( x, y , z , t ) ∂ 2 u ( x, y , z , t )
+ + =
∂x 2 ∂y 2 ∂z 2 ∂t 2

The function u(x,y,z,t) is used to represent the


displacement at time t of a particle whose
position at rest is (x,y,z) .
Used to model movement of 3D elastic body

SE301_Topic9 (c)Al-Amer 2005 ١٥

Laplace Equation
∂ 2 u( x, y, z, t ) ∂ 2 u( x, y, z, t ) ∂ 2 u( x, y, z, t )
+ + =0
∂x 2 ∂y 2 ∂z 2

Used to describe the steady state distribution of


heat in a body.
Also used to describe the steady state
distribution of electrical charge in a body.

SE301_Topic9 (c)Al-Amer 2005 ١٦

٨
Biharmonic Equation
∂ 4 u ( x, y , t ) ∂ 4 u ( x, y , t ) ∂ 4 u ( x, y , t )
+2 + =0
∂x 4 ∂x 2 ∂y 2 ∂y 4

Used in the study of elastic stress.

SE301_Topic9 (c)Al-Amer 2005 ١٧

Boundary conditions for PDE


S To uniquely specify a solution to the PDE,
a set of boundary conditions are needed.
S Both regular and irregular boundaries are
possible t
∂ 2 u ( x , t ) ∂ u ( x, t )
Heat Equation − =0
∂x 2 ∂t region of
interest
u (0, t ) = 0
u (1, t ) = 0
x
u ( x,0) = sin(π x) 1

SE301_Topic9 (c)Al-Amer 2005 ١٨

٩
The solution Methods for PDE
S Analytic solutions are possible for simple
and special (idealized) cases only.
S To make use of the nature of the
equations, different methods are used to
solve different classes of PDE.
S The methods discussed here are based on
finite difference technique

SE301_Topic9 (c)Al-Amer 2005 ١٩

Elliptic Equations
S Elliptic Equations
S Laplace Equation
S Solution

SE301_Topic9 (c)Al-Amer 2005 ٢٠

١٠
Elliptic Equations
A second order linear PDE (2 - indepent variables x , y)
A u xx + B u xy + C u yy + D = 0,
where D is a function of x, y, u x , u y

is Elliptic if B 2 − 4 AC < 0

SE301_Topic9 (c)Al-Amer 2005 ٢١

Laplace Equation
Laplace equation appears is several
engineering problems such as
Q Studying the steady state distribution of
heat in a body
Q Studying the steady state distribution of
electrical in a body
∂ 2 T ( x, y) ∂ 2 T ( x, y)
+ = f ( x, y)
∂x 2 ∂y 2
T :steady state temperature at point (x, y)
f(x, y): heat source (or heat sink)
SE301_Topic9 (c)Al-Amer 2005 ٢٢

١١
Laplace Equation
∂ 2 T ( x, y) ∂ 2 T ( x, y)
+ = f ( x, y)
∂x 2 ∂y 2
A = 1, B = 0, C = 1
B 2 − 4 AC = −4 < 0 Elliptic
S Temperature is function of the position (x and y)
S When no heat source is available Âf(x,y)=0

SE301_Topic9 (c)Al-Amer 2005 ٢٣

Solution Technique
SA grid is used to divide region of interest
S Since the PDE is satisfied at each point in
the area, it must be satisfied at each point
of the grid.
S A finite difference approximation is
obtained at each grid point.

∂ 2 T ( x, y) Ti +1, j − 2Ti , j + Ti −1, j ∂ 2 T ( x, y) Ti , j +1 − 2Ti , j + Ti , j −1


≈ , ≈
∂x 2 (∆x)2 ∂y 2 (∆y )2

SE301_Topic9 (c)Al-Amer 2005 ٢٤

١٢
Solution Technique
∂ 2 T ( x, y) Ti +1, j − 2Ti , j + Ti −1, j
= ,
∂x 2 (∆x)2
∂ 2 T ( x, y) Ti , j +1 − 2Ti , j + Ti , j −1
=
∂y 2 (∆y )2
∂ 2 T ( x, y) ∂ 2 T ( x, y)
⇒ + =0
∂x 2 ∂y 2
is approximated by
Ti +1, j − 2Ti , j + Ti −1, j Ti , j +1 − 2Ti , j + Ti , j −1
+ =0
(∆x) 2
(∆y )2
SE301_Topic9 (c)Al-Amer 2005 ٢٥

Solution Technique

Ti +1, j − 2Ti , j + Ti −1, j Ti , j +1 − 2Ti , j + Ti , j −1


+ =0
(∆x) 2
(∆y ) 2

( Laplacian DifferenceEquation)
assume ∆x = ∆y = h
⇒ Ti +1, j − 4Ti , j + Ti −1, j + Ti , j +1 + Ti , j −1 = 0
SE301_Topic9 (c)Al-Amer 2005 ٢٦

١٣
Solution Technique
Ti , j +1

Ti −1, j Ti , j Ti +1, j

Ti , j −1

Ti +1, j − 4Ti , j + Ti −1, j + Ti , j +1 + Ti , j −1 = 0


SE301_Topic9 (c)Al-Amer 2005 ٢٧

Example
It is required to determine the steady
state temperature at all points of a heated
sheet of metal. The edges of the sheet are
kept at constant temperature 100,50, 0
and 75 degrees. 100

75 50

The sheet is divided


by 5X5 grids 0
SE301_Topic9 (c)Al-Amer 2005 ٢٨

١٤
Known

Example To be determined

T1, 4 = 100 T2, 4 = 100 T3, 4 = 100


T1,3 T2,3
T0,3 = 75 T3,3
T4,3 = 50
T1, 2 T2, 2
T0, 2 = 75
T3, 2 T4, 2 = 50

T1,1 T2,1 T3,1


T0,1 = 75 T4,1 = 50

T1,0 = 0 T2, 0 = 0 T3, 0 = 0


SE301_Topic9 (c)Al-Amer 2005 ٢٩

Known

First equation To be determined

T1, 4 = 100 T2, 4 = 100


T1,3 T2,3
T0,3 = 75

T1, 2 T2, 2
T0, 2 = 75

T0,3 + T1, 4 + T1, 2 + T2,3 + −4T1,3 = 0


75 + 100 + T1, 2 + T2,3 + −4T1,3 = 0

SE301_Topic9 (c)Al-Amer 2005 ٣٠

١٥
Example
T1, 4 = 100 T2, 4 = 100
T1,3 T2,3
T0,3 = 75

T1, 2 T2, 2
T0, 2 = 75

T0,3 + T1,4 + T1, 2 + T2,3 − 4T1,3 = 0


75 + 100 + T1, 2 + T2,3 − 4T1,3 = 0

SE301_Topic9 (c)Al-Amer 2005 ٣١

Known

Another Equation To be determined

T1, 4 = 100 T2, 4 = 100 T3, 4 = 100


T1,3 T2,3 T3,3

T1, 2 T2, 2 T3, 2

T1,3 + T2, 4 + T3,3 + T2, 2 − 4T2,3 = 0


T1,3 + 100 + T3,3 + T2, 2 − 4T2,3 = 0

SE301_Topic9 (c)Al-Amer 2005 ٣٢

١٦
Solution
The rest of the equations
⎛ 4 −1 0 −1 ⎞ ⎛ T11 ⎞ ⎛ 75 ⎞
⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ −1 4 −1 0 −1 ⎟ ⎜ T21 ⎟ ⎜ 0 ⎟
⎜ 0 −1 4 0 0 −1 ⎟ ⎜ T ⎟ ⎜ 50 ⎟
⎜ ⎟ ⎜ 31 ⎟ ⎜ ⎟
⎜ −1 0 0 4 −1 0 −1 ⎟ ⎜ T12 ⎟ ⎜ 75 ⎟
⎜ −1 0 −1 4 −1 0 −1 ⎟ ⎜T ⎟ = ⎜ 0 ⎟
⎜ ⎟ ⎜ 22 ⎟ ⎜ ⎟
⎜ − 1 0 − 1 4 0 0 − 1⎟ ⎜ T32 ⎟ ⎜ 50 ⎟
⎜ ⎟⎜ ⎟ ⎜ ⎟
⎜ − 1 0 0 4 − 1 0 ⎟ ⎜ T13 ⎟ ⎜175 ⎟
⎜ − 1 0 − 1 4 − 1⎟ ⎜ T23 ⎟ ⎜100 ⎟
⎜⎜ ⎟⎜ ⎟ ⎜ ⎟
⎝ − 1 0 − 1 4 ⎟⎠ ⎜⎝ T33 ⎟⎠ ⎜⎝150 ⎟⎠

SE301_Topic9 (c)Al-Amer 2005 ٣٣

Convergence and stability of solution


S Convergence
The solutions converge means that the
solution obtained using finite difference
method approaches the true solution as
the steps ∆x and ∆t approaches zero.
S Stability:
An algorithm is stable if the errors at
each stage of the computation are not
magnified as the computation progresses.

SE301_Topic9 (c)Al-Amer 2005 ٣٤

١٧
Parabolic Equations
S Parabolic Equations
S Heat Conduction Equation
S Explicit Method
S Implicit Method
S Cranks Nicolson Method

SE301_Topic9 (c)Al-Amer 2005 ٣٥

Parabolic Equations
A second order linear PDE (2 - indepent variables x , y)
A u xx + B u xy + C u yy + D = 0,
where D is a function of x, y, u x , u y

is parabolic if B 2 − 4 AC = 0

SE301_Topic9 (c)Al-Amer 2005 ٣٦

١٨
Parabolic Problems

∂ 2 T ( x, t ) ∂ T ( x , t )
Heat Equation − =0
∂x 2 ∂t
T (0, t ) = T (1, t ) = 0
T ( x, o) = sin(π x) ice ice

* Parabolic problem ( B 2 − 4 AC = 0)
* Boundary conditions are needed to uniquely specify a solution

SE301_Topic9 (c)Al-Amer 2005 ٣٧

First order Partial derivative


Finite Difference

Central Forward Backward


difference difference difference
Method Method Method

∂T Ti +1, j − 2Ti , j + Ti −1, j ∂T Ti +1, j − Ti , j ∂T Ti , j − Ti −1, j


= = , =
∂x 2 ∆x ∂x ∆x ∂x ∆x

SE301_Topic9 (c)Al-Amer 2005 ٣٨

١٩
Finite Difference Methods
Replace the derivatives by finite difference formula [ T is function of x and t]
Central Difference Formulas :
∂ T ( x, t ) Ti +1, j − Ti −1, j

∂x 2 ∆x
∂ 2 T ( x, t ) Ti +1, j − 2Ti , j + Ti −1, j

∂x 2 ( ∆x ) 2
∂ 2 u ( x, t ) Ti , j +1 − 2Ti , j + Ti , j −1

∂t 2 ( ∆t ) 2
Forward Difference Formula :
∂ T ( x, t ) Ti +1, j − Ti , j ∂ T ( x, t ) Ti , j +1 − Ti , j
≈ , ≈
∂x ∆x ∂t ∆t
SE301_Topic9 (c)Al-Amer 2005 ٣٩

Finite Difference Methods


New Notation
Central Difference Formulas :
∂ T ( x, t ) Ti +l 1 − Ti −l 1 Superscript for t-axis
≈ And
∂x 2 ∆x Subscript for x-axis
Til-1=T(x,t-∆t)
∂ 2 T ( x, t ) Ti +l 1 − 2Ti l + Ti −l 1

∂x 2 ( ∆x ) 2
∂ 2 T ( x, t ) Ti l +1 − 2Ti l + Ti l −1

∂t 2 ( ∆t ) 2
Forward Difference Formula :
∂ T ( x, t ) Ti +l 1 − Ti l ∂ T ( x, t ) Ti l +1 − Ti l
≈ , ≈
∂x ∆x ∂t ∆t
SE301_Topic9 (c)Al-Amer 2005 ٤٠

٢٠
Solution of the PDE
∂ 2 T ( x , t ) ∂ T ( x, t )
Heat Equation − =0
∂x 2 ∂t t
T (0, t ) = T (1, t ) = 0
T ( x, o) = sin(π x)

Solution means x

Determine the value of T(x, t) at the grid points

SE301_Topic9 (c)Al-Amer 2005 ٤١

Solution of the Heat Equation


Two solutions to the Parabolic Equation
(Heat Equation) will be presented
1. Explicit Method:
Simple, Stability Problems
2. Crank-Nicolson Method:
involves solution of Tridiagonal system of
equations, stable.
SE301_Topic9 (c)Al-Amer 2005 ٤٢

٢١
Explicit Method
∂ 2 u ( x, t ) ∂ u ( x, t )
− =0
∂x 2 ∂t
u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) u ( x, t + k ) − u ( x , t )
2
=
h k
1
2
(u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) ) − 1 (u ( x, t + k ) + u ( x, t ) ) = 0
h k
k
Define σ = 2
h
u ( x, t + k ) = σ u ( x + h, t ) + (1 − 2 σ ) u ( x, t ) + σ u ( x − h, t )

SE301_Topic9 (c)Al-Amer 2005 ٤٣

Explicit Method
How do we compute
u ( x, t + k ) = σ u ( x + h, t ) + (1 − 2 σ ) u ( x, t ) + σ u ( x − h, t )
means

u(x,t+k)

u(x-h,t) u(x,t) u(x+h,t)

SE301_Topic9 (c)Al-Amer 2005 ٤٤

٢٢
Explicit Method
How do we compute
u ( x, t + k ) = σ u ( x + h, t ) + (1 − 2 σ ) u ( x, t ) + σ u ( x − h, t )
means

SE301_Topic9 (c)Al-Amer 2005 ٤٥

Explicit Method
u ( x, t + k ) can be computed directly using
u ( x, t + k ) = σ u ( x + h, t ) + (1 − 2 σ ) u ( x, t ) + σ u ( x − h, t )

can be unstable (errors are magnified )


h2
To guarantee stability (1 − 2 σ ) > 0 or k≤
2
this make it slow

SE301_Topic9 (c)Al-Amer 2005 ٤٦

٢٣
Crank-Nicolson Method
∂ 2 u ( x, t ) ∂ u ( x, t )
− =0
∂x 2 ∂t
u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) u ( x , t ) − u ( x, t − k )
2
=
h k
1
2
(u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) ) − 1 (u ( x, t ) + u ( x, t − k ) ) = 0
h k
h2
Define s = , r = 2+ s
k
s u ( x, t − k ) = − u ( x − h, t ) + r u ( x, t ) − u ( x + h, t )

SE301_Topic9 (c)Al-Amer 2005 ٤٧

Explicit Method
How do we compute
su ( x, t − k ) = u ( x + h, t ) + r u ( x, t ) + u ( x − h, t )
means

u(x-h,t) u(x,t) u(x+h,t)

u(x,t - k)

SE301_Topic9 (c)Al-Amer 2005 ٤٨

٢٤
Crank-Nicolson Method
The equation
s u( x, t − k ) = − u( x − h, t ) + r u( x, t ) − u( x + h, t )
can be expressed as a Tridiagonal system of equations
⎡ r −1 ⎤ ⎡ u1 ⎤ ⎡ b1 ⎤
⎢− 1 r − 1 ⎥ ⎢u ⎥ ⎢b ⎥
⎢ ⎥ ⎢ 2⎥ = ⎢ 2⎥
⎢ − 1 r − 1⎥ ⎢u3 ⎥ ⎢b3 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣ − 1 r ⎦ ⎣u4 ⎦ ⎣b4 ⎦

SE301_Topic9 (c)Al-Amer 2005 ٤٩

Crank-Nicolson Method

The method involves solving a Tridiagonal system of linear equations


The method is stable (No magnification of error)
→ We can use larger h, k (compared to the Explicit Method)

SE301_Topic9 (c)Al-Amer 2005 ٥٠

٢٥
Outlines
S Examples
Q Explicit
method to solve Parabolic PDE
Q Cranks-Nicholson Method

SE301_Topic9 (c)Al-Amer 2005 ٥١

Heat Equation

∂ 2 u ( x, t ) ∂ u ( x, t )
− =0
∂x 2 ∂t
u (0, t ) = u (1, t ) = 0
u ( x, o) = sin(π x) ice ice

* Parabolic problem ( B 2 − 4 AC = 0)
* Auxiliary conditions are needed to uniquely specify a solution

SE301_Topic9 (c)Al-Amer 2005 ٥٢

٢٦
Example 1
Solve the PDE
∂ 2u(x,t) ∂u(x,t)
− =0
∂2x ∂t
u (0, t ) = u (1, t ) = 0
u ( x,0) = sin(π x)

Use h = 0.25, k = 0.25 to find u(t, x) for x ∈ [0,1], t ∈ [0,1]


k
σ = 2 =4
h
SE301_Topic9 (c)Al-Amer 2005 ٥٣

Example 1 (cont.)

∂ 2 u ( x, t ) ∂ u ( x, t )
− =0
∂x 2 ∂t
u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) u ( x, t + k ) − u ( x, t )
2
− =0
h k
16(u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) ) − 4(u ( x, t + k ) + u ( x, t ) ) = 0
u ( x, t + k ) = 4 u ( x + h, t ) − 7 u ( x, t ) + 4 u ( x − h, t )

SE301_Topic9 (c)Al-Amer 2005 ٥٤

٢٧
Example 1

u ( x , t + k ) = 4 u ( x + h, t ) − 7 u ( x , t ) + 4 u ( x − h, t )

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٥٥

Example 1
u (0.25,0.25) = 4 u (.5,0) − 7 u (.25,0) + 4 u (0,0)
= 4 sin(π / 2) − 7 sin(π / 4) + 0 = −0.9497

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٥٦

٢٨
Example 1

u (0.5,0.25) = 4 u (0.75,0) − 7 u (0.5,0) + 4 u (0.25,0)


= 4 sin(3π / 4) − 7 sin(π / 2) + 4 sin(π / 2) = −0.1716

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٥٧

Remarks on Example 1
The obtained results are probably not accurate
because 1 − 2σ = −7

For accurate results 1 − 2σ > 0


One need to select k < 0.03125

Let k = 0.025

SE301_Topic9 (c)Al-Amer 2005 ٥٨

٢٩
Example 1

u ( x, t + k ) = 0.4 u ( x + h, t ) + 0.2 u ( x, t ) + 0.4 u ( x − h, t )

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٥٩

Example 1
u (0.25,0.025) = 0.4 u (0.5,0) + 0.2 u (0.25,0) + 0.4 u (0,0)
= 0.4 sin(π / 2) + .2 sin(π / 4) + 0 = 0.5414

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦٠

٣٠
Example 1
u (0.5,0.025) = 0.4 u (0.75,0) + 0.2 u (0.5,0) + 0.4 u (0.25,0)
= 0.4 sin(3π / 4) + .2 sin(π / 2) + 0.4 sin(π / 4) = 0.7657

t=0.10 0 0

t=0.075 0 0

t=0.05 0 0
t=0.025 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦١

Example 2
Solve the PDE
∂ 2u(x,t) ∂u(x,t)
− =0
∂2x ∂t
u (0, t ) = u (1, t ) = 0
u ( x,0) = sin(π x)

Solve using Crank - Nicolson method


Use h = 0.25, k = 0.25 to find u(t, x) for x ∈ [0,1], t ∈ [0,1]
SE301_Topic9 (c)Al-Amer 2005 ٦٢

٣١
Example 2
Crank-Nicolson Method

∂ 2 u ( x, t ) ∂ u ( x, t )
− =0
∂x 2 ∂t
u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) u ( x, t ) − u ( x, t − k )
2
=
h k
16(u ( x + h, t ) − 2u ( x, t ) + u ( x − h, t ) ) − 4(u ( x, t ) − u ( x, t − k ) ) = 0
h2
Define s = = 0.25, r = 2 + s = 2.5
k
0.25 u ( x, t − k ) = − u ( x − h, t ) + 2.5 u ( x, t ) − ( x + h, t )
u ( x, t − k ) = − 4 u ( x − h, t ) + 10 u ( x, t ) − 4( x + h, t )
SE301_Topic9 (c)Al-Amer 2005 ٦٣

Example 2
Crank-Nicolson Method

∂2 u(x, t) ∂ u(x, t)
− =0
∂x2 ∂ t
u(x + h, t) − 2u(x, t) + u(x − h, t) u(x, t) − u(x, t − k)
=
h2 k
16(u(x + h, t) − 2u(x, t) + u(x − h, t)) − 4(u(x, t) − u(x, t − k)) = 0
h2
Define s = = 0.25, r = 2 + s = 2.25
k
0.25u(x, t − k) = −u(x − h, t) + 2.25 u(x, t) −(x + h, t)
SE301_Topic9 (c)Al-Amer 2005 ٦٤

٣٢
Example 2

0.25u (0.0,0.25) = − u (0,0.25) + 2.25 u (0.25,0.25) − u (0.5,0.25)


0.25 sin(0.25π ) = 0 + 2.25 u1 − u2

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
u1 u2 u3
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦٥

Example 2

0.25u (0,0.5) = − u (0.25,0.25) + 2.25 u (.5,0.25) − u (0.75,0.25)


0.25 sin(0.5π ) = −u1 + 2.25 u 2 − u3

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
u1 u2 u3
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦٦

٣٣
Example 2

0.25u (0.75,0) = − u (0.5,0.25) + 2.25 u (.75,0.25) − u (1,0.25)


0.25 sin(0.75π ) = −u 2 + 2.25 u3 − 0

t=1.0 0 0

t=0.75 0 0

t=0.5 0 0
u1 u2 u3
t=0.25 0 0

t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦٧

Example 2
Crank-Nicolson Method

The solution of the PDE is converted to solution of the


following tridiagonal system
⎡2.25 − 1 ⎤ ⎡ u1 ⎤ ⎡0.25 sin(0.25π )⎤
⎢ − 1 2.25 − 1 ⎥ ⎢u ⎥ = ⎢ 0.25 sin(0.5π ) ⎥
⎢ ⎥ ⎢ 2⎥ ⎢ ⎥
⎢⎣ − 1 2.25⎥⎦ ⎢⎣u3 ⎥⎦ ⎢⎣0.25 sin(0.75π )⎥⎦
⎡ u1 ⎤ ⎡0.21152⎤
⇒ ⎢⎢u2 ⎥⎥ = ⎢⎢ 0.2912 ⎥⎥
⎢⎣u3 ⎥⎦ ⎢⎣ 0.21151⎥⎦
SE301_Topic9 (c)Al-Amer 2005 ٦٨

٣٤
Example 2
Second Row

0.25u (0.25,0.25) = − u (0,0.5) + 2.25 u (0.25,0.5) − u (0.5,0.5)


0.2115 = 0 + 2.25 u1 − u2

t=1.0 0 0

t=0.75 0 0
u1 u2 u3
t=0.5 0 0
t=0.25 0 0
0.2115 0.2991 0.2115
t=0 0 0
Sin(0.25π) Sin(0. 5π) Sin(0.75π)

x=0.0 x=0.25 x=0.5 x=0.75 x=1.0


SE301_Topic9 (c)Al-Amer 2005 ٦٩

Example 2

The process is continued until the values of


u(x,t) on the desired grid are computed.

SE301_Topic9 (c)Al-Amer 2005 ٧٠

٣٥
Remarks
The explicit metod:
• one need to select small k to ensure stability
• Computation per point is very simple but many
points are needed.
Cranks Nicolson
• Requires solution of Tridiagonal system
• Stable (larger k can be used).
SE301_Topic9 (c)Al-Amer 2005 ٧١

٣٦

You might also like