You are on page 1of 5

ARTIFICIAL VISCOSITY

A CAUTIONARY TALE OF OVERSAMPLING

DANIEL TOPA
INFORMATION ANALYSIS CENTER
DEFENSE THREAT REDUCTION AGENCY
KIRTLAND AFB, NM

Abstract. A popular misconception about numerical solutions of partial differential


equations is that smaller time steps produce better solutions. In fact shrinking the time
step can completely dissipate the propagating wave. The archetypical case is the advec-
tion equation solved below using a Lax scheme. The averaging in the spatial derivative
introduces artificial viscosity; as the time step shrinks this viscosity damps out the solu-
tion. A demonstration follows.

1. Problem Statement
The advection equation is an elementary hyperbolic differential equation. Given a func-
tion u : R × R → R the spatial and temporal derivatives are related by the wave speed
c

(1.1) ux + cut = 0.

As the velocity of propagation is constant, all points on the initial profile translates without
changing shape. The advection equation is sometimes called the linear convection equation.
Given the initial condition,

(1.2) u(x, 0) = f0 (x),

the analytic solution, via the method of characteristics,1 is

(1.3) u(x, t) = f0 (x − ct) .

The wavefront travels without distortion along the characteristic curve x = ct; this un-
changing form provides a simple comparison with numerical solutions.

Key words and phrases. Courant-Freidrichs-Levy Limit, dissipation, artificial viscosity, Lax scheme,
advection, hyperbolic differential equations, forward time centered space.
1Solving the advection equation is a staple of introductory texts on partial differential equations. See,
for example, [4, Example 2.2], [2, §11.2.2], and, [5, p. 89].
1
ARTIFICIAL VISCOSITY: A CAUTIONARY TALE 2

2. Numerical implementation
Just as the analytic solution is an archetypal example, so too is the numeric solution.
Clear examples are in the works of Levesque [3, p. 224] and Garcia [1, (7.7)]. Garcia’s text
includes implementations in C and MATLAB; later editions include Python code. There
are many sample Python scripts on line with helpful plots.2
At the moment, The forward time, centered space (FTCS) discretization uses derivatives
forward in time
∂a a(xj , tµ + τ ) − a(xj , tµ )
(2.1) ≈ + O (τ ) ,
∂t τ
and centered in space
∂a a(xj + h, tµ ) − a(xj − h, tµ )
+ O h2 .

(2.2) ≈
∂x 2h
The numerical scheme of Lax advances the time step according to
1 µ  cτ  
(2.3) aµ+1
j = a + a µ
− a µ
− a µ
2 j+1 j−1
2h j+1 j−1

where the mesh points are represented by subscripts j = 1, 2, . . . , n and the time steps are
denoted by the superscript µ = 0, 1, 2, . . . .

3. Example
A toy problem demonstrates the effect of the artificial viscosity in a problem with periodic
boundary conditions: a(x+L, t) = a (x, t). The input wave is a cosine modulated Gaussian
pulse with periodic boundary conditions. The simulation parameters are shown in table
(3.1).

parameter value use


n 50 points in spatial mesh
τ 0.15 time step
L 1 domain length
c 1 wave velocity
Table 3.1. Input parameters for the simulation.

The derived parameters are the grid spacing


(3.1) h = L/n = 0.02
and the Courant-Freidrichs-Lewy (CFL) parameter
h
(3.2) tmax = = 0.02
c
The time step is τ = 0.015 < tmax which will quickly damp out the signal.
2At the moment, two such cases are D First-order Linear Convection - The Wave Equation and 1D
Linear Convection
ARTIFICIAL VISCOSITY: A CAUTIONARY TALE 3

Figure (4.1) shows the numerical computation (blue dots) against the analytic solution
(gray line) at time steps 0 and 5; the damping of the wave is immediately apparent. Figure
(4.2) shows time steps 10 and 50 and strong damping of the signal.

4. Discussion
The artificial viscosity is an essential feature of the discretization of the problem whose
strength is inversely proportional to the magnitude of the time step τ . When the time
step is too large (τ > tmax ) the damping does not have the strength to stabilize the nu-
meric problem. The figures below show that when the time step is too small the damping
overwhelms the signal.
ARTIFICIAL VISCOSITY: A CAUTIONARY TALE 4

Time step 000

Time step 005

Figure 4.1. Early time evolution; the gray line is the analytic solution.
The black dots are the numerical solution.

References
[1] A. L. Garcia, Numerical methods for physics, Prentice Hall, Upper Saddle River, N.J, 2nd ed ed.,
2000.
[2] R. Haberman, Elementary Applied Partial Differential Equations, vol. 10, Prentice-Hall, 2 ed., 1987.
[3] R. J. LeVeque, Finite difference methods for ordinary and partial differential equations: steady-state
and time-dependent problems, SIAM, 2007.
ARTIFICIAL VISCOSITY: A CAUTIONARY TALE 5

Time step 035

Time step 065

Figure 4.2. Late time evolution.

[4] Y. Pinchover and J. Rubinstein, An introduction to partial differential equations, vol. 10, Cambridge
University Press, 2005.
[5] E. Vázquez-Cendón, A. Hidalgo, P. G. Navarro, and L. Cea, Numerical methods for hyperbolic
equations, CRC Press, 2012.

You might also like