Vous êtes sur la page 1sur 28

Page 41

3 Hyperbolic PDEs
3.1 Introduction
Hyperbolic PDEs describe wave propagation problems, for example waves in water, gas, plas-
mas, traffic flow, etc. In a number of simple cases the wave moves along with unchanged
form
1 1

0.8 0.8

0.6 0.6
u(x)

0.4 0.4

0.2 0.2

0 0
0 2 4 6 8 10 0 2 4 6 8 10
t=t t=t +T
0 0

In this case the wave moves from left to right, with a certain wave speed, and the wave form is
not damped in time. The simplest hyperbolic equation exhibiting solutions of this sort is the
first order advection equation for u(x, t)
∂u ∂u
+a = 0, a const. (3.1)
∂t ∂x
with IC: u(x, 0) = F (x) (3.2)
This equation is particularly simple but it is of interest since it displays much of the phenomena
which is specific to hyperbolic PDEs. Hence it is a useful test for schemes for solving hyperbolic
PDEs (analogous to the study of y ′ = λy in the numerical study of ODEs). Furthermore (3.1)
is easily generalised to more complicated examples such as

• advection equation with variable coefficient


∂u ∂u
+ a(x) =0
∂t ∂x
• The wave equation
∂2u ∂2u
=
∂t2 ∂x2
• higher dimensions
∂u ∂u ∂u
+ ax + ay =0
∂t ∂x ∂y
• nonlinear equations, for example Burger’s equation
∂u 1 ∂(u2 )
+ =0
∂t 2 ∂x
Page 42

Return to (3.1) and consider the pure initial value problem, i.e. assume (3.1) holds for all x.
Then the exact solution is
u(x, t) = F (x − at)
Exercise: check this!
For example with a pulse-like initial condition, if a > 0, we have something like the figure below

1.5
aT

1 t=0 t=T
u(x)

speed a

0.5

0
0 1 2 3 4 5 6 7 8 9 10
x

If a < 0 the wave moves to the left instead.


More typically (3.1) is defined on a finite interval, e.g. ∈ (0, 1). In that case we have to supply
only one boundary condition.
  
a>0 u(0, t) = g(t)
if we specify
a<0 u(1, t) = g(t)

For example, if a > 0, from the initial condition u(x, 0) = F (x) and the left-hand boundary
condition u(0, t) = g(t) we have the exact solution

g(t − x/a), x < at)
u(x, t) =
F (x − at), x > at

The solution is constant along each characteristic line with slope dx/dt = a.

1
t
0.9

0.8

0.7

0.6
at
x=
u=g(t)

0.5

0.4

0.3

0.2

0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
u=F(x)
Page 43

We see that the wave direction (i.e. sign(a)) is important for the analytic solution of the
advection equation. We need to consider how this “feeds” into our numerical finite difference
schemes. In particular

• Is there a preferred direction in our numerical scheme, in particular is there better sta-
bility/convergence if we include some of the underlying “physics of the problem” in our
solution?

• In addition to stability we want our scheme to propagate the wave at approximately the
correct speed – how do we analyse this in the numerical scheme?

3.2 Some simple numerical schemes for ut + aux = 0


We use the usual uniform grid in x and t, i.e. fixed values of ∆x and ∆t.

∆x

t
4

t
3

t2

t1
∆t
t0
x x x x x x x
0 1 2 3 4 J−1 J

with xj = x0 + j∆x, tn = n∆t, and the approximate solution u(xj , tn ) ≈ wjn .


Once again we need to approximate derivatives, this time ut and ux . We chose to approximate
ut by forward differences
n+1
Ft n wj − wjn
ut ≈ w = ,
∆t j ∆t
since this should lead to an explicit scheme.
There are various possibilities for approximating ux

 (wjn − wj−1
n
)/∆x, backwards diff.
n n
ux |(xj ,tn ) ≈ (wj+1 − wj−1 )/2∆x, central diff.
 n
(wj+1 − wjn )/∆x, forwards diff.
Page 44

We first consider a backwards difference approximation for ux , which will lead to a FTBS
scheme. We approximate ut + aux = 0 by

wjn+1 − wjn wjn − wj−1


n
+a =0
∆t ∆x
or wjn+1 = (1 − p)wjn + pwj−1
n
(3.3)
a∆t
where p = = CFL number (Courant-Friedrichs-Lewy, 1928)
∆x
Alternatively we can use a forward difference approximation for ux to get a FTFS scheme

wjn+1 = (1 + p)wjn − pwj+1


n
(3.4)

t t

t t
n+1 n+1

tn tn

x x x x x x
j−1 j j j+1
FTBS scheme, info “travels” to FTFS scheme, info “travels” to
right (like PDE with a > 0?). left (like PDE with a < 0?).

The figures suggest that the applicability of the schemes will depend on sign(a). We will try
to analyse this by studying the LTE and the stability of the schemes

LTE of FTBS and FTFS schemes

For the FTBS scheme we have


wjn+1 − wjn wjn − wj−1
n
L∆ wjn = +a ,
∆t ∆x
and the LTE is defined as L∆ u(xj , tn ), so

u(xj , tn+1 ) − u(xj , tn ) u(xj , tn ) − u(xj−1 , tn )


LTE = +a
 ∆t  ∆x 
1 2 1 2

= ut + ∆tutt + O(∆t ) + a ux − ∆xuxx + O(∆x )
2 2 (xj ,tn )
1
= (ut + aux ) + (∆t utt − a∆x uxx ) +O(∆t2 , ∆x2 ),
| {z } |2 {z }
=0 by PDE
6=0 in general
Page 45

