Finite Differences: Parabolic Problems Numerical Methods for PDEs Lecture 5 B. C. Khoo

advertisement
16.920J/SMA 5212
Numerical Methods for PDEs
Lecture 5
Finite Differences: Parabolic Problems
B. C. Khoo
Thanks to Franklin Tan
SMA-HPC ©2002 NUS
Outline
•
•
•
•
•
•
Governing Equation
Stability Analysis
3 Examples
Relationship between σ and λh
Implicit Time-Marching Scheme
Summary
SMA-HPC ©2002 NUS
2
Governing
Equation
Consider the Parabolic PDE in 1-D
∂u
∂u
=υ 2
∂t
∂x
2
x ∈ [ 0, π ]
subject to u = u0 at x = 0, u = uπ at x = π
u0
uπ
u ( x, t ) = ?
x=0
•
•
x =π
If υ ≡ viscosity → Diffusion Equation
If υ ≡ thermal conductivity → Heat Conduction Equation
SMA-HPC ©2002 NUS
3
Stability Analysis
Discretization
Keeping time continuous, we carry out a spatial
discretization of the RHS of
∂u
∂ 2u
=υ 2
∂t
∂x
x =π
x=0
x0
x1
x3
xN −1 xN
There is a total of N + 1 grid points such that x j = j ∆x,
j = 0,1, 2,...., N
SMA-HPC ©2002 NUS
4
Stability Analysis
Discretization
∂ 2u
Use the Central Difference Scheme for 2
∂x
u j +1 − 2u j + u j −1
 ∂ 2u 
2
=
+
O
(
∆
x
)
 2
2
∆x
 ∂x  j
which is second-order accurate.
• Schemes of other orders of accuracy may be
constructed.
SMA-HPC ©2002 NUS
5
Discretization
Stability Analysis
We obtain at
du1
υ
= 2 (uo − 2u1 + u2 )
dt ∆x
du
υ
x2 : 2 = 2 (u1 − 2u2 + u3 )
dt
∆x
x1 :
xj :
du j
dt
=
υ
∆x
2
(u j −1 − 2u j + u j +1 )
du N −1
υ
xN −1 :
= 2 (u N − 2 − 2u N −1 + u N )
dt
∆x
Note that we need not evaluate u at x = x0 and x = xN
since u0 and u N are given as boundary conditions.
SMA-HPC ©2002 NUS
6
Matrix Formulation
Stability Analysis
Assembling the system of equations, we obtain
 du1 
 −2 1
 dt 




 du2 
 1 −2
 dt 







 υ 

= 2
du
∆x 
j 


 dt 












du

 N −1 
 dt 
1
0
SMA-HPC ©2002 NUS
0
1
−2
1
1
 υu 
  u1   o2 
  ∆x 

 


  u2   0 
 


 


  0 

+


u
 j  

 


 


1 
  0 
 


 υ u 

−2  u N −1   N2 
 ∆x 
A
7
Stability Analysis
PDE to Coupled ODEs
Or in compact form
du
= Au + b
dt
where u = [ u1
 υu
b =  o2
 ∆x
u N −1 ]
T
u2
0
0
0
υuN 
T
∆x 2 
We have reduced the 1-D PDE to a set of
Coupled ODEs!
SMA-HPC ©2002 NUS
8
Stability Analysis
Eigenvalue and
Eigenvector of Matrix A
If A is a nonsingular matrix, as in this case, it is then
possible to find a set of eigenvalues
λ = {λ1 , λ2 ,...., λ j ,...., λN −1}
from det ( A − λ I ) = 0.
For each eigenvalue λ j , we can evaluate the eigenvector V j
consisting of a set of mesh point values vij , i.e.
V
jT
SMA-HPC ©2002 NUS
j

=  v1
j
2
v
v
j
N −1

9
Stability Analysis
Eigenvalue and
Eigenvector of Matrix A
The ( N − 1) × ( N − 1) matrix E formed by the ( N − 1) columns
V j diagonalizes the matrix A by
−1
E AE = Λ
λ1

