Escolar Documentos
Profissional Documentos
Cultura Documentos
Differential Equations
J.W.Haverkort
April 2009
Abstract
This is a summary of the course “Numerical Methods for time-dependent
Partial Differential Equations” by P.A. Zegeling of spring 2009.
Contents
1 General 2
1.1 Classification of PDEs . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Fourier domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Method of undetermined coefficients . . . . . . . . . . . . . . . . 2
1.4 Equivalence theorem . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Method of lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6.1 Eigenvalue method . . . . . . . . . . . . . . . . . . . . . . 3
1.6.2 Von Neumann stability analysis . . . . . . . . . . . . . . . 4
1.7 Numerical diffusion . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.8 CFL condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Various schemes 6
2.1 Heat equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Linear Advection equation . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Non-linear advection equation . . . . . . . . . . . . . . . . . . . . 9
2.4 Wave equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Advection-diffusion equation . . . . . . . . . . . . . . . . . . . . 10
1
1 General
1.1 Classification of PDEs
Second order equations of the form
2
ui+1 − 2ui + ui−1
uxx |i ≈ (5)
h2
The error term or local truncation error (LTE) τ = Ah4 /24+0+Ch4 /24)uxxxx,i =
h2 /12uxxxx,i + ... This finite difference (FD) scheme is said to be of order two
in space, or O(∆x2 ). Here
Note that A can be very large, especially in problems where the solutions
changes rapidly in time. A scheme is said to be consistent if in the limit ∆x → 0
the finite difference operators converge to the continuous operators.
1.6 Stability
1.6.1 Eigenvalue method
Consider the eigenvalue problem u̇(t) = λu(t) with u(0) = u0 with the exact
solution consisting of oscillations or exponential growth/decay depending on λ ∈
C. Discretizing using EF gives at a time t = n∆t the solution un = u0 (1+λ∆t)n .
This solution by EF is stable for |1 + λ∆t| ≤ 1 constituting a circular stability
region centred around z ≡ λ∆t = 1. After discretizing a particular equation
in space one generally obtains a matrix analogue of the discussed 1D-example:
u̇ = Au. In this case a similar stability analysis can be made, but now using
the eigenvalues of the matrix A:
3
The eigenvalues of the matrix A depend on the equation you are solving and
the scheme that is used. For the Forward in Time Central in Space (FTCS)
−4 2 pπ∆x
discretization of the heat equation the eigenvalues are λp = ∆x 2 sin 2 along
the negative real axis. The method using EF is therefore stable for → ∆x2 ≤ 12 ,
∆t
• Crank-Nicolson: S = {z ∈ C|<{z} ≤ 0}
• BTCS: S = {z ∈ C| |1−z|
1
≤ 1}
When the finite difference equations are linear, the behaviour of each sepa-
rate term of the series ∼ behaviour of the whole series. Just dealing with one
term of the series, one inserts εnm = eat eiξm x in the FD equation. We have
n+1
ε
g ≡ mn = eat (9)
εm
where the amplification factor should be g ≤ 1 for stability. As an example
we consider the FTCS discretization of the heat equation. We assume unj =
Ujn + εnj with U the exact solution of the discretized equation and εnj the round-
off error. Inserting uj into the discretized equations and subtracting the same
equation, only now with the exact solution Ujn inserted, yields by linearity only
the difference
εn+1
j − εnj εnj+1 − 2εnj + εnj−1
=κ (10)
∆t (∆x)2
Inserting εnj = eat eiξm x and dividing by eat eiξm x gives
same result for stability as the eigenvalue method. The criterion g ≤ 1 yields
κ∆t/(∆x)2 ≤ 1/2, the familiar result.
4
When this “numerical diffusion constant” however becomes negative, the scheme
is rendered unconditionally unstable. Some examples of occuring numerical
diffusion constants are in the Lax-Friedrichs scheme (LF), the Lax-Wendroff
scheme (LW) and the upwind scheme (upw)
(∆x)2 c2 ∆t c∆x
εLF = , εLW = , εupw = (12)
2∆t 2 2
5
2 Various schemes
2.1 Heat equation
ut = κux x (13)
• Forward Time Centred Space (FTCS):
un+1 − uni un − 2uni + uni−1
i
= κ i+1 (14)
∆t ∆x2
τ = O(∆t, ∆x2 )
• Backward Time Centred Space (BTCS):
6
• Alternative direction scheme. This is an example of a splitting method
which uses two half-time steps
n+1/2
uj,k − unj,k κ n+1/2 κ
= δ2 u + δ 2 un (19)
∆t/2 (∆x)2 x j,k (∆y)2 y j,k
n+1/2
j,k − uj,k
un+1 κ n+1/2 κ
= δx2 uj,k + δ 2 un+1 (20)
∆t/2 (∆x)2 (∆y)2 y j,k
n+1/2
where in the first step uj,k has to be found implicitly, but can then be di-
n+1/2
rectly used in the second half-time step where uj,k is obtained implicitly.
One thus has to solve a tridiagonal matrix equation twice. Although both
steps separately have their own stability criterion, the combined method
for a full time step is unconditionally stable.
un+1 − uni c ( n )
i
+ ui+1 − uni−1 = 0 (22)
∆t 2∆x
Although consistent, this scheme is unconditionally unstable. This can
be understood from evaluating the LTE = − ∆t 2 utt |j + .. which, with from
n
2
the advection equation itself utt = c uxx , implies some numerical diffusion
with a negative sign, i.e. trouble.
• Lax-Friedrichs:
1 n c∆t ( n )
un+1 = (u + unj+1 ) − u − uni−1 (23)
i
2 j−1 2∆x i+1
This scheme is obtained by replacing uni with an average value un+1 j =
1 n n 1 n n n
2 (u j−1 + u j+1 ) in the FTCS method. Because 2 (u j−1 + u j+1 ) = u j +
2 (uj−1 − 2uj + uj+1 ) some artificial diffusion is added and one actu-
1 n n n
along the imaginary axis in the z = λ∆t-plane, but form an ellipse with
2 such that for c∆t/∆x ≤ 1 they all lie
2ε∆t
centre and radius given by (∆x)
within the EF stability region, rendering the method conditionally stable.
7
Some second order in space and time options
• Crank Nicolson trapezoidal method for u̇ = Au
• Two-level explicit:
c∆t n c2 (∆t)2 n
un+1 = unj − (uj+1 − unj−1 ) + (u − 2unj + unj−2 ) (24)
j
2∆x 8(∆x)2 j+2
This scheme has a five-point stencil and requires additional boundary con-
ditions. The method is obtained from taking another time derivative of the
system u̇ = Au yielding ü = A2 u(t) which gives a second order method
un + 1 = un + ∆tAun + 12 (∆t)2 A2 u(t)
• Lax-Wendroff
c∆t n c2 (∆t)2 unj+1 − 2unj + unj−1
un+1
j = unj − (uj+1 − unj−1 ) + (25)
2∆x 2(∆x)2 (∆x)2
This scheme can be obtained by Taylor expanding the advection equa-
tion, replacing ut by −cux and utt by c2 uxx using central FDs and in the
time direction EF. This scheme actually solves the equation ut + cux =
−(1/6)c(∆x)2 (1 − (c∆t/∆x)2 uxxx to third order, thereby showing some
artificial numerical dispersion due to the non-zero right hand side. The
resulting oscillations lag behind the solution due to the negative sign, and
are damped by a term proportional to uxxxx in the modified equation.
Upwind methods use different spatial discretizations depending on the (local)
sign of c.
• First order upwind. For c > 0 it is just FTFS
c∆t n
un+1 = unj − (u − unj−1 ) (26)
j
∆x j
When c > 0, FTBS is used. The scheme is only first order accurate in
both space and time. Note that the right hand side can be written as
unj − 2∆x
c∆t
(unj+1 − unj−1 ) + 2∆x
c∆t
(unj+1 − 2unj − unj−1 ) so that a numerical
diffusion term with diffusion coefficient εupw = c∆x/2 is introduced. One
can even show that upwind schemes for the advection equation, to first
order, actually solve a modified advection-diffusion equation to second
order accuracy. Note that for c < 0 this becomes negative diffusion,
showing that the displayed FTBS can only stably be used for c > 0.
• Beam-Warming method: second order upwind. Again, for c > 0
( )2
c∆t 1 2 ∆t ( n )
ujn+1
= uj −
n
(3uj −4uj−1 +uj−2 )+ c
n n n
uj − 2unj−1 + unj−2
2∆x 2 ∆x
(27)
The derivation goes analogously to that of the Lax-Wendroff scheme, using
a one-sided approximation for spatial derivatives. It is stable for 0 ≤
c∆t/∆x ≤ 2. The modified equation for this equation is ut + cux =
( c∆t )2
6 c(∆x) (2 − ∆x + ∆x
1 2 3c∆t
)uxxx
Note that it can be proven that there exist no explicit unconditionally stable
FD schemes for solving hyperbolic PDEs.
8
2.3 Non-linear advection equation
ut + F (u)x = 0 (28)
An example is the conservative form of the Burger’s equation in which
F (u) = 12 u2 . Performing the differentiation, the non-conservative form ut +
uux = 0 is obtained. The characteristics satisfy x(t)0 = u(x(t), t).
∆t n n
un+1 = unj − u (u − unj−1 ) (29)
j
∆x k j
With k = j this gives a wrong solution. With k = j − 1 it gives a better
solution, but with the wrong wave speed.
• Lax-Friedrichs
1 n ∆t
un+1 = (u + unj−1 ) − ((un )2 − (unj−1 )2 ) (30)
j
2 j+1 4∆x j+1
which yields the correct speed.
• Non-linear Lax-Wendroff
n
Fj+1 − Fj−1
n
un+1
j = unj − ∆t (31)
2∆x
(∆t)2 (∆x)2 [ 0 n ( n ) ( )]
+ F (uj+ 1 ) Fj+1 − Fjn − F 0 (unj− 1 ) Fjn − Fj−1
n
2 2 2
This scheme is obtained using a second order Taylor expansion and substi-
tuting utt = ∂t (−F (u)x ) = −∂x (F (u)t ) = .. = ∂x Q with Q ≡ F 0 (u)∂x F (u).
Furthermore one uses central differences (CD), a whole step for ∂x F and
half step for ∂x Q, using Qnj+ 1 = F 0 (unj+ 1 (Fj+1
n
− Fjn )/∆x. Note that for
2 2
F (u) = cu the linear Lax-Wendroff result is obtained.
un+1
j = σ 2 unj+1 + 2(1 − σ 2 )unj + σ 2 un−1 − un−1
j (33)
To get this scheme started, however, one needs u1j which, if calculated using
u1j = fj + ∆t, renders the whole scheme first order accurate in time. It is
9
2 2
therefore better to use u1j = fj +∆tgj + c2(∆x)
(∆t)
2 (fj+1 − 2fj + fj−1 ) = 2 σ fj+1 +
1 2
The steady state version has, with u(0) = 0 and u(1) = 1, as exact solution
u(x)(ecx/ε − 1)/(ec/ε − 1) yielding a ‘boundary layer’ of O(ε/c). The cor-
responding FD scheme using central differences has the exact solution uj =
P j − 1/(P N − 1) with P j = (1 + P ejm )/(1 − P ejm ). For P ejm > 1 one has P j < 0
so that the numerical solution shows oscillations or wiggles, which can be shown
to be associated with the combination of first and second derivatives in the orig-
inal equation. The solution, circumventing the use of very small grid sizes, is
using an upwind scheme with the same exact solution but with P j = 1 + P ejm .
The wiggles are then absent, but at the cost of introducing some numerical
diffusion.
10
3 Higher order methods
3.1 Finite Differences
Using Taylor expansions, higher order approximations can be found. As an
example, an approximation of uxx using the five values uj−2 to uj+2 has an
error term of O(∆x6 ). At the boundaries one now needs additional values,
which over determines the system rendering it ill-posed. Another downside is
that the matrix becomes less sparse, making it computationally more expensive
to invert.
∞ ∫
∑ ∞
u(x, t) − uN (x, t) = ak (0)eikx e−k t ≤ max |ak (0)|
2
e−tx dx
2
(35)
0≤x≤2π N
k=N
11
4 Adaptive Mesh Refinement
Several types of Adaptive Mesh Refinement (AMR) variants exist
• r-refinement - nodes are moved around, while keeping the number of nodes
constant
ux = εuxx (36)
with u(0) = 0 and u(1) = 1. Define a transformation x → ξ ∈ [0, 1] with
v(ξ) ≡ u(x(ξ)) such that
[ ]
vξ ε vξξ xξ − vξ xξξ 2
= (37)
xξ xξ xξ
Now when one chooses v(ξ) = ξ, such that a uniform distribution of ξ yields
a uniform distribution in v(ξ) = u(x(ξ)), the equation becomes εxξξ + x2ξ = 0
and x(0) = 0 and x(1) = 1. One has in general vξ = ux xξ such that the
particular mapping v(ξ) = ξ satisfies xξ ux = 1. I.e. xξ is inversely proportional
to the grid point concentration, where ux is large xξ is small as is desirable.
This example leads to a principle that could be used for other equations as well:
xξ ω = 1 or (ωxξ )ξ = 0 (38)
with ω > 0 a ‘monitor function’ that is ideally some measure of the numeri-
cal error.
Using dx/dξ = (dξ/dx)−1 ∫ one obtains dξ/dx = cω or, with ξ(xR ) − ξ(xL ) = 1,
dξ
after integrating c = 1/ ωdx or dx = R xRωωdx from which the inverse transfor-
xL
mation is obtained
∫x
ω(x0 )dx0
ξ(x) = ∫ xxLR (39)
xL
ω(x0 )dx0
The Jacobian of the transformation dx/dξ > 0 such that the transformation
is regular, or non-singular. Note that the principle (ωxξ )ξ = 0 is equivalent to
∫1
minimization of the functional F = 0 ωx2ξ dξ, which can easily be derived from
the Euler-Lagrange equations. The discussed principle is therefore analogous to
the minimization of the energy of a spring system between the mesh points.
12
4.2 Equidistribution principle
In discrete terms the application of such
∫ xa transformation dξ/dx = cω implies
for the mesh size ∆xi = c/ωi . Because xii+1 ωdx = c independent of i
∫ xi+1 ∫
1 xR
ωdx = ωdx (40)
xi N xL
showing that ω is equally distributed over all subintervals, a principle called
the equidistribution principle. The equidistribution of the monitor function
ensures ∆xi is small where ωi is large.
ω(xi (0), 0)
δxi (t) = δxi (0) (41)
ω(xi (t), t)
From this we see that ω(xi (0), 0)/ω(xi (t), t) should be smaller than one
to ensure stability. A possibly resulting instability may be prevented by
adding a small ‘delay’-term to the equidistribution principle.
13
dependent advection-diffusion equation plus source term for the function u(x).
Let the transformation be the solution of
14