so the main component of the LTE is the second term which shows the FTBS scheme is in
general 1st order accurate in time and space.
Note: ut + aux = 0 ⇒ utt = −auxt = −a(ut )x = a2 uxx
1 1 1
so ∆t utt − a∆x uxx = a[a∆t − ∆x]uxx
2 2 2
= 0 iff p = 1 (p = a∆t/∆x).
But if p = 1 then (3.3) is wjn+1 = wj−1 n
, which is exact (recall that the exact solution is
u(x, t) = φ(x − at) for some function φ). This is reflected in the LTE in that if p = 1, the LTE
= 0.
Exercise: We have shown that only the first order terms in the LTE vanish if p = 1 – show
that this happens for the higher order terms also.
Exercise: Show that (3.4) is also 1st order accurate, unless p = −1 (∆x = −a∆t ⇒ a < 0),
in which case it is exact.
Hence the LTE of both schemes → 0 as ∆x, ∆t → 0, so they are both consistent. The Lax
equivalence theorem, Consistency + Stability ⇔ Convergence, also holds in the hyperbolic case,
so we need to determine whether these schemes are stable to prove convergence.

Stability of (3.3)

Set wjn = ξ n eiωj in (3.3)

⇒ ξ n+1 eiωj = (1 − p)ξ n eiωj + pξ n eiω(j−1)


cancelling ξ n eiωj as usual gives
ξ = (1 − p) + pe−iω .
Note that ξ is now complex, a complication we will return to later. We need |ξ| ≤ 1 for von
Neumann stability, for all ω ∈ [−π, π]. Now e−iω = cos ω − i sin ω, so
ξ = (1 − p + p cos ω) + p(−i sin ω)
so |ξ|2 = (1 − p + p cos ω)2 + p2 sin2 ω
= (1 − p)2 + 2(1 − p)p cos ω + p2 cos2 ω + p2 sin2 ω
= 1 − 2p(1 − p)(1 − cos ω)
= 1 − 4p(1 − p) sin2 (ω/2)
For |ξ| ≤ 1 we need p(1 − p) ≥ 0 which leads to the condition p ∈ [0, 1]. Since p = a∆t/∆x,
this means (3.3) is stable iff a > 0 and ∆t ≤ ∆x/a. Note in particular that if a < 0, (3.3) is
unstable for all ∆t.
Exercise: Show that (3.4) is stable ⇔ p ∈ [−1, 0], i.e. (3.4) is stable when a < 0 and
∆t ≤ ∆x/|a|, and it is unstable if a > 0.
Now we have an proper understanding of the ideas we discussed earlier: physically the exact
solution travels a distance a∆t in time ∆t. Meanwhile the numerical scheme is influenced
by a distance ∆x in time ∆t. The stability requirement means that the characteristic line of
the exact solution passing through (xj , tn ) must lie with the “computational molecule” of the
numerical solution.
Page 46

t a>0 slope=1/a t slope=1/a

t
n+1
t
n+1
a<0

∆t ∆t

a∆t |a|∆t
tn tn
x
x
j−1 ∆x x
j
x
j ∆x x
j+1

∆x ≥ a∆t for stability. ∆x ≥ |a|∆t for stability.

t a>0

tn+1

If ∆x < a∆t, a > 0 we have a diagram like


slope=1/a
the one on the right, with a similar diagram
for the case a < 0. The characteristic line
lies outside the computational molecule and
the scheme is not feeding information from tn

the correct range of x xj−1 xj

FTCS scheme

What happens if we use a central difference for ux ? We might expect that the central difference
will give higher order accuracy, but does the “prefered direction” in hyperbolic problems impose
greater restrictions? It is easily checked that the FTCS scheme gives
1
wjn+1 = wjn − p(wj+1
n n
− wj−1 ).
2
If we carry out a stability analysis in the usual way we get
1
ξ = 1 − p(eiω − e−iω ) = 1 − ip sin(ω).
2
Hence
|ξ|2 = 1 + p2 sin2 (ω)
> 1 for all ω 6= 0, ±π for any p 6= 0,
so the scheme is completely unstable, no matter what value of a and p are used - equally bad
for a > 0 and a < 0.

Summary

If a > 0 we can use the FTBS scheme (3.3) and if a < 0 we can use the FTFS scheme (3.4).
Both these schemes require |p| ≤ 1 for stability and are first order in space and time. They are
Page 47

called upwind schemes - information in the scheme flows in the same direction as that for the
PDE (a downwind scheme seeks information in the wrong direction).

Complex ξ and relative phase errors

Why do we get complex values for ξ in these problems? Return to our Fourier approach, and
assume we have a Fourier mode exp(iαx) as initial conditions at time t = 0. Then at time t
the wave will have travelled a distance x/a (we assume a > 0 here), so the solution is

u(x, t) = exp (iα(x − at))

In discrete form this is

u(xj , tn ) = unj = exp (iα(j∆x − an∆t)) = exp (−iαan∆t) exp (iαj∆x) = ξ n eiωj

where ω = α∆x and ξ = exp (−iαa∆t). Hence we should see a complex phase shift of
exp (−iαa∆t) in one time step. Ideally we want |ξ| = 1.
We can write ξ = |ξ|eiargξ = |ξ|eiφ say. For stability we require |ξ| ≤ 1, and to get the wave
travelling at the correct speed we require φ ≈ −αa∆t = −ωa∆t/∆x = −ωp, as ∆x, ∆t → 0.
Lets see how this works for the FTBS scheme (3.3). We have ξ = (1 − p + p cos ω) + i(−p sin ω).
So
 
−1 −p sin ω
φ = tan
1 − p + p cos ω
 
−1 p sin ω
= − tan
1 − p + p cos ω
 
1 2
≈ −pω 1 − (1 − p)(1 − 2p)ω + . . .
6

where we have used the expansions sin x = x − x3 /3! + . . . , cos x = 1 − x2 /2! + . . . , and
tan−1 x = x − x3 /3 + . . . .
Exercise: Check the details of this result.
Note in expanding for small ω, we are taking into account that large frequencies cannot be
represented accurately on the finite difference mesh.
The ratio between the exact value φ = −pω and the value given above is gives us the relative
phase error. More precisely, the relative phase error is obtained by subtracting the exact result
1 from the term multiplying −pω, so in the example above the relative phase error is
1
− (1 − p)(1 − 2p)ω 2 + . . . ,
6
and hence of order O(ω 2). When p = 1 or p = 21 the error disappears at this order, otherwise
the sign will depend on the size of p. When p = 1 we would expect the error to vanish since
the scheme is exact at this value of p.
Page 48

