Вы находитесь на странице: 1из 14

Numerical Methods for PDEs

Hyperbolic PDEs: The leapfrog scheme (LTE, stability & phase error)
and the Lax-Wendroff scheme (LTE, stability & phase error)
(Lecture 16, Week 6)

Markus Schmuck

Department of Mathematics and Maxwell Institute for Mathematical Sciences


Heriot-Watt University, Edinburgh

Edinburgh, February 16, 2015

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 1/ 14


Outline

1 Stability of the leapfrog scheme

2 The phase shift of the leapfrog scheme

3 The Lax-Wendroff scheme

4 LTE, stability, and phase shift of the Lax-Wendroff scheme

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 2/ 14


Stability of the leapfrog scheme
Leapfrog scheme: (or CTCS method)

wjn+1 − wjn−1 n − wn
wj+1 j−1
+a =0
2k 2h
⇒ wjn+1 = wjn−1 − p(wj+1
n
− wj−1
n
) (∗)

Step 1: Insert the ansatz wjn = ξ n eiωj into (∗), that is,
( )
ξ 2 = 1 − pξ eiω − e−iω
or ξ 2 + 2ipξ sin ω − 1 = 0.

For a = 1, b = 2ip sin ω and c = −1, we obtain the roots


√ √
−b ± b2 − 4ac
ξ± = = −ip sin ω ± 1 − p2 sin2 ω.
2a

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 3/ 14


Step 2: Stability requires |ξ± | ≤ 1. The discriminant 1 − p2 sin ω
induces two cases:

• Case |p| > 1: Worst case for sin ω = 1, hence


√ [ √ ]
ξ± = −ip ± i p − 1 = −i p ∓ p − 1
2 2

with |ξ− | > 1. Hence, the scheme is unstable.

• Case |p| ≤ 1: The discriminant is real for all ω and therefore

|ξ± |2 = (−p sin ω)2 + (1 − p2 sin2 ω) = 1 ∀ω,

and hence (∗) is stable for all |p| ≤ 1 (independent of a > 0 or a < 0).

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 4/ 14


Phase shift of the leapfrog method

ξ± = −ip sin ω ± 1 − p2 sin2 ω

Phase shift of ξ+ : Phase shift of ξ− :


ξ+ : ϕ+ = − sin−1 (p sin ω) ϕ− = π + sin−1 (p sin ω)
= − sin−1 (pω − pω 3 /3! + . . . ) = pω + π − 16 pω 3 (1 − p2 ) + . . .
= −pω(1 − 16 (1 − p2 )ω 2 + . . . )
(using sin−1 (x) = x + x 3 /6 + . . .) ⇒ Phase shift changes sign, since
wjn = ξ n eiωj , hence ϕ− n = nπ + . . .
⇒ Phase error of same sign ∀n > 0 ⇒ Oscillations (require “filtering”)
M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 5/ 14
Leapfrog scheme: Test example 1

Initial condition: Gaussian pulse


1.2

0.8
u(x,t)

0.6

0.4

0.2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


x

Observation: “Only” small amplitude oscillations to the left

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 6/ 14


Leapfrog scheme: Test example 2
Initial condition: Step function
1.2

0.8
u(x,t)

0.6

0.4

0.2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


x

Observation: Step front better approximated than in the upwind case


(i.e., FTBS for a > 0 and FTFS for a < 0) but strong oscillations
Recall: LTE = Cuxxx + O(k 4 , h4 ) is dispersive and not diffusive uxx
M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 7/ 14
The Lax-Wendroff scheme

Starting point: Leapfrog method shows strong oscillations/dispersion


Goal: Remove oscillations
Idea: Add a diffusive term by a(Taylor
) expansion
( ) up to 2nd order, i.e.,
∂ m ∂ m
for u smooth solving (AE) use ∂t u = −a ∂x u , and

1 2
3
u(x, t + k ) = u + kut + k utt + O(k ) ,
2 (x,t)

1 2 2 3

