Professional Documents
Culture Documents
Numerical Methods For Partial Differential Equations
Numerical Methods For Partial Differential Equations
Partial Differential
Equations
1. Introduction
1
Slides adapted from Prof. Shang-Xu. Hu of ZJU, “Appl
ied Numerical Computation Methods”. 2000.5
1. Introduction to PDEs
u x b 3u y 0 first order
u xx u 3y 0 second order
u x u yyy 0 third order
• characteristic
using the first order PDE as an example
au x bu y c 0
2
a , b, c are constants
a a x, y , b bx, y , c c x, y
x, y ...Linear
x, y, u ...Quasilinear
x, y, u, u x , u y ... Nonlinear
for examples :
u x bu y 0 ...Linear
ux u u y x 2 0 ...Quasilinear
u x u y 0 ... Nonlinear
2
3
• types
first order linear PDE
au x bu y c 0
ut v u x Advection Equation(AE)
second order linear PDE
Au xx Bu xy Cu yy G 0
B 2 4 AC 0 elliptic
u xx u yy f x, y Poisson equation
u xx u yy 0 Laplace eq., heat conduction eq.
B 2 4 AC 0 parabolic
u x u yy diffusion equation
u x u u y K u yy Burger equation
B 2 4 AC 0 hyperbolic
u xx u yy wave equation
4
• solution methods:
Method of Finite Differences (MFD)
Method of Characteristics (MOC)
Method of Lines (MOL)
Method of Finite Elements (MFE)
Method of Weighled Residuals (MWR)
• Numerical questions:
Convergence
When the steps approach to infinitely small,
will the numerical results coincide the theoreti
cal results? y dy
x dx
Stability
When the error is introduced at a certain ste
p, will this error be amplified or attenuated af
ter several steps of numerical computation?
y 1 y k
1
ey ey k 5
2. Finite difference method for fi
rst order hyperbolic PDEs
u u
v 0
t x
known as Advection Equation (AE)
v is the flow speed
The analytical solution is:
u f x vt
since u f w , w x vt
u du w du
v
t dw t dw
u du w du
x dw x dw
To find a specific solution, we need two
auxiliary conditions:
u x, t0 f x vt0
u x0 , t f x0 vt
6
assuming the forcing function is a Rump
1.0, 0 W f w
W 1.0
f W 1 , s W 0
s
0.0
0.0, W s
s 0 W
The solution of ut vu x 0 is shown below.
u
x x0
t t0
u x0 , t
u x j , t
u x,t 0
xj
tn x
u x , t n
t
t tn
x xj x v t
Fig. 1. Propagation of the Wave Front
7
2.1 The simplest finite difference format:
t
t n 1
tn
t
t0
x0 x j 1 xj x j 1 x
x
Fig. 2
u u
v
t x x j x0 j x
u t0 , x a x
u t , x0 bt t n t0 n t
u u j u jn n 1
Ot
t
j ,n t
u u jn1 u jn1 u jn 1 u jn u jn1 u jn1
O x 2 v
x j ,n 2x t 2x
v t n
u jn 1 u jn
2x
u j 1 u jn1 n n 1
8
The above method is called Forward Time Centered Space
FTCS representation
In fact, this method is not practical since it is an unstable metho
d
u jn1 rjnthe
Consider u jn rjnerror
1 numerical
2v rxt u jn1 rjn1 u jn1 rjn1
v t PDE
by
Because the original
rjn 1 rjn
2x
rjn1 r jn1
is linear, the error propagation is
We need to determine if
rj0 , rj1,, rjn 1, rjn , rjn 1,is an increasing sequence or not
9
Consider the linear ODE
d2y dy
2
P Qy F x
dx dx
D 2 y P Dy Qy F x
solution=auxiliary solution and specific solution
Auxiliary solution: D 2 y P Dy Qy 0
D 2
PD Q y 0
D P1 D P2 y 0
P1 , P2 are two roots of x 2 Px Q 0
auxiliary equation
Auxiliary solution composes of two independent solutions:
D P1 y 0 D P2 y 0
y1 A1 expP1 x y2 A2 expP2 x
Dy1 A1P1 expP1 x P1 y1
when P 2 4Q P i is a complex number
y y1 y2 y p
x j x j 1 x j
y j y j 1 y j f x j 1 f x j
y j 1 y j y j 1 y j Ey j
E 1 , Ey j y j 1
Ey j 1 y j 2
E 2 y j y j2
It is the same as the differential operator.I
t is a linear operator. When applied to the
linear second order difference equation
yn 2 Pyn 1 Qyn F x
E P1 yn 0
E P2 yn 0
Two independent solutions are
yn A1 P1n
1
yn A2 P2n2
Since : yn 1 A P n 1 P yn , Eyn P yn
yn A1 P1n A2 P2n
When P 2 4Q,P i exp ix
yn A n expi n x ( Eigenmode )
a2 an
expa 1 a
2! n!
a 2 ia 3 a 4
expia 1 ia
2! 3! 4!
a2 a4 a3 a5
1 i a
2! 4! 3! 5!
Eyn yn 1 A n 1 expi n 1x
pyn expix A n expinx
Eyn Pyn
12
The general form of the independent solution of
difference equation is given by:
yn A n expinx
t
Lax Method
instead of using u jn t n 1
let us use tn
1 n
2
u j 1 u jn1
t0
Then, our new finite
difference format becomes : x0 x j 1 xj x j 1 x
1 n v t n
u jn 1
2
u j 1 u jn1
2 x
u j 1 u jn1 Fig. 3
In this case, the correspond ing
amplificat ion factor is : I
v t
coskX i sin kX
x
i
2
R
The condition to ensure 1 kt
vt
is that x
1
vt
1
x
Fig. 4
Courant Condition
14
t
The physical meaning
Of Courant condition
t3
t 2
t1
Waveform travels along tn
The line x=vt x j 1 xj x j 1 x
t knot selection x
• when knot is on the line:
x vt
t 2 , 1 Fig. 5
v x
• when knot is outside the line:
x v t
t 3 , 1 unstable
v x
• when knot is inside the line:
x vt
t1 , 1 stable
v x
The Lax finite difference format can also be wri
tten as
u jn 1 u jn u jn1 u jn1 1 u jn1 2u jn u jn1
v
t
2x 2 t
19
4 Method of lines (MOL) approach fo
r first order hyperbolic PDEs
Finite Difference: PDE is completely discretized as
a set of difference equations. Using linear algebra t
o solve.
Method of lines: PDE is partly discretized as a set
of ODEs and using ODE numerical solution metho
d to solve.
u u
A B C
t x
u C B u
t A A x
u x , t 0 f x
u x0 , t g t
Discretizing x axis as xi , i 0,1,, n
we can get a set of ODEs :
dui C B u
i 0,1,, n
dt A A x xi ,t
20
Method of Lines (MOL)
a partial discretization method
Representing u x, t as ui t , i 0,1,, n
Line space
t
t1 Integration
t
step
t0
x0 xi xn x
x
Fig. 8
ui C B ui
i 0,1,, n
t A A x 21
5. Finite difference method for sec
ond order elliptic PDEs
2u 2u
2
2 0
x y
known as the steady-state heat conduction eq
uation and general form is
2u 0 Laplace equation
2
2
2
Laplace operator
k xk
• Dirichlet problem u x0 , y f1 y
2 2
u xm , y f 2 y
u u
2
2 0 u x1 , y0 f 3 y
x y
u x1 , yn f 4 y
• Neumann problem
u x x0 g1 y
2u 2u u x xm g 2 y
2 0
x 2
y u x y0 g 3 y
u x yn g 4 y
22
y u
g 4 x
y yn
yn
u x , y n f 4 x
u(x0,y)=f1(y)
u(xm,y)=f2(y)
yj 2u 2u
0 u
u x 2 y 2 g 2 x
g1 x
y x0 Q x , y y xm
u x , y 0 f 3 x
y0
u
g 3 x
x0 xi y y0 xm x
Fig. 9
Laplace equation: Dirichlet boundary condition and
Neumann boundary condition.
Poisson equation
2u 2u
x , y
x 2 y 2
Four (4) boundary conditions required. There ar
e 3 types of boundary conditions:
• Dirichlet boundary condition
• Neumann boundary condition
•Mixed or hybrid boundary condition. 23
5.1 Finite difference of Laplace operator
2 2u 2u
u 2 2 0
x y
The second order derivative can be expressed
in finite difference form from the Taylor series expansion
f '' xi 2 f ''' xi 3 f 4 i 4
f xi h f xi f xi h
'
h h h
2 6 24
f '' xi 2 f ''' xi 3 f 4 i 4
f xi h f xi f xi h
'
h h h
2 6 24
f xi h 2 f xi f xi h f 4 2
f xi
''
h
h2 12
This can be expressed in a concise form :
f i 1 2 f i f i 1
f '' i
h 2
O h 2
Apply the above for Laplace operator
u xi 1 , y j 2u xi , y j u xi 1 , y j
u xi , yi
2
x 2
u xi , y j 1 2u xi , y j u xi , y j 1
y 2
When x y h, we can simply use the following
1
2uij 2
ui1, j ui1, j ui, j 1 ui, j 1 4ui, j
h
24
ui , j 1
y j 1
ui 1, j ui , j ui 1, j
yj
ui , j 1
y j 1
xi 1 xi xi 1
Fig. 10
10
cm 0o c 100 o c
hy 5
0o c 0o c 0o c x
20 cm
hx 5
Fig. 11
For each interval knot, we can write a linear equation
0 T2 0 0 4T1 0
T1 T3 0 0 4T2 0
T2 100 0 0 4T3 0
4 1 0 T1 0
or, 1 4 1 T2 0
0 1 4 T3 100
the solution is
o
T1 1.786 C
o
T2 7.143 C
o
T3 26.786 C 26
To increase the accuracy, we should use a denser
grid:
1 8 15 5 12
2 9 16 6 13
3 10 17
7 14
4 11 18 1 8 15
5 12 2 9
6 13 3 10
7 14 4 11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 4 1 0 0 0 0 0 1
2 1 4 1 0 0 0 0 0 1
3 0 1 4 1 0 0 0 0 0 1
4 0 0 1 4 1 0 0 0 0 0 1
5 0 0 0 1 4 1 0 0 0 0 0 1
6 0 0 0 0 1 4 1 0 0 0 0 0 1
7 0 0 0 0 0 1 4 0 0 0 0 0 0 1
8 1 0 0 0 0 0 1 4 1 0 0 0 0 0 1
9 1 0 0 0 0 0 1 4 1 0 0 0 0 0 1
a
width 1 2 1 15, nonzero elements : 5
h
Fig. 12
27
Laplace equation with Dirichlet boundary conditio
n – numerical solutions
• elimination method:
2uij ui 1, j ui 1, j ui , j 1 ui , j 1 ,4ui , j 0
• Direct iteration Liebmann method
u u
i, j k i 1, j ui 1, j ui , j 1 ui , j 1 k 1 4
• S.O.R. method
R ui , j k 1
ui 1, j ui 1, j ui , j 1 ui , j 1 k 1
ui , j k 1
4
u u
i, j k i , j k 1 R ui , j k 1
• Alternating direction iteration (A.D.I.) method
P
u u
i, j k i, j ui 1, j ui1, j 2ui, j k
k 1
4
P
ui , j 1 ui , j 1 2ui , j k 1
4
P
u
i , j k 1 ui , j k ui 1, j ui 1, j 2ui , j k
4
P
ui , j 1 ui , j 1 2ui , j k 1
4
28
6 Finite element method for second
order elliptic PDEs
Finite Elements Method (FEM)
Let us use Laplace equation Dirichlet proble
m as an illustrative example
2u 2u
2
2 0, x, y D
x y
u x, y g x, y , x , y
Based on Variational S
D
Principles em
Equivalence theorem D
Fig. 13
The solution of the above PDE
will minimize the following functional
1 u 2 u 2
J u dxdy
2 x y 29
D
Discretize D, usually using trangulation method:
D em D, S
m
Then,
Wi xi yi 1 wi yi
1 1
a1 Wj xj yj a2 1 wj yj
2e 2e
Wk xk yk 1 wk yk
1 xi wi 1 xi yi
1
a3 1 xj wj where 2e 1 x j yj
2 e
1 xk wk 1 xk yk
30
u
Uk=Wk
Ui=Wi e
W x, y
u x , y
Uj=Wj
xk yi y
xj k
xi yj
k
e Y
X i
j
Fig. 14
31
Therefore,
1
W x , y
e
bi ci x d i y wi
2e
b j c j x d j y w j
bk ck x d k y wk
wherebi x j yk xk y j , ci y j yk , d i xk x j
b j xk y j xi yk , c j yk yi , d j xi xk
bk xi y j x j yi , ck yi y j , d k x j xi
1 e 2
wx wy dxdy
e e 2
e 2
with the following
approximation:
1 ci wi c j w j ck wk
2
J w
e e 2 2e
2
d i wi d j w j d k wk
dxdy
2e
W is given on the boundary
The J w 0, solution
minimum m 1,2,is
from
,n
Wm
n: the number of inner knots
Therefore,
A W wer can get
wm um , m 1,2, , n
That is 33
For a more general situation
u u
px, y qx, y r x, y u x, y
x x y y
f x , y
x , y D
u x, y g x, y x , y 1
u u
px, y cos1 qx, y cos 2 h1 x, y u x, y
x y
h2 x, y
x , y 2
The functional to be minimized is
1
2 2
u u
J u px, y qx, y r x, y u
2
2 x y
1
f x, y u dxdy h2 u h1u 2 ds
2
2
xs
y 2 normal
We can similarly do 2 1
ys
S
the discretization and D
tan gent
get the finite element 1
x
solution 34
Fig. 15
8 Finite difference method for sec
ond order parabolic PDEs
Dynamic diffusion equation:
2 1 C
C
D t
For one dimensional space
2
C x, t0 g1 x
C C
D 2 , C x0 , t g 2 x
t x
C xn , t g 3 x
When using finite difference to replace the differ
entiation, there are many options, e.g.,
C Ci , j 1 Ci , j 1
, ht t j 1 t j
t xit j 2ht
2C Ci 1 2Ci , j Ci 1, j
2 2
, hx xi 1 xi
t xit j hx
So, ht
Ci , j 1 Ci , j 1 2 D 2
Ci1, j 2Ci, j Ci 1, j
hx
We get
ht
ci , j 1 ci , j 2
ci 1, j 2ci, j ci1, j
Dhx
or,
ci , j 1 r ci 1, j ci 1, j 1 2r ci , j
ht D 2 1
where r , when h x 2 ht D,r
hx2 2
Then, we have
1
ci , j 1 ci 1, j ci 1, j
2
t
t j 1
tj
t0
x0 xi 1 xi xi 1 xn x
36
Fig. 16
Illustrative example:
c 2c
0.119 2
t x
cx,0 0.04
c0, t 0
c20, t 0.2
where hx 4cm
D 0.119 cm 2 sec
2 42
ht 67.2sec
0.119
Compare the numerical result with the follo
wing analytical result:
x 20 nx
C x, t exp 0.01175 n 2t sin
2 n 1 10
2n 1x
12
n 1
exp 0.002942n 1 t sin
2
20
air
D 0.11904 cm sec 2
mg
c0, t 0.0 3
Saturated steam cm
mg
c20, t 0.2 3
cx,0 0.04 mg cm3
cm
A cm 2
C2H5OH
20 0 x
20 cm
37
Fig. 17
c% 6
5
x 12cm
4
3
2
x 4cm
1
0
0 4 8 12 16 20 24
Fig. 18
Number of time steps
Analytical Solutions
Numerical Solutions
rD
t
0 . 25, D 0.119 cm 2
sec
x 2
set x 4.0cm
0.25
t 42 33.6sec per time step
0.119
Analytical versus Numerical Solutions
Diffusion Dynamics
r0.25
38
c% 6
5 x 12cm
4
3
2
x 4cm
1
0
0 2 4 6 8 10 12
Fig. 19
Number of time steps
Analytical Solutions
Numerical Solutions
rD
t
0 . 5, D 0 .119 cm 2
sec
x 2
set x 4.0cm
0.5
t 42 67.2sec per time step
0.119
Analytical versus Numerical Solutions
Diffusion Dynamics
r0.5
39
Stability analysis of the explicit method
The error at xi , t j is denoted as
ei , j ci , j Wi , j Therefore,
ei , j 1 r ei 1, j ei 1, j 1 2r ei , j
r wi 1, j wi 1, j 1 2 r wi ,, j w j , j 1
Taylor series expansion
wi 1, j
c
wi , j x
x 2c1 , t
2
x i , j 2 x 2
wi 1, j
c
wi , j x
x 2c 2 , t
2
x i , j 2 x 2
c xi ,
wi , j 1 wi , j t
t