3.2.1 Test problems for the advection equation

We now examine the result of applying the FTBS scheme (3.3) to two test problems, the
advection equation (3.1) with two different sets of initial conditions. Matlab programs for
these examples are available from the course web page.

(1) The first test problem (the upper plot in the figures) uses a Gaussian pulse as initial
condition:  
u(x, 0) = exp −400(x − 0.15)2 .
The figures show the initial “spike” u(x, 0) on the left (solid line), and the exact solu-
tion u(x, t) of the PDE (3.1) when t = 0.5 (r.h.spike, solid line). The solution of the
approximation scheme at time t = 0.5 is shown as a dashed line.

(2) The second test problem (the lower plot in the figure) uses a step function as initial
condition: 
1 for 0 ≤ x ≤ 0.15
u(x, 0) =
0 for 0.15 < x ≤ 1.
For this problem the figures show the exact solution u(x, t) of (3.1) when t = 0.5 as a
solid line, and the solution of the approximation scheme at time t = 0.5 as a dashed line.

Note: the closer the dashed and solid lines are together, the better the scheme is.
Numerical details: In all cases J = 100 and p = 0.8, so ∆x = 0.01 and ∆t = 0.008 (recall
that we are using a = 1).

1.2

0.8
u(x,t)

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

1.2

0.8
u(x,t)

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
Page 49

We see that the spike solution loses amplitude and spreads out, but its position looks accurate.
The step also smears out but appears to be in the correct position. An analysis of the LTE
explains the spreading. Using utt = a2 uxx we have
a
L∆ = ut + aux + (p − 1)∆x uxx +O(∆t2 , ∆x2 ),
| {z } 2
PDE | {z }
LTE leading term

Another way of looking at this is that we are using the scheme to model the equation

ut + aux − αuxx = 0,

where α = a2 (1 − p)dx. In this case the O(∆t2 , ∆x2 ) would be its local truncation error. The
extra term is a diffusion term and historically this is called artificial viscosity. A small amount
of artificial viscosity is usually necessary for a scheme, but too much smears the solution out.
Alternatively we see from the stability analysis that

|ξ|2 = 1 − 4p(1 − p) sin2 (ω/2) ≈ 1 − p(1 − p)ω 2 ,

so the ω 2 term is damping too much.

3.3 Leapfrog scheme for the advection equation


In this scheme, also called the CTCS scheme, we use central differences for both time and space

wjn+1 − wjn−1 n
wj+1 n
− wj−1
+a =0
2∆t 2∆x
⇒ wjn+1 = wjn−1 − p(wj+1
n n
− wj−1 ), (3.5)

where p = a∆t/∆x as usual. This scheme is also explicit but involves three time levels and
so it needs two time levels to start. The IC gives w0 and we need to obtain w1 using another
scheme, such as the (unstable) FTCS scheme.
Exercise: Show that the LTE of the leapfrog scheme (3.5) is
1 2 
LTE = ∆t uttt + a∆x2 uxxx + O(∆t4 , ∆x4 )
6
a
= (1 − p2 )uxxx ∆x2 + O(∆t4 , ∆x4 ), using uttt = −a3 uxxx ,
6
i.e. (3.5) is 2nd order accurate.
Now consider stability. Set wjn = ξ n eiωj as usual to get after some simplification

ξ 2 = 1 − pξ eiω − e−iω
or ξ 2 + 2ipξ sin ω − 1 = 0.

This has roots q


ξ± = −ip sin ω ± 1 − p2 sin2 ω.
Page 50

p
Wehneed |ξ± | ≤ 1i for stability. If |p| > 1 then when ω = π2 , we have ξ± = −ip ± i p2 − 1 =
p
−i p ∓ p2 − 1 and so one of the roots is > 1 in modulus, i.e. unstable if |p| > 1.
p
If |p| ≤ 1 then 1 − p2 sin2 ω is real for all ω and so

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

i.e. (3.5) is stable for all |p| ≤ 1 (−1 ≤ p ≤ 1) and it works equally well for a > 0 and a < 0.
There is no damping in this case since |ξ± |2 = 1. What about the phase error? There are two
roots in this case and we need to consider each in turn.

p sinω
1
π
2 2 1/2
(1−p sin ω)

ξ+ : φ+ = − sin−1 (p sin ω)
= − sin−1 (pω − pω 3/3! + . . . )
1
= −pω(1 − (1 − p2 )ω 2 + . . . )
6
(using sin−1 (x) = x + x3 /6 + . . . )

This part is similar to upwind schemes, although note now the phase error is always of one
sign. This seems fine, now consider the other root

ξ− : φ− = -π+ sin−1 (p sin ω)


1
= pω -- π − pω 3(1 − p2 ) + . . .
6

This is a mode oscillating from time step to time step and travelling in the wrong direction, a
mode absent in the exact solution of the equation. Suppressing this mode is necessary, some
form of “filtering” will be required if this scheme is to be useful in practice.
Page 51

The Leapfrog scheme applied to the test problems


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

The spike is handles pretty well by the scheme, but note some small amplitude oscillations to
the left of the pulse (the amplitude of these increases if ∆x, ∆t are made bigger).

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

The step front is reproduced quite well (steeper than in the upwind case, which is good), but
there are large oscillations (bad). The step function excites all Fourier modes and stimulates
the backwards travelling wave. Since |ξ| = 1 in the scheme, there is no damping so spurious
oscillations persist for long periods. The leading term of the LTE is dispersive (uxxx ) and not
diffusive (uxx ). What we need is a scheme that has a little artificial viscosity (but not too
much) in order to damp out the oscillations. We would also like to have a 2nd order accurate
method. The Lax-Wendroff scheme has these properties.
Page 52

3.3.1 The Lax-Wendroff scheme

This is a modification of the (unstable) FTCS scheme


1
wjn+1 = wjn − p(wj+1
n n
− wj−1 ).
2
Suppose u is a smooth solution of ut + aux = 0. Then as we have seen,
 m  m