λ2

where Λ = 



0
SMA-HPC ©2002 NUS






λN −1 
0
10
Stability Analysis
Coupled ODEs to
Uncoupled ODEs
du
= Au + b
dt
Premultiplication by E −1 yields
Starting from
du
E
= E −1 Au + E −1 b
dt
−1
du
E
= E −1 A ( EE −1 ) u + E −1 b
dt
−1
I
du
E
= ( E −1 AE ) E −1 u + E −1 b
dt
−1
SMA-HPC ©2002 NUS
Λ
11
Coupled ODEs to
Uncoupled ODEs
Stability Analysis
Continuing from
du
E
= ΛE −1 u + E −1 b
dt
−1
−1
−1
Let U = E u and F = E b , we have
d
U = ΛU + F
dt
which is a set of Uncoupled ODEs!
SMA-HPC ©2002 NUS
12
Stability Analysis
Expanding yields
Coupled ODEs to
Uncoupled ODEs
dU1
= λ1U1 + F1
dt
dU 2
= λ2U 2 + F2
dt
dU j
dt
= λ jU j + Fj
dU N −1
= λN −1U N −1 + FN −1
dt
Since the equations are independent of one another, they
can be solved separately.
The idea then is to solve for U and determine u = EU
SMA-HPC ©2002 NUS
13
Coupled ODEs to
Uncoupled ODEs
Stability Analysis
Considering the case of b independent of time, for the
general j th equation,
U j = c je
λ jt
is the solution for j = 1,2,….,N–1.
−
1
λj
( ) − EΛ
Evaluating, u = EU = E ce
λt
Complementary
(transient) solution
( ) = c e
where ce
SMA-HPC ©2002 NUS
λt
1
λ1t
c2 e
λ2t
−1
Fj
−1
E b
Particular (steady-state)
solution
c je
λ jt
cN −1e
λN −1t


T
14
Stability Analysis
Stability Criterion
We can think of the solution to the semi-discretized problem
( )
u = E ceλt − E Λ −1 E −1 b
as a superposition of eigenmodes of the matrix operator A.
Each mode j contributes a (transient) time behaviour of the form
λt
e j to the time-dependent part of the solution.
Since the transient solution must decay with time,
Real ( λ j ) ≤ 0
for all j
This is the criterion for stability of the space discretization (of a
parabolic PDE) keeping time continuous.
SMA-HPC ©2002 NUS
15
Stability Analysis
Use of Modal (Scalar)
Equation
It may be noted that since the solution u is expressed as a
contribution from all the modes of the initial solution,
which have propagated or (and) diffused with the eigenvalue
λ j , and a contribution from the source term b j , all the
properties of the time integration (and their stability
properties) can be analysed separately for each mode with
the scalar equation
 dU

= λU + F 

 dt
j
SMA-HPC ©2002 NUS
16
Stability Analysis
Use of Modal (Scalar)
Equation
The spatial operator A is replaced by an eigenvalue λ, and
the above modal equation will serve as the basic equation
for analysis of the stability of a time-integration scheme
(yet to be introduced) as a function of the eigenvalues λ of
the space-discretization operators.
This analysis provides a general technique for the
determination of time integration methods which lead to
stable algorithms for a given space discretization.
SMA-HPC ©2002 NUS
17
Continuous Time
Operator
Example 1
Consider a set of coupled ODEs (2 equations only):
du1
= a11u1 + a12u2
dt
du2
= a21u1 + a22u2
dt
 u1 
 a11
Let u =   , A = 
u2 
 a21
SMA-HPC ©2002 NUS
a12 

