Joljrnal of Computational Physics
Joljrnal of Computational Physics
C. W. HIRT
Los Alamos Scientific Laboratory, University of California, Las Alamos, New Mexico 87544
ABSTRACT
I. INTR~DU~I~N
* This work was performed under the auspices of the United States Atomic Energy Commission.
339
0 1968 by Academic Press Inc.
340 HlRt
difference equation is discussed. The Fourier stability analysis [1] and the trun-
cation-error method can be directly compared in this case. The example reveals
two basic kinds of instability.
Second, the technique is applied to the coupled, nonlinear equations of motion
for a one-dimensional compressible fluid. Four different finite-difference approxi-
mations are used in test calculations. Computational instabilities are observed
that are not predicted by a linear Fourier stability analysis. The source of these
instabilities is easily found using the technique proposed here.
Finally, the method is used ,to explain an instability observed in an application
of the Marker-And-Cell (MAC) method for computing the dynamics of an incom-
pressible fluid [2].
(1)
which describes the convection and diffusion of a function u(x, t). The convection
velocity c and diffusion coefficient v are assumed constant. Solutions of, this
equation are bounded and otherwise well-behaved.
A simple finite difference approximation to (1) is
If r has a magnitude greater than unity for any value of k, then the difference
equation is unstable, since that Fourier component will grow exponentially with
n, i.e., with time. A study of (4) shows that the magnitude of r is less than unity for
all k if two conditions are satisfied,
2dt
- 6x2 < 1, v > 1 &it.
2
These two inequalities are stability conditions for (2). For given values of V, c, and
6x they define a range of permissible St values.
In the remainder of this section we wish to show that the stability conditions (5)
can also be obtained from an examination of truncation errors. For this purpose,
consider each term in (2) as a continuous function of x and t (see Ref. [8]). For
example, consider u;+~ as denoting u(x + 6x, t). Expand each term of (2) in a
Taylor series about the point (x, t) to obtain
g + c g - y 2 = - ; St g + o(sxa, 222).
(6)
All second- and higher-order terms in 6x and St are represented by the order
symbol 0(6x2, SF). The zero-order terms on the left-hand-side of (6) form the
original differential equation (1). This is consistent with the requirement that the
approximation improve as 6x and St tend to zero.
If the Fourier component exp[i(kx + ot)] is substituted into (6), the result is
equal to the r Eq. (4), with x = $3x, r = exp(io&), and with all sines, cosines,
and r expanded in powers of k8x and co&. This suggests a useful approximation
to (6). The lowest-order even and odd derivative terms in (6), with respect to each
independent variable, generate the corresponding lowest-order real and imaginary
terms in the expanded form of (4). Since we are primarily interested in solutions
of the difference equation with wavelengths greater than or equal to 26x, or with
wave numbers k8x in the interval (0, ‘rr), the lowest-order terms in (4) serve as a
useful approximation. Thus, (6) is approximated by keeping only the lowest-order
even and odd derivative terms, which are
It is significant that (7) is not identical to (l), which we set out to approximate.
In fact, it is the difference between these equations that accounts for the computa-
tional instabilities of (2).
To see this, recall that the difference equation propagates information into a
region bounded by lines whose slopes are dx/dt = &8x/&. The St term in (7)
342 HIRT
makes that equation hyperbolic, with characteristic lines whose slopes are
dx/dt = *(2~/Sf)~/~. If the difference equation is to have solutions approximating
those of (7), then its region of influence must include the region of influence of (7).
The necessary condition is
Courant, Friedrichs, and Lewy (31 used a similar region of influence condition for
finite-difference approximations to linear wave equations. Their condition, now
called the Courant condition, restricts the distance a wave travels in one time
increment to less than one space interval. A violation of the Courant condition
leads to an oscillating and exponentially growing instability. Apparently this is
also true in our case, for condition (8) is identical to the first stability condition (5)
and a violation of condition (8) allows (2) to have exponentially growing solutions
that oscillate with increasing n.
The second stability condition can also be obtained from (7) if the term propor-
tional to 6, is rewritten. From (6) we find that
a2u “2
r2 --- C2 g-i - 2vc ;; -+ v2 2 + O(St>.
Combining (9) with (7), and neglecting terms of second order in at,
(10)
This is identical to the result that would have been obtained from a Taylor expan-
sion of (2) about the point x = j6x, t = (n -L $) 6t. The last two terms in (10) can
be dropped, as before, since they are higher-order derivatives, so that
au “. 1 a2u
_- i. cZ=( v - j c2& s .
at )
Comparing this result with (1) we now find there is an additional diffusion term.
When (I I) has a negative diffusion coefficient it has solutions that grow exponen-
tially in time. For nongrowing, stable solutions, it is necessary that
v >, ‘$c%t. (12)
This is also the difference equation stability condition (5). When (12) is violated
the difference equation has exponentially growing solutions.
These results are easily summarized. The stability conditions for the linear
difference equation have been obtained from the differential equations (7), (11).
These approximate equations were obtained from Taylor series expansions of the
STABILITY OF DIFFERENCE EQUATIONS 343
difference equation by keeping only the lowest-order even and odd derivative
terms with respect to each independent variable. The stability condition (8) was a
region-of-influence condition for Eq. (7). Violation of this condition results in
oscillating and exponentially growing solutions. Condition (12) guarantees a
positive diffusion coefficient in (11). Violation of this condition results in pure
exponentially growing solutions.
In the remainder of this paper generalizations of these conditions are applied to
difference equations that are nonlinear and have nonconstant coefficients.
The equations of motion for a fluid are coupled, nonlinear, partial differential
equations. Finite-difference approximations for these equations are easily con-
structed, but they frequently suffer from computational instabilities. The usual
Fourier method of testing for stability refers to perturbations about stationary and
uniform flows. In this section, the truncation error method is extended to study
instabilities that cannot be predicted by the Fourier method.
The Eulerian equations of motion for a fluid in one space dimension are
2 + & (pu)= 0,
g+&@u”+P+q)=o,
apu 2 $S + -& ;p [I + ; U2] u + (p + q) I.41= 0,
where p is the fluid density, u the velocity, p the fluid pressure, and I the specific
internal energy. An artifical viscosity term, q, has been added to permit the numeri-
cal calculation of shock waves [4]. The form we have chosen for q, which is different
from that suggested in [4], is
au
-cdxp-, if -au
ax ax co,
4= (14)
0 , .if g >, 0.
The parameter CIIis a constant having the dimensions of a velocity. Equations (13)
are written in conservative form, i.e., a time derivative plus the divergence of a flux.
A stable and conservative finite-difference approximation can be constructed
344 HIRT
from Eq. (13) by using the method of donor-cell differencing for the convection
terms [5]. The difference equations are
(15)
Donor-cell boundary values for a quantity Q are denoted by (Q) and are defined by
if u;+~,~>
I
QP, 0,
'Q'xl/n = Q~
5-l-l ’
if
%,a < 0.
(17)
and
(d) second-order donor cell
In all cases except (b) the difference equations (1 S), (18) are stable according to
a linearized Fourier stability analysis. Actual calculations, however, exhibit
computational instabilities in cases (b) thru (d). By developing the ideas presented
in Section II the origin of these instabilities is easily located.
A broken diaphragm (shock tube) problem was chosen to test the difference
equations. The setup consisted of a tube with closed ends and divided in half by a
diaphragm. Both halves initially contain gas at rest, but the left half is at a higher
pressure than the right half. Numerical calculations are started at the time when
the diaphragm is broken. At a later time the system consists of a shock moving to
the right, followed by a contact surface also moving to the right, and a rarefaction
moving to the left.
The density profile for a typical broken diaphragm calculation, obtained with
the stable donor-cell method (a), is shown in Fig. 1. The corresponding velocity
profile is shown in Fig. 2. For this calculation a polytropic equation of state was
used with a ratio of specific heats equal to 513, an initial pressure and density ratio
of 5,6t = 0.25,6x = 1.0, and (Y= 1.0. The shock, contact surface, and rarefaction
corners are smoothed out over several computational cells, because of artificial
viscosity and donor-cell effects.
This same calculation was repeated for each variation of the mass equation
(18b)-(18d). Results of these variations are shown in Figs. 3-5. In each case there
is an instability in the region behind the contact surface. These instabilities do not
flip-flop on successive computational cycles, which suggests they are related to a
lack of mass diffusion,
346 HIRT
61
I I I I 1
tiiiiiiiiiii;iiiiiiii
“0 50 100
CELL NUMBER
FIG. 1. A plot of density vs cell number at t = 30.00, as calculated by the stable donor-cell
method (18a).
To test this idea, we need the truncation errors associated with each mass
equation (18+(18d). However, only those terms that involve a second space
derivative of p are needed, since they are the only ones that contribute to a mass
diffusion. The effective difl’usion coefficients for each case in (18), through terms of
order 6t and 6x4 are
(4
STABILITY OF DIFFERENCE EQUATIONS 347
where c denotes the adiabatic speed of sound. Space truncation errors have been
retained to a higher order than time errors, because they are enhanced by the
initial discontinuity.
The results of Section II indicate that instabilities can occur wherever a diffusion
coefficient is negative. We shall show that this is also true here. For a short time
after the breaking of the diaphragm, the effective diffusion coefficients (19) are
negative in certain regions, because of the large initial velocity gradients. At late
times, all coefficients (19) are positive if evaluated from a mean velocity profile, but
the instabilities persist. This indicates that nonlinear effects arising from the insta-
bilities themselves are influencing the results. However, without directly evaluating
the coefficients in (19) we can see the influence on stability of individual truncation
terms by comparing results from cases (18a)-(18d).
The donor-cell terms in (19a) do not appear in (19b), making the leading term
in (19b) proportional to 6t and negative. This 22 term is the only contribution to
(19b) in the constant velocity region between the rarefaction foot and the shock.
Hence, the method is unstable, see Fig. 3. There is an instability starting at the
tiiiiiiiiii
0.4
-I
0.0
0 50 100
CELL NUMBER
FIG. 2. A plot of velocity vs cell number at t = 30.00, as calculated by the stable donor-cell
nWhod (Ha).
348 HIRT
I I I I I I I I I I, I I I I,, I,
50 100
CELL NUMBER
foot of the rarefaction and continuiting into the constant-velocity region, up to the
contact surface. There is no corresponding instability in the constant-velocity
region between the contact surface and the shock. This is probably associated
with the absence of a perturbation, since fluid enters that region by passing through
the shock where it is smoothed by artificial viscosity effects.
Case (18~) has the same diffusion coefficient as (18b), except the 6t term is
positive. If the instability arising in (18b) is solely an effect of the 6t term, then (18~)
should be stable. This is not the case. In Fig. 4 an instability is observed much like
that in Fig. 3. The amplitude of the instability is decreasing in the constant-velocity
region where only the positive 8t diffusion term is acting, but further inspection of
Fig. 4 reveals that the instability starts in the rarefaction at the point where the
Z%/M term in (19c) turns negative. A corresponding instability is not observed at
the head of the rarefaction where the &/ax? term is also negative, because fluid
passing through this region passes into a stable region before an appreciable insta-
bility can develop.
Case (18d) was chosen to change the sign of the au/ax term, The instability that
STABILITY OF DIFFERENCE EQUATIONS 349
started at the foot of the rarefaction in cases (18b), (I&) has been eliminated, but
there is a new instability, see Fig. 5. This instability is governed by the @‘u/ax2
term, since it grows only through the first half of the rarefaction, where @u/ax2 is
positive, and then damps through the remainder of the rarefaction, where a2u/ax2
is negative. The a3u/ax3 term is seen to retard the growth of the instability at the
head of the rarefaction. Apparently, the &/ax term, although positive, is too small
to completely stabilize the rarefaction zone.
If difference scheme (1Sd) is modified to have mass fluxes evaluated at time step
n instead of (n + l), the sign of the 6t term in (19d) is changed. This modification
yields results similar to those in Fig. 5, except for an additional instability growing
in the constant-velocity region, because of the negative St diffusion term.
Three additional comments should be made. First, the usual Fourier stability
analysis cannot predict the observed instabilities, because it requires a linearization
that neglects terms involving derivatives of u times derivatives of p, Although a
linear Fourier analysis does say (18b) is unstable, because of the negative u26t/2
term in (19b), it does not detect the real source of instability.
::
E
z
n
2
I
-. \
-.
0 I
0 50 iO0
CELL NUMBER
-0 50 100
CELL NUMBER
Second, the effects of terms up to order 6x4 are easy to detect, because the dis-
continuous initial condition produces large velocity gradients at early times. If
calculations are started with the stable donor-cell method and then a change is
made to another difference approximation, (18b)-(18d), the instabilities can be
weakened or completely eliminated depending on the length of time the donor-cell
method is used.
Third, the instabilities in the rarefaction region of Figs. 3-5 appear to maintain
a stationary amplitude. This phenomenon is not understood, but is probably
connected with nonlinear effects produced by the instability itself. A study related
to this has been made by Daly [6].
As a final example, consider a calculation of the flow of water under a sluice gate.
Figure 6 shows the computed configuration of fluid at t = 0.280 set, as obtained
o-
IM
352 HlRT
by the MAC technique [2]. For this problem 6t = 0.002 set, 6x = Sy = 0.03125 ft,
the kinematic viscosity coefficient is v = 0.003 fP/sec, and the acceleration of
gravity is g = 32.2 ft/sec2. A velocity vector plot, also at t = 0.280 set, is shown
in Fig. 7. Velocity vectors are drawn out from the center of each computing cell
with a magnitude and direction characterizing the cell velocity.
An instability is developing in the lower right-hand portion of the fluid. The
fluid preparing to flow under the sluice gate is unstable, it stabilizes as it passes
under the gate, again becomes unstable as it “jets” under the right-hand-side of the
surge wave, and then is finally stabilized under the left-hand-side of the surge wave,
Figure 8 shows the same calculation repeated with 6t reduced by a factor of
20 (at = 0.0001). The instability under the surge wave has been eliminated, but
little change is seen behind the sluice gate.
These results can be readily understood in terms of truncation errors in the
MAC difference equations. Keeping only the diffusion-like truncation errors, to
order 6t and 6x2, the horizontal and vertical velocity equations are, respectively,
6y2 au a2u
+(v-~v2-q&-p.
(20)
~+u~+v~+~(~)+g=(v-~u2-~~)~
fsy2 au a2v
+(v-fv~-l&-.
First, consider the flow region behind the sluice gate. A check of the velocity
field in this region, before the instability sets in, reveals that au/ax is approximately
equal to 16.0 see-l and the flow speed varies about unity. This means both the
tit = 0.002 set and 6t = 0.0001 set cases have a negative diffusion coefficient for
a2u/ax2 or a2v/ax2, and a positive diffusion coefficient for a2u/ay2 or i32v/ay2.Without
the space error proportional to 8x2, both coefficients would be positive and Eqs. (20)
would have stable solutions. With the 6x2 terms we can explain why the instability
occurs, why it does not vanish with reduced at, and why it occurs with respect to
the x coordinate and not the y coordinate.
Now, consider the region under the surge wave. The back of the wave (right-
hand side) consists of a large eddy. Before an appreciable instability has developed,
STABILITY OF DIFFERENCE EQUATIONS 353
llIllfll
llllllll
llllllll
1lllllll
lllll~ll
lllll~ll
lllllll1
llllltl1
11ll101
Illrltll
FIG. 8. Velocity vector plot, at t = 0.280 sec. Calculation was performed with 6t = 0.0001 sec.
the flow from the sluice gate jets under this eddy with an average speed of approxi-
mately 6 ft/sec. Under the right side of the eddy &@y is approximately -29 set-1
and under the left side it is approximately $20 set-l. In the 6t = 0.002 set case
the 6t diffusion term is large, making the jet region highIy unstable. Since the St
diffusion term is detected by a linear stability analysis this is an example of linear
instability.
In the St = 0.0001 set case, however, the jet is stable in the linear sense, but the
coefficient of &/ax2 or a2v/ax2 is negative in the region of large negative avjay
values under the right side of the eddy. No instability is observed probably because
the fluid passes through the unstable zone too quickly for an instability to develop
appreciably. A similar situation occurred in example (18~) where the head of the
rarefaction appeared stable, but should have been unstable.
As a useful rule-of-thumb the MAC method is considered stable if v is greater
than l/2 St u2, where u is the average maximum fluid speed, and if v is greater than
l/2 8x2(&/ax), where au/ax is the average maximum velocity gradient in the direc-
tion of flow. The first condition is needed for linear stability. The second condition
is a nonlinear stability requirement.
354 HIRT
V. CONCLUDING REMARIB
The purpose of this paper is to present a technique that we have found very
useful. In addition to the examples mentioned here, the truncation error method
for determining computational stability has been tested on a variety of linear
equations with uniformly good results. It has also been successfully applied to
additional one-dimensional fluid calculations, and to other examples of MAC
instabilities [7].
In addition to difference approximations (18a)-( 18d) there is another approxima-
tion that is particularly interesting from the standpoint of truncation errors. The
approximation is referred to as ZIP type differencing. It can be used to approximate
the convection of any quantity Q defined at the same mesh locations as the con-
vecting velocity. To illustrate the ZIP method, consider a one-dimensional convec-
tion term that is differenced about the point x = j6x according to
(Quh+l/z
Ea[Qjuj+I
+Qj+,ujl.
The advantage of ZIP dfierencing is that it introduces no truncation errors contri-
buting to a diffusion of Q. Thus, if ZIP differencing is used for the mass convection
term in Section III, the effective mass diffusion coefficient contains no space errors,
and hence, no instabilities associated with these errors. There will be an instability
associated with non-time centering in the equation (a negative 6t diffusion coeffi-
cient) and this must be compensated for in some way.
ACKNOWLEEGMENIX
This paper reflects the efforts of every member of Group T-3 at the Los Alamos Scientific
Laboratory. It is a pleasure to acknowledge their participation, and to particularly thank T. D.
Butler, B. J. Daly, R. A. Gentry, and F. H. Harlow for their contributkns.
581/z/4-2