Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Chapter 6

Numerical Methods for


Partial Differential Equations

Lecture 1:
Finite-difference
method for elliptic
equations
Introduction
A partial differential equation (PDE) is an equation
that involves an unknown function and its partial
derivatives.
Example: Heat equation
 u ( x, y, z, t )   2 u  2u  2u 
=  2 + 2 + 2 
t  x y z 
K
= : thermal diffusivity (cm 2 / s)
C
 : density of the material (g/cm3 )
C : heat capacity of the material [cal/(g O C )]
K : thermal conductivity [cal/(s cm O C )]
u = temperature (OC ) in a body at point ( x, y, z ), time t (s) 2
Laplace Equation

 2u ( x, y , z )  2u ( x, y , z )  2u ( x , y , z )
+ + =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.

MAFE208IU-L14 3
Wave Equation

 2u ( x , y , z , t )   2
u  2
u  2
u 
= c  2 + 2 + 2
2


t 2
 x y z 

It describes the displacement at time t of a particle


having coordinates (x,y,z) .
The constant c represents the propagation speed of
the wave.

MAFE208IU-L14 4
The Black–Scholes
equation
In mathematical finance, Black–Scholes
equation is
V 1 2 2  V V 2
+  S + rS − rV = 0
t 2 S 2
S
where V is the price of the option as a function of stock
price S and time t, r is the risk-free interest rate, and σ is
the volatility of the stock

Finite-difference methods in this lecture can be applied to this model

MAFE208IU-L14 5
Linear Second Order PDEs
A PDE is said to be linear if it is linear in the
unknown function and all its derivatives

Because of their widespread application, our


treatment of PDEs will focus on linear, second-
order equations of two-independent variables

A uxx + B uxy + C u yy + D( x, y, u, u x , u y ) = 0,
where A, B, and C are functions of x and y

MAFE208IU-L14 6
Linear Second Order PDEs
Classification
A second order linear PDE (2-independent variables)
A u xx + B u xy + C u yy + D ( x, y , u , u x , u y ) = 0,
is classified based on (B 2 − 4 AC) as follows:
B 2 − 4 AC  0 Elliptic
B 2 − 4 AC = 0 Parabolic
B 2 − 4 AC  0 Hyperbolic

MAFE208IU-L14 7
Poisson Equation Boundary Conditions
Let   R be a planar domain, and denote its
2

boundary by   . The boundary value problem

u u
2 2
+ 2 = f ( x, y), ( x, y) 
x y
2

u = g ( x, y), ( x, y)  
is called a Dirichlet problem because the value of
u is specified on the boundary. For simplicity we
will assume that  = (0, a)  (0, b) and therefore
  = { ( x, y) : 0  x  a, y = 0, b or 0  y  b, x = 0, a }
Finite Difference Grid
Ω is divided into m equal parts along x-axis and n parts along y-axis

yn = b
• • • boundary points
• • • • interior points
• • •
y2 • • •
y1 • • •
O x1 x2 xm = a

Coordinates of mesh (grid) points: ( xi , y j ),


where xi = ix, y j = j y, 0  i  m, 0  j  n
a b
Step sizes: x = , y =
MAFE208IU-L14 m n 9
Finite Difference Approximation
We approximate the PDE by CDA of 2nd derivatives:
 2u  2u
+ 2 = f ( x, y ), ( x, y ) = ( xi , y j )
x 2
y

u ( xi +1 , y j ) − 2u ( xi , y j ) + u ( xi −1 , y j ) u ( xi , y j +1 ) − 2u ( xi , y j ) + u ( xi , y j −1 )
+  fij
(x) 2
(y ) 2

b
• • •
• • • Notations:
• • •
y2 • • • fij = f ( xi , y j )
y1 • • •
xm = a
ui , j  u ( xi , y j )
O x1 xi
For boundary points u( xi , y j ) = g ( xi , y j )
Finite Difference Approximation
We approximate u ( xi , y j ) by the solutions ui , j of
ui +1, j − 2ui , j + ui −1, j ui , j +1 − 2ui , j + ui , j −1
+ = fi , j
(x) 2
(y ) 2