a22 
⇒
du
= Au
dt
18
Example 1
Continuous Time
Operator
Proceeding as before, or otherwise (solving the ODEs directly),
we can obtain the solution
u1 = c1ξ11eλ1t + c2ξ12 eλ2t
u2 = c1ξ 21eλ1t + c2ξ 22 eλ2t
ξ11 
where λ1 and λ2 are eigenvalues of A and   and
ξ 21 
eigenvectors pertaining to λ1 and λ2 respectively.
ξ 21 
ξ  are
 22 
As the transient solution must decay with time, it is imperative that
Real ( λ j ) ≤ 0 for j = 1, 2.
SMA-HPC ©2002 NUS
19
Discrete Time Operator
Example 1
Suppose we have somehow discretized the time operator on the
LHS to obtain
n
n −1
n
n −1
21 1
u1 = a11u1
u2 = a u
+ a12u2
n −1
+ a22u2
n −1
where the superscript n stands for the nth time level, then
n
u = Au
n −1
n
where u = u
n
1
 a11
u2  and A = 
 a21
n T
a12 
a22 
Since A is independent of time,
n
u = Au
SMA-HPC ©2002 NUS
n −1
= AAu
n−2
= .... = A u
n
0
20
Discrete Time Operator
Example 1
As A = E ΛE −1 ,
n
u = E ΛE −1 ⋅ E ΛE −1 ⋅ .... ⋅ E ΛE −1 ⋅ u 0
A
n
A
−1
u = EΛ E u
n
0
A
n

λ
where Λ n =  1
0
u = λ ξ c + λ2 ξ12 c2
n
1
'
n
1 11 1
n
'
u2 = λ1 ξ 21c1 + λ2 ξ 22 c2
n
n
SMA-HPC ©2002 NUS
'
n
'
0
n
λ2 
 c1 ' 
where   = E −1 u 0 are constants.
 c2 '
21
Example 1
Comparison
Comparing the solution of the semi-discretized problem where
time is kept continuous
 u1 
ξ11 ξ12   eλ1t 
u  = [ c1 c2 ] ξ
  λ2t 
ξ
 2
 21 22  e 
to the solution where time is discretized
n
n
u
 1
ξ11 ξ12   λ1 
 n
u  = [ c1 ' c2 '] ξ

 2
 21 ξ 22  λ2 
The difference equation where time is continuous has exponential
solution eλt .
The difference equation where time is discretized has power
solution λ n .
SMA-HPC ©2002 NUS
22
Comparison
Example 1
In equivalence, the transient solution of the difference
equation must decay with time, i.e.
λ <1
n
for this particular form of time discretization.
SMA-HPC ©2002 NUS
23
Example 2
Leapfrog Time Discretization
Consider a typical modal equation of the form
 du
µt 
u
ae
λ
=
+


dt

j
where λ j is the eigenvalue of the associated matrix A.
(For simplicity, we shall henceforth drop the subscript j).
We shall apply the “leapfrog” time discretization scheme given
as
n +1
n −1
du u − u
=
dt
2h
where h = ∆t
Substituting into the modal equation yields
u n +1 − u n −1
= ( λ u + ae µt )
t = nh
2h
= λu n + ae µ hn
SMA-HPC ©2002 NUS
24
Leapfrog Time Discretization
Example 2
Time Shift Operator
u n +1 − u n −1
= λu n + ae µ hn
2h
⇒
u n +1 − 2hλ u n − u n −1 = 2ha ( e µ hn )
Solution of u consists of the complementary solution cn, and the
particular solution pn, i.e.
un = cn + pn
There are several ways of solving for the complementary and
particular solutions. One way is through use of the shift operator
S and characteristic polynomial.
The time shift operator S operates on cn such that
Scn = cn+1
S2cn = S(Scn) = Scn+1 = cn+2
SMA-HPC ©2002 NUS
25
Example 2
Leapfrog Time Discretization
Time Shift Operator
The complementary solution cn satisfies the homogenous equation
c n +1 − 2hλ c n − c n −1 = 0
n
c
Sc n − 2hλ c n − = 0
S
( S 2 c n − 2hλ Sc n − c n )
1
=0
S
n
c
( S 2 − 2hλ S − 1) = 0
S
characteristic polynomial
p ( S ) = ( S 2 − 2hλ S − 1) = 0
SMA-HPC ©2002 NUS
26
Leapfrog Time Discretization
Example 2
Time Shift Operator
The solution to the characteristic polynomial is
σ (λ h ) = S = λ h ± 1 + λ 2 h 2
σ1 and σ2 are the two roots
The complementary solution to the modal equation would then be
n
n
c n = β1σ 1 + β 2σ 2
2ahe µ hn e µ h
The particular solution to the modal equation is p = 2 µ h
e − 2hλ e µ h − 1
n
Combining the two components of the solution together,
u n = ( cn ) + ( pn )
(

=  β1 λ h + 1 + h 2 λ 2

SMA-HPC ©2002 NUS
)
n
(
+ β 2 λ h − 1 + h 2λ 2
)
n
µ hn µ h

  2ahe e