∂ ∂
u = −a u ∀m
∂t ∂x

Now

1 2
3
u(x, t + ∆t) = u + ∆tut + ∆t utt + O(∆t ) ,
2 (x,t)

1 2 2 3

= u − a∆tux + a ∆t uxx + O(∆t ) ,
2 (x,t)
Dx 1 δ2
≈ u − a∆t u + a2 ∆t2 x 2 u,
2∆x 2 ∆x
where the final line results from truncating the expansion and replacing derivatives by their
central difference approximations. This suggests the following explicit scheme

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

rearranging gives
1 1
wjn+1 = (1 − p2 )wjn − p(1 − p)wj+1
n n
+ p(1 + p)wj−1 , (3.6)
2 2
the Lax-Wendroff Scheme (L-W).
Consider now the LTE of the L-W scheme. We can write the scheme in the form
wjn+1 − wjn Dx n 1 2 δ2
L∆ wjn = +a wj − a ∆t x 2 wjn ,
∆t 2∆x 2 ∆x
which most closely mirrors the PDE ut + aux = 0. By definition

u(xj , tn+1 ) − u(xj , tn ) Dx 1 δ2


LTE = L∆ u(xj , tn ) = +a u(xj , tn ) − a2 ∆t x 2 u(xj , tn )
∆t 2∆x 2 ∆x
1 1 a
= ∆t[utt − a2 uxx ] + ∆t2 uttt + ∆x2 uxxx + O(∆t3 , ∆x4 , ∆t∆x2 )
|2 {z } 6 6
=0
a
= (1 − p ) ∆x2 uxxx + O(∆x3 ).
2
6
Hence the method is 2nd order accurate.
Page 53

We now look at stability. Inserting wjn = ξ n eiωj into (3.6) and simplifying, we get
1 1
ξ = (1 − p2 ) − p(1 − p)eiω + p(1 + p)e−iω
2 2
2
= 1 + p (cos ω − 1) − ip sin ω
= 1 − 2p2 sin2 (ω/2) − ip sin ω
= 1 − 2p2 sin2 (ω/2) − 2ip sin(ω/2) cos(ω/2)

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

Clearly this is ≤ 1 for all |p| ≤ 1 and > 1 for all |p| > 1, so the scheme is stable if and only if
|p| ≤ 1. We also see that |ξ|2 ≈ 1 − p2 (1 − p2 ) ω 4/4 + . . . for small ω, so there is some damping
but substantially less than the upwind schemes.
What about the phase error? We have
 
−1 p sin ω
φ = − tan
1 − 2p2 sin2 (ω/2)
 
−1 1 3 2 2
= − tan p(ω − ω + . . . )(1 + p ω /2 + . . . )
6
 
−1 2 1 2 1
= − tan pω(1 + ω ( p − ) + . . . )
2 6
 
1 2 2
= −pω 1 − ω (1 − p ) + . . . .
6
This is the same as the first root of the Leapfrog scheme, a phase error always of one sign (lag),
but the second troublesome root of the Leapfrog scheme is now absent.

The Lax-Wendroff scheme applied to the test problems


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

The spike is handled well by the scheme.


Page 54

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

Less smeared out than the upwind scheme, 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. It is worth looking at the Crank-Nicholson
scheme to see if an implicit scheme would be any better.

Backward time schemes

Backward time schemes can be constructed in a similar way to Forward time schemes. For
example the BTCS scheme is
wjn+1 − wjn n+1
wj−1 n+1
− wj+1
+a =0
∆t 2∆x
or
1
wjn+1 + p(wj+1
n+1 n+1
− wj−1 ) = wjn
2
Exercise Show the BTCS scheme is first order in the LTE. Show that the scheme is stable for
all p.
By taking the average of the FTCS scheme and the BTCS scheme we get the following:

Crank-Nicholson scheme for the advection equation

The PDE is ut = −aux . Approximate the spatial part of this by an average across time levels
n and n + 1.
wjn+1 − wjn a 
≈ − ux |t=tn + ux |t=tn+1
∆t 2 
a Dx n Dx n+1
=− w + w ,
2 2∆x j 2∆x j
using central differences in space to approximate ux . If we rearrange all this we get the CN
scheme for the advection equation.
p n+1  p n 
wjn+1 + n+1
wj+1 − wj−1 = wjn − n
wj+1 − wj−1 (3.7)
4 4
Page 55

As in the parabolic case, we need to solve a tridiagonal system of equations to get the solution
at each timestep.
As usual, with any new scheme, we need to consider the LTE, the stability, and the phase error.
First the LTE. Standard calculations show that
∆t ∆t2 a∆x2 a∆t2
LTE = ut + aux + (utt + auxt ) + uttt + uxxx + uxtt + h.o.t.
| {z }
|2 {z } 6 6 4
=0
=0
2
a∆x 1
= uxxx (1 + p2 ) + O(∆x3 )
6 2
Now stability - inserting wjn = ξ n eiωj into (3.7) and simplifying, we get
 
 p iω  p
ξ 1 + (e − e ) = 1 − (eiω − e−iω )
−iω 

 |4 {z } 4
ip
2
sin ω
2
1 − 12 ip sin ω 1 − p4 sin2 ω − ip sin ω
⇒ξ = =
1 + 21 ip sin ω
2
1 + p4 sin2 ω
|1 − 21 ip sin ω|2 1 + 14 p2 sin2 ω
⇒|ξ|2 = = = 1 ∀p, ω.
|1 + 21 ip sin ω|2 1 + 41 p2 sin2 ω

So the scheme is stable for all p (all the other schemes we have looked at are unstable for p > 1).
However it contains no artificial viscosity since |ξ|2 = 1.
Now phase error. We have
" #
p sin ω
φ = − tan−1 2
1 − p4 sin2 (ω)
  2  
−1 2 p 1
= − tan pω(1 + ω − + ...)
4 6
 
1 2 1 2
= −pω 1 − ω (1 + p ) + . . . .
6 2

