You are on page 1of 19

Properties of numerical methods

The following criteria are crucial to the performance of a numerical algorithm:


1. Consistency

The discretization of a PDE should become exact as the


mesh size tends to zero (truncation error should vanish)

2. Stability

Numerical errors which are generated during the solution


of discretized equations should not be magnified

3. Convergence

The numerical solution should approach the exact solution of


the PDE and converge to it as the mesh size tends to zero

4. Conservation

Underlying conservation laws should be respected at the


discrete level (artificial sources/sinks are to be avoided)

5. Boundedness

Quantities like densities, temperatures, concentrations etc.


should remain nonnegative and free of spurious wiggles

These properties must be verified for each (component of the) numerical scheme

Consistency
Relationship:

discretized equation

differential equation

Truncation errors should vanish as the mesh size and time step tend to zero
Example. Pure convection equation

u
t

+ v u
x = 0 discretized by

uni+1 uni1
un+1
uni
i
+v
= O[(t)q , (x)p ]
CDS in space, FE in time:
t
2x
 2 n

(t)2
n+1
u
u n
n
+ ...
Taylor series expansions: ui
= ui + t t i + 2
t2
i
 2 n
 3 n

3
2
n
(x)
(x)
u

u
u
uni1 = uni x x i + 2

+ ...
2
x
6
x3
i

Hence,

un+1
un
i
i
t

n
un
i+1 ui1
v 2x

n
+ v u
where
x i + = 0
n
n


(x)2 3 u
t 2 u
v
+ O[(t)2 , (x)4 ]
=
2
3
2
t i
6
x i
+

u
t

residual of the difference scheme for the exact nodal values um


j = u(jx, mt)

Stability
numerical solution of
discretized equations

Relationship:

exact solution of
discretized equations

Definition 1

Numerical errors (roundoff due to final precision of computers)


should not be allowed to grow unboundedly

Definition 2

The numerical solution itself should remain uniformly bounded

Stability analysis: can only be performed for a very limited range problems
Matrix method:

Aun+1 = Bun

un+1 = Cun , where C = A1 B

is assumed to be a linear operator. In practice un = u


n + en so that
un+1 = Cun

for the numerical solution un of the discretized equations

u
n+1 = C u
n

for the exact solution u


n of the discretized equations

en+1 = Cen

for the roundoff error en incurred in the solution process

Matrix method for stability analysis


In the linear case

un+1 = Cun = . . . = C n u0 ,

en+1 = Cen = . . . = C n e0

i.e., the error evolves in the same way as the solution and is bounded by
||e|| ||C||n ||e0 ||,

||C|| (C) = maxi |i |

spectral radius of C

Unstable schemes: if (C) > 1 then ||C|| 1 and the errors may grow
Example. Convection-diffusion equation
CDS in space, FE in time:
or

un+1
= uni
i

un+1
un
i
i
t

u
t

u
+ v u
=
d
x
x2 discretized by

n
un
i+1 ui1
v 2x

n
n
un
i1 2ui +ui+1
d
(x)2

n
(ui+1 uni1 ) + (uni1 2uni + uni+1 )
2

t
t
where = v x
is the Courant number, = d (x)
2 is the diffusion number

Matrix method for stability analysis

a b c

C=
a b c

a b c

Eigenvectors
Eigenvalues

(m)

a=+

high frequen ies

b = 1 2
c=

m=N

(m)

(m)

(m)

(m)

+ cj1 = m j

m = 1 + 2(cos m 1) + i2 sin m ,

,
m = m N

i2 = 1

(m)

divide by j

= eim j

m = 1, . . . , N

|m |2 = [1 + 2(cos m 1)]2 + 4 2 sin2 m 1

Stability condition
pure convection:

m=0


= cos m j + i sin m j = eim j ,

aj+1 + bj

low frequen ies

=0

pure diffusion: = 0

|m | 1

