19.1 Flux-Conservative Initial Value Problems: Partial Differential Equations
19.1 Flux-Conservative Initial Value Problems: Partial Differential Equations
2
u
t
2
= v
2
2
u
x
2
(19.1.2)
19.1 Flux-Conservative Initial Value Problems 835
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
can be rewritten as a set of two rst-order equations
r
t
= v
s
x
s
t
= v
r
x
(19.1.3)
where
r v
u
x
s
u
t
(19.1.4)
In this case r and s become the two components of u, and the ux is given by
the linear matrix relation
F(u) =
_
0 v
v 0
_
u (19.1.5)
(The physicist-reader may recognize equations (19.1.3) as analogous to Maxwells
equations for one-dimensional propagation of electromagnetic waves.)
We will consider, in this section, a prototypical example of the general ux-
conservative equation (19.1.1), namely the equation for a scalar u,
u
t
= v
u
x
(19.1.6)
with v a constant. As it happens, we already know analytically that the general
solution of this equation is a wave propagating in the positive x-direction,
u = f(x vt) (19.1.7)
where f is an arbitrary function. However, the numerical strategies that we develop
will be equally applicable to the more general equations represented by (19.1.1). In
some contexts, equation (19.1.6) is called an advective equation, because the quantity
u is transported by a uid ow with a velocity v.
How do we go about nite differencing equation (19.1.6) (or, analogously,
19.1.1)? The straightforward approach is to choose equally spaced points along both
the t- and x-axes. Thus denote
x
j
= x
0
+ jx, j = 0, 1, . . . , J
t
n
= t
0
+ nt, n = 0, 1, . . . , N
(19.1.8)
Let u
n
j
denote u(t
n
, x
j
). We have several choices for representing the time
derivative term. The obvious way is to set
u
t
j,n
=
u
n+1
j
u
n
j
t
+ O(t) (19.1.9)
This is called forward Euler differencing (cf. equation 16.1.1). While forward Euler
is only rst-order accurate in t, it has the advantage that one is able to calculate
836 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
t or n
x or j
FTCS
Figure 19.1.1. Representation of the Forward Time Centered Space (FTCS) differencing scheme. In this
and subsequent gures, the open circle is the new point at which the solution is desired; lled circles are
known points whose function values are used in calculating the new point; the solid lines connect points
that are used to calculate spatial derivatives; the dashed lines connect points that are used to calculate time
derivatives. The FTCS scheme is generally unstable for hyperbolic problems and cannot usually be used.
quantities at timestep n + 1 in terms of only quantities known at timestep n. For the
space derivative, we can use a second-order representation still using only quantities
known at timestep n:
u
x
j,n
=
u
n
j+1
u
n
j1
2x
+ O(x
2
) (19.1.10)
The resulting nite-difference approximation to equation (19.1.6) is called the FTCS
representation (Forward Time Centered Space),
u
n+1
j
u
n
j
t
= v
_
u
n
j+1
u
n
j1
2x
_
(19.1.11)
which can easily be rearranged to be a formula for u
n+1
j
in terms of the other
quantities. The FTCS scheme is illustrated in Figure 19.1.1. Its a ne example of
an algorithm that is easy to derive, takes little storage, and executes quickly. Too
bad it doesnt work! (See below.)
The FTCS representation is an explicit scheme. This means that u
n+1
j
for each
j can be calculated explicitly from the quantities that are already known. Later we
shall meet implicit schemes, which require us to solve implicit equations coupling
the u
n+1
j
for various j. (Explicit and implicit methods for ordinary differential
equations were discussed in 16.6.) The FTCS algorithm is also an example of
a single-level scheme, since only values at time level n have to be stored to nd
values at time level n + 1.
von Neumann Stability Analysis
Unfortunately, equation (19.1.11) is of very limited usefulness. It is an unstable
method, which can be used only (if at all) to study waves for a short fraction of one
oscillation period. To nd alternative methods with more general applicability, we
must introduce the von Neumann stability analysis.
The von Neumann analysis is local: We imagine that the coefcients of the
difference equations are so slowly varying as to be considered constant in space
and time. In that case, the independent solutions, or eigenmodes, of the difference
equations are all of the form
u
n
j
=
n
e
ikjx
(19.1.12)
19.1 Flux-Conservative Initial Value Problems 837
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
t or n
x or j
Lax
Figure 19.1.2. Representation of the Lax differencing scheme, as in the previous gure. The stability
criterion for this scheme is the Courant condition.
where k is a real spatial wave number (which can have any value) and = (k) is
a complex number that depends on k. The key fact is that the time dependence of
a single eigenmode is nothing more than successive integer powers of the complex
number . Therefore, the difference equations are unstable (have exponentially
growing modes) if |(k)| > 1 for some k. The number is called the amplication
factor at a given wave number k.
To nd (k), we simply substitute (19.1.12) back into (19.1.11). Dividing
by
n
, we get
(k) = 1 i
vt
x
sin kx (19.1.13)
whose modulus is > 1 for all k; so the FTCS scheme is unconditionally unstable.
If the velocity v were a function of t and x, then we would write v
n
j
in equation
(19.1.11). In the von Neumann stability analysis we would still treat v as a constant,
the idea being that for v slowly varying the analysis is local. In fact, even in the
case of strictly constant v, the von Neumann analysis does not rigorously treat the
end effects at j = 0 and j = N.
More generally, if the equations right-hand side were nonlinear in u, then a
von Neumann analysis would linearize by writing u = u
0
+ u, expanding to linear
order in u. Assuming that the u
0
quantities already satisfy the difference equation
exactly, the analysis would look for an unstable eigenmode of u.
Despite its lack of rigor, the von Neumann method generally gives valid answers
and is much easier to apply than more careful methods. We accordingly adopt it
exclusively. (See, for example, [1] for a discussion of other methods of stability
analysis.)
Lax Method
The instability in the FTCS method can be cured by a simple change due to Lax.
One replaces the term u
n
j
in the time derivative term by its average (Figure 19.1.2):
u
n
j
1
2
_
u
n
j+1
+ u
n
j1
_
(19.1.14)
This turns (19.1.11) into
u
n+1
j
=
1
2
_
u
n
j+1
+ u
n
j1
_
vt
2x
_
u
n
j+1
u
n
j1
_
(19.1.15)
838 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
t or n
t
x or j
t
x x
unstable stable
(a) ( b)
Figure 19.1.3. Courant condition for stability of a differencing scheme. The solution of a hyperbolic
problem at a point depends on information within some domain of dependency to the past, shown here
shaded. The differencing scheme (19.1.15) has its own domain of dependency determined by the choice
of points on one time slice (shown as connected solid dots) whose values are used in determining a new
point (shown connected by dashed lines). A differencing scheme is Courant stable if the differencing
domain of dependency is larger than that of the PDEs, as in (a), and unstable if the relationship is the
reverse, as in (b). For more complicated differencing schemes, the domain of dependency might not be
determined simply by the outermost points.
Substituting equation (19.1.12), we nd for the amplication factor
= cos kx i
vt
x
sin kx (19.1.16)
The stability condition ||
2
1 leads to the requirement
|v|t
x
1 (19.1.17)
This is the famous Courant-Friedrichs-Lewy stability criterion, often
called simply the Courant condition. Intuitively, the stability condition can be
understood as follows (Figure 19.1.3): The quantity u
n+1
j
in equation (19.1.15) is
computed from information at points j 1 and j + 1 at time n. In other words,
x
j1
and x
j+1
are the boundaries of the spatial regionthat is allowed to communicate
information to u
n+1
j
. Now recall that in the continuum wave equation, information
actually propagates with a maximum velocity v. If the point u
n+1
j
is outside of
the shaded region in Figure 19.1.3, then it requires information from points more
distant than the differencing scheme allows. Lack of that information gives rise to
an instability. Therefore, t cannot be made too large.
The surprising result, that the simple replacement (19.1.14) stabilizes the FTCS
scheme, is our rst encounter with the fact that differencing PDEs is an art as much
as a science. To see if we can demystify the art somewhat, let us compare the FTCS
and Lax schemes by rewriting equation (19.1.15) so that it is in the form of equation
(19.1.11) with a remainder term:
u
n+1
j
u
n
j
t
= v
_
u
n
j+1
u
n
j1
2x
_
+
1
2
_
u
n
j+1
2u
n
j
+ u
n
j1
t
_
(19.1.18)
But this is exactly the FTCS representation of the equation
u
t
= v
u
x
+
(x)
2
2t
2
u (19.1.19)
19.1 Flux-Conservative Initial Value Problems 839
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
where
2
=
2
/x
2
in one dimension. We have, in effect, added a diffusion term to
the equation, or, if you recall the formof the Navier-Stokes equation for viscous uid
ow, a dissipative term. The Lax scheme is thus said to have numerical dissipation,
or numerical viscosity. We can see this also in the amplication factor. Unless |v|t
is exactly equal to x, || < 1 and the amplitude of the wave decreases spuriously.
Isnt a spurious decrease as bad as a spurious increase? No. The scales that we
hope to study accurately are those that encompass many grid points, so that they have
kx 1. (The spatial wave number k is dened by equation 19.1.12.) For these
scales, the amplication factor can be seen to be very close to one, in both the stable
and unstable schemes. The stable and unstable schemes are therefore about equally
accurate. For the unstable scheme, however, short scales with kx 1, which we
are not interested in, will blow up and swamp the interesting part of the solution.
Much better to have a stable scheme in which these short wavelengths die away
innocuously. Both the stable and the unstable schemes are inaccurate for these short
wavelengths, but the inaccuracy is of a tolerable character when the scheme is stable.
When the independent variable u is a vector, then the von Neumann analysis
is slightly more complicated. For example, we can consider equation (19.1.3),
rewritten as
t
_
r
s
_
=
x
_
vs
vr
_
(19.1.20)
The Lax method for this equation is
r
n+1
j
=
1
2
(r
n
j+1
+ r
n
j1
) +
vt
2x
(s
n
j+1
s
n
j1
)
s
n+1
j
=
1
2
(s
n
j+1
+ s
n
j1
) +
vt
2x
(r
n
j+1
r
n
j1
)
(19.1.21)
The von Neumann stability analysis now proceeds by assuming that the eigenmode
is of the following (vector) form,
_
r
n
j
s
n
j
_
=
n
e
ikjx
_
r
0
s
0
_
(19.1.22)
Here the vector on the right-hand side is a constant (both in space and in time)
eigenvector, and is a complex number, as before. Substituting (19.1.22) into
(19.1.21), and dividing by the power
n
, gives the homogeneous vector equation
_
_
(cos kx) i
vt
x
sin kx
i
vt
x
sin kx (cos kx)
_
_
_
_
r
0
s
0
_
_
=
_
_
0
0
_
_
(19.1.23)
This admits a solution only if the determinant of the matrix on the left vanishes, a
condition easily shown to yield the two roots
= cos kx i
vt
x
sin kx (19.1.24)
The stability condition is that both roots satisfy || 1. This again turns out to be
simply the Courant condition (19.1.17).
840 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
Other Varieties of Error
Thus far we have been concerned with amplitude error, because of its intimate
connection with the stability or instability of a differencing scheme. Other varieties
of error are relevant when we shift our concern to accuracy, rather than stability.
Finite-difference schemes for hyperbolic equations can exhibit dispersion, or
phase errors. For example, equation (19.1.16) can be rewritten as
= e
ikx
+ i
_
1
vt
x
_
sin kx (19.1.25)
An arbitrary initial wave packet is a superposition of modes with different ks.
At each timestep the modes get multiplied by different phase factors (19.1.25),
depending on their value of k. If t = x/v, then the exact solution for each mode
of a wave packet f(xvt) is obtained if each mode gets multiplied by exp(ikx).
For this value of t, equation (19.1.25) shows that the nite-difference solution
gives the exact analytic result. However, if vt/x is not exactly 1, the phase
relations of the modes can become hopelessly garbled and the wave packet disperses.
Note from (19.1.25) that the dispersion becomes large as soon as the wavelength
becomes comparable to the grid spacing x.
A third type of error is one associated with nonlinear hyperbolic equations and
is therefore sometimes called nonlinear instability. For example, a piece of the Euler
or Navier-Stokes equations for uid ow looks like
v
t
= v
v
x
+ . . . (19.1.26)
The nonlinear term in v can cause a transfer of energy in Fourier space from
long wavelengths to short wavelengths. This results in a wave prole steepening
until a vertical prole or shock develops. Since the von Neumann analysis
suggests that the stability can depend on kx, a scheme that was stable for shallow
proles can become unstable for steep proles. This kind of difculty arises in
a differencing scheme where the cascade in Fourier space is halted at the shortest
wavelength representable on the grid, that is, at k 1/x. If energy simply
accumulates in these modes, it eventually swamps the energy in the long wavelength
modes of interest.
Nonlinear instability and shock formation is thus somewhat controlled by
numerical viscosity such as that discussed in connection with equation (19.1.18)
above. In some uid problems, however, shock formation is not merely an annoyance,
but an actual physical behavior of the uid whose detailed study is a goal. Then,
numerical viscosity alone may not be adequate or sufciently controllable. This is a
complicated subject which we discuss further in the subsection on uid dynamics,
below.
For wave equations, propagation errors (amplitude or phase) are usually most
worrisome. For advective equations, on the other hand, transport errors are usually
of greater concern. In the Lax scheme, equation (19.1.15), a disturbance in the
advected quantity u at mesh point j propagates to mesh points j + 1 and j 1 at
the next timestep. In reality, however, if the velocity v is positive then only mesh
point j + 1 should be affected.
19.1 Flux-Conservative Initial Value Problems 841
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
t or n
x or j
v
upwind
v
Figure 19.1.4. Representation of upwind differencing schemes. The upper scheme is stable when the
advection constant v is negative, as shown; the lower scheme is stable when the advection constant v is
positive, also as shown. The Courant condition must, of course, also be satised.
The simplest way to model the transport properties better is to use upwind
differencing (see Figure 19.1.4):
u
n+1
j
u
n
j
t
= v
n
j
_
_
u
n
j
u
n
j1
x
, v
n
j
> 0
u
n
j+1
u
n
j
x
, v
n
j
< 0
(19.1.27)
Note that this scheme is only rst-order, not second-order, accurate in the
calculation of the spatial derivatives. How can it be better? The answer is
one that annoys the mathematicians: The goal of numerical simulations is not
always accuracy in a strictly mathematical sense, but sometimes delity to the
underlying physics in a sense that is looser and more pragmatic. In such contexts,
some kinds of error are much more tolerable than others. Upwind differencing
generally adds delity to problems where the advected variables are liable to undergo
sudden changes of state, e.g., as they pass through shocks or other discontinuities.
You will have to be guided by the specic nature of your own problem.
For the differencingscheme (19.1.27), the amplication factor (for constant v) is
= 1
vt
x
(1 cos kx) i
vt
x
sinkx (19.1.28)
||
2
= 1 2
vt
x
_
1
vt
x
_
(1 cos kx) (19.1.29)
So the stability criterion ||
2
1 is (again) simply the Courant condition (19.1.17).
There are various ways of improving the accuracy of rst-order upwind
differencing. In the continuum equation, material originally a distance vt away
842 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
staggered
leapfrog
t or n
x or j
Figure 19.1.5. Representation of the staggered leapfrog differencing scheme. Note that information
from two previous time slices is used in obtaining the desired point. This scheme is second-order
accurate in both space and time.
arrives at a given point after a time interval t. In the rst-order method, the
material always arrives from x away. If vt x (to insure accuracy), this can
cause a large error. One way of reducing this error is to interpolate u between j 1
and j before transporting it. This gives effectively a second-order method. Various
schemes for second-order upwind differencing are discussed and compared in [2-3].
Second-Order Accuracy in Time
When using a method that is rst-order accurate in time but second-order
accurate in space, one generally has to take vt signicantly smaller than x to
achieve desired accuracy, say, by at least a factor of 5. Thus the Courant condition
is not actually the limiting factor with such schemes in practice. However, there are
schemes that are second-order accurate in both space and time, and these can often be
pushed right to their stability limit, with correspondingly smaller computation times.
For example, the staggered leapfrog method for the conservation equation
(19.1.1) is dened as follows (Figure 19.1.5): Using the values of u
n
at time t
n
,
compute the uxes F
n
j
. Then compute new values u
n+1
using the time-centered
values of the uxes:
u
n+1
j
u
n1
j
=
t
x
(F
n
j+1
F
n
j1
) (19.1.30)
The name comes from the fact that the time levels in the time derivative term
leapfrog over the time levels in the space derivative term. The method requires
that u
n1
and u
n
be stored to compute u
n+1
.
For our simple model equation (19.1.6), staggered leapfrog takes the form
u
n+1
j
u
n1
j
=
vt
x
(u
n
j+1
u
n
j1
) (19.1.31)
The von Neumann stability analysis now gives a quadratic equation for , rather than
a linear one, because of the occurrence of three consecutive powers of when the
19.1 Flux-Conservative Initial Value Problems 843
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
form (19.1.12) for an eigenmode is substituted into equation (19.1.31),
2
1 = 2i
vt
x
sinkx (19.1.32)
whose solution is
= i
vt
x
sin kx
1
_
vt
x
sin kx
_
2
(19.1.33)
Thus the Courant condition is again required for stability. In fact, in equation
(19.1.33), ||
2
= 1 for any vt x. This is the great advantage of the staggered
leapfrog method: There is no amplitude dissipation.
Staggered leapfrog differencing of equations like (19.1.20) is most transparent
if the variables are centered on appropriate half-mesh points:
r
n
j+1/2
v
u
x
n
j+1/2
= v
u
n
j+1
u
n
j
x
s
n+1/2
j
u
t
n+1/2
j
=
u
n+1
j
u
n
j
t
(19.1.34)
This is purely a notational convenience: we can think of the mesh on which r and
s are dened as being twice as ne as the mesh on which the original variable u is
dened. The leapfrog differencing of equation (19.1.20) is
r
n+1
j+1/2
r
n
j+1/2
t
=
s
n+1/2
j+1
s
n+1/2
j
x
s
n+1/2
j
s
n1/2
j
t
= v
r
n
j+1/2
r
n
j1/2
x
(19.1.35)
If you substitute equation (19.1.22) in equation (19.1.35), you will nd that once
again the Courant condition is required for stability, and that there is no amplitude
dissipation when it is satised.
If we substitute equation (19.1.34) in equation (19.1.35), we nd that equation
(19.1.35) is equivalent to
u
n+1
j
2u
n
j
+ u
n1
j
(t)
2
= v
2
u
n
j+1
2u
n
j
+ u
n
j1
(x)
2
(19.1.36)
This is just the usual second-order differencing of the wave equation (19.1.2). We
see that it is a two-level scheme, requiring both u
n
and u
n1
to obtain u
n+1
. In
equation (19.1.35) this shows up as both s
n1/2
and r
n
being needed to advance
the solution.
For equations more complicated than our simple model equation, especially
nonlinear equations, the leapfrog method usually becomes unstable when the gradi-
ents get large. The instability is related to the fact that odd and even mesh points are
completely decoupled, like the black and white squares of a chess board, as shown
844 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
Figure 19.1.6. Origin of mesh-drift instabilities in a staggered leapfrog scheme. If the mesh points
are imagined to lie in the squares of a chess board, then white squares couple to themselves, black to
themselves, but there is no coupling between white and black. The x is to introduce a small diffusive
mesh-coupling piece.
in Figure 19.1.6. This mesh drifting instability is cured by coupling the two meshes
through a numerical viscosity term, e.g., adding to the right side of (19.1.31) a small
coefcient ( 1) times u
n
j+1
2u
n
j
+ u
n
j1
. For more on stabilizing difference
schemes by adding numerical dissipation, see, e.g., [4].
The Two-Step Lax-Wendroff scheme is a second-order in time method that
avoids large numerical dissipation and mesh drifting. One denes intermediate
values u
j+1/2
at the half timesteps t
n+1/2
and the half mesh points x
j+1/2
. These
are calculated by the Lax scheme:
u
n+1/2
j+1/2
=
1
2
(u
n
j+1
+ u
n
j
)
t
2x
(F
n
j+1
F
n
j
) (19.1.37)
Using these variables, one calculates the uxes F
n+1/2
j+1/2
. Then the updated values
u
n+1
j
are calculated by the properly centered expression
u
n+1
j
= u
n
j
t
x
_
F
n+1/2
j+1/2
F
n+1/2
j1/2
_
(19.1.38)
The provisional values u
n+1/2
j+1/2
are now discarded. (See Figure 19.1.7.)
Let us investigate the stability of this method for our model advective equation,
where F = vu. Substitute (19.1.37) in (19.1.38) to get
u
n+1
j
= u
n
j
_
1
2
(u
n
j+1
+ u
n
j
)
1
2
(u
n
j+1
u
n
j
)
1
2
(u
n
j
+ u
n
j1
) +
1
2
(u
n
j
u
n
j1
)
_ (19.1.39)
19.1 Flux-Conservative Initial Value Problems 845
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
t or n
x or j
halfstep points
two-step Lax Wendroff
Figure 19.1.7. Representation of the two-step Lax-Wendroff differencing scheme. Two halfstep points
() are calculated by the Lax method. These, plus one of the original points, produce the new point via
staggered leapfrog. Halfstep points are used only temporarily and do not require storage allocation on the
grid. This scheme is second-order accurate in both space and time.
where
vt
x
(19.1.40)
Then
= 1 isinkx
2
(1 cos kx) (19.1.41)
so
||
2
= 1
2
(1
2
)(1 cos kx)
2
(19.1.42)
The stability criterion ||
2
1 is therefore
2
1, or vt x as usual.
Incidentally, you should not think that the Courant condition is the only stability
requirement that ever turns up in PDEs. It keeps doing so in our model examples
just because those examples are so simple in form. The method of analysis is,
however, general.
Except when = 1, ||
2
< 1 in (19.1.42), so some amplitude damping does
occur. The effect is relatively small, however, for wavelengths large compared with
the mesh size x. If we expand (19.1.42) for small kx, we nd
||
2
= 1
2
(1
2
)
(kx)
4
4
+ . . . (19.1.43)
The departure from unity occurs only at fourth order in k. This should be contrasted
with equation (19.1.16) for the Lax method, which shows that
||
2
= 1 (1
2
)(kx)
2
+ . . . (19.1.44)
for small kx.
846 Chapter 19. Partial Differential Equations
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
In summary, our recommendation for initial value problems that can be cast in
ux-conservativeform, and especially problems related to the wave equation, is to use
the staggered leapfrog method when possible. We have personally had better success
with it than with the Two-Step Lax-Wendroff method. For problems sensitive to
transport errors, upwind differencing or one of its renements should be considered.
Fluid Dynamics with Shocks
As we alluded to earlier, the treatment of uid dynamics problems with shocks
has become a very complicated and very sophisticated subject. All we can attempt
to do here is to guide you to some starting points in the literature.
There are basically three important general methods for handling shocks. The
oldest and simplest method, invented by von Neumann and Richtmyer, is to add
articial viscosity to the equations, modeling the way Nature uses real viscosity
to smooth discontinuities. A good starting point for trying out this method is the
differencing scheme in 12.11 of [1]. This scheme is excellent for nearly all problems
in one spatial dimension.
The second method combines a high-order differencing scheme that is accurate
for smooth ows with a low order scheme that is very dissipative and can smooth
the shocks. Typically, various upwind differencing schemes are combined using
weights chosen to zero the low order scheme unless steep gradients are present, and
also chosen to enforce various monotonicity constraints that prevent nonphysical
oscillations from appearing in the numerical solution. References [2-3,5] are a good
place to start with these methods.
The third, and potentially most powerful method, is Godunovs approach. Here
one gives up the simple linearization inherent in nite differencing based on Taylor
series and includes the nonlinearity of the equations explicitly. There is an analytic
solution for the evolution of two uniformstates of a uid separated by a discontinuity,
the Riemann shock problem. Godunovs idea was to approximate the uid by a
large number of cells of uniform states, and piece them together using the Riemann
solution. There have been many generalizations of Godunovs approach, of which
the most powerful is probably the PPM method [6].
Readable reviews of all these methods, discussing the difculties arising when
one-dimensional methods are generalized to multidimensions, are given in [7-9].
CITED REFERENCES AND FURTHER READING:
Ames, W.F. 1977, Numerical Methods for Partial Differential Equations, 2nd ed. (New York:
Academic Press), Chapter 4.
Richtmyer, R.D., and Morton, K.W. 1967, Difference Methods for Initial Value Problems, 2nd ed.
(New York: Wiley-Interscience). [1]
Centrella, J., and Wilson, J.R. 1984, Astrophysical Journal Supplement, vol. 54, pp. 229249,
Appendix B. [2]
Hawley, J.F., Smarr, L.L., and Wilson, J.R. 1984, Astrophysical Journal Supplement, vol. 55,
pp. 211246, 2c. [3]
Kreiss, H.-O. 1978, Numerical Methods for Solving Time-Dependent Problems for Partial Differ-
ential Equations (Montreal: University of Montreal Press), pp. 66ff. [4]
Harten, A., Lax, P.D., and Van Leer, B. 1983, SIAM Review, vol. 25, pp. 3661. [5]
Woodward, P., and Colella, P. 1984, Journal of Computational Physics, vol. 54, pp. 174201. [6]
Roache, P.J. 1976, Computational Fluid Dynamics (Albuquerque: Hermosa). [7]
19.2 Diffusive Initial Value Problems 847
S
a
m
p
l
e
p
a
g
e
f
r
o
m
N
U
M
E
R
I
C
A
L
R
E
C
I
P
E
S
I
N
C
:
T
H
E
A
R
T
O
F
S
C
I
E
N
T
I
F
I
C
C
O
M
P
U
T
I
N
G
(
I
S
B
N
0
-
5
2
1
-
4
3
1
0
8
-
5
)
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
C
a
m
b
r
i
d
g
e
U
n
i
v
e
r
s
i
t
y
P
r
e
s
s
.
P
r
o
g
r
a
m
s
C
o
p
y
r
i
g
h
t
(
C
)
1
9
8
8
-
1
9
9
2
b
y
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
S
o
f
t
w
a
r
e
.
P
e
r
m
i
s
s
i
o
n
i
s
g
r
a
n
t
e
d
f
o
r
i
n
t
e
r
n
e
t
u
s
e
r
s
t
o
m
a
k
e
o
n
e
p
a
p
e
r
c
o
p
y
f
o
r
t
h
e
i
r
o
w
n
p
e
r
s
o
n
a
l
u
s
e
.
F
u
r
t
h
e
r
r
e
p
r
o
d
u
c
t
i
o
n
,
o
r
a
n
y
c
o
p
y
i
n
g
o
f
m
a
c
h
i
n
e
-
r
e
a
d
a
b
l
e
f
i
l
e
s
(
i
n
c
l
u
d
i
n
g
t
h
i
s
o
n
e
)
t
o
a
n
y
s
e
r
v
e
r
c
o
m
p
u
t
e
r
,
i
s
s
t
r
i
c
t
l
y
p
r
o
h
i
b
i
t
e
d
.
T
o
o
r
d
e
r
N
u
m
e
r
i
c
a
l
R
e
c
i
p
e
s
b
o
o
k
s
o
r
C
D
R
O
M
s
,
v
i
s
i
t
w
e
b
s
i
t
e
h
t
t
p
:
/
/
w
w
w
.
n
r
.
c
o
m
o
r
c
a
l
l
1
-
8
0
0
-
8
7
2
-
7
4
2
3
(
N
o
r
t
h
A
m
e
r
i
c
a
o
n
l
y
)
,
o
r
s
e
n
d
e
m
a
i
l
t
o
d
i
r
e
c
t
c
u
s
t
s
e
r
v
@
c
a
m
b
r
i
d
g
e
.
o
r
g
(
o
u
t
s
i
d
e
N
o
r
t
h
A
m
e
r
i
c
a
)
.
Woodward, P., and Colella, P. 1984, Journal of Computational Physics, vol. 54, pp. 115173. [8]
Rizzi, A., and Engquist, B. 1987, Journal of Computational Physics, vol. 72, pp. 169. [9]
19.2 Diffusive Initial Value Problems
Recall the model parabolic equation, the diffusion equation in one space
dimension,
u
t
=
x
_
D
u
x
_
(19.2.1)
where D is the diffusion coefcient. Actually, this equation is a ux-conservative
equation of the form considered in the previous section, with
F = D
u
x
(19.2.2)
the ux in the x-direction. We will assume D 0, otherwise equation (19.2.1) has
physically unstable solutions: Asmall disturbance evolves to become more and more
concentrated instead of dispersing. (Dont make the mistake of trying to nd a stable
differencing scheme for a problemwhose underlying PDEs are themselves unstable!)
Even though (19.2.1) is of the form already considered, it is useful to consider
it as a model in its own right. The particular form of ux (19.2.2), and its direct
generalizations, occur quite frequently in practice. Moreover, we have already seen
that numerical viscosity and articial viscosity can introduce diffusive pieces like
the right-hand side of (19.2.1) in many other situations.
Consider rst the case when D is a constant. Then the equation
u
t
= D
2
u
x
2
(19.2.3)
can be differenced in the obvious way:
u
n+1
j
u
n
j
t
= D
_
u
n
j+1
2u
n
j
+ u
n
j1
(x)
2
_
(19.2.4)
This is the FTCS scheme again, except that it is a second derivative that has been
differenced on the right-hand side. But this makes a world of difference! The FTCS
scheme was unstable for the hyperbolic equation; however, a quick calculation shows
that the amplication factor for equation (19.2.4) is
= 1
4Dt
(x)
2
sin
2
_
kx
2
_
(19.2.5)
The requirement || 1 leads to the stability criterion
2Dt
(x)
2
1 (19.2.6)