So although we can use a large |p| from the stability result, the phase errors will grow when
|p| > 1, so the extra stability range is not so useful.
Let’s see how it works on the test problems.
Page 56

The Crank-Nicholson scheme applied to the test problems


1.2

0.8

0.6
u(x,t)

0.4

0.2

−0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

The spike is not resolved very well by the scheme and there are some oscillations.

1.2

0.8

0.6
u(x,t)

0.4

0.2

−0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

The step conditions induce bad oscillations. The numerical evidence suggests that the lack of
artificial viscosity in this scheme means that undamped oscillations are a serious problem.
We can summarise our results in a table.

Scheme accuracy stable p = ±1 Comments


Upwind 1st |p| ≤ 1 exact Need to use (3.3) for a > 0, (3.4) for
a < 0. Solutions smear out too much.
Leapfrog 2nd |p| ≤ 1 exact Multi-level. Bad oscillations.
Lax-Wendroff 2nd |p| ≤ 1 exact Best solution
C-N 2nd ∀p Not exact Implicit. Bad oscillations

3.4 2nd order equations


The prototype for 2nd order equations is the wave equation. In one spatial dimension this is

utt = a2 uxx , (3.8)


Page 57

and in 3D, for example, we have

utt = a2 (uxx + uyy + uzz ).

This models, for example, the transmission of sound waves in air or water. The parameter a is
the speed of the wave, as in the advection equation. The appropriate initial conditions are to
give both u(x, 0) and ut (x, 0). In finite regions we would specify u or ux at both l..h. and r.h.
boundaries.
We consider now the 1D case. There is an exact solution due to D’Alembert

u(x, t) = F (x − at) + G(x + at)

for arbitrary functions F and G. The simplest numerical approximation is to use central
differences in both space and time

wjn+1 − 2wjn + wjn−1 n


wj−1 − 2wjn + wj+1
n
=
∆t2 ∆x2
⇒wj = 2wj − wj + p (wj−1 − 2wjn + wj+1
n+1 n n−1 2 n n
), p = a∆t/∆x. (3.9)

Since this is a 3-level scheme, we need some way of getting the n = 1 time level when we start.
We can do this by a form of the fictitious point scheme, this time an extra set of grid points at
t = −∆t. Suppose we have at t = 0 (n = 0) that

u(x, 0) = f (x) ⇒ wj0 = fi


wj1 − wj−1
ut (x, 0) = g(x) ⇒ = gi ,
2∆t
using central differences for the time derivative. Now write down the scheme (3.9) at n = 0
and use the above equations to give the wj0 and to eliminate the ficitious point at n = −1.

wj1 = 2wj0 − wj−1 + p2 (wj−1


0
− 2wj0 + wj+1
0
)
⇒ wj1 = 2fj − wj−1 + p2 (fj−1 − 2fj + fj+1 )
⇒ wj1 = 2fj − wj1 + 2∆tgi + p2 (fj−1 − 2fj + fj+1)
1
⇒ wj1 = fj + ∆tgi + p2 (fj−1 − 2fj + fj+1 ), j = 1, 2, . . . , J.
2
This last equation gives the solution at the n = 1 time level from the known initial functions.
Exercise: show that the LTE of scheme (3.9) is
1
LTE = (∆t2 utttt − a2 ∆x2 uxxxx ) + O(∆t4 , ∆x4 )
12
a2
= (p2 − 1)∆x2 uxxxx + O(∆x4 ),
12
i.e. it is 2nd order accurate.
Page 58

3.4.1 Stability of scheme for wave Equation.

Now consider stability of (3.9). Set wjn = ξ n eiωj as usual to get after some simplification

ξ 2 = 2ξ − 1 + p2 ξ eiω − 2 + e−iω
| {z }
=−4 sin2 (ω/2)

= 2ξ[1 − 2p2 sin2 (ω/2)] − 1.

i.e. ξ satisfies the quadratic

ξ 2 − 2[1 − 2p2 sin2 (ω/2)] + 1 = 0.

This has roots


q
2 2
ξ± = 1 − 2p sin (ω/2) ± (1 − 2p2 sin2 (ω/2))2 − 1
q
= 1 − 2p2 sin2 (ω/2) ± 4p2 sin2 (ω/2)[p2 sin2 (ω/2) − 1].

Since 4p2 sin2 (ω/2) > 0, the expression under the square root is ≤ 0 if p2 ≤ 1, and in this case
the roots are complex and have the form
q
2 2
ξ± = 1 − 2p sin (ω/2) ± i2p sin(ω/2) 1 − p2 sin2 (ω/2)
⇒ |ξ± |2 = [1 − 2p2 sin2 (ω/2)]2 + 4p2 sin2 (ω/2)[1 − p2 sin2 (ω/2)]
= 1 ∀ω.

So if p2 ≤ 1 then (3.9) is stable. Now consider the p2 > 1 case. Put ω = π, say, to get
p
ξ± = 1 − 2p2 ± 2p p2 − 1
So ξ− < 1 − 2p2 < −1 for p2 > 1
⇒ |ξ− | > 1 at ω = π,

and so the scheme is unstable for p2 > 1. To summarise, (3.9) is von Neumann stable ⇔ p2 ≤ 1.
Now consider the phase error. We have (after some algebra)
 
ω2 2
φ± = ±pω 1 − (1 − p ) + . . . .
24

This time we expect two solutions since the equation has waves travelling in both directions.

3.4.2 Test problems

This time we generalise our test problems to initial data which results in two pulses travelling in
opposite directions. The first picture show the case where the two pulses are Gaussian shaped.
Page 59

1.5

1
u(x,t)

0.5

−0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

The initial pulse in the centre splits into two smaller pulses travelling to the left and to the right.
The dashed-dotted line is the exact solution, the dashed line the numerical one. Agreement is
quite good.
If we replace the gaussian pulses by square pulses we see the figure shown below.
2

1.5

1
u(x,t)

0.5

−0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x

This time we get quite strong oscillations, as in the corresponding leapfrog scheme for the
advection equation. In this case the problem is that we have no damping since |ξ| = 1 and
hence the oscillations induced by the sharp step do not die away.

