Professional Documents
Culture Documents
CFD Notes
CFD Notes
CFD Notes
T. H. Pulliam
NASA Ames
1
TIME-MARCHING METHODS FOR ODE’S
F~ (~u) = 0 (2)
2
• Linearization will produce coupled systems of linear algebraic
equations which must be solved at each iteration.
• These can be solved iteratively using relaxation methods
• Alternatively, a time-dependent path to the steady state
• Time-marching method to integrate the unsteady equations
– To accurately resolve on unsteady solution in time.
– Until the solution is sufficiently close to the steady solution.
• When using a time-marching method to compute steady flows
– The goal is simply to remove the transient portion of the
solution as quickly as possible
– Time-accuracy is not required.
– This motivates the study of stability and stiffness.
3
Notation
u0n = Fn = F (un , tn ) , tn = nh
4
Converting Time-Marching Methods to O∆E ’s
Predictor-Corrector
5
Converting Time-Marching Methods to O∆E ’s
• Representative ODE:
du
= u0 = λu + aeµt (7)
dt
• Replacing u0 in Eq.’ 4 un+1 = un + hu0n
un+1 = un + h(λun + aeµhn ) or
6
• The predictor-corrector sequence, Eq. 6, gives
ũ0n+1 = F (ũn+1 , tn + h)
= λũn+1 + aeµh(n+1)
7
Euler Explicit: Recursive Solution
un+1 = (1 + λh)un
u1 = (1 + λh)u0
2
u2 = (1 + λh)u1 = (1 + λh) u0
3
u3 = (1 + λh)u2 = (1 + λh) u0
..
.
n
un = (1 + λh) u0 (11)
8
Euler Implicit: Recursive Solution
9
Predictor- Corrector: Recursive Solution
1
un+1 = (un + ũn+1 + λhũn+1 ) : Corrector Step (14)
2
• Substituting Eq.13 into Eq.14
1
un+1 = 1 + λh + (λh)2 un
2
• By recursion
n
1
un+1 = 1 + λh + (λh)2 u0 (15)
2
10
Recursive Solution with Forcing Function
u1 = (1 + λh)u0 + a
u2 = (1 + λh)u1 + aeµh =
(1 + λh) ((1 + λh)u0 + a) + aeµh =
2 µh
(1 + λh) u0 + (1 + λh)a 1 + e
..
.
n
X
n
un = (1 + λh) u0 + (1 + λh)l−1 ae(l−1)µh (16)
l=1
11
Generalize Solutions, O∆E
un = σ n u0
with
σee = (1 + λh)
1
σei =
1 − λh
1
σpc = 1 + λh + (λh)2
2
12
Notation and Displacement Operator
bα · bn = bn+α = E α · bn
13
Solution to Representative O∆E
E −(1 + λh) ũ 1
= h aeµhn (19)
− 12 (1 + λh)E E− 1
2 u 1
2E
n
14
Predictor-Corrector:Matrix Form O∆E
E −(1 + λh) ũ 1
= h aeµhn
− 12 (1 + λh)E E− 1
2 u 1
2E
n
15
General Solution to O∆E
K
X n µhn Q(eµh )
un = ck (σk ) + ae · (21)
P (eµh )
k=1
16
Examples of Solutions: O∆E
P (E) = E − 1 − λh
Q(E) = h (22)
n µhn h
un = c1 (1 + λh) + ae · µh
e − 1 − λh
• Implicit Euler method, Eq. 18, we have
P (E) = (1 − λh)E − 1
Q(E) = hE (23)
n
heµh
1
un = c1 + aeµhn ·
1 − λh (1 − λh)eµh − 1
17
• Coupled predictor-corrector equations, Eq. 19,
– Solve for the final family un
– Intermediate family ũ, not used in general
• Using Determinants for P (E) and Q(E)
E −(1 + λh)
P (E) = det
− 12 (1 + λh)E E − 12
1
= E E − 1 − λh − λ2 h2
2
E h
Q(E) = det
− 21 (1 + λh)E 1
2 hE
1
= hE(E + 1 + λh)
2
18
• The σ-root is found from
1 2 2
P (σ) = σ σ − 1 − λh − λ h = 0
2
19
Establishing the σ − λ Relation
20
• The solution for O∆E
n n
~un = c1 (σ1 ) ~x1 + · · · + cm (σm ) ~xm + · · ·
n
+ cM (σM ) ~xM + P.S. (26)
where the cm and the ~xm in the two equations are identical and
σm = (1 + λm h).
• Correspondence between σm and eλm h .
• eλh can be expressed in terms of the series
1 1 1
eλh = 1 + λh + λ2 h2 + λ3 h3 + · · · + λn hn + · · ·
2 6 n!
21
• The truncated expansion σ = 1 + λh approximates eλh
– Define erλ = eλh − σ = O(λ2 h2 ).
– O∆E solution is for un
– Typically define error for a derivative, e.g. ert
erλ
– Define Order of accuracy p for O∆E as: O(hp ) ≡ h
– Euler explicit O∆E : erλ = O(h), a first order method.
22
Leapfrog O∆E
• Leapfrog method:
• Characteristic polynomial
P (E) = E 2 − 2λhE − 1
leads to
2
σm − 2λm hσm − 1 = 0 (28)
23
• For one of these we find
+
p
σm = λm h + 1 + λ2m h2
1 1
= 1 + λm h + λ2m h2 − λ4m h4 + · · · (29)
2 8
• Approximation to eλm h with an error O(λ3 h3 ).
• Therefore: erλ = O(h2 ), a second order method.
p
• The other root, λm h − 1 + λ2m h2 , is a spurious root.
24
Principal and Spurious Roots
25
Accuracy Measures of Time-Marching Methods
26
• Taylor Series analysis is a very limited tool for finding the more
subtle properties of a numerical time-marching method. For
example, it is of no use in:
– finding spurious roots.
– evaluating numerical stability and separating the errors in
phase and amplitude.
– analyzing the particular solution of predictor-corrector
combinations.
– finding the global error.
27
Comparison of Exact ODE and O∆E Error
n µhn Q(eµh )
un = c1 (σ1 ) + ae · (31)
P (eµh )
28
Error Measures for O∆E ’s
• Transient error
– All time-marching methods produce a principal σ-root for
every λ-root that exists in a set of linear ODE’s.
– Compare the unsteady part of Eq.30, eλh
– With the unsteady part of Eq.31, σ
– Define, erλ ≡ eλh − σ1
erλ
– With the Order of accuracy defined as O(hp ) ≡ h
– Or the term in the expansion of eλh which matches the last
term of erλ .
29
• Amplitude and Phase Error
– Assume λ eigenvalue is pure imaginary.
– Equations governing periodic convection.
– Let λ = iω where ω is real representing a frequency.
– Numerical method produces a principal σ-root: complex
– Expressible in the form
30
– Amplitude and phase errors are important measures of the
suitability of time-marching methods for convection and wave
propagation phenomena.
• Local Accuracy of the Particular Solution (erµ )
– Compare the particular solution of the ODE with that for the
O∆E.
1
P.S.(ODE) = aeµt ·
(µ − λ)
and
µh
µt Q(e )
P.S.(O∆E) = ae ·
P (eµh )
– Measure of the local error in the particular solution: introduce
the definition
P.S.(O∆E)
erµ ≡ h −1 (34)
P.S.(ODE)
31
– Multiplication by h converts the error from a global measure
to a local one, so that the order of erλ and erµ are consistent.
– Determine the leading error term, Eq. 34 in terms of the
characteristic and particular polynomials as
co µh
µh
erµ = · (µ − λ)Q e −P e (35)
µ−λ
32
Global Accuracy
33
−1 (σ1 )i
Erω ≡ N ωh − tan
(σ1 )r
= ωT − N tan−1 [(σ1 )i /(σ1 )r ] (38)
34
Linear Multistep Methods
35
Linear Multistep Methods
" 1
! 1
! # 1
!
X X X
αk E k − βk E k hλ un = h βk E k aeµhn
k=1−K k=1−K k=1−K
[P (E)] un = Q(E)aeµhn
36
Families of Linear Multistep Methods
• Adams-Moulton family
37
Examples of Linear Multistep Methods
Explicit Methods
un+1 = un + hu0n Euler
un+1 = un−1 + 2hu0n Leapfrog
= un + 12 h 3u0n − u0n−1
un+1 AB2
h
23u0n − 16u0n−1 + 5u0n−2
un+1 = un + 12 AB3
38
Examples of Linear Multistep Methods
Implicit Methods
un+1 = un + hu0n+1 Implicit Euler
= un + 21 h u0n + u0n+1
un+1 Trapezoidal (AM2)
= 13 4un − un−1 + 2hu0n+1
un+1 2nd-order Backward
h
5u0n+1 + 8u0n − u0n−1
un+1 = un + 12 AM3
39
Two-Step Linear Multistep Methods
0 0 0 Euler 1
1 0 0 Implicit Euler 1
1/2 0 0 Trapezoidal or AM2 2
1 1/2 0 2nd Order Backward 2
3/4 0 −1/4 Adams type 2
1/3 −1/2 −1/3 Lees 2
1/2 −1/2 −1/2 Two–step trapezoidal 2
5/9 −1/6 −2/9 A–contractive 2
0 −1/2 0 Leapfrog 2
0 0 1/2 AB2 2
0 −5/6 −1/3 Most accurate explicit 3
1/3 −1/6 0 Third–order implicit 3
5/12 0 1/12 AM3 3
1/6 −1/2 −1/6 Milne 4
40
1
• Both erµ and erλ are reduced to 0(h3 ) if ϕ = ξ − θ + 2
5
• The class of all 3rd-order methods ξ = 2θ − 6
41
Predictor-Corrector Methods
ũn+α = un + αhu0n
0 0
un+1 = un + h β ũn+α + γun
42
• Second-order accuracy: both erλ and erµ must be O(h3 ).
1
• Leads to: γ + β = 1 ; αβ = 2
ũn+α = un + αhu0n
1 1 0 2α − 1 0
un+1 = un + h ũ + un
2 α n+α α
43
Predictor-Corrector Methods: Examples
44
• The Burstein method α = 1/2 is
1
ũn+1/2 = un + hu0n
2
un+1 = un + hũ0n+1/2
• MacCormack’s method
ũn+1 = un + hu0n
1
un+1 = [un + ũn+1 + hũ0n+1 ]
2
45
Runge-Kutta Methods
u
bn+α = un + βhu0n
ũn+α1 = un + β1 hu0n + γ1 hb
u0n+α
un+α2 = un + β2 hu0n + γ2 hb
u0n+α + δ2 hũ0n+α1
un+1 = un + µ1 hu0n + µ2 hb
u0n+α + µ3 hũ0n+α1
+µ4 hu0n+α2
46
Runge-Kutta Methods
α = β
α1 = β1 + γ 1
α2 = β2 + γ 2 + δ 2
47
Runge-Kutta Methods
• Finding P (E) and Q(E) and then eliminating the β’s results in
the four conditions
µ1 + µ2 + µ3 + µ4 = 1 (1)
µ2 α + µ3 α1 + µ4 α2 = 1/2 (2)
µ3 αγ1 + µ4 (αγ2 + α1 δ2 ) = 1/6 (3)
µ4 αγ1 δ2 = 1/24 (4)
48
• To satisfy the condition that erµ = O(h5 )
49
RK4 Method
50
Implementation of Implicit Methods
51
Implicit Euler For Coupled System
52
Example
53
Application to Nonlinear Equations
54
– Solved using implicit Euler time marching
1 2
un+1 + h un+1 = un (45)
2
– Requires a nontrivial method to solve for un+1 .
• Linearization to produce a solvable method
• Think in terms of small perturbations from a reference state
55
Local Linearization for Scalar Equations
56
• Assuming t is within h of tn , both (t − tn )k and (u − un )k are O(hk ),
and Eq. 46 can be written
∂F ∂F
F (u, t) = Fn + (u − un ) + (t − tn ) + O(h2 ) (48)
∂u n ∂t n
57
Implementation of the Trapezoidal Method
• Note that the O(h2 ) term within the brackets (which is due to the
local linearization) is multiplied by h and therefore is the same order
as the hO(h2 ) error from the trapezoidal method.
58
• The local linearization updated at each time step has not reduced the
order of accuracy of a second-order time-marching process.
59
Implementation of the Implicit Euler Method
60
Newton’s Method
61