1  i  m − 1, 1  j  n − 1

b
• • • Where, at every
• • • boundary point,
• • •
y2 • • • we define
y1 • • •
xm = a
ui , j = g ( xi , y j )
O x1 x2 11
Finite Difference Approximation
If we choose x = y = h
ui +1, j + ui −1, j + ui , j +1 + ui , j −1 − 4 ui , j = h fi , j
2

1  i  m − 1, 1  j  n − 1

b u0, j = g 0, j , um, j = g m, j
• • •
• • • ui ,0 = gi ,0 , ui ,n = gi ,n
• • •
y2 • • •
y1 • • •
O x1 x2 xm = a
12
2D Laplace Equation
 T ( x, y )  T ( x, y )
2 2
+ =0
x 2
y 2

It represents heat distribution over a body occupying


a planar region without heat source

Take x = y = h for discretizing the PDE and the region

MAFE208IU-L14 13
2D Laplace equation
Solution Technique
x = y = h

Ti , j +1

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

Ti , j −1

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


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

75 50

The sheet is divided to


5x5 grids.
MAFE208IU-L14
Ti +1, j + Ti −1, j + Ti , j +1 + Ti , j −1 − 4Ti , j = 0 15
Known

Example 1 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


MAFE208IU-L14 16
Known

First Equation To be determined

T12

T11 T21
T01 = 75

T10 = 0

T21 + T01 + T12 + T10 − 4T11 = 0


T21 + 75 + T12 + 0 − 4T11 = 0
4T11 − T21 − T12 = 75
MAFE208IU-L14 17
Known

Second Equation To be determined

T22

T11 T21 T31

T20 = 0

T31 + T11 + T22 + T20 − 4T21 = 0


T31 + T11 + T22 + 0 − 4T21 = 0
−T11 + 4T21 − T31 − T22 = 0
MAFE208IU-L14 18
Full system:
 4 −1 0 −1 0 0 0 0   T11   75 
0
    
 −1 4 −1 0 −1 0 0 0 0   T21   0 
 0 −1 4 0 0 −1 0 0 0   T31   50 
    
 −1 0 0 4 −1 0 −1 0 0   T12   75 
 0 −1 0 −1 4 −1 0 −1 0   T22  =  0 
    
 0 0 −1 0 −1 4 0 0 −1  T32   50 
 0 0 0 −1 0 0 4 −1 0   T13  175 
    
0 0 0 0 −1 0 −1 4 −1  T23  100 
0 0 0 0
 0 −1 0 −1 4   T33  150 

MAFE208IU-L14 19
Example 2
Use a finite-difference method with ∆x=∆y=1/2 to compute
Approximate values of solution of the boundary-value problem
 2u ( x, y)  2u ( x, y)
+ = 4, 0  x  1, 0  y  2
y xu = ( x − 2)2 y
2 2

2
with boundary conditions
u3
3/2 u ( x, 0) = x 2 , u ( x, 2) = ( x − 2) 2 , 0  x  1
u2 u (0, y ) = y 2 , u (1, y ) = ( y − 1) 2 , 0  y  2
1
u=y 2 u = (1 − y)2
u1
1/2 And find the errors, given the exact
uxx + u yy = 4
solution:
x
O
u=x 2
1/2
u( x, y) = ( x − y)2
1
Solution

ui +1, j + ui −1, j + ui , j +1 + ui , j −1 − 4 ui , j = h 2 fi , j = 1
xi = 1/ 2, y j = j / 2, 1  i  2, 1  j  4

Set 𝑢1 = 𝑢11 , 𝑢2 = 𝑢12 , 𝑢3 = 𝑢13