3.4.3 Coupled equations

In practice it is common to write the 2nd order wave equation as a pair of coupled first order
equations
ut + avx = 0
vt + aux = 0.
It is easy to check that if we differentiate the first equation with respect to t, the second with
respect to x, then eliminate vxt , we recover (3.8). Usually when the equation is given in this
form we have initial conditions u(x, 0) and v(x, 0) given from physical grounds.
We can write the above in vector form
   
u 0 a
ut + Aux = 0, where u = , A=
v a 0
Page 60

In this form it is easy to apply the Lax-Wendroff scheme. As before we have


 m  m
∂ ∂
u = −A u ∀m
∂t ∂x

So, again following the scalar case



1 2
u(x, t + ∆t) = u + ∆tut + ∆t utt + O(∆t3 ) ,
2 (x,t)

1 2 2
3
= u − A∆tux + A ∆t uxx + O(∆t ) ,
2 (x,t)
Dx 1 δ2
≈ u − A∆t u + A2 ∆t2 x 2 u,
2∆x 2 ∆x
This suggests the following explicit scheme
1 1
n
wjn+1 = wjn − P (wj+1 n
− wj−1 ) + P 2 (wj+1
n
− 2wjn + wj−1
n
)
2 2
where    
w u ∆t
w= ≈ , P = A.
z v ∆x
rearranging gives
1 1
wjn+1 = (I − P 2 )wjn − P (I − P )wj+1
n n
+ P (I + P )wj−1 , (3.10)
2 2
where I is the 2 × 2 unit matrix.

3.5 Nonlinear Conservation Laws


All the example hyperbolic problems we have seen so far are linear, i.e. we have no terms where
u and its derivatives are multipled together or are the arguments of nonlinear functions. In real
life, for example fluid and gas flow problems, the equations are nonlinear, for example

ut + a(u)ux = 0

now the wave speed a is a function of the solution u(x, t). The simplest example is when
a(u) = u, so the equation becomes Burger’s equation

ut + u ux = 0.

Roughly speaking, the speed of the wave is now greater if its amplitude is bigger, so if we have
a pulse travelling to the right, its “top” moves faster than the tail on either side, and eventually
overtakes the tail, at which point a shock (discontinuity) forms
Page 61

fastest
u

faster steepens shock

slow

flow direction

In this case a(u) > 0 so the flow is in the +ve x direction. If a(u) < 0 the steepening is in the
−ve x direction.
Direct approximation of ut + a(u)ux = 0 often doesn’t give sensible or stable results, but things
work better if we write the equation as a conservation law
rearrange ∂
ut + a(u)ux = 0 → ut + (F (u)) = 0 (3.11)
∂x
where
d ∂F dF ∂u
F (u) = a(u), since =
du ∂x du ∂x
In the case where a(u) = u, we have F (u) = u, so F (u) = 12 u2 and the conservation form of

Burgers equation is
1 ∂ 2
ut + (u ) = 0.
2 ∂x

3.6 Nonlinear Lax Wendroff scheme


We now describe how to extend the Lax-Wendroff scheme to approximate the nonlinear con-
servation law equation
ut + [F (u)]x = 0 (3.12)
We use a similar procedure to that for the advection equation ut + aux = 0. Suppose u(x, t)
is a smooth function (this will only be true up to the point where a shock forms). We write a
truncated Taylor series for u(x, t + ∆t)
 
1 2
u(x, t + ∆t) ≈ u + ∆t ut + ∆t utt
2 (x,t)

and then replace the time derivatives by space derivatives, using (3.12)
ut = −[F (u)]x
∂ ∂ ∂
utt = (−[F (u)]x ) = − ([F (u)]t ) = − (F ′ (u) · ut )
∂t ∂x  ∂x 
∂ ′ ∂ ′ ∂
= − (F (u)[−F (u)]x ) = F (u) F (u)
∂x ∂x ∂x
For simplicity define
∂ ∂
Q(u) = F ′ (u) F (u), so that utt = Q(u).
∂x ∂x
Page 62

to get  
∂ 1 ∂
u(xj , tn+1 ) ≈ u − ∆t F (u) + ∆t2 Q(u) . (3.13)
∂x 2 ∂x (xj ,tn )
Now approximate the x-derivatives using central differences, firstly
n n n n
∂ F (wj+1 ) − F (wj−1 ) Fj+1 − Fj−1
F (u)
≈ = ,
∂x 2∆x
(xj ,tn ) 2∆x
where we have introduced the shorthand Fjn = F (wjn ), etc. Similarly for the 2nd space derivative


Qnj+ 1 − Qnj− 1
Q(u)
≈ 2 2
,
∂x (xj ,tn ) ∆x
but with the crucial difference is that the central difference here is applied with a spacing of
∆x/2. We have also used the notation
 n 
n ′ n ∂ ′ n
Fj+1 − Fjn
Qj+ 1 = F (wj+ 1 ) F (u) ≈ F (wj+ 1 )
2 2 ∂x 2 ∆x
(xj+ 1 ,tn )
2
so
∂ 1 n ′ n n n
 ′ n n n
o
Q(u) ≈ F (w j+ 21
) Fj+1 − Fj − F (w j− 21
) Fj − Fj−1 .
∂x (xj ,tn ) ∆x2
Since we do not have values for u at half-integer points xj+ 1 , we further approximate
2

1 ′ n 
F ′ (wj+
n
1) ≈ F (wj ) + F ′ (wj+1
n
)
2 2
′ n
and similarly for F (wj− 1 ). Putting all this into (3.13) we get
2

∆t  ∆t2 n n  n   n o
wjn+1 = wjn − n
Fj+1 n
− Fj−1 + a n
1 Fj+1 − Fj − an n
1 Fj − Fj−1 (3.14)
2∆x 2∆x2 j+ 2 j− 2

where
1 ′ n 
F (wj ) + F ′ (wj+1
anj+ 1 = n
) ≈ F ′ (wj+
n
1 ).
2 2 2