= u − akux + a k uxx + O(k ) ,
2 (x,t)
Dx 1 δ2
≈ u − ak u + a2 k 2 x2 u,
2h 2 h
where we truncated the expansion (last line) and replaced derivatives
by their central difference approximations.

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 8/ 14


Now, use the result from previous slide, that is,

Dx 1 δ2
u(x, t + k ) ≈ u − ak u + a2 k 2 x2 u
2h 2 h
as our numerical scheme. That means,

p n p2 n
wjn+1 = wjn − (wj+1 − wj−1
n
) + (wj+1 − 2wjn + wj−1
n
)
| 2 {z } | 2 {z }
FTCS scheme extra term

which gives after rearranging the following Lax-Wendroff scheme

1 1
wjn+1 = (1 − p2 )wjn − p(1 − p)wj+1
n n
+ p(1 + p)wj−1 . (LW)
2 2

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 9/ 14


LTE of the Lax-Wendroff method
The Lax-Wendroff scheme (LW):

wjn+1 − wjn Dx n 1 2 δx2 n


L∆ wjn = +a w − a k 2 wj ,
k 2h j 2 h

Computing the LTE:


u(xj , tn+1 ) − u(xj , tn ) Dx
LTE = L∆ u(xj , tn ) = + a u(xj , tn )
k 2h
1 δ2
− a2 k x2 u(xj , tn )
2 h
1 1 a
= k [utt − a2 uxx ] + k 2 uttt + h2 uxxx + O(k 3 , h4 , kh2 )
2
| {z } 6 6
=0
a
= (1 − p2 ) h2 uxxx + O(h3 ).
6
Hence the method is 2nd order accurate.
M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 10/ 14
Stability of the Lax-Wendroff scheme
After inserting wjn = ξ n eiωj into (LW) and simplifying, we get

1 1
ξ = (1 − p2 ) − p(1 − p)eiω + p(1 + p)e−iω
2 2
= 1 + p (cos ω − 1) − ip sin ω
2

= 1 − 2p2 sin2 (ω/2) − ip sin ω


= 1 − 2p2 sin2 (ω/2) − 2ip sin(ω/2) cos(ω/2).

Hence,
[ ]2
|ξ|2 = 1 − 2p2 s2 + 4p2 s2 c 2 , where s = sin(ω/2), c = cos(ω/2)
= 1 + 4p2 s2 (c 2 − 1) + 4p4 s4
= 1 − 4p2 (1 − p2 )s4

⇒ |ξ|2 ≤ 1 for all |p| ≤ 1 and |ξ|2 > 1 for all |p| > 1
⇒ Scheme is stable for all |p| ≤ 1
M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 11/ 14
Phase shift in the Lax-Wendroff method
We have
[ ]
p sin ω
ϕ = − tan−1
1 − 2p2 sin2 (ω/2)
[ ]
1
= − tan−1 p(ω − ω 3 + . . . )(1 + p2 ω 2 /2 + . . . )
6
[ ]
−1 2 1 2 1
= − tan pω(1 + ω ( p − ) + . . . )
2 6
( )
1 2
= −pω 1 − ω (1 − p ) + . . . .
2
6

Observations:
• The same shift as for the first root of the Leapfrog scheme
• Second troublesome root of the Leapfrog scheme disappeared

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 12/ 14


Lax-Wendroff scheme: Test example 1

Initial condition: Gaussian pulse


1.2

0.8
u(x,t)

0.6

0.4

0.2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


x

Observation: The Gaussian is well-preserved by the scheme.

M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 13/ 14


Lax-Wendroff scheme: Test example 2
Initial condition: Step function
1.2

0.8
u(x,t)

0.6

0.4

0.2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


x

Observations: • Less smeared out than the upwind schemes (i.e.,


FTFS for a < 0 & FTBS for a > 0), fewer oscillations than the leapfrog
scheme (most are damped).
• The Lax-Wendroff is a well-used method.
• All the methods we have seen so far are explicit.
M. Schmuck (Heriot-Watt University) Numerical Methods for PDEs, Lecture 16 14/ 14

Вам также может понравиться