+

  2µh
µh
  e − 2hλ e − 1 
27
Leapfrog Time Discretization
Example 2
Stability Criterion
For the solution to be stable, the transient
(complementary) solution must not be allowed to grow
indefinitely with time, thus implying that
(
= (λh −
)
1+ h λ ) < 1
σ 1 = λ h + 1 + h2λ 2 < 1
σ2
2
2
is the stability criterion for the leapfrog time
discretization scheme used above.
SMA-HPC ©2002 NUS
28
Example 2
Leapfrog Time Discretization
Stability Diagram
The stability diagram for the leapfrog (or any general)
time discretization scheme in the σ-plane is
Im(σ )
Region of Stability
-1
SMA-HPC ©2002 NUS
1
Re(σ )
29
Example 2
Leapfrog Time Discretization
In particular, by applying to the 1-D Parabolic PDE
∂u
∂ 2u
=υ 2
∂t
∂x
the central difference scheme for spatial discretization, we
obtain
 −2 1
 1 −2

υ 
A= 2 
∆x 



1
0
0
1






1

−2 
which is the tridiagonal matrix.
SMA-HPC ©2002 NUS
30
Example 2
Leapfrog Time Discretization
According to analysis of a general triadiagonal matrix B(a,b,c), the
eigenvalues of the B are
 jπ 
λ j = b + 2 ac cos   , j = 1,..., N − 1



λ j =  −2 + 2 cos 

 N 
jπ   υ

