NumerPDEs Lecture
NumerPDEs Lecture
Differential Equations
Seongjai Kim
In organizing the lecture note, I am indebted by Ferziger and Peric [23], John-
son [32], Strikwerda [64], and Varga [68], among others. Currently the lecture
note is not fully grown up; other useful techniques would be soon incorporated.
Any questions, suggestions, comments will be deeply appreciated.
3
4
Contents
Title 2
Prologue 3
Table of Contents 9
1 Mathematical Preliminaries 1
1.1. Taylor’s Theorem & Polynomial Fitting . . . . . . . . . . . . . . . . . . . . . . . 2
1.2. Finite Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1. Uniformly spaced grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.2. General grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3. Overview of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.4. Difference Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.5. Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5
6 Contents
3.3. Convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.4. Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.4.1. Approaches for proving stability . . . . . . . . . . . . . . . . . . . . . . . 70
3.4.2. The von Neumann analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.4.3. Influence of lower-order terms . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.5. Boundedness – Maximum Principle . . . . . . . . . . . . . . . . . . . . . . . . . 77
3.5.1. Convection-dominated fluid flows . . . . . . . . . . . . . . . . . . . . . . . 78
3.5.2. Stability vs. boundedness . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
3.6. Conservation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
3.7. A Central-Time Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.8. The θ-Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
3.8.1. Stability analysis for the θ-Method . . . . . . . . . . . . . . . . . . . . . . 84
3.8.2. Accuracy order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
3.8.3. Maximum principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
3.8.4. Error analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
3.9. Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
11 Projects∗ 347
11.1.High-order FEMs for PDEs of One Spacial Variable . . . . . . . . . . . . . . . . 347
Bibliography 383
Index 391
10 Contents
Chapter 1
Mathematical Preliminaries
1
2 CHAPTER 1. MATHEMATICAL PRELIMINARIES
The formula (1.1) can be rewritten for u(x + h) (about x) as follows: for
x, x + h ∈ (a, b),
n
X u(k) (x) k u(n+1) (ξ) n+1
u(x + h) = h + h (1.2)
k! (n + 1)!
k=0
1.1. Taylor’s Theorem & Polynomial Fitting 3
Curve fitting
Another useful tool in numerical analysis is the curve fitting. It is often the
case that the solution must be represented as a continuous function rather
than a collection of discrete values. For example, when the function is to be
evaluated at a point which is not a grid point, the function must be interpo-
lated near the point before the evaluation.
First, we introduce the existence theorem for interpolating polynomials.
Theorem 1.2. Let x0 , x1 , · · · , xN be a set of distinct points. Then, for arbi-
trary real values y0 , y1 , · · · , yN , there is a unique polynomial pN of degree ≤ N
such that
pN (xi ) = yi , i = 0, 1, · · · , N.
4 CHAPTER 1. MATHEMATICAL PRELIMINARIES
Newton polynomial
The Newton form of the interpolating polynomial that interpolates u at
{x0 , x1 , · · · , xN } is given as
N h
X k−1
Y i
pN (x) = ak (x − xj ) , (1.5)
k=0 j=0
u[xj ] = u(xj ),
u[xj+1 ] − u[xj ]
u[xj , xj+1 ] = ,
xj+1 − xj (1.7)
u[xj+1 , xj+2 ] − u[xj , xj+1 ]
u[xj , xj+1 , xj+2 ] = ,
xj+2 − xj
and the recursive rule for higher-order divided differences is
u[xj , xj+1 , · · · , xm ]
u[xj+1 , xj+2 , · · · , xm ] − u[xj , xj+1 , · · · , xm−1 ] (1.8)
= ,
xm − xj
for j < m.
6 CHAPTER 1. MATHEMATICAL PRELIMINARIES
xj u[xj ] u[ , ] u[ , , ] u[ , , , ] u[ , , , , ]
x0 u[x0 ]
x1 u[x1 ] u[x0 , x1 ]
x2 u[x2 ] u[x1 , x2 ] u[x0 , x1 , x2 ]
x3 u[x3 ] u[x2 , x3 ] u[x1 , x2 , x3 ] u[x0 , x1 , x2 , x3 ]
x4 u[x4 ] u[x3 , x4 ] u[x2 , x3 , x4 ] u[x1 , x2 , x3 , x4 ] u[x0 , x1 , x2 , x3 , x4 ]
Example
1.1. Taylor’s Theorem & Polynomial Fitting 7
Further, assume that the points are uniformly spaced and max |u(N +1) (x)| ≤
x∈[a,b]
M , for some M > 0. Then,
M b − a N +1
max |u(x) − pN (x)| ≤ . (1.10)
x∈[a,b] 4(N + 1) N
8 CHAPTER 1. MATHEMATICAL PRELIMINARIES
xi = a + ih, i = 0, 1, · · · , N.
• Define ui = u(xi ), i = 0, 1, · · · , N .
One-sided FD operators
Solve the above equations for ux (xi ) to have
ui+1 − ui uxx (xi ) uxxx (xi ) 2
ux (xi ) = − h− h
h 2! 3!
uxxxx (xi ) 3
− h + ··· ,
4! (1.12)
ui − ui−1 uxx (xi ) uxxx (xi ) 2
ux (xi ) = + h− h
h 2! 3!
uxxxx (xi ) 3
+ h − ··· .
4!
By truncating the terms including hk , k = 1, 2, · · · , we define the first-order
FD schemes
ui+1 − ui
ux (xi ) ≈ Dx+ ui := , (forward)
h (1.13)
− ui − ui−1
ux (xi ) ≈ Dx ui := , (backward)
h
where Dx+ and Dx− are called the forward and backward difference operators,
respectively.
10 CHAPTER 1. MATHEMATICAL PRELIMINARIES
Central FD operators
The central second-order FD scheme for ux : Subtract (1.11.b) from (1.11.a)
and divide the resulting equation by 2h.
ui+1 − ui−1 uxxx (xi ) 2
ux (xi ) = − h
2h 3! (1.14)
uxxxxx (xi ) 4
− h − ··· .
5!
Thus the central second-order FD scheme reads
ui+1 − ui−1
ux (xi ) ≈ Dx1 ui := . (central) (1.15)
2h
Note that the central difference operator Dx1 is the average of the forward and
backward operators, i.e.,
1 Dx+ + Dx−
Dx = .
2
A FD scheme for uxx (xi ): Add the two equations in (1.11) and divide the
resulting equation by h2 .
ui−1 − 2ui + ui+1 uxxxx (xi ) 2
uxx (xi ) = − 2 h
h2 4! (1.16)
uxxxxxx (xi ) 4
−2 h − ··· .
6!
Thus the central second-order FD scheme for uxx at xi reads
ui−1 − 2ui + ui+1
uxx (xi ) ≈ Dx2 ui := . (1.17)
h2
Note that
Dx2 = Dx− Dx+ = Dx+ Dx− . (1.18)
hi = xi − xi−1 , i = 1, 2, · · · , N.
1.2. Finite Differences 11
The Taylor series expansions for ui+1 and ui−1 (about xi ) become
uxx (xi ) 2
(a) ui+1 = ui + ux (xi )hi+1 + hi+1
2!
uxxx (xi ) 3
+ hi+1 + · · · ,
3! (1.19)
uxx (xi ) 2
(b) ui−1 = ui − ux (xi )hi + hi
2!
uxxx (xi ) 3
− hi + · · · .
3!
which correspond to (1.11).
12 CHAPTER 1. MATHEMATICAL PRELIMINARIES
where
ai−2,k = u[xi−2 , xi−1 , · · · , xi−2+k ], k = 0, · · · , 4.
Then it follows from the Interpolation Error Theorem (1.9) that
ux (xi ) = p0i−2,4 (xi )
u(5) (ξ)
+ (xi − xi−2 )(xi − xi−1 )(xi − xi+1 )(xi − xi+2 ).
5!
Therefore, under the assumption that u(5) (x) exists, p0i−2,4 (xi ) approximates
ux (xi ) with a fourth-order truncation error.
1.2. Finite Differences 15
A higher-order FD scheme for uxx can be obtained from the twice differen-
tiation of pi−2,4 in (1.23):
uxx (xi ) ≈ p00i−2,4 (xi ), (1.25)
which is a third-order approximation and becomes fourth-order for uniform
grids.
Note: To make the heat equation well-posed (existence, uniqueness, and sta-
bility), we have to supply an initial condition and appropriate boundary con-
ditions on the both ends of the rod.
1.3. Overview of PDEs 17
Hyperbolic Equations
The second-order hyperbolic differential equation
1
utt − uxx = f (x, t), x ∈ (0, L) (1.29)
v2
is often called the wave equation. The coefficient v is the wave velocity, while
f represents a source. The equation can be used to describe the vibration of a
flexible string, for which u denotes the displacement of the string.
In higher dimensions, the wave equation can be formulated similarly.
Elliptic Equations
The second-order elliptic equations are obtained as the steady-state solu-
tions (as t → ∞) of the parabolic and hyperbolic equations. For example,
−∇ · (K∇u) = f, x ∈ Ω
(1.30)
u(x) = g(x), x ∈ Γ
represents a steady-state heat distribution for the given heat source f and the
boundary condition g.
1.3. Overview of PDEs 19
Fluid Mechanics
The 2D Navier-Stokes (NS) equations for viscous incompressible fluid flows:
Momentum equations
ut + px − R1 ∆u + (u2 )x + (uv)y = g1
vt + py − R1 ∆v + (uv)x + (v 2 )y = g2 (1.31)
Continuity equation
ux + vy = 0
Here (u, v) denote the velocity fields in (x, y)-directions, respectively, p is the
pressure, R is the (dimensionless) Reynolds number, and (g1 , g2 ) are body
forces. See e.g. [23] for computational methods for fluid dynamics.
20 CHAPTER 1. MATHEMATICAL PRELIMINARIES
Finance Modeling
In option pricing, the most popular model is the Black-Scholes (BS) differ-
ential equation
1 2 2 ∂ 2u ∂S −
ut + σ S + rS S ru = 0 (1.32)
2 ∂S 2 ∂u
Here
Image Processing
• Noise model:
f =u+η (1.33)
where f is the observed (noisy) image, u denotes the desired image, and η
is the noise.
• Optimization problem
Minimize the total variation (TV) with the constraint
ˆ
min |∇u|dx subj. tokf − uk2 = σ 2 . (1.34)
u Ω
Remarks:
Solution: Let
yn = α n . (1.38)
and plug it into the first equation of (1.37) to have
which implies
2α2 − 5α + 2 = 0. (1.39)
The last equation is called the characteristic equation of the difference
equation (1.37), of which the two roots are
1
α = 2, .
2
1.4. Difference Equations 25
Then, the difference equation has the general solution of the form as in (1.40):
1 n
n
wn = c1 2 + c2 . (1.44)
2
Using the new initial conditions, we have
c2
w0 = c1 + c2 = 2, w1 = 2 c1 + = 1.01,
2
Thus, the solution becomes
1 n 299 1 n
wn = 2 + . (1.45)
150 150 2
Comparison
y0 = 2 w0 = 2
y1 = 1 w1 = 1.01
.. ..
. .
y10 = 9.7656 × 10−4 w10 = 6.8286
y20 = 9.5367 × 10−7 w20 = 6.9905 × 103
Stability Theory
Physical Definition: A (FD) scheme is stable if a small change in the initial
conditions produces a small change in the state of the system.
• stable if for every set of initial data, the solution remains bounded as
t → ∞.
• strongly stable if the solution approaches zero as t → ∞.
28 CHAPTER 1. MATHEMATICAL PRELIMINARIES
1.5. Homework
1. For an interval [a, b], let the grid be uniform:
b−a
xi = ih + a; i = 0, 1, · · · , N, h= . (1.46)
N
Second-order schemes for ux and uxx , on the uniform grid given as in
(1.46), respectively read
ui+1 − ui−1
ux (xi ) ≈ Dx1 ui = ,
2h
(1.47)
ui−1 − 2ui + ui+1
uxx (xi ) ≈ Dx2 ui = Dx+ Dx− ui = .
h2
(a) Use Divided Differences to construct the second-order Newton poly-
nomial p2 (x) which passes (xi−1 , ui−1 ), (xi , ui ), and (xi+1 , ui+1 ).
(b) Evaluate p02 (xi ) and p002 (xi ) to compare with the FD schemes in (1.47).
2. Find the general solution of each of the following difference equations:
(a) yn+1 = 3yn
(b) yn+1 = 3yn + 2
(c) yn+2 − 8yn+1 + 12yn = 0
(d) yn+2 − 6yn+1 + 9yn = 1
3. Determine, for each of the following difference equations, whether it is
stable or unstable.
(a) yn+2 − 5yn+1 + 6yn = 0
(b) 8yn+2 + 2yn+1 − 3yn = 0
(c) 3yn+2 + yn = 0
(d) 4yn+4 + 5yn+2 + yn = 0
30 CHAPTER 1. MATHEMATICAL PRELIMINARIES
Chapter 2
The first-order initial value problem (IVP) is formulated as follows: find {yi (x) :
i = 1, 2, · · · , M } satisfying
dyi
= fi (x, y1 , y2 , · · · , yM ),
dx i = 1, 2, · · · , M, (2.1)
yi (x0 ) = yi0 ,
31
32 Chapter 2. Numerical Methods for ODEs
In the following, we describe step-by-step methods for (2.2); that is, we start
from y0 = y(x0 ) and proceed stepwise.
For the problem, a continuous approximation to the solution y(x) will not be
obtained; instead, approximations to y will be generated at various points,
called mesh points, in the interval [x0 , T ] for some T > x0 .
Let
0h2 00
y(x + h) = y(x) + hy (x) + y (x) + · · · . (2.4)
2
Letting x = x0 and utilizing y(x0 ) = y0 and y 0 (x0 ) = f (x0 , y0 ), the value y(x1 )
can be approximated by
y1 = y0 + hf (x0 , y0 ), (2.5)
where the second- and higher-order terms of h are ignored.
Such an idea can be applied recursively for the computation of solution on
later subintervals. Indeed, since
h2 00
y(x2 ) = y(x1 ) + hy 0 (x1 ) + y (x1 ) + · · · ,
2
by replacing y(x1 ) and y 0 (x1 ) with y1 and f (x1 , y1 ), respectively, we obtain
y2 = y1 + hf (x1 , y1 ), (2.6)
In general, for n ≥ 0,
Theorem 2.1. Let f satisfy the Lipschitz condition in its second variable,
i.e., there is λ > 0 such that
Here we will prove (2.9) by using (2.11) and induction. It holds trivially when
n = 0. Suppose it holds for n. Then,
ken+1 k ≤ (1 + λh)ken k + Ch2
C
≤ (1 + λh) · h[(1 + λh)n − 1] + Ch2
λ
C
= h[(1 + λh)n+1 − (1 + λh)] + Ch2
λ
C
= h[(1 + λh)n+1 − 1],
λ
which completes the proof.
2.1. Taylor-Series Methods 37
0 h2 00
y(xn+1 ) = y(xn ) + hy (xn ) + y (xn ) + · · ·
2!
m (2.12)
h (m) hm+1 (m+1)
+ y (xn ) + y (ξn ).
m! (m + 1)!
Successive differentiation of the solution, y(x), gives
and generally,
y (k) (x) = f (k−1) (x, y(x)). (2.13)
Thus, we have
h2 0
y(xn+1 ) = y(xn ) + hf (xn , y(xn )) + f (xn , y(xn )) + · · ·
2!
(2.14)
hm (m−1) hm+1 (m)
+ f (xn , y(xn )) + f (ξn , y(ξn ))
m! (m + 1)!
38 Chapter 2. Numerical Methods for ODEs
where
h 0
Tm (xn , yn ) = f (xn , yn ) + f (xn , yn ) + · · ·
2! (2.16)
hm−1 (m−1)
+ f (xn , yn ).
m!
Remarks
• m = 1 ⇒ yn+1 = yn + hf (xn , yn )
which is the Euler method.
h h 0 i
• m = 2 ⇒ yn+1 = yn + h f (xn , yn ) + f (xn , yn )
2
• As m increases, the method achieves higher-order accuracy; however, it
requires to compute derivatives of f (x, y(x)).
2.1. Taylor-Series Methods 39
f 0 (x, y) = y 0 − 3x2 + 1
= (y − x3 + x + 1) − 3x2 + 1
= y − x3 − 3x2 + x + 2
and
f 00 (x, y) = y 0 − 3x2 − 6x + 1
= (y − x3 + x + 1) − 3x2 − 6x + 1
= y − x3 − 3x2 − 5x + 2
Thus
h 0 h2 00
T3 (x, y) = f (x, y) + f (x, y) + f (x, y)
2 6
h
= y − x3 + x + 1 + (y − x3 − 3x2 + x + 2)
2
2
h
+ (y − x3 − 3x2 − 5x + 2)
6
40 Chapter 2. Numerical Methods for ODEs
where
• wj ≥ 0 and w1 + w2 + · · · + wm = 1
• Kj are recursive evaluations of the slope f (x, y)
• Need to determine wj and other parameters to satisfy
0 h2 00
y(x + h) = y(x) + hy (x) + y (x) + O(h3 ).
2
Since y 0 = f and y 00 = fx + fy y 0 = fx + fy f ,
h2
y(x + h) = y(x) + hf + (fx + fy f ) + O(h3 ). (2.21)
2
42 Chapter 2. Numerical Methods for ODEs
which reads
y + h(w1 K1 + w2 K2 )
(2.22)
= y + (w1 + w2 )hf + h2 (w2 αfx + w2 βfy f ) + O(h3 )
The comparison of (2.21) and (2.22) drives the following result, for the
second-order Runge-Kutta methods.
Results:
1 1
w1 + w2 = 1, w2 α = , w2 β = (2.23)
2 2
2.2. Runge-Kutta Methods 43
Common Choices:
1
I. w1 = w2 = , α=β=1
2
Then, the algorithm becomes
h
yn+1 = yn + (K1 + K2 ) (2.24)
2
where
K1 = f (xn , yn )
K2 = f (xn + h, yn + hK1 )
This algorithm is the second-order Runge-Kutta (RK2) method, which
is also known as the Heun’s method.
1
II. w1 = 0, w2 = 1, α = β =
2
For the choices, the algorithm reads
h h
yn+1 = yn + hf xn + , yn + f (xn , yn ) (2.25)
2 2
where
K1 = f (xn , yn )
K2 = f (xn + α1 h, yn + β1 hK1 )
K3 = f (xn + α2 h, yn + β2 hK1 + β3 hK2 )
K4 = f (xn + α3 h, yn + β4 hK1 + β5 hK2 + β6 hK3 )
Requirement: Determine wj , αj , βj such that
w1 K1 + w2 K2 + w3 K3 + w4 K4 = T4 (xn , yn ) + O(h4 )
2.2. Runge-Kutta Methods 45
The most common choice: The most commonly used set of parameter val-
ues yields
h
yn+1 = yn + (K1 + 2K2 + 2K3 + K4 ) (2.27)
6
where
K1 = f (xn , yn )
1 1
K2 = f (xn + h, yn + hK1 )
2 2
1 1
K3 = f (xn + h, yn + hK2 )
2 2
K4 = f (xn + h, yn + hK3 )
The local truncation error for the above RK4 can be derived as
h5 (5)
y (ξn ) (2.28)
5!
for some ξn ∈ [xn , xn+1 ]. Thus the global error becomes
(T − x0 )h4 (5)
y (ξ) (2.29)
5!
for some ξ ∈ [x0 , T ]
46 Chapter 2. Numerical Methods for ODEs
where m is the mass attached at the end of a spring of the spring constant
κ, the term F0 cos(µt) is a periodic driving force of frequency µ, and c0 is the
initial displacement from the equilibrium position.
Accuracy comparison
Table 2.1 presents the `2 -error at t = 1 for various time step sizes h, defined
as
2 h 2 1/2
|ynht h
− y(1)| = y1,nt − y1 (1) + y2,nt − y2 (1) ,
where ynht denotes the computed solution at the nt -th time step with h = 1/nt .
as
log(E(2h)/E(h))
α := ,
log 2
where E(h) and E(2h) denote the errors obtained with the grid spacing to
be h and 2h, respectively.
• As one can see from the table, the one-step methods exhibit the expected
accuracy.
• RK4 shows a much better accuracy than the lower-order methods, which
explains its popularity.
50 Chapter 2. Numerical Methods for ODEs
Numerical Methods:
Remarks
Let u = y 0 . Then,
u0 = y 00 = f (x, y, y 0 ) = f (x, y, u)
Notes:
2.6. Homework
1. For the IVP in (2.17),
(a) Find T4 (x, y).
(b) Perform two steps of the 3rd and 4th-order Taylor methods, with h =
1/2, to find an approximate solutions of y at x = 1.
(c) Compare the errors, given that the exact solution
7
y(x) = 4 + 5x + 3x2 + x3 − ex
2
2. Derive the global error of RK4 in (2.29), given the local truncation error
(2.28).
3. Write the following DE as a system of first-order differential equations.
x00 + x0 y − 2y 00 = t,
−2y + y 00 + x = e−t ,
55
56 Chapter 3. Properties of Numerical Methods
where f is a heat source, Γ denotes the boundary of Ω, i.e., Γ = {0, 1}, and u0
is the prescribed initial value of the solution at t = 0.
3.1. A Model Problem: Heat Conduction in 1D 57
Let
S n := Ω × (tn−1 , tn ] (3.2)
be the nth space-time slice. Suppose that the computation has been performed
for uk = {ukj }, 0 ≤ k ≤ n − 1. Then, the task is to compute un by integrating the
equation on the space-time slice S n , utilizing FD schemes.
n
unj−1 − 2unj + unj+1
uxx (xj , t ) =
∆x2 (3.4)
uxxxx (xj , tn ) 2
−2 ∆x + O(∆x4 ).
4!
For the temporal direction, one can also apply a difference formula for the
approximation of the time-derivative ut . Depending on the way of combining
the spatial and temporal differences, the resulting scheme can behave quite
differently.
3.1. A Model Problem: Heat Conduction in 1D 59
Explicit Scheme
The following presents the simplest scheme:
n−1
vjn − vjn−1 vj−1 − 2vjn−1 + vj+1
n−1
− 2 = fjn−1 (3.5)
∆t ∆x
which is an explicit scheme for (3.1), called the forward Euler method.
Here vjn is an approximation of unj .
where
∆t
µ=
∆x2
60 Chapter 3. Properties of Numerical Methods
3.2. Consistency
The bottom line for an accurate numerical method is that the discretization
becomes exact as the grid spacing tends to zero, which is the basis of consis-
tency.
n−1
φij − φn−1
j
φt (xj , t ) =
∆t (3.7)
φtt (xj , tn−1 )
− ∆t + O(∆t2 ).
2!
It follows from (3.4) and (3.7) that the truncation error of the forward Euler
scheme evaluated at (xj , tn−1 ) becomes
Truncation Error
Definition 3.3. Let u be smooth and
Then, Tunj is called the truncation error of the FD scheme P∆x,∆t v = f eval-
uated at (xj , tn ).
It follows from (3.8) that the truncation error of the forward Euler scheme
(3.5) is
O(∆t + ∆x2 )
for all grid points (xj , tn ).
3.3. Convergence 63
3.3. Convergence
A numerical method is said to be convergent if the solution of the FD scheme
tends to the exact solution of the PDE as the grid spacing tends to zero. We
define convergence in a formal way as follows:
∆t 1
µ= ≤ . (3.10)
∆x2 2
P∆x,∆t un−1
j + Tun−1
j = fjn−1 (3.13)
+∆t |T un−1
j |
≤ µ E n−1 + (1 − 2µ) E n−1 + µ E n−1 (3.16)
+∆t T n−1
= E n−1 + ∆t T n−1 .
and therefore
E n ≤ E n−1 + ∆t T n−1
≤ E n−2 + ∆t T n−1 + ∆t T n−2
≤ ··· (3.18)
n−1
X
0
≤ E + ∆t T k .
k=1
Since E 0 = 0,
E n ≤ (n − 1)∆t Tb ≤ T Tb , (3.19)
where T is the upper bound of the time available. Since Tb = O(∆t + ∆x2 ), the
maximum norm of the error approaches zero as (∆x, ∆t) → 0.
66 Chapter 3. Properties of Numerical Methods
Remarks
• The assumption µ ≤ 1/2 makes coefficients in the forward Euler scheme
n−1 n−1 n−1
(3.6) nonnegative, which in turn makes vjn a weighted average of {vj−1 , vj , vj+1 }.
• The analysis can often conclude
E n = O(Tb ), ∀ n
An Example: µ ≤ 1/2
The problem:
ut − α2 uxx = 0, (x, t) ∈ [0, 1] × [0, 1],
u = 0, (x, t) ∈ {0, 1} × [0, 1], (3.20)
u = sin(πx), x ∈ [0, 1], t = 0,
The exact solution:
2
u(x, t) = e−π t sin(πx)
68 Chapter 3. Properties of Numerical Methods
Parameter setting:
a := 0; b := 1; T := 1; α := 1; f := 0;
nx := 10;
Numerical results:
nt := 200 (µ = 1/2) kunt − v nt k∞ = 7.94 × 10−6
nt := 170 (µ ≈ 0.588) kunt − v nt k∞ = 1.31 × 109
• For the case µ ≈ 0.588, the numerical solution becomes oscillatory and
blows up.
3.4. Stability 69
3.4. Stability
The example with Figure 3.1 shows that consistency of a numerical method is
not enough to guarantee convergence of its solution to the exact solution. In
order for a consistent numerical scheme to be convergent, a required property
is stability. Note that if a scheme is convergent, it produces a bounded solution
whenever the exact solution is bounded. This is the basis of stability. We first
define the L2 -norm of grid function v:
X 1/2
2
kvk∆x = ∆x |vj | .
j
(1 + C∆t)n = (1 + CT /nt )n
≤ (1 + CT /nt )nt
h iCT
nt /CT
= (1 + CT /nt )
≤ eCT ,
• Parseval’s identity
kφn k∆x = kφbn k∆x , (3.26)
where ∞
X 1/2
n 2
kφ k∆x = |φj | ∆x ,
j=−∞
ˆ π/∆x 1/2
bn
kφ k∆x = |φ(ξ)|
b 2
dξ
−π/∆x
Example
To show how one can use the above analysis, we exemplify the forward Euler
scheme (3.6), with f = 0:
vjn = µ vj−1
n−1
+ (1 − 2µ) vjn−1 + µ vj+1
n−1
(3.28)
• Letting ϑ = ∆xξ, we define the amplification factor for the scheme (3.6)
by
g(ϑ) = µ e−i∆xξ + (1 − 2µ) + µ ei∆xξ
= µ e−iϑ + (1 − 2µ) + µ eiϑ
(3.32)
= (1 − 2µ) + 2µ cos(ϑ)
= 1 − 2µ(1 − cos(ϑ)) = 1 − 4µ sin2 (ϑ/2)
• Equation (3.31) can be rewritten as
vbn (ξ) = g(ϑ) vbn−1 (ξ) = g(ϑ)2 vbn−2 (ξ) = · · · = g(ϑ)n vb0 (ξ). (3.33)
Therefore, when g(ϑ)n is suitably bounded, the scheme is stable. In fact,
g(ϑ)n would be uniformly bounded only if |g(ϑ)| ≤ 1 + C∆t.
74 Chapter 3. Properties of Numerical Methods
only if
0 ≤ µ ≤ 1/2 (3.34)
which is the stability condition of the scheme (3.6).
3.4. Stability 75
A simpler and equivalent procedure of the von Neumann analysis can be sum-
marized as follows:
vjn = µ vj−1
n−1
+ (1 − 2µ) vjn−1 + µ vj+1
n−1
a∆t 2
2
+(b∆t) + sin(ϑ)
∆x
Hence, under the condition 0 < µ = ∆t/∆x2 ≤ 1/2,
2 |a|2
2
|g(ϑ)| ≤ 1 + 2|b|∆t + (b∆t) + ∆t
2 2 (3.38)
≤ 1 + (|b| + |a|2 /4) ∆t .
Thus, lower-order terms do not change the stability condition. (Homework for
details.)
3.5. Boundedness – Maximum Principle 77
In the absence of sources and sinks, some variables are required to have
maximum and minimum values on the boundary of the domain. The above
property is call the maximum principle, which should be inherited by the
numerical approximation.
78 Chapter 3. Properties of Numerical Methods
• The second condition imposes no limit on the time step. But it gives a
relation between convection and diffusion coefficients.
3.6. Conservation
When the equations to be solved are from conservation laws, the numerical
scheme should respect these laws both locally and globally. This means that
the amount of a conserved quantity leaving a control volume is equal to the
amount entering to adjacent control volumes.
If divergence form of equations and a finite volume method is used, this
is readily guaranteed for each individual control volume and for the solution
domain as a whole.
For other discretization methods, conservation can be achieved if care is
taken in the choice of approximations. Sources and sinks should be carefully
treated so that the net flux for each individual control volume is conservative.
Conservation is a very important property of numerical schemes. Once
conservation of mass, momentum, and energy is guaranteed, the error of con-
servative schemes is only due to an improper distribution of these quantities
over the solution domain.
Non-conservative schemes can produce artificial sources or sinks, changing
the balance locally or globally. However, non-conservative schemes can be
consistent and stable and therefore lead to correct solutions in the limit of
mesh refinement; error due to non-conservation is appreciable in most cases
only when the mesh is not fine enough.
The problem is that it is difficult to know on which mesh the non-conservation
error is small enough. Conservative schemes are thus preferred.
3.7. A Central-Time Scheme 81
To study its stability, we set f ≡ 0 and substitute vjn = g n eijϑ into (3.43) to
obtain
g − 1/g e−iϑ − 2 + eiϑ
− = 0,
2∆t ∆x2
or
g 2 + (8µ sin2 (ϑ/2))g − 1 = 0. (3.45)
We see that (3.45) has two distinct real roots g1 and g2 which should satisfy
g1 · g2 = −1. (3.46)
Hence the magnitude of one root must be greater than one, for some modes
and for all µ > 0, for which we say that the scheme is unconditionally un-
stable.
This example warns us that we need be careful when developing a FD
scheme. We cannot simply put combinations of difference approximations to-
gether.
82 Chapter 3. Properties of Numerical Methods
(I + θ∆tA1 )v n
(3.48)
= [I − (1 − θ)∆tA1 ]v n−1 + ∆tf n−1+θ .
n−1
(3.52)
= (1 − θ)µ vj−1 + [1 − 2(1 − θ)µ]vjn−1 + (1 − θ)µ vj+1
n−1
,
where µ = ∆t/∆x2 .
For an stability analysis for this one-parameter family of systems by uti-
lizing the von Neumann analysis in §3.4.2, substitute g n eijϑ for vjn in (3.52) to
have
g −θµ e−iϑ + (1 + 2θµ) − θµ eiϑ
or
ϑ 1
(1 − 2θ)µ sin2 ≤ .
2 2
Thus the θ-method (3.48) is stable if
1
(1 − 2θ)µ ≤ . (3.54)
2
In conclusion:
`
h uxxxx 2 uxxxxxx 4 i`
A1 uj = − uxx + ∆x + 2 ∆x + · · · , ` = n − 1, n.
12 6! j
We now expand each term in the right side of the above equation in powers
of ∆t, about (xj , tn−1/2 ), to have
(n− 12 )± 12
h uxxxx 2 uxxxxxx 4 in−1/2
A1 uj = − uxx + ∆x + 2 ∆x + · · ·
12 6! j
∆t h uxxxxt 2 uxxxxxxt 4 in−1/2
∓ uxxt + ∆x + 2 ∆x + · · · (3.57)
2 12 6! j
1 ∆t 2 h uxxxxtt 2 in−1/2
− uxxtt + ∆x + · · · − ··· .
2 2 12 j
Note that the second choice of θ in (3.60) is less than 1/2, which is equivalent
to
∆t 1
2 = .
∆x 6(1 − 2θ)
Hence it satisfies (3.55); the method is stable and we can take large time steps
while maintaining accuracy and stability. For example, when ∆x = ∆t = 0.01,
we have θ = 21 − 1200
1
for the (2, 4)-accuracy scheme in time-space.
3.8. The θ-Method 87
Under the hypotheses of the theorem all coefficients in the right side of the
above equation are nonnegative and sum to (1 + 2θµ). Hence this leads to
the conclusion that the interior point (xj , tn ) can have a local maximum or
minimum only if all five neighboring points, related to the right side of (3.62),
have the same maximum or minimum value. The argument then implies that
v has the same value at all grid points including those on the boundary. This
completes the proof.
3.8. The θ-Method 89
n−1/2
where T uj is the truncation error at (xj , tn−1/2 ) defined in (3.59).
1
Theorem 3.10. Let θ ∈ [0, 1] and (1 − θ)µ ≤ 2 for the θ-method. Then,
n
X
n
E ≤ ∆t T k−1/2 . (3.63)
k=1
3.9. Homework
1. The energy method can be utilized to prove stability of the forward Euler
scheme for ut − uxx = 0:
vjn = µ vj−1
n−1
+ (1 − 2µ) vjn−1 + µ vj+1
n−1
(3.65)
The analysis requires you to prove
kv n k2∆x ≤ (1 + C∆t)2 kv n−1 k2∆x , (3.66)
for some C ≥ 0. Prove it, assuming 1 − 2µ ≥ 0 and using the following
hint
• Start with squaring (3.65).
a2 + b 2
• Apply the inequality |ab| ≤ .
2
• Use the observation
X X X
n−1 2 n−1 2 n−1 2
|vj−1 | = |vj | = |vj+1 |
j j j
This chapter introduces finite difference methods for elliptic PDEs defined on
1-dimensional (1D), 2-dimensional (2D), or 3-dimensional (3D) regions.
91
92 Chapter 4. Finite Difference Methods for Elliptic Equations
(a) −∇ · (a∇u) + cu = f, x ∈ Ω
(4.1)
(b) auν + βu = g, x ∈ Γ,
To explain the main feature of the central FD method, we may start with
the problem (4.1) with the constant diffusivity, i.e., a = 1.
4.1. Finite Difference (FD) Methods 93
However, we will meet ghost grid values at the end points. For example, at
the point ax = x0 , the formula becomes
Here the value u−1 is not defined and we call it a ghost grid value.
Now, let’s replace the value by using the boundary condition (4.3.b). Recall
the central FD scheme (1.15) for ux at x0 :
u1 − u−1 uxxx (x0 ) 2
ux (x0 ) ≈ , Trunc.Err = − hx + · · · . (4.7)
2hx 6
Thus he equation (4.3.b) can be approximated (at x0 )
The same can be considered for the algebraic equation at the point xn .
4.1. Finite Difference (FD) Methods 95
A1 u1 = b1 , (4.10)
where
2 + h2x c + 2hx β
−2
−1 2 + h2x c −1
... ... ...
A1 = ,
−1 2 + h2x c −1
2
−2 2 + hx c + 2hx β
and
h2x f0 2hx g0
h2x f1 0
.. ..
b1 = . + . .
2
hx fnx −1 0
h2x fnx 2hx gnx
Such a technique of removing ghost grid values is called outer bordering.
We can use it for the 2D problem (4.2) along the boundary grid points.
Notes
• The y-directional approximation can be done in the same fashion.
• The reader should also notice that the quantities ai+1/2 evaluated at mid-
points are not available in general.
• We may replace it by the arithmetic/harmonic average of ai and ai+1 :
−1
ai + ai+1 1 1 1
ai+1/2 ≈ or + . (4.15)
2 2 ai ai+1
• The harmonic average is preferred; the resulting system holds the con-
servation property. See §5.7.
98 Chapter 4. Finite Difference Methods for Elliptic Equations
−∇ · (A(x)∇u) + b · ∇u + cu = f, x ∈ Ω ⊂ Rd , (4.16)
where 1 ≤ d ≤ 3 and
X ∂ ∂u
−∇ · (A(x)∇u) = − aij (x) .
i,j
∂x i ∂x j
−∆u = f, x ∈ Ω,
(4.18)
u = g, x ∈ Γ,
∂2 ∂2 ∂2 ∂2
∆=∇·∇= + = + .
∂x2 ∂y 2 ∂x21 ∂x22
4.1. Finite Difference (FD) Methods 99
where Ωh and Γh are the sets of grid points on Ω◦ and Γ, respectively. Note
that the exact solution u of (4.18) satisfies
Thus it follows from (4.20) and (4.21) that for some C > 0 independent of h,
where k · k∞,Ωh denotes the maximum norm measured on the grid points Ωh .
4.1. Finite Difference (FD) Methods 101
fh := −∆h vh , x ∈ Ωh .
Then obviously
(a) kfh k∞,Ωh = k∆h vh k∞,Ωh ,
(4.24)
(b) −kfh k∞,Ωh ≤ −∆h vh ≤ kfh k∞,Ωh .
Let x
b = (x̂, ŷ) be the centroid of Ω and consider
1 1
b|2 = (x − x̂)2 + (y − ŷ)2 ,
wh (x) = |x − x x ∈ Ωh .
4 4
Then wh has its maximum on the boundary, bounded by a constant C > 0
independent on h, and
−∆h wh = −1, x ∈ Ωh .
So from (4.24.b) we have
and therefore from the discrete maximum principle for subharmonic func-
tions, Theorem B.7 on page 363,
Since wh ≥ 0,
vh ≤ C kfh k∞,Ωh . (4.25)
The argument in the proof can be applied for the same conclusion, when vh is
replaced by −vh . Thus, (4.23) follows from (4.24.a) and (4.25).
102 Chapter 4. Finite Difference Methods for Elliptic Equations
Theorem 4.3. Let u and uh be the solutions of (4.27) and (4.28), respectively.
Assume h is sufficiently small for the case b 6= 0. Then
−∆u = f, x ∈ Ω,
(4.32)
u = g, x ∈ Γ.
Then, when the grid points are ordered row-wise, the algebraic system for
the FDM reads
Au = b, (4.34)
where
B −I/h2y 0
−I/h2 B −I/hy2
y
A=
. .. ... ...
(4.35)
−I/h2y −I/h2y
B
0 −I/h2y B
with I being the identity matrix of dimension nx − 1 and B being a matrix of
order nx − 1 given by
d −1/h2x 0
−1/h2 d −1/h2x
x
B=
. . . . . . . . .
(4.36)
2 2
−1/hx −1/hx
d
0 −1/h2x d
2 2
where d = + .
h2x h2y
On the other hand,
gp−1,q gp+1,q
bpq = fpq + δp−1,0 + δp+1,nx
h2x h2x
gp,q−1 gp,q+1 (4.37)
+ 2 δq−1,0 + δq+1,ny
hy h2y
Here, the global point index for the row-wise ordering of the interior points,
i = 0, 1, 2, · · · , becomes
i = (q − 1) ∗ (nx − 1) + p − 1 (4.38)
4.1. Finite Difference (FD) Methods 107
Ax = b, (4.41)
L = [lij ], U = [uij ]
Using the Gauss elimination procedure, A(k+1) and the entries of L can be
determined as
( (k) (k) (k) (k)
(k+1) aij − aik akk akj , for i = k + 1, · · · , n, j = k, · · · , n,
aij = (k)
aij , else, (4.45)
lkk = 1,
(k) (k)
lik = aik akk , i = k + 1, · · · , n.
Then, finally
(n)
U = A(n) = [aij ]. (4.46)
112 Chapter 4. Finite Difference Methods for Elliptic Equations
In the output of the algorithm, the upper part including the main diagonal
becomes U , while its strictly lower part is the corresponding part of L.
Algorithm (4.47) should be modified to incorporate the so-called partial piv-
oting when a pivot akk is expected to be zero or small in modulus.
4.2. Solution of Linear Algebraic Systems 113
The LU factorization with partial pivoting must look like the following:
Fork = 1 to n − 1
amax ← 0 ; imax ← 0 ; /*find pivot*/
For i = k to n
ik | > amax )
if (|a
amax ← |aik | ; imax ← i ;
if (i
max = 0) stop ; /*A is singular*/
if (imax 6= k)
for j = 1 to n
/*row interchange*/
tmp ← akj ;
akj ← aimax ,j ;
(4.48)
aimax ,j ← tmp ;
itmp ← intch[k] ;
/*save interchange*/
intch[k] ← intch[imax ] ;
intch[imax ] ← itmp ;
For i = k + 1 to n /*row operations*/
mi ← aik /akk ;
if mi = 0, continue ;
aik ← mi ;
For j = k + 1 to n
aij ← aij − mi akj ;
b[i] ← b[intch[i]], i = 1, · · · , n
114 Chapter 4. Finite Difference Methods for Elliptic Equations
A = M − N, (4.49)
M x = N x + b. (4.50)
M xk = N xk−1 + b, (4.51)
or, equivalently,
Notes:
M ek = N ek−1
or, equivalently,
ek = M −1 N ek−1 . (4.53)
Since
kek k ≤ kM −1 N k · kek−1 k
≤ kM −1 N k2 · kek−2 k
.. (4.54)
.
≤ kM −1 N kk · ke0 k,
a sufficient condition for the convergence is
kM −1 N k < 1. (4.55)
Let σ(B) be the spectrum, the set of eigenvalues of the matrix B, and ρ(B)
denote the spectral radius defined by
Figure 4.1: The directed paths for nonzero aii and aij .
P1 , P2 , · · · , Pn
Definition 4.7. A directed graph is strongly connected if, for any ordered
pair of nodes (Pi , Pj ), there is a directed path of a finite length
−→ −→ −→
Pi Pk1 , Pk1 Pk2 , · · · , Pkr−1 Pkr =j ,
connecting from Pi to Pj .
The theorems to be presented in this subsection can be found in [68] along
with their proofs.
It is obvious that the matrices obtained from FD/FE methods of the Poisson
equation are strongly connected. Therefore the matrices are irreducible.
120 Chapter 4. Finite Difference Methods for Elliptic Equations
|λ − 2| < 2
Positiveness
Definition 4.10. An n × n complex-valued matrix A = [aij ] is diagonally
dominant if n
X
|aii | ≥ Λi := |aij |, (4.59)
j=1
j 6= i
for all 1 ≤ i ≤ n. An n × n matrix A is irreducibly diagonally dominant if A is
irreducible and diagonally dominant, with strict inequality holding in (4.59)
for at least one i.
−1 ρ(A−1 N )
ρ(M N) = < 1. (4.60)
1 + ρ(A−1 N )
Thus, the matrix M −1 N is convergent and the iterative method of (4.51) con-
verges for any initial value x0 .
Definition 4.16. An n × n real matrix A = [aij ] with aij ≤ 0 for all i 6= j is an
M-matrix if A is nonsingular and A−1 ≥ 0.
Theorem 4.17. Let A = (aij ) be an n × n M -matrix. If M is any n × n matrix
obtained by setting certain off-diagonal entries of A to zero, then A = M − N
is a regular splitting of A and ρ(M −1 N ) < 1.
Theorem 4.18. Let A be an n×n real matrix with A−1 > 0, and A = M1 −N1 =
M2 − N2 be two regular splittings of A. If N2 ≥ N1 ≥ 0, where neither N2 − N1
nor N1 is null, then
A = D − E − F, (4.62)
where
· · · , ann ),
D = diag(a11 , a22 ,
−aij , if i > j,
E = (eij ), eij =
0, else,
−aij , if i < j,
F = (fij ), fij =
0, else.
4.2. Solution of Linear Algebraic Systems 123
Jacobi method
It is formulated as
Dxk = (E + F )xk−1 + b, (4.64)
which is the same as choosing
M = D, N =E+F
or, equivalently,
i−1
X n
X .
xki = bi − aij xjk−1 − aij xk−1
j aii , (4.65)
j=1 j=i+1
for i = 1, · · · , n.
4.2. Solution of Linear Algebraic Systems 125
Gauss-Seidel method
For the choice
M = D − E, N = F,
we obtain the Gauss-Seidel method:
which is equivalent to
i−1
X n
X .
xki = bi − k
aij xj − k−1
aij xj aii , i = 1, · · · , n. (4.67)
j=1 j=i+1
Note:
• The difference of the Gauss-Seidel method (4.67) out of the Jacobi method
(4.65) is to utilize the updated values xkj , j = 1, · · · , i − 1.s
• It makes the method converge or diverge twice faster asymptotically.
126 Chapter 4. Finite Difference Methods for Elliptic Equations
for i = 1, · · · , n. Note that SOR turns out to be the Gauss-Seidel method when
ω = 1.
4.2. Solution of Linear Algebraic Systems 127
Theorem 4.19. (Stein and Rosenberg [62]) On and only one of the follow-
ing mutually exclusive relations is valid:
1. ρ(B) = ρ(L1 ) = 0,
2. 0 < ρ(L1 ) < ρ(B) < 1,
(4.70)
3. ρ(B) = ρ(L1 ) = 1,
4. 1 < ρ(B) < ρ(L1 ).
Thus the Jacobi and Gauss-Seidel methods are either both convergent or both
divergent.
Theorem 4.20. (Ostrowski [55]) Let A = D − E − E ∗ be an n × n Hermitian
matrix, where D is Hermitian and positive definite and D − ωE is nonsingular
for 0 ≤ ω ≤ 2. Then,
Note that the matrices D and E in Ostrowski’s theorem need not to be diago-
nal and strictly lower triangular matrices.
128 Chapter 4. Finite Difference Methods for Elliptic Equations
However, in most cases you can find a better parameter for a given algebraic
system.
4.2. Solution of Linear Algebraic Systems 129
Then, for the column-wise point ordering, the algebraic system for the FDM
reads
Au = b, (4.75)
where
C −I/h2x 0
−I/h2 C −I/h2x
x
A=
... ... ...
(4.76)
−I/h2x −I/h2x
C
0 −I/h2x C
with I being the identity matrix of dimension ny − 1 and C being a matrix of
order nx − 1 given by
d −1/h2y 0
−1/h2 d −1/h2y
y
C=
. . . . . . . . .
(4.77)
2 2
−1/hy −1/hy
d
0 −1/h2y d
2 2
where d = + .
h2x h2y
The following table includes the spectral radii of iteration matrices ρ(T ) and
the required iteration counts k for the convergence to satisfy the tolerance
kek k ke0 k < 10−6 .
Ax = b, (4.78)
f 0 (η) = Aη − b, f 00 (η) = A.
So,
rk · pk
αk = . (4.83)
pk · Apk
Convergence of the steepest descent method: For the method, the fol-
lowing is known
k
1
k x − xk k2 ≤ 1 − k x − x0 k2 . (4.84)
κ(A)
Thus, the number of iterations required to reduce the error by a factor of ε is
in the order of the condition number of A:
1
k ≥ κ(A) log . (4.85)
ε
span{p0 , · · · , pm } = span{r0 , · · · , rm }
(4.88)
= span{r0 , Ar0 , · · · , Am r0 }.
Theorem 4.23. The search directions and the residuals satisfy the orthogo-
nality,
pi · Apj = 0; ri · rj = 0, i 6= j. (4.89)
κ(A) − 1 k
p
k x − xk kA ≤ 2 p k x − x0 kA . (4.90)
κ(A) + 1
So the required iteration number to reduce the error by a factor of ε is
1p 2
k≥ κ(A) log . (4.91)
2 ε
Proofs of the above theorems can be found in e.g. [32].
4.3. Krylov Subspace Methods 137
M ≈A
and it is easy to invert, we may try to apply the CG algorithm to the following
system
M −1 Ax = M −1 b. (4.93)
Since
κ(M −1 A) κ(A) (4.94)
(hopefully, κ(M −1 A) ≈ 1), the CG algorithm will converge much faster.
4.3. Krylov Subspace Methods 139
M = LI UI = A + N, (4.97)
where LI and UI are respectively the lower and upper triangular components
of the ILU factorization of A, where the entries of the main diagonal of UI are
all one.
The iteration corresponding to the splitting (4.97) is formulated as
LI UI xk = N xk−1 + b, (4.98)
or, since N = LI UI − A,
(a) rk−1 = b − Axk−1 ,
(b) LI UI δ k = rk−1 , (4.99)
(c) xk = xk−1 + δ k .
MS`,m = L`,m
S ,
`,m
MSE = L`,m
S UE
`,m−1
,
`,m
MW = L`,m
W ,
MC`,m = L`,m
S UN
`,m−1
+ L`,m
W UE
`−1,m
+ L`,m
C , (4.100)
ME`,m = L`,m `,m
C UE ,
MN`,m `,m `−1,m
W = LW UN ,
MN`,m = L`,m `,m
C UN .
142 Chapter 4. Finite Difference Methods for Elliptic Equations
NS`,m = −αMSE
`,m
= −αL`,m
S UE
`,m−1
,
`,m
NW = −αMN`,m `,m `−1,m
W = −αLW UN ,
NC`,m = α(MSE
`,m
+ MN`,m `,m `,m−1
W ) = α(LS UE + L`,m
W UN
`−1,m
), (4.104)
NE`,m = −αMSE
`,m
= −αL`,m
S UE
`,m−1
,
NN`,m = −αMN`,m `,m `−1,m
W = −αLW UN .
4.4. Other Iterative Methods 143
Now, utilizing M = A + N , (4.100), and (4.104), one can obtain Stone’s SIP
[63]:
L`,m
S = A`,m
S /(1 + αUE
`,m−1
),
L`,m
W = A`,m `−1,m
W /(1 + αUN ),
L`,m
C = A`,m `,m `,m−1
C + α(LS UE + L`,m
W UN
`−1,m
)
(4.105)
−L`,m
S UN
`,m−1
− L`,m
W UE
`−1,m
,
UE`,m = (A`,m `,m `,m−1
E − αLS UE )/L`,m
C ,
UN`,m = (A`,m `,m `−1,m
N − αLW UN )/L`,m
C .
Figure 4.4: Contour plots of computed solution with n = 40 (left) and the
10000-times magnified error (right)
#=======================================================
# Elliptic_2D.py
# This module solves, by the 2nd-order FD method & SOR
# -(u_xx+u_yy)=f, (x,y) in (ax,bx)x(ay,by)
# u=g, (x,y) on its boundary
# Supporting functions are built in "util_ellip2D.py"
#=======================================================
from util_ellip2D import *
##----------------------
## User Input
##----------------------
ax,bx = 0., 1.
ay,by = 0., 1.
nx= 40; ny=nx
itmax = 1000
tol = 1.e-6
omega = 1.8
level = 2
##----------------------
## End of "User Input"
##----------------------
## Checking error
if level:
print " Max-error=%g" % (error8(U,X,level))
##===================================================
## util_ellip2D.py
##===================================================
import numpy as np
from numpy import abs,sqrt,pi,sin,cos
import matplotlib.pyplot as plt
from matplotlib.mlab import griddata
from copy import deepcopy
def coeff_matrix(ax,bx,ay,by,nx,ny,level=0):
matA = np.ndarray((ny+1,nx+1,5),float)
hx,hy= (bx-ax)/nx, (by-ay)/ny
for p in range(0,nx+1):
matA[0][p]=[0,0,1,0,0]; matA[ny][p]=[0,0,1,0,0]
for q in range(0,ny+1):
matA[q][0]=[0,0,1,0,0]; matA[q][nx]=[0,0,1,0,0]
rx,ry = 1./hx**2, 1./hy**2
d = 2*(rx+ry)
for q in range(1,ny):
for p in range(1,nx):
matA[q][p][0] = -ry
matA[q][p][1] = -rx
matA[q][p][2] = d
matA[q][p][3] = -rx
matA[q][p][4] = -ry
return matA
148 Chapter 4. Finite Difference Methods for Elliptic Equations
def get_rhs(ax,bx,ay,by,nx,ny,level=0):
vec_b = np.ndarray((ny+1,nx+1),float)
hx,hy = (bx-ax)/nx, (by-ay)/ny
for q in range(0,ny+1):
y = ay+q*hy
for p in range(0,nx+1):
x = ax+p*hx
vec_b[q][p] = funct_f(x,y)
return vec_b
def get_exact_sol(ax,bx,ay,by,nx,ny,level=0):
vec_u = np.ndarray((ny+1,nx+1),float)
hx,hy = (bx-ax)/nx, (by-ay)/ny
for q in range(0,ny+1):
y = ay+q*hy
for p in range(0,nx+1):
x = ax+p*hx
vec_u[q][p] = funct_u(x,y)
return vec_u
def funct_f(x,y):
return 2*pi**2*sin(pi*x)*sin(pi*y)
def funct_u(x,y):
return sin(pi*x)*sin(pi*y)
def contourplot(XX,ax,bx,ay,by,title,level=0):
ny,nx = len(XX),len(XX[0])
xi = np.linspace(ax,bx,nx)
yi = np.linspace(ay,by,ny)
X,Y= np.meshgrid(xi, yi)
Z = griddata(X.ravel(),Y.ravel(),XX.ravel(),xi,yi)
CS = plt.contour(X, Y, Z, linewidths=2,colors='k')
plt.clabel(CS, inline=2, fmt='%1.1f', fontsize=12)
plt.title(title)
4.5. Numerical Examples with Python 149
plt.show()
def init_X(U,level=0):
X = deepcopy(U)
ny,nx = len(U),len(U[0])
for q in range(1,ny-1):
for p in range(1,nx-1):
X[q][p] = 0.
return X
def sol_SOR(A,X,b,omega,tol,itmax,level=0):
ny,nx = len(X),len(X[0])
for it in range(0,itmax):
err=0.
for j in range(1,ny-1):
for i in range(1,nx-1):
gs =( b[j][i]-(A[j][i][0]*X[j-1][i]\
+A[j][i][1]*X[j][i-1]\
+A[j][i][3]*X[j][i+1]\
+A[j][i][4]*X[j+1][i]) )\
/ A[j][i][2]
xnew = (1.-omega)*X[j][i]+omega*gs
err = max(err, abs(X[j][i]-xnew))
X[j][i] = xnew
if err<tol:
if level>=1:
print "sol_SOR: converged it= %d" %(it+1)
break
def error8(X,Y,level=0):
ny,nx = len(X),len(X[0])
err8=0.
for q in range(0,ny):
for p in range(0,nx):
err8=max(err8,abs(X[q][p]-Y[q][p]))
return err8
150 Chapter 4. Finite Difference Methods for Elliptic Equations
4.6. Homework
1. Verify that the overall truncation error for the FD scheme (4.14) is second-
order in hx . Hint: Define
uxxx (x) hx 2
K(x) = a(x) + ··· ,
3! 2
for the truncation errors appeared in (4.13). Then the truncation error for
the approximation of (aux )i+1/2 − (aux )i−1/2 becomes K(xi+1/2 ) − K(xi−1/2 ) =
hx K 0 (xi ) + · · · .
2. Implement a code to solve
(
−(uux )x = 0, x ∈ (0, 2),
(4.108)
u(0) = gL , u(2) = gR ,
(b) Estimate the convergence rate by running different mesh sizes, for
example, n = 10, 20, 40, 80.
(c) Visualize computed solutions with 3D mesh/surface plots in Python.
7. (Optional) Let A = (aij ) be a nonsingular square matrix, obtained from
a FD/FE approximation of an elliptic problem of the form
−∇ · (a(x)∇u) + b(x) · ∇u + c(x)u = f (x), x ∈ Ω,
(4.116)
α(x)uν + β(x)u = g(x), x ∈ Γ,
Au ≤ 0 (Au ≥ 0).
This chapter consideres finite element and finite volume methods for elliptic
PDEs defined on 1D and 2D regions.
153
154 Chapter 5. Finite Element Methods for Elliptic Equations
Claim 5.1. The problem (D) is equivalent to the problem (V), when solutions
are sufficiently smooth.
Proof. ((D) ⇒ (V)): Clear.
((D) ⇐ (V)): Let u be a solution of (V). Then,
Minimization problem:
Define a functional F : V → R as
1
F (v) = (v 0 , v 0 ) − (f, v), v ∈ V. (5.7)
2
which reads
(u01 − u02 , v 0 ) = 0, ∀ v ∈ V.
Thus, by choosing v = (u1 − u2 ), we reach at
ˆ
(u01 − u02 )2 dx = 0,
I
In summary:
hj = xj − xj−1 , Ij = [xj−1 , xj ], j = 1, 2, · · · , M + 1
and
h= max hj .
1≤j≤M +1
Notes:
ϕj (x) = −1 (5.13)
(x − xj+1 ), x ∈ [xj , xj+1 ],
hj+1
0, elsewhere.
Notes:
ηj = v(xj ), j = 1, 2, · · · , M.
162 Chapter 5. Finite Element Methods for Elliptic Equations
• For each interval Ij = [xj−1 , xj ], the degree of freedom of k-th order poly-
nomials is k + 1.
It requires to choose k + 1 nodal points in each interval.
• As for the linear FEM, the two endpoints can naturally become nodal
points.
We should select k − 1 extra nodal points inside the interval Ij .
• In the literature, a common practice is to select those nodal points in
such a way that the numerical quadrature of the integrals is as accurate
as possible when the nodal points are used as quadrature points.
• Such selection is related to the family of orthogonal polynomials such as
Legendre polynomials and Chebyshev polynomials; see Appendix E for
details.
5.1. Finite Element (FE) Methods in 1D Space 163
Then, we have
R(u) = P (u) − f = 0.
M
X
However, for uh (x) = ξj ϕj (x),
j=1
which satisfies ˆ
R(uh ) w(x) dx = 0, (5.16)
I
for a sequence of weight functions w(x) ∈ {wi (x)}, which is also called
trial functions.
When the integration by parts is utilized, (5.16) reads
The linear Galerkin method: For the subspace Vh of linear basis functions
{ϕj (x)}, let
wi (x) = ϕi (x) (5.18)
Then, the linear Galerkin FEM for the differential problem (5.1) is formulated
as
Find uh ∈ Vh s.t. (u0h , ϕ0i ) = (f, ϕi ), ∀ ϕi ∈ Vh (5.19)
The next objective is to assemble the linear system for the unknown vector
ξ := (ξ1 , ξ2 , · · · , ξM )T . From (5.20) and (5.21),
M
X
(u0h , ϕ0i ) = ξj (ϕ0j , ϕ0i ) = (f, ϕi ), ∀ ϕi ∈ Vh .
j=1
Define
aij = (ϕ0j , ϕ0i ), bi = (f, ϕi ). (5.23)
166 Chapter 5. Finite Element Methods for Elliptic Equations
Aξ = b, (5.24)
• The matrix A has good properties such as being symmetric and positive
definite.
• We will show them later; we first consider details for the computation of
aij and bi .
• Note that
ˆ
aij = (ϕ0j , ϕ0i ) = ϕ0j (x)ϕ0i (x)dx = 0, if |i − j| ≥ 2,
I
because the support of ϕj is [xj−1 , xj+1 ]. Thus, there are only three cases
for nonzero entries of A:
j = i − 1, i, i + 1.
5.1. Finite Element (FE) Methods in 1D Space 167
ϕj (x) = −1 (5.25)
(x − xj+1 ), x ∈ [xj , xj+1 ],
hj+1
0, elsewhere.
Case j = i + 1:
ˆ xi+1
ai,i+1 = (ϕ0i+1 , ϕ0i ) = ϕ0i+1 (x)ϕ0i (x)dx
ˆ xi+1
xi
1 −1 −1
= · dx = .
xi hi+1 hi+1 hi+1
It has been known that a matrix S is symmetric positive definite if and only
if all eigenvalues of S are strictly positive.
Lemma 5.5. The matrix A in (5.24) is symmetric positive definite.
Proof. Symmetry is easy to see, because
M
X M
X
η · Aη = ηi aij ηj = ηi (ϕ0i , ϕ0j )ηj
i,j=1 i,j=1
M
X M (5.26)
X
= ηi ϕ0i , ηj ϕ0j ≥ 0,
i j
Figure 5.2: The element Ii = [xi−1 , xi ] and the basis functions for the cubic FE
method.
Higher-order FEMs:
• Higher-order FE methods introduce higher-order basis functions.
• Figure 5.2 presents the element Ii = [xi−1 , xi ] and the basis functions each
of which is cubic in Ii .
• Since the degree of freedom for cubic polynomials is four, we need to pro-
vide four independent information to determine the polynomial uniquely.
• For the purpose, one can choose four distinct points (including two edge
points), as shown in Figure 5.2. The points are called the nodal points.
170 Chapter 5. Finite Element Methods for Elliptic Equations
ϕj (`p ) = δjp , j, p = 0, · · · , 3.
• Select extra (k −1) nodal points such that each element Ii has (k +1) nodal
points including the two edge points.
• Denote them by `m , m = 0, · · · , k.
• Define the local basis functions as
k x−`
m
Y
ϕj (x) = , j = 0, · · · , k.
`j − `m
m=0
m 6= j
• The basis functions associated with the edge points must be extended
both side for the final form of the basis functions.
172 Chapter 5. Finite Element Methods for Elliptic Equations
for some C > 0, independent of u and f . The above regularity estimate holds
for higher-dimensional problems (the Poisson equation in 2D and 3D) when
the boundary is smooth enough. See Appendix B.1 for the details.
174 Chapter 5. Finite Element Methods for Elliptic Equations
Notes
• The inequality (5.31) allows us to analyze the error k(u − uh )0 k quantita-
tively.
• That is, we can choose v ∈ Vh suitably to estimate the right side of (5.31).
• We shall choose v to be the interpolant of u, πh u, which interpolates u at
all the nodal points xj . See Figure 5.3.
(See Homework 5.2.) The above inequalities hold for any (sufficiently smooth)
function u and its interpolant πh u. The estimates are called the interpolation
estimates.
176 Chapter 5. Finite Element Methods for Elliptic Equations
ku − uh k1 ≤ Ch|u|2 , (5.36)
5.3. An error estimate for FEM in 1D 177
Estimation of ku − uhk0
Theorem 5.7. Let u and uh be the solutions of Problem (V) and Problem
(Vh ), respectively. Then
(e0 , v 0 ) = 0, ∀v ∈ Vh . (5.38)
We shall estimate (e, e) = kek20 using the so-called duality argument which
is popular in FEM error analysis. Let φ be the solution of the following dual
problem
−φ00 = e, x ∈ I,
(5.39)
φ = 0, x = 0 or 1.
Then, from (5.29) with s = 0,
where C > 0 is independent on e. Using the integration by parts and the fact
that e(0) = e(1) = 0,
Summary: Error estimate for the linear FEM: The error estimates in
(5.36) and (5.37) can be rewritten as
178 Chapter 5. Finite Element Methods for Elliptic Equations
Error estimate for general-order FEMs: When piecewise k-th order poly-
nomials (k ≥ 1) are employed for the basis functions, one can use the same
arguments presented in this section to show
which implies
ˆ ˆ ˆ
∂v ∂w
wdx = vwni ds − v dx, i = 1, 2. (5.45)
Ω ∂x i Γ Ω ∂xi
Thus we have the Green’s formula
ˆ ˆ
∂v ∂w ∂v ∂w
∇v · ∇wdx ≡ +
Ω ∂x1 ∂x1 ∂x ∂x
Ω
ˆ ˆ 2 22
∂w ∂ w
= v n1 ds − v 2
dx
∂x ∂x
Γ
ˆ 1 Ω
ˆ 1
∂w ∂ 2w
+ v n2 ds − v 2
dx
ˆ Γ ∂x 2 ˆ Ω ∂x 2
∂w
= v ds − v∆wdx.
Γ ∂n Ω
That is,
´
where < v, w >= Γ vwds.
182 Chapter 5. Finite Element Methods for Elliptic Equations
Let ˆ
a(u, v) = ∇u · ∇vdx.
Ω
Define the variational problem (V)
(
Find u ∈ V such that
(V) (5.48)
a(u, v) = (f, v), ∀ v ∈ V,
where
1
F (v) = a(v, v) − (f, v).
2
Then, as for the 1D model problem in §5.1.1, one can prove that
• problems (D), (V), and (M) are equivalent when the solution u is suffi-
ciently smooth, and
• they admit a unique solution.
5.5. FEM for the Poisson equation 183
• Triangulation
• Subspace Vh ⊂ V and basis functions
• Application of variational principles
• Assembly for the linear system
184 Chapter 5. Finite Element Methods for Elliptic Equations
h = max diam(Kj ).
j
Th = {K1 , K2 , · · · , Km }.
An FE mesh consists of
nPT the number of vertices (points)
nEL the number of elements/triangles
(x, y)i the vertices
(n1 , n2 , n3 )j the connectivity
5.5. FEM for the Poisson equation 185
Figure 5.5: Two meshes Dr. Kim made, using the Python package MeshPy.
ϕj (Ni ) = δij ,
The error analysis for the linear Galerkin method can be carried out fol-
lowing the arguments in §5.3.
Theorem 5.9. Let u and uh be the solutions of (5.48) and (5.51), respec-
tively. Then
ku − uh ks ≤ Ch2−s |u|2 , s = 0, 1, (5.52)
where C > 0 is a constant independent on h.
It is fun to prove the theorem; challenge it for an extra credit, or more impor-
tantly, for your pride!
5.5. FEM for the Poisson equation 187
Aξ = b, (5.53)
Notes:
Stiffness matrix A:
Let the stiffness matrix be A = (aij ). Then,
X
aij = a(ϕj , ϕi ) = aK
ij , (5.54)
K∈Th
where ˆ
aK
ij = aK (ϕj , ϕi ) = ∇ϕj · ∇ϕi dx. (5.55)
K
Definition 5.10. The element stiffness matrix AK of the element K is
K K K
a11 a12 a13
K K K
AK = a21 a22 a23 ,
aK K K
31 a32 a33
b → K.
Figure 5.6: The affine mapping F : K
AK := aK 3×3
ij ∈ R
a1 = [0, 0]T , b
b a2 = [1, 0]T , b
a3 = [0, 1]T , (5.56)
ϕ x) = 1 − x
b1 (b b1 − x
b2 , ϕ
b2 (b
x) = x
b1 , ϕ
b3 (b
x) = x
b2 . (5.57)
190 Chapter 5. Finite Element Methods for Elliptic Equations
b → K (b
Affine mapping F : The mapping F : K x 7→ x) must be defined as
ai = F (b
ai ), ϕi (x) = ϕ
bi (b
x), i = 1, 2, 3. (5.58)
That is, the corners and the basis functions of K are defined as the affine
images of those of K.
b
Let J be the Jacobian of the affine mapping F :
" ∂x1 ∂x1 #
∂Fi ∂xi ∂b
x ∂b
x
J := = = ∂x12 ∂x22 . (5.59)
∂b
xj ∂bxj ∂b
x ∂b
x 1 2
∇ϕj = J −T ∇ϕ
bj , j = 1, 2, 3, (5.60)
Notes:
x) = [a2 − a1 , a3 − a1 ] x
F (b b + a1 (5.62)
Thus
J = [a2 − a1 , a3 − a1 ] ∈ R2×2 . (5.63)
5.5. FEM for the Poisson equation 191
For the problem, it is natural to choose V = H 1 (Ω) for the linear space.
Integration by parts: It follows from the Green’s formula (5.46) that (5.64)
reads
(∇u, ∇v) + (u, v) = (f, v)+ < g, v >, v ∈ V. (5.65)
Define
a(u, v) = (∇u, ∇v) + (u, v),
1
F (v) = a(v, v) − (f, v)− < g, v > .
2
Then, one can formulate the variational problem
(
Find u ∈ V such that
(V) (5.66)
a(u, v) = (f, v)+ < g, v >, ∀ v ∈ V,
Notes:
• For the problem (5.66), an FEM can be formulated as for (5.48); a similar
error analysis can be obtained.
5.6. Finite Volume (FV) Method 193
Formulation of FV methods
1. Triangulation: Let Ω be a rectangular domain partitioned into elements,
called cells. For simplicity, we assume all cells are rectangular of size hx × hy .
See Figure 5.7.
2. Localization: Let φpq be the characteristic function of the cell Kpq , i.e.,
1, if x ∈ Kpq ,
φpq (x) =
0, else.
3. Variational principle: Multiplying the first equation of (5.68) by φpq and
integrating the result over the domain Ω, we have
ˆ ˆ ˆ
−∇ · (a∇u)φpq dx = −∇ · (a∇u)dx = f dx.
Ω Kpq Kpq
where s is the edge element and npq denotes the unit out normal to ∂Kpq .
4. Approximation and evaluation: Now we have to evaluate or approxi-
mate the quantity aunpq along the boundary of the cell Kpq .
5.6. Finite Volume (FV) Method 195
On ∂Kpq ∩ ∂Kp+1,q (“East", the right vertical edge), for example, it can be
approximated as
up+1,q − up,q
aunpq (x) ≈ ap+1/2,q , x ∈ ∂Kpq ∩ ∂Kp+1,q , (5.70)
hx
where the approximation is second-order accurate.
Thus ˆ
hy
(E) aunpq (x)ds ≈ ap+1/2,q (up+1,q − up,q ). (5.71)
Kpq ∩∂Kp+1,q hx
The same can be applied for other edges. That is,
ˆ
hy
(W) aunpq (x)ds ≈ ap−1/2,q (up−1,q − up,q )
ˆKpq ∩∂Kp−1,q hx
hx
(N) aunpq (x)ds ≈ ap,q+1/2 (up,q+1 − up,q ) (5.72)
ˆ pq
K ∩∂Kp,q+1
hy
hx
(S) aunpq (x)ds ≈ ap,q−1/2 (up,q−1 − up,q )
Kpq ∩∂Kp,q−1 hy
196 Chapter 5. Finite Element Methods for Elliptic Equations
The right-hand side term: The right-hand side term of (5.69) can be inte-
grated by the mass-lumping technique to become hx hy fpq . That is,
ˆ
f dx ≈ hx hy fpq . (5.73)
Kpq
For (5.69), combine (5.71), (5.72), and (5.73) and divide the resulting equa-
tion by hx hy to have
h 1 1
− 2 ap+1/2,q (up+1,q − up,q ) + 2 ap−1/2,q (up−1,q − up,q )
hx hx
1 1 i
+ 2 ap,q+1/2 (up,q+1 − up,q ) + 2 ap,q−1/2 (up,q−1 − up,q )
hy hy
−ap−1/2,q up−1,q + (ap−1/2,q + ap+1/2,q )up,q − ap+1/2,q up+1,q (5.74)
= 2
hx
−ap,q−1/2 up,q−1 + (ap,q−1/2 + ap,q+1/2 )up,q − ap,q+1/2 up,q+1
h2y
= fpq
which is the same as the finite difference equation for interior nodal points.
Convection term: When a convection term b · ∇u appears in the differential
equation, the same idea can be applied. For example, since b · ∇u = b1 ux + b2 uy
in 2D,
ˆ ˆ
b · ∇uφpq dx = (b1 ux + b2 uy )dx
Ω Kpq (5.75)
up+1,q − up−1,q up,q+1 − up,q−1
≈ hx hy b1,pq + b2,pq ,
2hx 2hy
which is again the same as the FD method.
5.6. Finite Volume (FV) Method 197
Remarks:
• The idea used in the above is the basis for the finite volume method de-
fined on control volumes (CVs).
• Here we have put the nodal points at the center of the rectangular cells
and used the cells for the CVs. Thus the method is sometimes called the
cell-centered finite difference method.
• At interior points, the algebraic equations obtained from the FV method
are equivalent to those of the second-order FD method (on rectangular
meshes) or the linear FE method (on triangular meshes).
• Boundary conditions must be treated accurately. See Homework 5.3.
• When the nodal points are set on the corners of the cells, the CV should be
determined such that it contains the nodal point in an appropriate way;
the CVs are nonoverlapping and their union becomes the whole domain.
198 Chapter 5. Finite Element Methods for Elliptic Equations
Remarks
• The conormal flux aun on a interface denotes the mass or energy move-
ment through the interface.
• Thus it must be continuous (mass/energy conservation), on the interfaces
of finite elements or control volumes. That is,
f (x, y) = π 2 sin(πx)
For various number of grid points nx and the order of basis functions k, the
maximum errors are found as in the table.
The following shows the main routine FEM_1D_High_Order.py, the user pa-
rameter file USER_PARS.py, and the core functions for the construction of the
stiffness matrix.
## FEM_1D_High_Order.py
##-- read USER_PARS and util ---------
from USER_PARS import *
from util_FEM_1D import *
level = 2
print_USER_PARS(level)
from fem_1d import *
#------------------------------------
A = stiffness_mtx(level)
b = get_rhs(level)
dirichlet_BC(A)
ALU = mtx_banded_lu(A,level)
mtx_banded_lusol(ALU,b)
U = exact_sol(level)
print "L8-error = %.3g" %(max_difference(U,b))
## USER_PARS.py
##-----------------------
ax,bx = 0.,1.0;
nx = 20
poly_order = 3
## fem_1d.py
##-----------------------
def stiffness_mtx(level=0):
A = np.ndarray((row,col),float)
init_array(A)
for e in range (nx):
5.9. Numerical Examples with Python 205
g0,g1 = e*kpoly,(e+1)*kpoly
xl,xr = XG[e],XG[e+1]
E = element_stiffness(xl,xr,kpoly)
for i in range(kpoly+1):
for j in range(kpoly+1):
A[g0+i][kpoly+j-i] += E[i][j]
return A
def element_stiffness(xl,xr,kpoly):
m = kpoly+1
E = np.ndarray((m,m),float)
init_array(E)
XL,WT = local_points_weights(xl,xr,kpoly)
XT = get_XT(XL)
for i in range(m):
for j in range(m):
for l in range(m):
dphi_i_xl=eval_dphi(i,kpoly,XL[i],XL[l],XT)
dphi_j_xl=eval_dphi(j,kpoly,XL[j],XL[l],XT)
E[i][j]+=(dphi_i_xl*dphi_j_xl*WT[l])
return E
206 Chapter 5. Finite Element Methods for Elliptic Equations
5.10. Homework
1. Consider the model problem (5.1). Verify that the algebraic system from
the linear Galerkin method is equivalent to that of finite difference method
when the mesh is uniform, i.e.,
h = hi , i = 1, · · · , M + 1,
2. Prove (5.32) and (5.33). Hint: In each subinterval Ij = [xj−1 , xj ], the differ-
ence between u and its linear interpolant can be expressed as follows: for
x ∈ Ij ,
u00 (ξj )
u(x) − πh u(x) = (x − xj−1 )(x − xj ), for some ξj ∈ Ij .
2!
(See (1.9)on p.7.)
3. Let Ω = (0, 1)2 and Γ = ∂Ω and consider
−∇ · (a(x)∇u) = f, x ∈ Ω,
u = gD , x ∈ ΓD , (5.89)
aun = gN , x ∈ ΓN ,
where Γ = ΓD ∪ ΓN and ΓD and ΓN are distinct nonempty boundary por-
tions corresponding to the Dirichlet and Neumann boundary conditions,
respectively. Consider a FV method on a rectangular cells with cell-
centered nodal points, as considered in Section 5.6. Design to suggest
numerical methods for an effective treatment for each of the boundary
conditions. (You may assume gD = gN ≡ 0, if you want.)
4. Consider the following 1D elliptic problem of general form
−((1 + x2 )ux )x + 5ux = f, x ∈ (0, 1)
(5.90)
ux (0) = gN , u(1) = gD
Choose the exact solution as in (5.88):
u(x) = sin(πx)
and correspondingly the right side f and the boundary data, gN and gD .
(a) Formulate the Galerkin method for (5.90).
5.10. Homework 207
(b) Modify the Python code in §5.9 to solve the above problem.
(c) Carry out an error analysis as in Table 5.1.
5. Assume that v(x) ∈ C 1 [a, b] and v(a) = 0. Prove that the one-dimensional
Poincaré inequality
b−a
kvk0 ≤ √ kv 0 k0 . (5.91)
2
Hint: You may begin with
ˆ x ˆ x
0
v(x) = v(a) + v (t)dt = v 0 (t)dt.
a a
Now, square the inequality and then integrate over the interval.
6. (Optional) Use the arguments in the proof of Homework 5.5 to prove the
Poincaré inequality (5.85) when Ω = (0, 1)2 :
ˆ ˆ
2
u dx ≤ C |∇u|2 dx, ∀v ∈ H01 (Ω), (5.93)
Ω Ω
for some C ˆ> 0. Try to ˆdetermine the constant ˆ 1as small as possible.
ˆ 1C
1ˆ 1
Note that f (x) dx = f (x, y) dxdy = f (x, y) dydx.
Ω 0 0 0 0
208 Chapter 5. Finite Element Methods for Elliptic Equations
Chapter 6
This chapter considers finite difference methods for hyperbolic PDEs. We be-
gin with numerical methods for the linear scalar wave equation. Then, numer-
ical methods for conservation laws are treated along with nonlinear stability.
A Python code is included for the Lax-Wendroff scheme to solve the one-way
wave equation.
209
210 Chapter 6. FD Methods for Hyperbolic Equations
6.1. Introduction
Consider the initial value problem
ut + A ux = 0
(6.1)
u|t=0 = u0 (x),
• The problem (6.1) is well-posed if and only if all eigenvalues of A are real
and there is a complete set of eigenvectors [27].
• Such a system is called (strongly) hyperbolic.
• We will restrict our discussions to such hyperbolic problems.
6.1. Introduction 211
S = [φ1 , · · · , φm ], Γ = diag(λ1 , · · · , λm ).
A = SΓS −1 . (6.2)
Hence the chapter begins with discussions focusing on the scalar equation:
ut + aux = 0, (x, t) ∈ Ω × J,
(6.5)
u(x, 0) = u0 (x), x ∈ Ω, t = 0,
where Ω = (ax , bx ) ⊂ R and J = (0, T ], T > 0, the time interval. Here the
boundary condition is ignored for simplicity. (Or, we may assume Ω = R.)
When a is a constant, (6.5) has the exact solution
Let
S n := Ω × (tn−1 , tn ]
be the nth space-time slice. Suppose that the computation has been performed
for uj = {ujm }, 0 ≤ j ≤ n − 1. Then, the task is to compute un by integrating
the equation on the space-time slice S n , utilizing FD schemes.
214 Chapter 6. FD Methods for Hyperbolic Equations
6.2.1. Consistency
The bottom line for accurate numerical methods is that the discretization be-
comes exact as the grid spacing tends to zero, which is the basis of consistency.
Recall the definition of consistency.
Definition 6.1. Given a PDE P u = f and a FD scheme P∆x,∆t u = f , the
FD scheme is said to be consistent with the PDE if for every smooth function
φ(x, t)
P φ − P∆x,∆t φ → 0 as (∆x, ∆t) → 0,
with the convergence being pointwise at each grid point.
Not all numerical methods based on Taylor series expansions are consis-
tent.
216 Chapter 6. FD Methods for Hyperbolic Equations
∆t2
φnm= n−1
φm n−1
+ ∆t φt (xm , t ) + φtt (xm , tn−1 ) + O(∆t3 ),
2
∆x2
n−1 n−1 n−1
φm+1 = φm + ∆x φx (xm , t ) + φxx (xm , tn−1 ) + O(∆x3 ).
2
With some algebra, one can obtain
∆t ∆x
P∆x,∆t φ = φt + aφx + φtt + a φxx + O(∆x2 + ∆t2 ).
2 2
Thus, as (∆x, ∆t) → 0,
∆t ∆x
P φ − P∆x,∆t φ = − φtt − a φxx + O(∆x2 + ∆t2 ) → 0.
2 2
Therefore, the scheme is consistent.
6.2. Basic Difference Schemes 217
6.2.2. Convergence
A numerical method is said to be convergent if the solution of the FD scheme
tends to the exact solution of the PDE as the grid spacing tends to zero. We
redefine convergence in a formal way as follows:
Definition 6.3. A FD scheme approximating a PDE is said to be convergent
if
u(x, t) − unm → 0 as (xm , tn ) → (x, t) as (∆x, ∆t) → 0,
where u(x, t) is the exact solution of PDE and unm denotes the the solution of
the FD scheme.
Consistency implies that the truncation error
(P u − P∆x,∆t u) → 0
Figure 6.1: The characteristic curve passing the origin of the xt-plane.
Example 6.4. The forward-time forward-space scheme for (6.5) is not con-
vergent, when a > 0.
Proof. The scheme (6.7b) is consistent from Example 6.2. The problem (6.5)
has the exact solution
u(x, t) = u0 (x − at),
a shift of u0 by at. The lines having the slope 1/a in the xt-plane become
characteristics of the problem; when a > 0, the characteristic curve passing
the origin is shown in Figure 6.1.
On the other hand, the scheme (6.7b) can be rewritten as
n n−1 n−1 n−1 n−1 n−1
vm = vm − aλ(vm+1 − vm ) = (1 + aλ)vm − aλvm+1 , (6.8)
n
See Figure 6.2. The above holds for any choices of ∆x and ∆t. Therefore, vm
cannot converge to the exact solution u(x, t) in (6.6).
Showing that a given consistent scheme is convergent is not easy in gen-
eral, if attempted in a direct manner as in Homework 6.1. However, there is
a related concept, stability, that is easier to check.
220 Chapter 6. FD Methods for Hyperbolic Equations
6.2.3. Stability
Example 6.4 shows that consistency is not enough for a numerical method to
guarantee convergence of its solution to the exact solution. In order for a con-
sistent numerical scheme to be convergent, the required property is stability.
Recall the L2 -norm of grid function v:
X∞ 1/2
2
kvk∆x = ∆x |vm | .
m=−∞
Example 6.6. The schemes (6.7a) and (6.7b) can be written of the form
n n−1 n−1
vm = αvm + βvm∓1 .
Thus the scheme is stable if |α| + |β| = |1 − aλ| + |aλ| ≤ 1, where λ = ∆t/∆x.
Therefore, a sufficient condition for stability of (6.7a) is 0 ≤ aλ ≤ 1. The
analysis is similar for (6.7b); it is stable if −1 ≤ aλ ≤ 0.
The stability inequality (6.9) can be easily satisfied when
|aλ| ≤ 1.
Proof. Let ∆t = 1/n, for some n ≥ 1. Then the physical domain of dependence
for the exact solution at the point (x, t) = (0, 1) must be (±a, 0), i.e.,
u(0, 1) = u0 (±a).
On the other hand, it follows from the FD scheme that the numerical solu-
0
tion v0n depends on vm , |m| ≤ n. Since
m∆x = m∆t/λ ≤ n∆t/λ = 1/λ,
we can see that the numerical solution at (0, 1), v0n , depends on x for |x| ≤ 1/λ.
Suppose |aλ| > 1. Then we have |a| > 1/λ. So v0n depends on x for
|x| ≤ 1/λ < |a|.
Thus v0n cannot converge to the exact value u(0, 1) = u0 (±a) as ∆x → 0 with
λ = ∆t/∆x keeping constant. This proves the theorem.
One can see from the above theorem and proof that
stability requires the numerical domain of dependence contain the physical
domain of dependence.
This physical observation is very useful for stability analysis for certain
nonlinear problems [40].
224 Chapter 6. FD Methods for Hyperbolic Equations
6.2.4. Accuracy
We define the order of accuracy for numerical schemes for PDEs.
Definition 6.9. (Order of accuracy). Let P∆x,∆t u = R∆x,∆t f be a numerical
scheme for P u = f . Assume that for every smooth function φ,
Then, the scheme is said to have the p-th order accuracy in space and the q-th
order accuracy in time, and denoted by the “accuracy order (p, q) in space-
time".
For example, the forward-time forward-space, forward-time central-space,
and leapfrog schemes for (6.5) have the accuracy orders (1, 1), (2, 1), and (2, 2)
in space-time, respectively.
6.2. Basic Difference Schemes 225
O(∆x2 ) + O(∆t2 ).
It follows from the von Neumann analysis presented in §6.2.3 that the am-
plification factor for the CN scheme is
1 − i aλ
2 sin ϑ ∆t
g(ϑ) = , λ= .
1 + i aλ
2 sin ϑ
∆x
Thus its magnitude is identically one and therefore the CN scheme is stable
for every choice of ∆x and ∆t (unconditional stability).
Note: The numerical solution of the CN method (6.12) may involve oscilla-
tions when the initial data is nonsmooth.
∂ ∂
u(x, t) + f (u(x, t)) = 0. (6.13)
∂t ∂x
Here
u : R × R → Rm
and f : Rm → Rm is called the flux function. For simplicity, we may consider
the pure initial value problem, or Cauchy problem, in which (6.13) holds for
−∞ < x < ∞ and t ≥ 0. In this case we must specify initial conditions only
We assume that the system (6.13) is hyperbolic. That is, the Jacobian ma-
trix f 0 (u) of the flux function is
where
u : R2 × R → Rm , f, g : Rm → Rm .
Assume that the walls of the tube are impermeable and that mass is neither
created nor destroyed. Then the mass in a section [x1 , x2 ] can change only
because of gas flowing across the end points x1 and x2 . The rate of flow, or flux
of gas at (x, t) is given by
• For any quantity z which is advected with the flow will have a contribu-
tion to the flux of the form zv.
• Besides advection, there are forces on the fluid that cause acceleration
due to Newton’s laws. Since we assume there is no outside forces, the
only force is due to variations in the fluid itself; it is proportional to the
pressure gradient for momentum and proportional to the gradient of vp
for energy.
232 Chapter 6. FD Methods for Hyperbolic Equations
The polytropic gas is such that the internal energy is proportional to the tem-
perature, so the coefficients cv and cp are constants, called respectively the
specific heat at constant volume and the specific heat at constant pressure. (In
general, “specific" means “per unit mass".)
6.3. Conservation Laws 233
The equation of state for a polytropic gas: Note that T = p/(Rρ) so that
cv p cv p 1 p
e = cv T = = = .
R ρ cp − cv ρ γ − 1 ρ
Thus the equation of state for a polytropic gas is
p 1
E= + ρv 2 . (6.21)
γ−1 2
p = R ρ T = a2 ρ,
√
where a = RT is the sound speed. Thus the isothermal equations read
ρ ρv
+ = 0. (6.22)
ρv t ρv 2 + a2 ρ x
234 Chapter 6. FD Methods for Hyperbolic Equations
u(x, t) = u0 (x − at), t ≥ 0.
The solution is constant along each ray x − at = x0 . Such rays are known as
the characteristics of the equation.
Note that the characteristics are curves in the x-t plane satisfying the ODE
x0 (t) = a, x(0) = x0 . Let us differentiate u(x, t) along one of these curves to find
the change rate of the solution along the characteristics:
d ∂ ∂
u(x, t) = u(x, t) + u(x, t)x0 = ut + aux = 0,
dt ∂t ∂x
which confirms that u is constant along the characteristics.
There is a fundamental property of linear hyperbolic equations: singulari-
ties propagate only along characteristics.
6.4. Shocks and Rarefaction 235
Thus, after solving the heat equation, we can compute uε (x, t) = v ε (x − at, t)
explicitly. It is easy to verify that the vanishing-viscosity solution is equal to
u0 (x − at):
lim uε (x, t) = u(x, t) = u0 (x − at).
ε→0
236 Chapter 6. FD Methods for Hyperbolic Equations
Known facts:
n
Ujn+1 − Ujn k k2
ut (xj , t ) = − utt − uttt − · · · .
k 2 6
Since
ut = −aux ,
we have
utt = (ut )t = (−aux )t = −auxt = −autx
= −a(ut )x = −a(−aux )x = a2 uxx
Therefore, the Lax-Wendroff scheme can be obtained by taking care of utt =
a2 uxx by the central scheme; its truncation error is
k2 h2 k2 3 h2
− uttt − a uxxx + · · · = a uxxx − a uxxx + · · ·
6 6 6 6
2 2
h k 2
= a 2 a − 1 uxxx + · · ·
6 h
Thus, when h and k are sufficiently small, solving (6.26) by the Lax-Wendroff
scheme is equivalent to solving the following equation exactly:
h2 k 2 2
ut + aux = a 2 a − 1 uxxx . (6.29)
6 h
Equation (6.29) is called the modified equation of (6.26) for the Lax-Wendroff
scheme. By analyzing (6.29) in PDE sense, one can understand the Lax-
Wendroff scheme.
240 Chapter 6. FD Methods for Hyperbolic Equations
Finite difference equation was introduced in the first place because it is eas-
ier to solve than a PDE; on the other hand, it is often easier to predict qualita-
tive behavior of a PDE than difference equations.
Dispersion analysis: Equation (6.29) is a dispersive equation of the form
where ξ is the wave number. Here the purpose is to see that the Fourier
components with different wave number ξ propagate at different speeds (dis-
persion).
Due to linearity, it suffices to consider each wave number in isolation, so
suppose that we look for solution of (6.30) of the form
where c = c(ξ) is called the frequency. Plugging this into (6.30) gives
c(ξ) = aξ + µ ξ 3 . (6.32)
Define
cp (ξ) = c(ξ)/ξ, (phase velocity)
cg (ξ) = c0 (ξ). (group velocity)
The phase velocity is the speed of wave peaks or in single frequency, while the
group velocity is the speed of energy in wavetrain.
Then, for the modified equation of Lax-Friedrichs scheme in (6.29), we have
cp = a + µ ξ 2 , cg = a + 3µ ξ 2 . (6.33)
Recall that the CFL condition reads
|aλ| = |ak/h| ≤ 1.
Thus, when the Lax-Friedrichs scheme is stable, the coefficient µ for (6.29)
must be nonpositive, i.e.,
h2 k 2 2
µ = a 2 a − 1 ≤ 0, (6.34)
6 h
which implies from (6.33) that both the phase velocity and the group velocity
are smaller than the actual velocity a.
242 Chapter 6. FD Methods for Hyperbolic Equations
Remarks:
• For the step function in (6.26), the Fourier spectrum decays only as
x = cg t.
• Since µ > 0 for sufficiently small k, the group velocity will be larger than
the actual speed a; there must be oscillation propagating faster than the
shock speed.
• Here the point is that a upwind modification is not sufficient enough to
cure oscillation.
244 Chapter 6. FD Methods for Hyperbolic Equations
ut + uux = 0. (6.39)
k
Ujn+1 = Ujn − [F (Ujn , Uj+1
n n
) − F (Uj−1 , Ujn )]. (6.43)
h
6.5. Numerical Methods 247
Comparing this with (6.43), we can see that the numerical flux F (Ujn , Uj+1 n
)
n n+1
plays the role of an average flux at x = xj+1/2 over the time interval [t , t ]:
ˆ tn+1
1
F (Ujn , Uj+1
n
) ≈ f (u(xj+1/2 , t))dt. (6.46)
k tn
Upwind scheme: For the Burgers’s equation (6.38), the upwind scheme in
conservative form reads
n+1 n k h 1 n 2 1 n 2i
Uj = Uj − (U ) − (Uj−1 ) , (6.47)
h 2 j 2
where
1
F (Ujn , Uj+1
n
) = (Ujn )2 .
2
Lax-Friedrichs scheme: The generalization of the Lax-Friedrichs scheme
to the conservation law takes the form
n+1 1 n n kh n n
i
Uj = (Uj−1 + Uj+1 ) − f (Uj+1 ) − f (Uj−1 ) , (6.48)
2 2h
which can be rewritten in the conservation form by taking
h n 1
F (Ujn , Uj+1
n
)= n
(Uj − Uj+1 ) + (f (Ujn ) + f (Uj+1
n
)). (6.49)
2k 2
6.5. Numerical Methods 249
6.5.3. Consistency
The numerical method (6.43) is said to be consistent with the original conser-
vation law if the numerical flux F reduces to the true flux f for the constant
flow. That is, if u(x, t) ≡ u
b, say, then we expect
F (b
u, u
b) = f (b
u), ∀u
b ∈ R. (6.50)
|F (v, w) − f (b
u)| ≤ K max(|v − u
b|, |w − u
b|).
Here
• u
e(x, t) is the piecewise constant representation of the solution, over the
grid cell (xj−1/2 , xj+1/2 ).
• u∗ (Ujn , Uj+1
n
) is the Riemann solution on {xj+1/2 } × [tn , tn+1 ].
• The method is consistent.
• Stability of the method requires to choose k small enough to satisfy
k
σ= max |f 0 (Ujn )| ≤ 1,
h j
where σ is called the Courant number.
6.6. Nonlinear Stability 251
T V (U n+1 ) ≤ T V (U n ) (6.58)
Vj = Uj−1 , ∀ j.
Then
1
kU − V k1 .
T V (U ) =
h
Now, suppose the method (6.62) is l1 -contracting. Define Vjn = Uj−1
n
. Note that
the methods under consideration are translation invariant, i.e.,
v0 (x) ≥ u0 (x), ∀ x,
This means that if we increase the value of any Uin then the value of Ujn+1
cannot decrease as a result.
Example 6.18. The Lax-Friedrichs scheme (6.48) (See page 248) is monotone
provided that the CFL condition is satisfied, because
n 1 n n kh n n
i
H(U ; j) = (Uj−1 + Uj+1 ) − f (Uj+1 ) − f (Uj−1 )
2 2h
satisfies
1 k 0 n
1 + f (Uj−1 ) , i = j − 1,
∂
2 h
n 1 k 0 n
H(U ; j) =
∂Uin 1 − f (Uj+1 ) , i = j + 1,
2 h
0, otherwise.
6.6. Nonlinear Stability 259
Figure 6.3: The Lax-Wendroff scheme: (left) The initial solution and (right)
the solution at t = 2.
6.7. Numerical Examples with Python 261
def lax_wendroff(U0,ax,bx,nx,T,nt,a,level=0):
hx,ht = (bx-ax)/nx, T/nt
if level>=1:
print("Lax-Wendroff: a=%g, nx=%d, nt=%d, hx=%g, ht=%g")\
%(a,nx,nt,hx,ht)
U =np.ndarray((2,nx+1),float)
for i in range(nx+1):
U[0][i]=U0[i]; U[1][i]=0.
alam = a*ht/hx
alam2= alam**2
for n in range(0,nt):
id0,id1 = n%2,(n+1)%2
for j in range (1,nx):
U[id1][j]=U[id0][j]-(alam/2.)*(U[id0][j+1]-U[id0][j-1
+(alam2/2.)*(U[id0][j+1]-2.*U[id0][j]+U[id0][j-1
return U[id1]
262 Chapter 6. FD Methods for Hyperbolic Equations
6.8. Homework
1. Find conditions on a and λ with which the FD schemes in (6.7.a)-(6.7.c)
are stable or unstable.
2. Consider the leapfrog scheme (6.7.d).
(a) Derive the relation
∞
X
n+1 2 n 2 n+1 n n+1 n
|vm | + |vm | + aλ(vm vm+1 − vm+1 vm )
m=−∞
∞
X
n 2 n−1 2 n n−1 n n−1
= |vm | + |vm | + aλ(vm vm+1 − vm+1 vm )
m=−∞
∞
X
1 2 0 2 1 0 1 0
= |vm | + |vm | + aλ(vm vm+1 − vm+1 vm )
m=−∞
n+1 n−1
(Hint: Multiply the leapfrog scheme by vm + vm and sum over all
m.)
(b) Show that
∞
X ∞
X
n+1 2 n 2 1 2 0 2
(1 − |aλ|) |vm | + |vm | ≤ (1 + |aλ|) |vm | + |vm |.
m=−∞ m=−∞
265
266 Chapter 7. Domain Decomposition Methods
Figure 7.1: The domain used by Schwarz to show the existence of harmonic
solutions on irregular domains.
7.1. Introduction to DDMs 267
Ω1 Ω2
0.3 (2,4)
Ω
e1
Ω
e2
Lu := −∇ · (a(x)∇u) = f (x), x ∈ Ω,
(7.1)
u = 0, x ∈ Γ,
where ˆ ˆ
a(u, v) = a∇u · ∇vdx, (f, v) = f v dx.
Ω Ω
270 Chapter 7. Domain Decomposition Methods
Vej = {v ∈ V : v = 0 on Ω \ Ω
e j }, j = 1, 2.
Then, Vej are subspaces of V and V = Ve1 + Ve2 . Let an initial guess u0 = {u01 , u02 } ∈
V be given. Then, the iterate un ∈ V is determined from un−1 by sequentially
solving
n−1/2
(a) Lu1 = f, in Ω
e 1,
n−1/2
(b) u1 = 0, on Γ
e1,
n−1/2
(c) u1 = un−1
2 , on Γ12 ,
e
(7.3)
(d) Lun2 = f, in Ω
e 2,
(e) un2 = 0, on Γ
e2,
n−1/2
(f) un2 = u 1 , on Γ
e21 ,
where Γ e j ∩ ∂Ω and Γ
ej = ∂ Ω e j ∩ Ωk .
ejk = ∂ Ω
Since
(f, v) = a(u, v), v ∈ Vej , j = 1, 2,
one can rewrite (7.4) as
n−1/2 n−1/2
a(u1 − un−1 , v) = a(u − un−1 , v), v ∈ Ve1 , u1 − un−1 ∈ Ve1 ,
(7.5)
a(un2 − un−1/2 , v) = a(u − un−1/2 , v), v ∈ Ve2 , un2 − un−1/2 ∈ Ve2 .
or equivalently
u − un−1/2 = (I − P1 ) (u − un−1 ),
u − un = (I − P2 ) (u − un−1/2 ),
where I is the identity operator. Therefore, the error propagates as
u − un = (I − P2 ) (I − P1 ) (u − un−1 ). (7.6)
Notes
• The multiplicative Schwarz method has an important variant, i.e., the
additive Schwarz method which decouples the subproblems (7.3.a)-(7.3.c)
and (7.3.d)-(7.3.f). In additive Schwarz method, (7.3.f) is replaced by
un2 = un−1
1 , on Γ
e21 ;
H = max Hj .
j=1,··· ,M
Known: Let λ∗ > 0 and λ∗ > 0 be the minimum and the maximum eigen-
values for a symmetric positive definite (SPD) matrix A, respectively. The
condition number of A, κ(A), is defined by
κ(A) = λ∗ /λ∗ .
The
prequired
iteration number for the CG method to solve SPD systems is
O κ(A) for a given accuracy. (For more general systems, GMRES [59] and
QMR [24] can be used.) The following result was established by Dryja and
Widlund [19].
Theorem 7.1. Let δ = min dist(∂Ωj \ ∂Ω, ∂ Ω e j \ ∂Ω) > 0. Assume the
j=1,··· ,M
problem coefficient a is continuous on Ω̄. Then, the condition number of the
additive Schwarz method for solving (7.12) satisfies
Final Notes
where r depends on the amount of overlap and the regularity of the diffu-
sion coefficient a.
• The convergence analysis of Schwarz method is more complicated when
the subdomains overlap less. See [47] and the survey papers [19, 45] for
details.
7.3. Nonoverlapping DDMs 277
Lu := −∇ · (a(x)∇u) = f (x), x ∈ Ω,
(7.15)
u = 0, x ∈ Γ,
Ω = ∪Mj=1 Ωj ; Ωj ∩ Ωk = ∅, j 6= k;
Γj = Γ ∩ ∂Ωj ; Γjk = Γkj = ∂Ωj ∩ ∂Ωk .
Then, the problem (7.15) can be formulated as follows: Find {uj } such that
(a) Luj = f, x ∈ Ωj ,
(b) uj = 0, x ∈ Γj ,
(c) uj = uk , x ∈ Γjk , (7.16)
∂uj ∂uk
(d) =− , x ∈ Γjk ,
∂νL,j ∂νL,k
where the conormal derivative is defined as
∂uj
= a∇uj · nj ,
∂νL,j
where nj indicates the unit outer normal from ∂Ωj .
We first introduce the Steklov-Poincaré operator which is useful for the con-
vergence analysis for the variational formulation of the DDMs.
7.3. Nonoverlapping DDMs 279
Lu0j = 0, x ∈ Ωj ,
u0j = 0, x ∈ Γj , (7.19)
u0j = λjk , x ∈ Γjk ,
and
Lu∗j = f, x ∈ Ωj ,
u∗j = 0, x ∈ Γj , (7.20)
u∗j = 0, x ∈ Γjk ,
Note that when a(x) = 1, u0j is the harmonic extension of {λjk } (for k’s such that
Γjk 6= ∅) into Ωj ; for general coefficients, we still call it the harmonic extension
and denote by Hj λjk . We will also write Gj f instead of u∗j , j = 1, · · · , M .
280 Chapter 7. Domain Decomposition Methods
Here the sr-th entry of Ajj , the `r-th entry of ABj , and the `m-th entry of ABB
are given by
(j) (B)
where aj (·, ·) is the restriction of a(·, ·) to Ωj , and ϕs and ϕ` are the basis
functions associated with nodes lying in Ωj and ∪Γjk , respectively.
282 Chapter 7. Domain Decomposition Methods
Σ uB = fB − ATIB A−1
II fI , (7.26)
Convergence
Lunj = f,
x ∈ Ωj ,
(7.27)
un = 0,
x ∈ Γ ,
j j
(b) n
j ∈ IR ,
∂u n
j ∂u
= − k , x ∈ Γjk ,
∂νL,j ∂νL,k
(c) λnjk = θjk unj,R + (1 − θjk )λn−1
jk ,
where {θjk } > 0 is an acceleration parameter and unj,R denotes the solution
from the subdomains colored red.
7.4. Iterative DDMs Based on Transmission Conditions 285
The acceleration parameter is often set less than one; the method without
relaxation (i.e., θjk ≡ 1) is not necessarily convergent, unless special assump-
tions are made on the size of the subdomains. We refer readers interested in
the Dirichlet-Neumann method to [4, 6, 52] and [57] for details.
286 Chapter 7. Domain Decomposition Methods
Lvjn = 0,
x ∈ Ωj ,
(7.28)
v n = 0,
x ∈ Γj ,
j
(b)
∂vjn ∂unj ∂unk
= + , x ∈ Γjk ,
∂νL,j ∂νL,j ∂νL,k
(c) λnjk = λjkn−1
− θjk σjk vjn + (1 − σjk )vkn Γjk , j > k,
(a) Lunj = f, x ∈ Ωj ,
(b) unj = 0, x ∈ Γj ,
(7.29)
∂unj ∂un−1
(c) + θjk uj = − k + θjk un−1
n
k , x ∈ Γjk ,
∂νL,j ∂νL,k
where {θjk } ≥ 0 is an acceleration parameter with
Lions [48] proved the convergence of the method through an energy estimate
on the interfaces.
Note that (7.29.c) is defined twice on each of Γjk from both sides of the
interface:
∂unj ∂un−1
+ θjk uj = − k + θjk un−1
n
k ,
∂νL,j ∂νL,k
∂unk n
∂un−1
j
+ θkj uk = − + θkj un−1
j .
∂νL,k ∂νL,j
When the iterates converge, the limit {uj } would satisfy the above equations
in the same way (without the superscripts n and n − 1). By subtracting
and adding the equations, one can get the transmission conditions (7.16.c)-
(7.16.d).
288 Chapter 7. Domain Decomposition Methods
W O E
S
Ωj Γjk Ωk
Figure 7.3: The five point stencil at a grid point on the interface Γjk .
∂b,jk uj (O) = (uj (O) − uj (W) )/h, ∂f,jk uj (O) = (uj (E) − uj (O) )/h,
∂b,kj uk (O) = (uk (O) − uk (E) )/h, ∂f,kj uk (O) = (uk (W) − uk (O) )/h.
Note that (7.31.c) imposes the continuity of the discrete solution only, when
the algorithm converges. Such a treatment of the Robin condition, a forward-
backward difference matching, was introduced by Kim [36, 38] to enforce
equivalence of the DD method to the original discrete problem of the multi-
linear FE methods.
292 Chapter 7. Domain Decomposition Methods
where unj,O = unj (O), the value of unj at the point O, and the others are similarly
defined.
The term unj,E in (7.32) evaluated at a point out of the subdomain Ωj can be
substituted by using (7.31.c). Equation (7.31.c) is written as
unj,E − unj,O n
un−1 n−1
k,E − uk,O
+ β uj,O = + β un−1
k,O ,
h h
or equivalently
In the same manner, one can treat cross points arising in a box-type decom-
position of the domain. When the algorithm converges, the limit would clearly
satisfy the original algebraic equation
4uO − uE − uW − uS − uN = h2 fO ,
7.5. Homework
1. Derive (7.10) for the additive Schwarz method for two overlapping subdo-
mains.
2. Consider the bilinear FE method of grid size h on the unit square applied
to the DD method (7.30): Given {uh,0
j }, uj
h,0
∈ Vjh := V h Ωj , j = 1, · · · , M ,
find {uh,n
j }, n ≥ 1, satisfying
X
(∇uh,n
j , ∇v)Ωj + hβuh,n
j , viΓjk = (f, v)Ωj
k
X h,n−1
∂uk X (7.35)
+ h− , viΓjk + hβuh,n−1
k , viΓjk , v∈ Vjh .
∂νk
k k
(a) Show that the algebraic equation of (7.35) at the boundary nodal point
O as given in Figure 7.3 reads
1 n 1 n h2
(2 + βh) unj,O
− unj,W
− uj,S − uj,N = fO + un−1 n−1
k,E − (1 − βh) uk,O , (7.36)
2 2 2
provided that the mass-lumping quadrature rule is used.
(b) Show that (7.36) is equivalent to (7.34), in their limits, if the discrete
solution is linear across the subdomain boundary Γjk .
3. A modification of (7.35) can be obtained incorporating the forward-backward
difference matching (7.31.c) as follows: Given {uh,0 h,0 h
j }, uj ∈ Vj , j = 1, · · · , M ,
find {uh,n
j }, n ≥ 1, satisfying
X
(∇uh,nj , ∇v)Ωj + h−∂c,jk uh,n
j , viΓjk = (f, v)Ωj , v ∈ Vjh ,
k (7.37)
n n n−1 n−1
∂f,jk uj + β uj = −∂b,kj uk + β uk , x ∈ Γjk ,
∂uh,n
where ∂c,jk uh,nj is the central approximation of ∂νj j , i.e., ∂c,jk = (∂b,jk +
∂f,jk )/2. (We have assumed the outer bordering.) Equations (7.37) can be
rewritten as
h,n
X 1
(∇uj , ∇v)Ωj + h (−∂b,jk uh,n n
j + β uj ), viΓjk
2
k
X 1 (7.38)
h,n−1 n−1 h
= (f, v)Ωj + h (−∂b,kj uk + β uk ), viΓjk , v ∈ Vj .
2
k
7.5. Homework 295
Prove that the algorithm (7.38) solves the original discrete solution if it
converges.
296 Chapter 7. Domain Decomposition Methods
Chapter 8
Multigrid Methods∗
297
298 Chapter 8. Multigrid Methods∗
8.2. Homework
1.
300 Chapter 8. Multigrid Methods∗
Chapter 9
Explicit schemes for parabolic equations are easy to implement, but they are
stable only if the time step size is chosen sufficiently small: ∆t = O(∆x2 ).
Implicit methods are often unconditionally stable; however, a large algebraic
system must be solved (directly or iteratively) for the time integration on each
of the space-time slices. In this chapter, we will introduce the locally one-
dimensional (LOD) methods such as the alternating direction implicit (ADI)
method and the fractional step (FS) method, in order to solve the algebraic
system of equations efficiently. The LOD methods can be viewed as a pertur-
bation of standard implicit methods.
301
302 Chapter 9. Locally One-Dimensional Methods
where Γ is the boundary of Ω, i.e., Γ = {0, 1}, and u0 is the prescribed initial
value of the solution at t = 0.
Let
∆t = T /nt , tn = n∆t, n = 0, 1, · · · , nt ;
∆x = 1/nx , xj = j∆x, j = 0, 1, · · · , nx ;
for some positive integers nt and nx . Define unj = u(xj , tn ). Let A1 be the central
second-order approximation of −∂xx , defined as
−unj−1 + 2unj − unj+1
A1 unj := .
∆x2
Then the θ-method for (9.1) is
v n − v n−1
+ A1 θv n + (1 − θ)v n−1 = 0,
θ ∈ [0, 1], (9.2)
∆t
or equivalently
v n = (I − ∆tA1 )v n−1 ,
which is explicit and cheap to compute the solution in each time level. How-
ever, we shall see later that its stability requires to choose ∆t small enough to
satisfy
∆t 1
µ= ≤ .
∆x2 2
Backward Euler method (θ = 1): This is an implicit method written as
(I + ∆tA1 )v n = v n−1 .
The method must invert a tridiagonal matrix to get the solution in each time
level. But it is stable independently on the choice of ∆t.
Crank-Nicolson method (θ = 1/2):
∆t n ∆t n−1
I+ A1 v = I − A1 v .
2 2
It requires to solve a tridiagonal system in each time level, as in the backward
Euler method. However, the Crank-Nicolson method is most popular, because
• it is unconditionally stable
• its error = O(∆x2 + ∆t2 )
Stability analysis
Components of the algebraic system (9.3) are
n
−θµ vj−1 + (1 + 2θµ)vjn − θµ vj+1
n
n−1 (9.4)
= (1 − θ)µ vj−1 + [1 − 2(1 − θ)µ]vjn−1 + (1 − θ)µ vj+1
n−1
,
where µ = ∆t/∆x2 .
For an stability analysis for this one-parameter family of systems, substi-
tute g n eijϑ for vjn in (9.4) to have
i.e.,
1 − 2(1 − θ)µ (1 − cos ϑ) 1 − 4(1 − θ)µ sin2 ϑ2
g= = .
1 + 2θµ (1 − cos ϑ) 1 + 4θµ sin2 ϑ2
Because µ > 0 and θ ∈ [0, 1], the amplification factor g cannot be larger than
one. The condition g ≥ −1 is equivalent to
2 ϑ 2 ϑ
h i
1 − 4(1 − θ)µ sin ≥ − 1 + 4θµ sin ,
2 2
or
ϑ 1
(1 − 2θ)µ sin2 ≤ .
2 2
Thus (9.3) is stable if
1
(1 − 2θ)µ ≤ . (9.5)
2
9.1. Heat Conduction in 1D Space: Revisited 305
In conclusion:
∆t ≤ ∆x2 /2;
Maximum principle
For heat conduction without interior sources/sinks, it is known mathemat-
ically and physically that the extreme values of the solution appear either
in the initial data or on the boundary. This property is called the maximum
principle. It is quite natural and sometimes very important to examine if the
numerical solution satisfies the maximum principle, too.
Theorem 9.1. (Maximum principle for the θ-method). Let the θ-method
be set satisfying θ ∈ [0, 1] and
1
(1 − θ)µ ≤ .
2
If the computed solution v has an interior maximum or minimum, then v is
constant.
9.1. Heat Conduction in 1D Space: Revisited 307
Error analysis
Let
enj = unj − vjn ,
where unj = u(xj , tn ) with u being the exact solution of (9.1). Define
n−1/2
E n = max |enj |, T n−1/2 = max |T uj |,
j j
n−1/2
where T uj is the truncation error expanded at (xj , tn−1/2 ). Note that vj0 =
u0j , j = 0, · · · , nx , and therefore E 0 = 0.
Theorem 9.2. Let the θ-method be set satisfying θ ∈ [0, 1] and (1 − θ)µ ≤ 21 .
Then,
Xn
n
E ≤ ∆t T k−1/2 . (9.7)
k=1
where
Au ≈ −∇ · (a∇u) + cu + O(hp ).
1
Here we used f n−1/2 , instead of f n−1+θ , for a simplier presentation.
310 Chapter 9. Locally One-Dimensional Methods
Notes:
n v n − v n−1
∂ tv = .
∆t
Let
en = un − v n ,
where un is the exact solution of (9.8) at the time level tn . Then, the error
equation associated with the θ-method (9.9) is
Note that
1
θen + (1 − θ)en−1 = (en + en−1 ) + (2θ − 1)(en − en−1 )
2
and therefore
A[θen + (1 − θ)en−1 ], ∂ t en ∆t
1h
= (Aen , en ) − (Aen−1 , en−1 ) (9.13)
2 i
n n 2
+(2θ − 1)(A∂ t e , ∂ t e )∆t , n ≥ 1.
312 Chapter 9. Locally One-Dimensional Methods
Now, we apply the inequality (|ab| ≤ (a2 + b2 )/2) to the last term in (9.15) to
obtain the following inequality:
n
X n
X
j 2
k∂ t e k ∆t + (2θ − 1) (A∂ t ej , ∂ t ej )∆t2 + (Aen , en )
j=1 j=1
n
X (9.16)
≤ (Ae0 , e0 ) + kδ j−1/2 k2 ∆t.
j=1
1 + (2θ − 1)ρ(A)∆t ≥ 0,
A = A1 + A2 .
Then the Crank-Nicolson difference equation for the heat equation (9.8) reads
v n − v n−1 1
+ A(v n + v n−1 ) = f n−1/2 + O(hp + ∆t2 ), (9.18)
∆t 2
where
1
f n−1/2 = (f n + f n−1 ).
2
The truncation error for the CN procedure (9.18) is
O(∆x2 + ∆t2 ).
316 Chapter 9. Locally One-Dimensional Methods
Notes:
• an LU-based algorithm,
• a PCG-ILU0 procedure for the Crank-Nicolson equation derivable from
(9.9), and
• the ADI procedure of (9.19).
and the iteration stopped when the residual was reduced by a factor of 10−5 .
322 Chapter 9. Locally One-Dimensional Methods
n = 40 n = 80 n = 160
CPU L2 -error CPU L2 -error CPU L2 -error
LU-based 0.74 4.10e-3 9.07 1.00e-3 126 2.47e-4
PCG-ILU0 0.46 4.11e-3 5.67 1.00e-3 53.4 2.47e-4
ADI 0.26 4.10e-3 2.16 1.00e-3 17.9 2.47e-4
Table 9.1: The performances of the LU-based, PCG-ILU0, and ADI methods
for u = u+ . The elapsed time (CPU) is measured in seconds and the L2 -norm
of the error is evaluated at t = 1.
n = 40 n = 80 n = 160
CPU L2 -error CPU L2 -error CPU L2 -error
LU-based 0.91 2.46e-4 10.5 5.98e-5 136 1.47e-5
PCG-ILU0 0.83 2.46e-4 12.5 5.97e-5 121 1.42e-5
ADI 0.45 8.44e-3 3.62 2.02e-3 29.0 4.90e-4
Table 9.2: The performances of the LU-based, PCG-ILU0, and ADI methods
for u = u× .
Table 9.1 presents the elapsed times and numerical errors for u = u+ for
various grid sizes. As one can see from the table, the three different algo-
rithms show the same errors and their second-order convergence.
Table 9.2 shows the results for u = u× . The computation cost for the ADI
method increases linearly as the number of grid points grows, while the PCG-
ILU0 calculation shows a slight superlinearity in its computation cost. How-
ever, the ADI method produces an error approximately 34 times larger than
that for the LU-based or PCG-ILU0 methods for the same grid size.
9.3. LOD Methods for the Heat Equation 323
Truncation error vs. splitting error: The truncation error for the Crank-
Nicolson difference equation is of the form
4 4 3
∂ u ∂ u ∂ u
O h2x 4 + O h2y 4 + O ∆t2 3 ,
∂x ∂y ∂t
while the splitting error of the ADI method is
2 2
∂ ∂ ∂
O ∆t2 2 2 u .
∂x ∂y ∂t
This is, roughly speaking, why the ADI method introduces no splitting error
for u+ and a large splitting error for u× .
Now, since the operators Ai usually represent second-order differential op-
erators in an xi direction, it should not be surprising that the higher-order
derivatives in B∆t contribute bigger errors than the truncation error. We shall
see in §9.3.4 that it is not only possible but also quite feasible to modify the
algorithm (9.26) in a rather simple fashion to reduce the splitting error to
O(∆t3 ).
324 Chapter 9. Locally One-Dimensional Methods
i.e., the splitting error term is worse than the inherent local error in the
Crank-Nicolson equation.
This is the reason that (9.33) is not common; the FS methods have been
employed for the backward Euler method rather than the Crank-Nicholson
method. However, we shall be able to modify the procedure (9.33) in an
equally simple fashion to reduce the splitting error to O(∆t3 ) below.
326 Chapter 9. Locally One-Dimensional Methods
if the right hand side term of (9.26) is f n−1/2 , then the right hand side
of (9.29) is also f n−1/2 and the splitting error is given by B∆t (wn −
wn−1 ).
If we could add B∆t (wn − wn−1 ) to the right hand side of (9.29), then we
could cancel the perturbation term completely; but since we do not know wn ,
we cannot make this modification in the algorithm.
Our best estimate for (wn − wn−1 ) is (wn−1 − wn−2 ).
9.3. LOD Methods for the Heat Equation 327
Modification of the ADI: Let us modify the ADI algorithm to the fol-
lowing: For n ≥ 2,
n
FAD = f n−1/2 + B∆t (z n−1 − z n−2 ),
m
∆t ∆t X
1+ A1 z n,1 = 1− A1 − ∆t Ai z n−1 + ∆t FAD n
,
2 2 i=2 (9.37)
∆t ∆t
1+ Aκ z n,κ = z n,κ−1 + Aκ z n−1 , κ = 2, . . . , m,
2 2
zn n,m
= z .
and the splitting error is now higher order in ∆t than the truncation error of
the Crank-Nicolson equation.
We shall both prove the convergence of the solution of (9.37) to that of (9.8)
under certain circumstances and demonstrate that the error in the solution of
(9.37) is reduced essentially to that of the Crank-Nicolson procedure for the
example u× considered above, for which the splitting error was many times as
large as the Crank-Nicolson error.
9.3. LOD Methods for the Heat Equation 329
ζ 0 = wn−1 . (9.41)
On the other hand, the solution z n of (9.37) is the first iterate of (9.40) with
γ = z n−1 and the initial value
Remarks [16]:
• We have not only shown how to reduce the splitting errors for the ADI
and FS methods but also discovered that their improved procedures lead
to identical results “(after several decades of being considered to be
different techniques)."
• Again, it is advisable to obtain z 1 as discussed earlier.
• If the values of Ai z n−1 are saved, then there is essentially no difference in
the implementation of algorithms (9.37) and (9.45). That being the case,
we shall address both algorithms as pertaining to the ADI-II method.
9.3. LOD Methods for the Heat Equation 333
Apply the inequality (|ab| ≤ (a2 +b2 )/2) to the last term in (9.52). Then utilizing
(9.53), one can obtain the following inequality:
n
X
k∂ t ej k2 ∆t + (Aen , en ) + ∆t2 (B∆t ∂ t en , ∂ t en )
j=2
n
X (9.54)
≤ kδ j k2 ∆t + (Ae1 , e1 ) + ∆t2 (B∆t ∂ t e1 , ∂ t e1 ), n ≥ 2.
j=2
Thus, the estimation of the error generated by the ADI-II method is, in
the commutative case, reduced to bounding the errors in z 0 and z 1 , thereby
emphasizing the remarks above on the evaluation of z 1 . Try to compare the
above analysis with (9.16) when θ = 1/2.
9.3. LOD Methods for the Heat Equation 335
• The first time step to obtain z 1 for the ADI-II was made by following the
w1 -ADI calculation by SOR iterations to get the Crank-Nicolson value.
• Here, we compare the results of four different algorithms, namely the
LU-based, PCG-ILU0, ADI, and ADI-II methods.
336 Chapter 9. Locally One-Dimensional Methods
a = a1 a = a2 a = a3
CPU L2 -error CPU L2 -error CPU L2 -error
LU-based 23.6 1.10e-3 27.2 3.52e-3 24.2 5.35e-3
PCG-ILU0 21.6 1.09e-3 24.0 3.52e-3 24.7 5.36e-3
ADI 7.14 1.70e-2 10.9 1.02e-2 7.91 2.67e-2
ADI-II 7.77 1.10e-3 11.3 3.54e-3 8.46 5.35e-3
Table 9.3: The performances of the LU-based, PCG-ILU0, ADI, and ADI-II
methods with c = α2 ≡ 0, νt = 1, νx = 4, νy = 3, nx = ny = nt = 100 for u = u× .
∆t = 2h ∆t = h ∆t = h/2 ∆t = h/4
CPU L2 -error CPU L2 -error CPU L2 -error CPU L2 -error
LU-based 28.4 2.12e-3 49.6 2.13e-3 92.1 2.13e-3 176 2.13e-3
PCG-ILU0 24.9 2.14e-3 36.5 2.15e-3 57.6 2.14e-3 96.8 2.13e-3
ADI 8.19 2.01e-1 16.3 6.76e-2 32.4 1.75e-2 64.5 4.86e-3
ADI-II 8.80 1.10e-2 16.9 2.17e-3 33.2 2.13e-3 66.1 2.13e-3
Table 9.4: The performances of the LU-based, PCG-ILU0, ADI, and ADI-II
methods with a = a4 , c = α2 ≡ 0, νt = 2.0, νx = 6.25, νy = 7, h = hx = hy = 1/120,
and u = u× .
Table 9.3 presents the performances of the four algorithms for the first
three diffusion coefficients in (9.55) for u = u× with νt = 1, νx = 4, and νy = 3.
The error for the ADI method is 16, 3, and 5 times larger than the Crank-
Nicolson error for a = a1 , a2 , and a3 , respectively. The ADI-II method requires
only about 5-7% extra cost over the ADI method and its accuracy hardly differs
from that of the direct, LU-based solver, when ∆t ≤ h.
Table 9.4 shows numerical results for various time steps, when a = a4 (an
anisotropic diffusivity), c = α2 ≡ 0, νt = 2, νx = 6.25, and νy = 7, and h = hx =
hy = 1/120. The ADI calculations show large splitting errors, even for small
time steps. Here again the improved initialization (9.42) greatly improves
the accuracy of the alternating direction procedure, for a few percent of extra
cost. However, as one can see from the table, the ADI-II algorithm generates a
splitting error that is a few times the Crank-Nicolson error for ∆t = 2h. Thus
one has to choose ∆t sufficiently small, although the splitting error is O(∆t3 ).
9.4. Homework 337
9.4. Homework
1. Show that all of (9.19), (9.20), and (9.23) are equivalent to each other.
Count and compare the required operations for (9.20) and (9.23) in each
time level.
2. Show that (9.28) is equivalent to (9.29)-(9.30), for m = 3.
3. Check if (9.37) is equivalent to (9.43), when m = 2. Count to compare the
required operations for them.
4. The given code in Matlab is an implementation for the ADI (9.20) solving
the heat equation in 2D. Adjust the code for ADI-II (9.37) with m = 2.
(a) The major step you should fulfill is to adjust F in xy_sweeps.m.
(b) Perform error analysis comparing errors from ADI and ADI-II.
(c) Report your additions to the code.
338 Chapter 9. Locally One-Dimensional Methods
Chapter 10
Special Schemes
339
340 Chapter 10. Special Schemes
iω
u
b+ubν = 0, (10.3)
v
where i is the imaginary unit, ω (:= 2πλ) denotes the angular frequency, and
ˆ ∞
1
b(x, ω) = √
u u(x, t)e−iωt dt.
2π −∞
In order to suppress the boundary reflection, Kim et al. [43] introduced the
following ABC
iω τν u
b+u
bν = 0, (10.4)
where τ is an appropriate solution of the eikonal equation
1
|∇τ | = , τ (xs ) = 0, (10.5)
v
which can be solved effectively by employing optimal solvers such as the group
marching method (GMM) [39] and a high-order ENO-type iterative method
[40].
For the time domain simulation of the acoustic waves, we apply the inverse
Fourier transform to (10.4) to obtain
τν ut + uν = 0, (10.6)
which will be called the traveltime ABC (TT-ABC). Note that τν ≥ 0 for out-
going waves and
cos θ
τν = ∇τ · ν = |∇τ | cos θ = ,
v
where θ is the angle of the wave measured with respect to the normal of the
boundary. Thus the TT-ABC is a canonical form of the first-order ABC [29].
For normally incident wavefronts, τν = |∇τ | and therefore the TT-ABC (10.6)
acts like the CE-ABC (10.1.b).
342 Chapter 10. Special Schemes
• See Engquist-Majda [22] and Higdon [29, 30] for a hierarchy of ABCs
which approximate the nonlocal, pseudodifferential ABC [21].
• See [28, 31, 49, 66] for recent strategies for effective ABCs.
• For the point C, unS and unW are ghost values to be eliminated. The WF-
ABC (10.10) reads
2 2
Perform (10.11)+ (10.14.a)+ (10.14.b) and then solve the resulting
∆x ∆y
n+1
equation for uO at the point C:
Projects∗
347
348 Chapter 11. Projects∗
– (a, b) = (0, π)
– K(x) = 1 + x
– r(x) ≡ 1
– The exact solution u(x) = sin(x).
You have to set f and g correspondingly; for example, g(0) = 1 and g(π) =
−(1 + π).
• Report your results by Tue Nov 24, 2015, in hard copies, including new
functions (you implemented) and convergence analysis. The project is
worth 100 points.
Appendix A
349
350 Appendix A. Basic Concepts in Fluid Dynamics
where ΩCV is the CV, n denotes the unit outward normal to ∂ΩCV , dS repre-
sents the surface element, v is the fluid velocity, and vb denotes the velocity
of the CV surface ∂ΩCV . The equation (A.4) is called the control volume equa-
tion or the Reynolds’s transport equation. For a fixed CV, vb = 0 and the first
derivative on the right hand side of (A.4) becomes a local (partial) derivative:
ˆ ˆ ˆ
d ∂
ρφ dΩ = ρφ dΩ + ρφ v · n dS. (A.5)
dt ΩCM ∂t ΩCV ∂ΩCV
where we have omitted the subscript CV from Ω. The above equation is also
called the continuity equation. Recall the Gauss’s divergence theorem
ˆ ˆ
∇ · A dΩ = A · n dS, (A.7)
Ω ∂Ω
for any vector field A defined in the control volume Ω. Applying (A.7) to (A.6)
and allowing the CV to become infinitesimally small, we have the following
differential coordinate-free form of the continuity equation
∂ρ
+ ∇ · (ρv) = 0, (A.8)
∂t
and its Cartesian form
∂ρ ∂(ρvi ) ∂ρ ∂(ρu) ∂(ρv) ∂(ρw)
+ = + + + = 0, (A.9)
∂t ∂xi ∂t ∂x ∂y ∂z
where xi (i = 1, 2, 3) or (x, y, z) are the Cartesian coordinates and vi or (u, v, w)
are the Cartesian components of the velocity v. Here we have utilized the
Einstein convention that whenever the same index appears twice in any term,
summation over the range of that index is applied.
where p is the static pressure, µ and κ are respectively the shear coefficient
of viscosity and the bulk coefficient of viscosity, I is the unit (identity) tensor,
and D is the rate of strain (deformation) tensor defined by
1 T
D= ∇v + (∇v) . (A.12)
2
The following notation is often used in the literature to denote the viscous
part of the stress tensor
2
τ = 2µD + κ − µ ∇ · v I. (A.13)
3
Thus the stress tensor can be written as
T = τ − pI (A.14)
where D is the diffusivity for φ. The equation (A.30) is called Fick’s law for
mass diffusion or Fourier’s law for heat diffusion. Since the sources/sinks can
be expressed as ˆ
fφs = qφ dΩ,
Ω
setting fφ = fφd + fφs and applying the Gauss’s divergence theorem, one can
obtain the generic transport equation, the coordinate-free form of the equation
(A.29):
∂(ρφ)
+ ∇ · (ρφv) = ∇ · (D∇φ) + qφ . (A.31)
∂t
The lecture note will first focus on the numerical methods for (A.31). More pre-
cisely, we will consider numerical methods for the convection-diffusion equa-
tion of the form
∂c
(a) + ∇ · (vc) − ∇ · (D∇c) = f, (x, t) ∈ Ω × J,
∂t (A.32)
(b) (D∇c) · ν = 0, (x, t) ∈ Γ × J,
(c) c = c0 , x ∈ Ω, t = 0,
where c is the unknown (e.g. concentration), Ω ⊂ Rd , 1 ≤ d ≤ 3, is a bounded
domain with its boundary Γ = ∂Ω and J = (0, T ] the time interval, T > 0.
Here v = v(c) is the fluid velocity, ν is the outward normal to Γ, and f = f (c)
denotes chemical reactions and source/sink. The diffusion tensor D = D(v, c)
is symmetric and positive definite:
DT = D; D∗ |y|2 ≤ yT D(x)y ≤ D∗ |y|2 , ∀ x ∈ Ω, ∀ y ∈ Rd ,
for some positive constants D∗ and D∗ . The velocity either can be obtained
by solving another equation such as the pressure equation or is given from
experiments.
Special features of the continuity and momentum equations (Navier-Stokes
equations) will be considered afterwards as applications of the numerical meth-
ods for the generic equation.
A.6. Homework
1. Use ∇ · (ρvi v) = vi ∇ · (ρv) + ρv · ∇vi to derive (A.22) from (A.9) and (A.18).
A.6. Homework 357
2. Derive (A.23).
358 Appendix A. Basic Concepts in Fluid Dynamics
Appendix B
−∇ · (A∇u) + b · ∇u + cu = f, (B.2)
where b = (b1 , b2 ).
The Fourier transform in 2D reads
ˆ
1
u
b(ξ) = u(x)e−ix·ξ dx;
2π R2
its inverse formula is ˆ
1
u(x) = u(ξ)eix·ξ dξ.
2π R2
The Fourier transform satisfies the Parseval’s identity
ˆ ˆ
2
|u(x)| dx = u(ξ)|2 dξ.
|b (B.3)
R2 R2
359
360 Appendix B. Elliptic Partial Differential Equations
Since
|α| α
∂d
x u=i ξ u
α
b, (B.4)
equation (B.2) in its Fourier transform becomes
P (ξ) u
b(ξ) = fb(ξ), (B.5)
where
P (ξ) = ξ · Aξ + ib · ξ + c.
From the ellipticity requirements: a11 > 0, a22 > 0, and a11 a22 > a212 , we see
ξ · Aξ ≥ C0 |ξ|2 ,
for some C0 > 0. Thus there are C1 > 0 and R0 ≥ 0 such that
With the aid of Theorem B.1, the strong maximum principle for subhar-
monic functions and the strong minimum principle for superharmonic func-
tions can be derived as follows.
Theorem B.2. Let −∆u ≤ 0 (≥ 0) in Ω and suppose there is a point y ∈ Ω
such that
u(y) = sup u (inf u).
Ω Ω
Theorem B.2 implies the following weak maximum and minimum princi-
ples.
Theorem B.3. Let u ∈ C 2 (Ω) ∩ C 0 (Ω) with −∆u ≤ 0 (≥ 0) in Ω. Then,
provided that Ω is bounded,
sup u = sup u (inf u = inf u).
Ω ∂Ω Ω ∂Ω
The uniqueness theorem for the classical Dirichlet problem for the Poisson
equation in bounded domains follows from Theorem B.3.
Theorem B.4. Let u, v ∈ C 2 (Ω) ∩ C 0 (Ω) satisfy −∆u = −∆v in Ω and u = v
on ∂Ω. Then u = v in Ω.
B.3. Discrete Maximum and Minimum Principles 363
Proof. First, consider the case −∆h u ≤ 0; let u have a maximum value at an
interior point xpq . The condition −∆h u ≤ 0 is equivalent to
1
upq ≤ 2
(up−1,q + up+1,q + r2 up,q−1 + r2 up,q+1 ), (B.14)
2 + 2r
where r = hx /hy . Hence this easily leads to the conclusion that the interior
point xpq can have a (local) maximum only if all neighboring points have the
364 Appendix B. Elliptic Partial Differential Equations
same maximum value and that the inequality is actually an equality. The
argument then implies that u has the same value at all grid points includ-
ing those on the boundary. This proves the discrete maximum principle for
−∆h u ≤ 0. Now, the discrete minimum principle for the superharmonic func-
tions can be proved by replacing u by −u and following the same argument.
When b = 0, it is easy to see that the coefficients apq rs , (pq) 6= (rs), are all
strictly negative; for the case b 6= 0, one needs to choose the grid size h suffi-
ciently small in order for the four off-diagonal entries of the algebraic system
to remain negative. Now, let upq be an interior (local) maximum. Then it fol-
lows from (B.15), (B.16), and apq rs < 0, (pq) 6= (rs), that all the neighboring
values must be the same as the maximum, which implies u is constant on
B.4. Coordinate Changes 365
and
ξ2
1 −
T
T 1 + ξ1
B = JAJ = JJ = .
ξ2 ξ22 + 4
−
1 + ξ1 (1 + ξ1 )2
The matrix B(ξ) is clearly symmetric and positive definite on the unit square.
The problem
−∇ · B(ξ)∇ u = f (ξ), ξ ∈ (0, 1)2 ,
can be approximated by the standard second-order FD method.
∂ 2u
∂ ∂u sin φ ∂ ∂u
= cos φ −
∂x2 ∂ρ ∂x ρ ∂φ ∂x
∂ ∂u sin φ ∂u sin φ ∂ ∂u sin φ ∂u
= cos φ cos φ − − cos φ −
∂ρ ∂ρ ρ ∂φ ρ ∂φ ∂ρ ρ ∂φ
2 2 2 2
∂ u 2 sin φ cos φ ∂ u sin φ ∂ u
= cos2 φ 2 − +
∂ρ ρ ∂φ∂ρ ρ2 ∂φ2
2
sin φ ∂u 2 sin φ cos φ ∂u
+ + .
ρ ∂ρ ρ2 ∂φ
(B.23)
B.5. Cylindrical and Spherical Coordinates 367
To be included.
369
370 Appendix C. Helmholtz Wave Equation∗
Appendix D
To be included.
371
372 Appendix D. Richards’s Equation for Unsaturated Water Flow∗
Appendix E
Let w be a given function defined on (−1, 1) and positive there. (The function
w is often called a weight function.) Let f and g be defined on the interval
(−1, 1). Define the scalar product of the functions f and g on (−1, 1) as
ˆ 1
(f, g)w = f (x)g(x)w(x)dx. (E.1)
−1
Then, the orthogonal polynomials on (−1, 1) with respect to the weight func-
tion w are a series of polynomials {Pk }k=0,1,2,··· satisfying
Pk ∈ Pk ; (Pk , Pm )w = 0, k 6= m, (E.2)
373
374 Appendix E. Orthogonal Polynomials and Quadratures
where
P−1 ≡ 0,
αk+1
Ak = ,
αk
(xPk , Pk )w
Bk = ,
Sk
arbitrary, k = 0,
Ck = Ak Sk
, k > 0.
Ak−1 Sk−1
Sk = (Pk , Pk )w .
w(x) ≡ 1.
With this choice of the weight function, starting with L0 (x) = 1, one can get
2k + 1 k
Ak = , Bk = 0, Ck = ,
k+1 k+1
where a normalization is applied for Lk (1) = 1. Thus the Legendre polynomi-
als satisfy the following three-term recurrence relation
L0 (x) = 1,
L1 (x) = x,
3 2 1
L2 (x) = x − ,
2 3 (E.5)
5 3 3
L3 (x) = x − x ,
2 5
35 4 6 2 3
L4 (x) = x − x + .
8 7 35
E.2. Gauss-Type Quadratures 375
w(x) := (1 − x2 )−1/2 .
With this choice of the weight function, one can get the three-term recurrence
relation for the Chebyshev polynomials
Tk+1 (x) = 2xTk (x) − Tk−1 (x). (E.7)
A few first Chebyshev polynomials are
T0 (x) = 1,
T1 (x) = x,
T2 (x) = 2x2 − 1, (E.8)
T3 (x) = 4x3 − 3x,
T4 (x) = 8x4 − 8x2 + 1.
Relevant properties are
|Tk (x)| ≤ 1, ∀ x ∈ [−1, 1],
Tk (±1) = (±1)k ,
|Tk0 (x)| ≤ k 2 , ∀ x ∈ [−1, 1],
(E.9)
Tk0 (±1) = (±1)k k 2 ,
π, if k = 0,
(Tk , Tk )w =
π/2, if k ≥ 1.
Then,
ˆ 1 n
X
f (x)w(x) = f (xj )wj , ∀ f ∈ P2n−1 . (E.11)
−1 j=0
For the Legendre polynomials, the explicit formulas for the quadrature
nodes are not known. Thus the nodal points and the corresponding weights
must be computed numerically as zeros of appropriate polynomials and the
E.2. Gauss-Type Quadratures 377
Legendre-Gauss-Lobatto:
x0 = −1, xn = 1; xj (= zeros of L0n ), j = 1, 2, · · · , n − 1,
2 (E.13)
wj = , j = 0, 1, · · · , n.
n(n + 1)[Ln (xj )]2
Chebyshev-Gauss:
(2j + 1)π π
xj = − cos , wj = , j = 0, 1, · · · , n. (E.14)
2n + 2 n+1
Chebyshev-Gauss-Lobatto:
jπ π/(2n), j = 0, n,
xj = − cos , wj = (E.15)
n π/n, j = 1, · · · , n − 1.
A · B = A1 B1 + A2 B2 + A3 B3
379
380 Appendix F. Some Mathematical Formulas
and
A × B = (A2 B3 − A3 B2 , A3 B1 − A1 B3 , A1 B2 − A2 B1 )
jb1 jb2 jb3
= det A1 A2 A3 ,
B1 B2 B3
where jbi is the unit vector in the xi -direction. Then
A · B = |A| |B| cos θ, A × B = |A| |B| sin θ n
b,
where θ is the angle between A and B and n b is the unit normal vector from the
plane containing A and B whose orientation is determined by the right-hand
rule. (When four fingers grab directing from A to B, then the direction of the
thumb determines n b .) Let ∇× denote the curl operator defined as
∂A3 ∂A2 ∂A1 ∂A3 ∂A2 ∂A1
∇×A= − , − , − .
∂y ∂z ∂z ∂x ∂x ∂y
Then,
A · (B × C) = B · (C × A) = C · (A × B),
A × (B × C) = (A · C)B − (A · B)C,
(A × B) · (C × D) = (A · C)(B · D) − (A · D)(B · C),
∇(A · B) = A × (∇ × B) + B × (∇ × A) + (A · ∇)B + (B · ∇)A,
∇ · (A × B) = B · (∇ × A) − A · (∇ × B),
(F.3)
∇ × (f A) = f (∇ × A) − A × (∇f ),
∇ × (A × B) = (B · ∇)A − (A · ∇)B + A(∇ · B) − B(∇ · A),
∇ · (∇ × A) = 0,
∇ × (∇f ) = 0,
∇ × (∇ × A) = ∇(∇ · A) − ∇2 A.
Associated with vectors are the following integrals.
Gauss’s divergence theorem:
ˆ ˛
∇ · B dx = B · n ds
V A
Stokes’s theorem: ˆ ˛
(∇ × B) · n ds = B · dl
A C
Appendix G
u1 − u−1
ux (x0 ) ≈
2h
u1 − 2u0 + u−1
uxx (x0 ) ≈
h2 (G.1)
u2 − 2u1 + 2u−1 − u−2
uxxx (x0 ) ≈
2h3
u2 − 4u1 + 6u0 − 4u−1 + u−2
u(4) (x0 ) ≈
h4
[4] P. B JORSTAD AND O. W IDLUND, Iterative methods for the solution of el-
liptic problems on regions partitioned into substructures, SIAM J. Numer.
Anal., 23 (1986), pp. 1097–1120.
383
384 BIBLIOGRAPHY
[19] M. D RYJA AND O. W IDLUND, Some recent results on Schwarz type do-
main decomposition algorithms, in Domain Decomposition Methods in
Science and Engineering, A. Quarteroni, J. Periaux, Y. Kuznetsov, and
O. Widlund, eds., vol. 157 of Contemporary Mathematics, Philadelphia,
1994, SIAM, pp. 53–61.
[21] B. E NGQUIST AND A. M AJDA, Absorbing boundary conditions for the nu-
merical simulation of waves, Math. Comp., 31 (1977), pp. 629–651.
[25] S. G ERSCHGORIN, Über die abgrenzung der eigenwerte einer matrix, Izv.
Akad. Nauk SSSR Ser. Mat., 7 (1931), pp. 746–754.
[39] , An O(N ) level set method for eikonal equations, SIAM J. Sci. Com-
put., 22 (2001), pp. 2178–2193.
[40] S. K IM AND R. C OOK, 3D traveltime computation using second-order
ENO scheme, Geophysics, 64 (1999), pp. 1867–1876.
[41] S. K IM AND S OOHYUN K IM, Multigrid simulation for high-frequency so-
lutions of the Helmholtz problem in heterogeneous media, SIAM J. Sci.
Comput., 24 (2002), pp. 684–701.
[42] S. K IM AND M. L EE, Artificial damping techniques for scalar waves in the
frequency domain, Computers Math. Applic., 31, No. 8 (1996), pp. 1–12.
[43] S. K IM , C. S HIN, AND J. K ELLER, High-frequency asymptotics for the
numerical solution of the Helmholtz equation, Appl. Math. Letters, 18
(2005), pp. 797–804.
[44] S. K IM AND W. S YMES, Multigrid domain decomposition methods for
the Helmholtz problem, in Mathematical and Numerical Aspects of Wave
Propagation, J. A. DeSanto, ed., SIAM, Philadelphia, 1998, pp. 617–619.
[45] P. L E T ALLEC, Domain decomposition methods in computational me-
chanics, Comput. Mech. Advances, 1 (1994), pp. 121–220.
[46] H. L IM , S. K IM , AND J. D OUGLAS, J R ., Numerical methods for viscous
and nonviscous wave equations, Appl. Numer. Math., 57 (2007), pp. 194–
212.
[47] P. L IONS, On the Schwarz alternating method I, in First International
Symposium on Domain Decomposition Method for Partial Differential
Equations, R. Glowinski, G. Golub, G. Meurant, and J. Periaux, eds.,
Philadelphia, PA, 1988, SIAM, pp. 1–42.
[48] , On the Schwarz alternating method III: a variant for nonoverlap-
ping subdomains, in Domain Decomposition Methods for Partial Differ-
ential Equations, T. Chan, R. Glowinski, J. Periaux, and O. Widlund, eds.,
Philadelphia, PA, 1990, SIAM, pp. 202–223.
[49] F. M AGOULÈS , F.-X. R OUX , AND L. S ERIES, Algebraic way to derive
absorbing boundary conditions for the Helmholtz equation, J. Comput.
Acoust., 13 (2005), pp. 433–454.
388 BIBLIOGRAPHY
[65] O. T AUSSKY, Bounds for characteristic roots of matrices, Duke Math. J.,
15 (1948), pp. 1043–1044.
[71] N. YANENKO, Convergence of the method of splitting for the heat con-
duction equations with variable coefficients (English translation), USSR
Comp. Math., 3 (1963), pp. 1094–1100.
390 BIBLIOGRAPHY
391
392 INDEX