1/ 4 + 1/ 4 + 1/ 4 + u2 − 4u1 = 1
y u = ( x − 2) 2

2
−4u1 + u2 = 1/ 4 (1)

u3 0 + 1 + u3 + u1 − 4u2 = 1
3/2 u1 − 4u2 + u3 = 0 (2)
u2 1/ 4 + 9 / 4 + 9 / 4 + u2 − 4u3 = 1
1 u2 − 4u3 = −15 / 4 (3)
u = y2 u = (1 − y) 2

u1 From (1), (2) and (3): Au=b


1/2
uxx + u yy = 4 (u1 ,u2 ,u3 ) = (0,1/ 4,1)
O x
Exact values u = (0,1/ 4,1)
u=x 2
1/2 errors = 0
1 21
Exercise
Approximate solution of the elliptic equation
 2u ( x, y )  2u ( x, y )
+ = ( x 2
+ y 2
) e xy
, 0  x  2, 0  y  1
x 2
y 2

with boundary conditions


u (0, y ) = 1, u (2, y ) = e2 y , 0  y  1
u ( x, 0) = 1, u ( x,1) = e x , 0  x  2
with ∆x= ∆y=1/2 and find the error. Exact solution:

u ( x, y ) = e xy

MAFE208IU-L15
Exercise 2
Using ∆x=∆y=1/3, find approximate solution of the
boundary value problem
u xx + u yy = 6 + e x , 0  x  1, 0  y  1
u (0, y ) = 2 y 2 + 1, u (1, y ) = 2 y 2 + e + 1, 0  y  1
u ( x, 0) = x 2 + e x , u ( x,1) = x 2 + e x + 2, 0  x  1
y
1
Find the error
given exact solution: u3 u4
2/3
u ( x, y) = x + 2 y + e
2 2 x
u1 u2
1/3

O x
ui +1, j + ui −1, j + ui , j +1 + ui , j −1 − 4 ui , j = h 2 f i , j 1/3 2/3 1
Exercise 3
Using ∆x=∆y=1/3, find approximate solution of the
boundary value problem
u xx + u yy − u x = 6 − 2 x, 0  x  1, 0  y  1
u (0, y ) = 2 y 2 + 1, u (1, y ) = 2 y 2 + e + 1, 0  y  1
u ( x, 0) = x 2 + e x , u ( x,1) = x 2 + e x + 2, 0  x  1
y
1
Find the error
given exact solution: u3 u4
2/3
u ( x, y) = x + 2 y + e
2 2 x

u1 u2
1/3

O x
MAFE208IU-L15
1/3 2/3 1
Homework Chapter 6

Problem 1: Approximate solution of the elliptic equation

 2u ( x, y)  2u ( x, y)
+ = ( mx 2
+ ny 2
) e xy
, 0  x  2, 0  y  1
x 2
y 2

with boundary conditions


u (0, y ) = m, u (2, y ) = e2 y , 0  y  1
u ( x, 0) = n, u ( x,1) = e x , 0  x  2
with ∆x=2/3, ∆y=1/3 and find the error.

MAFE208IU-L15
Homework Chapter 6
Problem 2: Approximate solution of the heat equation

u ( x, t ) m  2u ( x, t )
= 0  x  1, t  0
t 5n x 2
with boundary conditions u(0, t ) = u(1, t ) = 0, t  0
and initial condition u( x,0) = 2sin(2 x), 0  x 1

at the time t=0.1 and t=0.2 with ∆x=0.2, ∆t=0.1 using


a) explicit method and
b) implicit Crank-Nicholson method

MAFE208IU-L15 26
Homework Chapter 6: Problem 3
Determine the steady state temperature at all points
of a heated sheet of metal. The edges of the sheet are
kept at a constant temperature: 300, 150, 100, and 0
degrees as in Figure below.

The sheet is divided to 300


5X5 grids.

100 150

Deadline: 2 weeks

MAFE208IU-L14 27

You might also like