N   ∆x 2
The most “dangerous” mode is that associated with the eigenvalue
4υ
of largest magnitude
λmax = − 2
∆x
i.e. σ 1 ( λmax h ) = λmax h + λ 2 max h 2 + 1
σ 2 ( λmax h ) = λmax h − λ 2 max h 2 + 1
which can be plotted in the absolute stability diagram.
SMA-HPC ©2002 NUS
31
Leapfrog Time Discretization
Example 2
Absolute Stability Diagram for σ
As applied to the 1-D Parabolic PDE, the absolute stability
diagram for σ is
Im(σ)
Region of
instability
Unit
circle
σ1with h
σ2 with h
increasing
increasing
σ2 at h = ∆t = 0
SMA-HPC ©2002 NUS
Region of
stability
σ1 at h = ∆t = 0
Re(σ)
32
Stability Analysis
Some Important
Characteristics Deduced
A few features worth considering:
1. Stability analysis of time discretization scheme can be carried out for
all the different modes λ j .
2. If the stability criterion for the time discretization scheme is valid for
all modes, then the overall solution is stable (since it is a linear
combination of all the modes).
3. When there is more than one root σ , then one of them is the principal
root which represents an approximation to the physical behaviour.
The principal root is recognized by the fact that it tends towards one
as λ h → 0, i.e. lim σ ( λ h ) = 1. (The other roots are spurious, which
λ h →0
affect the stability but not the accuracy of the scheme.)
SMA-HPC ©2002 NUS
33
Stability Analysis
Some Important
Characteristics Deduced
4. By comparing the power series solution of the principal root to eλ h ,
one can determine the order of accuracy of the time discretization
scheme. In this example of leapfrog time discretization,
1 1
.−
1
1
σ 1 = λ h + (1 + h 2 λ 2 ) 2 = λ h + 1 + ( h 2λ 2 ) + 2 2 .h 4λ 4
2
2!
h2λ 2
σ 1 = 1 + hλ +
+ ...
2
and compared to
e
λh
h2λ 2
= 1 + hλ +
+ ...
2!
is identical up to the second order of hλ . Hence, the above scheme
is said to be second-order accurate.
SMA-HPC ©2002 NUS
34
Example 3
Euler-Forward Time Discretization
Stability Analysis
Analyze the stability of the explicit Euler-forward time
discretization
n +1
n
du u − u
=
dt
∆t
as applied to the modal equation
du
= λu
dt
du
Substituting u = u + h
where h = ∆t
dt
into the modal equation, we obtain u n +1 − (1 + λ h)u n = 0
n +1
SMA-HPC ©2002 NUS
n
35
Example 3
Euler-Forward Time Discretization
Stability Analysis
Making use of the shift operator S
c n +1 − (1 + λ h)c n = Sc n − (1 + λ h)c n = [ S − (1 + λ h)]c n = 0
characteristic polynomial
Therefore
σ (λ h ) = 1 + λ h
and
c n = βσ n
The Euler-forward time discretization scheme is stable if
σ ≡ 1+ λh < 1
or bounded by λ h = σ − 1
SMA-HPC ©2002 NUS
s.t. σ < 1 in the λ h-plane.
36
Example 3
Euler-Forward Time Discretization
Stability Diagram
The stability diagram for the Euler-forward time
discretization in the λh-plane is
Im(λh)
Unit Circle
Re(λh)
-2
-1
0
Region of Stability
SMA-HPC ©2002 NUS
37
Example 3
Euler-Forward Time Discretization
Absolute Stability Diagram
As applied to the 1-D Parabolic PDE, λ = λmax = −
σ leaves the unit circle at λh = −2
Im(σ)
4υ
∆x 2
σ at h (=∆t) = 0
-1
σ with h increasing
1
The stability limit for largest h ≡ ∆t =
SMA-HPC ©2002 NUS
Re(σ)
−2
λmax
38
Relationship
between σ and λh
σ = σ(λh)
Thus far, we have obtained the stability criterion of the time
discretization scheme using a typical modal equation. We can
generalize the relationship between σ and λh as follows:
•
Starting from the set of coupled ODEs
du
= Au + b
dt
•
Apply a specific time discretization scheme like the
“leapfrog” time discretization as in Example 2
du u n +1 − u n −1
=
2h
dt
SMA-HPC ©2002 NUS
39
Relationship
between σ and λh
•
σ = σ(λh)
The above set of ODEs becomes
n
u n +1 − u n −1
n
= Au + b
2h
•
Introducing the time shift operator S
i
Premultiplying E −1 on the LHS and RHS and introducing
I = EE −1 operating on u n
−1
 −1
 −1
−1 S − S
−1 n
E
AE
E
E
E
u
E
b
−
=
−


2h


Λ
SMA-HPC ©2002 NUS
n
n
u
n
n
+ 2hAu + 2hb
Su =
S
n

S − S −1  n
 A − 2h I  u = −b


40
σ = σ(λh)
Relationship
between σ and λh
•
−1 n
Putting U = E u ,
n
−1
F =E b
n
n
−1

 n
−1 S − S
E U = −F n
we obtain  Λ − E
2h


S − S −1
2h

S − S −1  n
n
i.e.  Λ −
=
−
U
F

2
h


which is a set of uncoupled equations.
Hence, for each j, j = 1,2,….,N-1,

S − S −1 
λ j −
 U j = − Fj
2h 