unconditionally unstable :-(

|m | 1 if

1
2

conditionally stable

Von Neumanns stability analysis


Objective: to investigate the propagation and amplification of numerical errors
Assumptions: linear PDE, constant coefficients, periodic boundary conditions
Continuous error representation
P
e(x, t) = am (t)eikm x Fourier series

i2 = 1,

eikm x = cos km x + i sin km x

lmax = 2L
lmin = 2x

i.e. the error is a superposition of harmonics


characterized by their wave number km = l2
m
(for wave length lm ) and amplitide am (t)
Discretization

x =

L
N

km = m L
=

0
x0

m
N x ,

L
xi1 xi xi+1

xN

m = km x = m N

Here m is the phase angle, m is the number of waves fitted into the interval
(L, L) and x determines the highest frequency resolvable on the mesh

Von Neumanns stability analysis


Representation of numerical error (trigonometric interpolation)
X
X
0
0 im j
n
ej =
am e
ej =
anm eim j , where anm = a0n nm
m

Due to linearity, the error satisfies the discretized equation and so does each
harmonic. Hence, it suffices to check stability for enj = anm eim j , m
Amplification factor
Gm

an+1
= mn = m
am

the enhancement of the mth


harmonic during one time step

Stability condition
|Gm | 1,

guarantees that the error component


enj = (Gm )n e0j remains bounded

Remark. The accuracy of approximation can be assessed by analyzing phase


errors i.e. the actual speed of harmonics as compared to the exact speed

Example: pure convection equation in 1D


1. Let

u
t

+ v u
x = 0 be discretized by CDS in space, FE in time

un+1
unj
unj+1 unj1
j
+v
=0
t
2x

and substitute enj = an eij

The resulting difference equation for the error can be written as


(an+1 an )eij +
Divide by eij

n i(j+1)
a (e
ei(j1) ) = 0,
2

an+1 = an 2 an (ei ei )

=v

t
x

and note that

ei ei = cos + i sin cos + i sin = 2i sin


Amplification factor

G=

|G|2 = 1 + 2 sin2 1

an+1
an

= 1 i sin

is responsible for stability

the scheme is unconditionally unstable :-(

Example: pure convection equation in 1D


2. Let

u
t

+ v u
x = 0 be discretized by BDS in space, FE in time

un+1
unj
unj unj1
j
+v
=0
t
x
which yields

and substitute enj = an eij


t
= v x

(an+1 an )eij + an (eij ei(j1) ) = 0,

G = 1 + ei = 1 + (cos i sin ) = 1 2 sin2


Re(G) = 1 + cos ,

Im(G) = sin

Stability restriction |G|2 1 means that G must


lie within the unit circle in the complex plane.
This leads to the CFL condition

01
x
v

v>0

upwind scheme, stable for t

v<0

downwind scheme, unconditionally unstable

i sin

Im(G)
region of
instability

 


1
region of
stability

Re(G)

Example: pure convection equation in 1D


The numerical domain of dependence should contain the analytical one:
if > 1, then the data at some grid point may
affect the true solution but not the numerical one
on the other hand, for < 1 some grid points influence the solution although they should not

dx
dt

n+1

for accuracy reasons it is desirable to have 1;


some schemes are exact for = 1 (unit CFL property)
3. Let

u
t

dx
dt

=v

00000000000
11111111111
11111111111
00000000000
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111
00000000000
11111111111

n
xi

t

x

xi
v

t
x

xi+1

+ v u
x = 0 be discretized by CDS in space, BE in time

n+1
un+1
unj
un+1
j
j+1 uj1
+v
=0
t
2x

and substitute enj = an eij

(an+1 an )eij + 2 an+1 (ei(j+1) ei(j1) ) = 0


It follows that

=
|G|2 = G G

1
sin2

1+ 2

G=

1
1+i sin

unconditional stability

Spectral analysis of numerical errors


Consider

u
t

u
+ v u
x = d x2

Exact solution:

convection-diffusion equation

u(x, t) = eik(xvt)k

dt

= a(t)eikx ,

a(t) = eikvtk

dt

a wave with exponentially decaying amplitude traveling at constant speed


Amplification factor
|Gex | = e ,
Amplitude error

Gex =

a(tn+1 )
a(tn )

= k 2 dt,
=

|Gnum |
|Gex |

e(ikv+k d)(n+1)t
e(ikv+k2 d)nt

= e(+i)

= kvt = arg(Gex )

= |Gnum |e

numerical damping

arg(Gnum )
arg(G )
=
= vv numerical dispersion
= arg(Gnum

ex )
arg(Gnum )
where v = kt
is the numerical propagation speed

Phase error

Harmonics travel too fast if > 1 (leading phase error)


and too slow in the case < 1 (lagging phase error)

Convergence
Relationship:

numerical solution of
discretized equations

exact solution of the


differential equation

Definition: A numerical scheme is said to be convergent if it produces the


exact solution of the underlying PDE in the limit h 0 and t 0
Lax equivalence theorem:

stability + consistency = convergence

For practical purposes, convergence can be investigated numerically by


comparing the results computed on a series of successively refined grids
The rate of convergence is governed by the leading truncation error of
the discretization scheme and can also be estimated numerically:
u = uh + e(u)hp + . . . = u2h + e(u)(2h)p + . . . = u4h + e(u)(4h)p + . . .


u
u
2h
log u4h
u2h uh e(u)hp (1 2p )
2h uh

p
p
p p
log 2
u4h u2h e(u)h (1 2 )2

Conservation
Physical principles should apply at the discrete level: if mass, momentum
and energy are conserved, they can only be distributed improperly
Integral form of a generic conservation law
Z
Z
Z

u dV +
f n dS =
q dV,
f = vu du
t V
S
V
accumulation
influx source/sink
flux function

Caution: nonconservative discretizations may produce reasonably looking


results which are totally wrong (e.g. shocks moving with a wrong speed)
even nonconservative schemes can be consistent and stable
correct solutions are recovered in the limit of very fine grids
Problem: it is usually unclear whether or not the mesh is sufficiently fine

Discrete conservation
1. Any finite volume scheme is conservative by construction both locally
(for every single control volume) and globally (for the whole domain)
2. A finite difference scheme is conservative if it can be written in the form
fi+1/2 fi1/2
un+1
uni
i
+
=q
t
x
which is equivalent to a vertex-centered finite volume discretization
3. Any finite element scheme is conservative, at least globally


Z
N
X
uh
i 1,
i
+ fh qh dV = 0, i = 1, . . . , N
t
V
i=1
Summation over i yields a discrete counterpart of the integral conservation law
R  uh
V

+ fh qh dV = 0

uh dV +

f n dS =
S h

qh dV

Boundedness
Convection-dominated / hyperbolic PDEs

P e 1,

Re 1

spurious undershoots and overshoots occur in the vicinity of steep gradients


quantities like densities, temperatures and concentrations become negative
the method may become unstable or converge to a wrong weak solution
1

low-order
0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

high-order

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Idea: make sure that important properties of the exact solution (monotonicity,
positivity, nonincreasing total variation) are inherited by the numerical one

Design of nonoscillatory methods


u
t

Monotone methods
H(un ; i)
0,
unj
Example.

Let

u
t

i, j

f
x

Then

vin uni ,

such that

vin+1 un+1
,
i

+ v u
x = 0 be discretized by UDS in space, FE in time

uni uni1
un+1
uni
i
+v
= 0,
t
x
Derivatives

un+1
= H(un ; i)
i

=0

H(un ;i)
un
i

= 1 ,

H(un ; i) = uni v

H(un ;i)
un
i1

= ,

where

t n
(ui uni1 )
x

t
= v x

monotone under the CFL condition 1 (cf. stability analysis)

Lax-Wendroff theorem: If a monotone consistent and conservative method


converges, then it converges to a physically acceptable weak solution

Design of nonoscillatory methods


Godunovs theorem: Monotone method are at most first-order accurate
(monotone if linear)

Monotonicity-preserving methods
u0i u0i+1 ,

uni uni+1 ,

i, n

If the initial data u0 is monotone, then so is the solution un at all times


It is known that the total variation defined as

R u
dx
T V (u) =
x

is a

nonincreasing function of time for any physically admissible weak solution


Total variation diminishing methods
T V (un+1 ) T V (un ),
Classification

monotone

(monotone if linear)
X
n
where T V (u ) =
|uni uni1 |
i

TVD

monotonicity-preserving

Total variation diminishing methods


Hartens theorem:

An explicit finite difference scheme of the form

un+1
uni
i
= ci1/2 (uni1 uni ) + ci+1/2 (uni+1 uni )
t
is total variation diminishing (TVD) provided that the coefficients satisfy
ci1/2 0,
Semi-discrete problem

ci+1/2 0,
dui
dt

fi+1/2 fi1/2
x

ci1/2 + ci+1/2 1
=0

conservation form

Idea: switch between high- and low-order flux approximations depending on


the local smoothness of the solution so as to enforce Hartens conditions:
L
H
L
]
fi+1/2
+ i+1/2 [fi+1/2
fi+1/2 = fi+1/2

where 0 i+1/2 2 is a solution-dependent correction factor (flux limiter)

TVD discretization of convective terms


Example. Pure convection equation

u
t

+ v u
x = 0,

Linear flux approximations


upwind difference

H
= v ui+12+ui
fi+1/2

central difference

Hartens coefficients

ri =

ui ui1
ui+1 ui

fi+1/2 = vui + v2 (ri )(ui+1 ui )


h
i
(ri )
v
ci1/2 = 2x 2 + ri (ri1 ) ,

Standard flux limiters:

f = vu

Smoothness indicator

L
= vui
fi+1/2

Nonlinear TVD flux

v > 0,

(r) =

r+|r|
1+|r|

(r) = max{0, min{1, r}}


 1+r

(r) = max{0, min 2 , 2, 2r }

(r) = max{0, min{1, 2r}, min{2, r}}

Van Leer
minmod

ci+1/2 = 0
1D stencil
ui
u i+1

u i1

MC
superbee
x i1

xi

x i+1

You might also like