This nonlinear version of the L-W scheme should reduce to the linear version when F (u) =
au, a = const, i.e. when F ′ = a. Check:
∆t  ∆t2   n   
wjn+1 = wjn − n
awj+1 n
− awj−1 + 2
a awj+1 − awjn − a awjn − awj−1
n
2∆x 2∆x
2
p n  p  a∆t
= wjn − n
wj+1 − wj−1 + n
wj+1 − 2wjn + wj−1
n
, p=
2 2 ∆x
which is the formula derived earlier.
In the linear scheme we have stability only for |p| ≤ 1. In the nonlinear scheme, F ′ (u) plays
the role of a, so we should require that
′ n ∆t
F (w ) ≤1
j
∆x
for all m. For safety we replace “≤ 1” by “= 0.9” and require
0.9∆x
∆t =
maxj F ′ (w n ) j

Note that ∆t will vary from step to step.


Page 63

4 Elliptic PDE’s
4.1 Introduction
Typically Elliptic PDEs represent “equilibrium” problems. The most common (and most im-
portant) examples of an elliptic PDE is the Poisson equation

∇2 u = f (x, y, . . . )
In 2D: uxx + uyy = f (x, y)

This models, for example, steady flow of incompressible fluids, potential fields obeying an
inverse square law such as electrostatics or gravity, etc.
Note that f is a known function of x, y, . . . . When f = 0 we have the Laplace equation ∇2 u = 0,
which for example models the steady state distribution of heat in a metal plate (2D) or other
shapes in 3D, etc. This follows since the heat equation is ut = ∇2 u.
An important feature of elliptic PDEs that we have not met so far is that quite often the
equation is to be solved in an irregularly shaped domain Ω.

This is particularly important in engineering applications, where the equations model the dis-
tribution of temperature or of stress or strain throughout a body. The appropriate boundary
conditions are that at each point on the boundary ∂Ω, either u or its normal derivative ∂u/∂n
is specified.
We cover two different type of numerical methods for elliptic PDEs – finite differences and
finite elements.

4.2 A finite difference example for uxx + uyy = f (x, y).


Consider the 2D Poisson equation applied on the square domain (x, y) ∈ [0, 1] (Ω = [0, 1]2 ) and
assume Dirichlet boundary conditions, u(x, y) = g(x, y) on ∂Ω.
Page 64

y
∂Ω u=g
1

u +u =f
xx yy

∂Ω Ω ∂Ω
u=g u=g

0 0 ∂Ω u=g 1 x

Introduce a mesh and choose ∆x = ∆y (assume there is no “preferred” space direction). Use
wj,k to represent the finite difference approximation to the exact solution u(xj , yk ) ≈ wj,k .
Furthermore denote f (xj , yk ) = fj,k . Now use central difference approximations for both uxx
and uyy to get after simplification
wj−1,k + wj+1,k + wj,k−1 + wj,k+1 − 4wj,k = ∆x2 fj,k . (4.1)
We apply (4.1) at each internal point in the domain.
k+1

k−1
j−1 j j+1

If j = 0, . . . , J and k = 0, . . . , K on the boundary of the square we will have in general


(J − 1)(K − 1) internal points and (J − 1)(K − 1) unknowns, the wj,k at the internal points
(of course in the square case we have J = K, but we keep the notation general to allow for
rectangular regions). In matrix form we can write this as
Sw = b
where  
w1,1

 w1,2 

 .. 
 . 
 
w =  w1,K−1 ,
 
 w2,1 
 .. 
 . 
wJ−1,K−1
Page 65

and b contains the boundary conditions. Each row of S will contain the coefficients in the lhs
of (4.1), except those referring to boundary values. For example consider the case ∆x = 1/3,
J = K = 3. Then we have the figure shown

y3

y2

y1

y
0
x0 x1 x2 x3

and the four equations from the PDE are


1
w0,1 + w2,1 + w1,0 + w1,2 − 4w1,1 = f1,1
9
1
w0,2 + w2,2 + w1,1 + w1,3 − 4w1,2 = f1,2
9
1
w1,1 + w3,1 + w2,0 + w2,2 − 4w2,1 = f2,1
9
1
w1,2 + w3,2 + w2,1 + w2,3 − 4w2,2 = f2,2 .
9
The boundary conditions give us w0,1 = g0,1 , etc. so the four equations become

1
w2,1 + w1,2 − 4w1,1 = f1,1 − g0,1 − g1,0
9
1
w2,2 + w1,1 − 4w1,2 = f1,2 − g0,2 − g1,3
9
1
w1,1 + w2,2 − 4w2,1 = f2,1 − g3,1 − g2,0
9
1
w1,2 + w2,1 − 4w2,2 = f2,2 − g3,2 − g2,3 .
9
or
Sw = b
with    
1
−4 1 1 0 f
9 1,1
− g0,1 − g1,0
 1 −4 1
0 1   f
9 1,2
− g0,2 − g1,3 
S=
 1
 , and b =  1

0 −4 1   f
9 2,1
− g3,1 − g2,0 
1
0 1 1 −4 f
9 2,2
− g3,2 − g2,3
Page 66

Numerical Example: with the problem above, take f (x, y) = 1 and g(x, 0) = sin πx, g(x, 1) =
g(0, y) = g(1, y) = 0.
In this case the rhs vector is  1 √3 
9
− √2
 1− 3 
b=  9 1 2 ,

9
1
9

since sin(π/3) = 3/2. Solving this system by Gaussian elimination we get
   1 √   
w1,1 − 18 + 316

3
0.26920
1
 w1,2   + 3√163  

 − 18 0.26920 
w=   =  = 
w2,1  1 3
 − 18 + √16   0.05270 
w2,2 1
− 18 + 163 0.05270

Note the symmetry w1,1 = w1,2 , w2,1 = w2,2 , which we would expect since the BCs are
symmetric about the line x = 1/2.
In general we would be using a smaller value of ∆x and the matrix S will be large and sparse.
We could solve the equation Sx = b directly, or using an iteration method such as the Gauss-
Seidel or SOR method.
We next consider the LTE. Define
wj−1,k − 2wj,k + wj+1,k wj,k−1 − 2wj,k + wj,k+1
L∆ wj,k = + ,
∆x2 ∆x2
so the numerical solution satisfies L∆ wj,k − fj,k = 0. We define the LTE as