SMA-HPC ©2002 NUS
41
Relationship
between σ and λh
σ = σ(λh)
Note that the analysis performed above is identical
to the analysis carried out using the modal equation

 dU
+
=
λ
U
F


j
 dt
All the analysis carried out earlier for a single modal
equation is applicable to the matrix after the
appropriate manipulation to obtain an uncoupled set
of ODEs.
Each j th equation can be solved independently for
U nj and the U nj 's can then be coupled through u n = EU n .
SMA-HPC ©2002 NUS
42
Relationship
between σ and λh
σ = σ(λh)
Hence, applying any “consistent” numerical technique
to each equation in the set of coupled linear ODEs is
mathematically equivalent to
1.
Uncoupling the set,
2.
Integrating each equation in the uncoupled set,
3.
Re-coupling the results to form the final solution.
These 3 steps are commonly referred to as the
ISOLATION THEOREM
SMA-HPC ©2002 NUS
43
Implicit TimeMarching Scheme
Thus far, we have presented examples of explicit time-marching
methods and these may be used to integrate weakly stiff
equations.
Implicit methods are usually employed to integrate very stiff
ODEs efficiently. However, use of implicit schemes requires
solution of a set of simultaneous algebraic equations at each
time-step (i.e. matrix inversion), whilst updating the variables at
the same time.
Implicit schemes applied to ODEs that are inherently stable will
be unconditionally stable or A-stable.
SMA-HPC ©2002 NUS
44
Implicit TimeMarching Scheme
Euler-Backward
Consider the Euler-backward scheme for time discretization
 du 
 
 dt 
n +1
u n +1 − u n
=
h
Applying the above to the modal equation for Parabolic PDE
du
= λu + ae µ t
dt
yields
u n +1 − u n  n +1
µ n +1 h
= λ u + ae ( ) 


h
(1 − hλ ) u n+1 − u n = ahe µ ( n+1)h
SMA-HPC ©2002 NUS
45
Implicit TimeMarching Scheme
Euler-Backward
Applying the S operator,
(1 − hλ ) S − 1 u n = ahe µ ( n +1)h
the characteristic polynomial becomes
Ρ (σ ) = Ρ ( S ) = (1 − hλ ) S − 1 = 0
The principal root is therefore
1
σ=
= 1 + λ h + λ 2 h 2 + ....
1 − λh
1 2 2
λh
which, upon comparison with e = 1 + λ h + λ h + .... , is only
2
first-order accurate.
The solution is
SMA-HPC ©2002 NUS
n
µ ( u +1) h
ahe
 1 
U =β
 +
µh
λ
λ
−
−
1
1
h
e
h
) −1
 (

n
46
Implicit TimeMarching Scheme
Euler-Backward
For the Parabolic PDE, λ is always real and < 0.
Therefore, the transient component will always tend
towards zero for large n irregardless of h (≡ ∆t).
The time-marching scheme is always numerically stable.
In this way, the implicit Euler/Euler-backward time
discretization scheme will allow us to resolve different
time-scaled events with the use of different time-step
sizes. A small time-step size is used for the short timescaled events, and then a large time-step size used for
the longer time-scaled events. There is no constraint on
hmax.
SMA-HPC ©2002 NUS
47
Implicit TimeMarching Scheme
Euler-Backward
However, numerical solution of u requires the solution
of a set of simultaneous algebraic equations or matrix
inversion, which is computationally much more
intensive/expensive compared to the multiplication/
addition operations of explicit schemes.
SMA-HPC ©2002 NUS
48
Summary
• Stability Analysis of Parabolic PDE
ƒ Uncoupling the set.
ƒ Integrating each equation in the uncoupled set →
modal equation.
ƒ Re-coupling the results to form final solution.
• Use of modal equation to analyze the stability
|σ(λh)| < 1.
• Explicit time discretization versus Implicit time
discretization.
SMA-HPC ©2002 NUS
49
Download