LTE = L∆ u(xj , yk ) − fj,k


u(xj − ∆x, yk ) − 2u(xj , yk ) + u(xj + ∆x, k)
= +
∆x2
u(xj , yk − ∆x) − 2u(xj , yk ) + u(xj , yk + ∆x)
+ − fj,k ,
 ∆x2   
1 2 4 1 2 4
= uxx + ∆x uxxxx + O(∆x ) + uyy + ∆x uyyyy + O(∆x ) − fj,k .
12 (xj ,yk ) 12 (xj ,yk )

Since u is a solution of uxx + uyy = f , the LTE after cancelling these terms is

1
LTE = ∆x2 (uxxxx + uyyyy ) + O(∆x4 ).
12
Now consider convergence. The von Neumann stability analysis is not directly applicable here
(the schemes do not develop over a series of steps, but are “all or nothing”, i.e. we get the entire
solution wj,k , ∀j, k in one step. How do we show convergence? We have

wj,k is a solution of L∆ wj,k − f = 0


and u(xj , yk ) is a solution of uxx + uyy − f = 0.
Page 67

Now define the error as zj,k = u(xj , yk ) − wj,k . For convergence we require |zj,k | → 0 as ∆x → 0
for all j, k. Apply the finite difference operator L∆ to zj,k .
L∆ zj,k = L∆ u(xj , yk ) − L∆ wj,k = LTE.
We now introduce a comparison function Cj,k = x2j + yk2. We have
(xj − ∆x)2 − 2x2j + (xj + ∆x)2 (yk − ∆x)2 − 2yk2 + (yk + ∆x)2
L∆ Cj,k = + = 2 + 2 = 4,
∆x2 ∆x2
and Cj,k is non-negative with a maximum value of 2 at x = y = 1. Now we define yet another
function on the mesh, cj,k
1
cj,k = zj,k + Cj,k |LTE|max
4
so
1
L∆ cj,k = LTE + × 4 |LTE|max
4
≥ 0, ∀(xj , yk ) ∈ Ω (∗)
Now we claim that if L∆ mj,k ≥ 0, ∀(j, k) for any function mj,k (i.e. cj,k ), then mj,k attains
its maximum value on the boundary. i.e. (xj , yk ) ∈ ∂Ω. (This is an example of what is known
as a maximum principle).
Proof: Let M = maxj,k=0,...,J [mj,k ], and assume this is attained at an interior point, say (j ∗ , k ∗ ).
This implies that
mj ∗ −1,k∗ + mj ∗ +1,k∗ + mj ∗ ,k∗ −1 + mj ∗ ,k∗ +1 − 4M ≥ 0
1
i.e. M ≤ (mj ∗ −1,k∗ + mj ∗ +1,k∗ + mj ∗ ,k∗ −1 + mj ∗ ,k∗ +1 )
4
1
≤ (4M) = M.
4
Equality is only possible if all interior points and their neighbours take the value M, so the
maximum value must be attained somewhere on the boundary. (We have assumed here that
M ≥ 0 which is sufficient for our needs).
Hence from (*), cj,k must attain its maximum value on the boundary, however zj,k vanishes
on the boundary if the B.C. data is exact. Furthermore the maximum value of Cj,k on the
boundary is 2, so max(cj,k ) = 12 |LTE|max .
Now we have
1
zj,k = cj,k − Cj,k |LTE|max by definition
4
≤ cj,k , ∀j, k, since Cj,k is non-negative
1
so zj,k ≤ |LTE|max .
2
We can similarly repeat the analysis to place a lower bound on zj,k . Define
1
c̄j,k = −zj,k + Cj,k |LTE|max
4
so L∆ c̄j,k = −LTE + |LTE|max
≥ 0, ∀j, k.
Page 68

so the max of c̄j,k is attained on the boundary and is equal to 21 |LTE|max . Hence
1
zj,k = −c̄j,k + Cj,k |LTE|max
4
≥ −c̄j,k since Cj,k is nonnegative
1
≥ − |LTE|max .
2
We have finally that
1 1
− |LTE|max ≤ zj,k ≤ |LTE|max
2 2
so zj,k → 0 as ∆x → 0 since the scheme is consistent. This is sufficient to prove convergence.

Derivative Boundary conditions

We can use the fictitious point method to approximate derivative boundary conditions in the
same way as before - see Tutorial sheet 5.
The standard Finite Difference scheme does not work well on curved boundaries - better to use
finite elements. Before we look at finite elements we need to review how we can write the PDE
in variational form.

4.3 Elliptic PDE’s as variational problems


4.3.1 1D case

It helps to consider the 1D case first, when the Poisson equation becomes an ODE
d2 u(x)
= f (x),
dx2
on some interval, say Ω = [0, 1]. To write this as a variational problem, consider the functional
Z "  2 #
1 dv(x)
J[v] = + f (x)v(x) dx (4.2)
Ω 2 dx
Now we claim that the function that minimises J[v] is exactly u(x), the solution of the ODE.
That is (δJ[v]/δv)|v=u = 0, i.e.,
J[u + ǫφ] − J[u]
(δJ[v]/δv)|v=u = lim = 0,
ǫ→0 ǫ
for a sufficiently smooth function φ which is zero on the boundary.
To prove this let v = u + ǫφ be a function for which J[v] is defined and which satisfies the
boundary conditions of the ODE (i.e. φ = 0 at the boundaries). Then
δJ ≡ J[u + ǫφ] − J[u]
Z "  2  2 ! #
1 du dǫφ du
= + − + f (x) ((u + ǫφ) − u) dx
Ω 2 dx dx dx
Z "     2 #
du dǫφ 1 dǫφ
= . + f ǫφ + dx
Ω dx dx 2 dx

Vous aimerez peut-être aussi