Numerical Modeling of Earth Systems
Numerical Modeling of Earth Systems
Thorsten W. Becker
Department of Earth Sciences,
University of Southern California, Los Angeles CA, USA
and
Boris J. P. Kaus
University of Mainz, Germany
Preface
1.1 Purpose of these lecture notes
1.2 Acknowledgments . . . . . .
1.3 Abbreviations used . . . . . .
1.4 Typesetting conventions . . .
1.5 Other resources . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
7
9
10
10
10
Introduction
12
13
13
13
13
14
18
19
19
19
19
22
25
25
26
27
28
29
32
32
33
35
II
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
39
40
40
41
42
44
45
45
46
3.3.3
3.3.4
III
4
Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Additional examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
52
Finite differences
4.1 Introduction to the finite difference method . . . . . . . . . . . . . . . . . .
4.1.1 Finite differences and Taylor series expansions . . . . . . . . . . . .
4.1.2 Finite difference approximations overview . . . . . . . . . . . . . .
4.1.3 Derivatives with variable coefficients . . . . . . . . . . . . . . . . .
4.2 Finite difference example: 1D explicit heat equation . . . . . . . . . . . . .
4.2.1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Implicit FD schemes and boundary conditions . . . . . . . . . . . . . . . .
4.3.1 Time derivatives explicit vrs. implicit . . . . . . . . . . . . . . . .
4.4 Finite difference example: 1D implicit heat equation . . . . . . . . . . . . .
4.4.1 Boundary conditions Neumann and Dirichlet . . . . . . . . . . .
4.4.2 Solving an implicit finite difference scheme . . . . . . . . . . . . . .
4.4.3 Matlab implementation . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Derivation of flux boundary conditions (fictitious boundary points) . . . .
4.6 Non-linearities with FD methods . . . . . . . . . . . . . . . . . . . . . . . .
4.6.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7 Two-dimensional heat equation with FD . . . . . . . . . . . . . . . . . . . .
4.7.1 Explicit method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7.2 Fully implicit method . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7.3 Other methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.8 Exercise: 2D heat equation with FD . . . . . . . . . . . . . . . . . . . . . . .
4.9 Advection equations with FD . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9.1 The diffusion-advection (energy) equation for temperature in convection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9.2 Advection (transport equations) . . . . . . . . . . . . . . . . . . . .
4.9.3 Advection and diffusion: operator splitting . . . . . . . . . . . . . .
4.10 2D Stokes equations on a staggered grid using primitive variables . . . . .
4.10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.10.2 Governing equations . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.10.3 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11 Stokes equations with FD on a staggered grid using the stream-function
approach. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11.2 Governing equations . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.11.3 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.12 Wave propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
53
53
53
56
57
58
60
63
63
66
66
67
68
69
71
73
73
75
75
76
79
79
83
.
.
.
.
.
.
.
83
85
94
96
96
96
97
.
.
.
.
.
100
100
100
102
104
Finite elements
5.1 Introduction to finite element methods . . . . . . . . . . . . . . . . . . . .
5.1.1 Philosophy of the finite element (FE) method . . . . . . . . . . . .
5.1.2 A one dimensional example . . . . . . . . . . . . . . . . . . . . .
5.1.3 Galerkin method . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.4 Shape functions and discretization . . . . . . . . . . . . . . . . . .
5.2 A 1-D FE example implementation . . . . . . . . . . . . . . . . . . . . . .
5.2.1 Local vs. global points of view . . . . . . . . . . . . . . . . . . . .
5.2.2 Matrix assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2.3 Element-local computations . . . . . . . . . . . . . . . . . . . . . .
5.3 Exercise: 1-D heat conduction with finite elements . . . . . . . . . . . . .
5.3.1 Implementation of the 1-D heat equation example . . . . . . . . .
5.3.2 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4 Solution of large, sparse linear systems of equations . . . . . . . . . . . .
5.4.1 Direct solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4.2 Iterative solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Two-Dimensional boundary value problems with FE . . . . . . . . . . .
5.5.1 Linear heat conduction . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.2 Matrix assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.3 Isoparametric elements . . . . . . . . . . . . . . . . . . . . . . . .
5.5.4 Numerical integration . . . . . . . . . . . . . . . . . . . . . . . . .
5.5.5 Simple elements, shape functions and Gaussian quadrature rules
5.5.6 Inverse transformation of parametric elements . . . . . . . . . . .
5.6 Exercise: Heat equation in 2-D with FE . . . . . . . . . . . . . . . . . . . .
5.6.1 Implementation of 2-D heat equation . . . . . . . . . . . . . . . .
5.7 Exercise: Linear elastic, compressible finite element problem . . . . . . .
5.7.1 Implementation of static 2-D elasticity . . . . . . . . . . . . . . . .
5.8 Incompressible flow and elasticity with FE . . . . . . . . . . . . . . . . .
5.8.1 Governing equations . . . . . . . . . . . . . . . . . . . . . . . . . .
5.8.2 FE solution to the incompressible elastic/flow problem . . . . . .
5.9 Exercise: Linear, incompressible Stokes flow with FE . . . . . . . . . . . .
5.9.1 Implementation of incompressible, Stokes flow . . . . . . . . . . .
5.9.2 Problem in strong form . . . . . . . . . . . . . . . . . . . . . . . .
5.9.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.10 Time-dependent FE methods . . . . . . . . . . . . . . . . . . . . . . . . .
5.10.1 Example: Heat equation . . . . . . . . . . . . . . . . . . . . . . . .
5.10.2 Solution of the semi-discrete heat equation . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
110
110
110
112
115
115
117
118
119
121
122
122
124
125
125
126
131
132
135
136
137
140
143
144
144
148
149
156
156
157
162
162
164
167
170
170
172
IV
6
Appendix
Basic calculus and algebra review
6.1 Calculus . . . . . . . . . . . . . . .
6.1.1 Full and partial derivatives
6.1.2 Divergence and curl . . . .
6.1.3 Integrals . . . . . . . . . . .
6.2 Linear algebra . . . . . . . . . . . .
6.2.1 The dot product . . . . . . .
6.2.2 Vector or cross product . . .
6.2.3 Matrices and tensors . . . .
6.2.4 Tensors . . . . . . . . . . . .
175
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
176
176
176
178
180
182
182
183
184
187
.
.
.
.
.
.
.
188
188
189
191
192
193
193
193
. 195
. 196
Introduction to MATLAB
8.1 Introduction . . . . . . . . . . . . .
8.2 Useful linear algebra (reprise) . . .
8.3 Exploring MATLAB . . . . . . . . .
8.3.1 Getting started . . . . . . .
8.3.2 Vectors/arrays and plotting
8.3.3 Matrices and 3D plotting .
8.3.4 Matlab scripting . . . . . .
8.3.5 Loops . . . . . . . . . . . . .
8.3.6 Cumulative sum . . . . . .
8.3.7 IF command . . . . . . . . .
8.3.8 FIND command . . . . . . .
8.3.9 Matrix operations . . . . . .
8.3.10 Functions . . . . . . . . . .
8.3.11 Variables and structures . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 195
197
197
198
199
199
200
200
202
202
202
203
203
203
203
204
205
Bibliography
208
Index
213
Chapter 1
Preface
1.1
Numerical modeling in the solid Earth Sciences has come a long way over the last fourty
years. Long-standing questions such as that of how surface tectonics arises from mantle convection can now be addressed with near-realistic convective vigor and material
behavior.
The modeling software used for such research can be increasingly complex, which is
why scientists often rely on existing codes, rather than writing them from scratch. Assuming the use of community software (such as those provided by the Computational
Infrastructure for Geodynamics (CIG), geodynamics.org) will continue to increase over
the next years, geodynamics as a field faces the challenge to educate graduate students
in numerical analysis without having each PhD student write their own code. This one
semester course is supposed to help address this challenge and is geared toward all Earth
science or engineering students (grad and advanced undergrad), and not just geophysicists.
The course discusses the numerical solution of problems arising in the quantitative
modeling of Earth systems. The focus is on continuum mechanics problems as applied
to geological processes in the solid Earth, but the numerical methods have broad applications including in geochemistry or climate modeling. The quantitative skills which are
to be learned are therefore useful for all Earth scientists, but the focus of the class is on
mantle convection and seismology type problems.
After an introduction with few details on numerical analysis and programming, we
briefly discuss ordinary differential equations (ODEs). Thereafter, the class spends the
majority of the time discussing finite difference (FD) and finite element (FE) solutions to
partial differential equations (PDEs). An example syllabus for how to use these notes is
given in sec. 9.1 A brief review of basic math and continuum mechanics fundamentals is
provided in secs. 6 and 7, respectively.
Every subject in this class is accompanied by hands-on Matlab programming exer1 The
syllabus in sec. 9 is not the 2013 version, the latter can be found on the course web page.
CHAPTER 1. PREFACE
cises. The course web site, geodynamics.usc.edu/~becker/teaching-557.html has the
required Matlab files, and splits the associated exercises up into single documents rather
than the complete set of notes provided here. The fact that many of the exercises are selfcontained also means that some material, such as the governing equations, are repeated
in several instances in these lecture notes.
We chose Matlab as a programming language because of its ease in developing and
debugging, as well as the built-in visualization capabilities. The fact that the language is
interpreted, and not compiled, does somewhat limit the direct applications of the implementations that are discussed, pretty much to 2D problems, yet at high efficiencies (e.g.
Dabrowski et al., 2008). Solutions for the Matlab exercises are available for instructors upon
request, and a brief introduction to Matlab exercise is provided in sec. 8.
Students should ideally have had exposure to calculus, some linear algebra, a classic,
introductory geodynamics (or continuum/rock mechanics) course (e.g., based on Turcotte
and Schubert, 2002), and have some introductory level knowledge of computer programming. Earth science students have diverse backgrounds and often do not fulfill all of
these math and programming prerequisites. We like to err on the side of learning by
doing and supporting a broad group of students, and therefore also provide primers on
calculus, linear algebra, continuum mechanics, and computer programming. After learning some basic programming skills, the students are then guided through increasingly
more involved programming using the problem sets as examples.
These notes are an attempt at an almost self-contained, introductory survey of numerical modeling. This necessitates skimming over many technical or theoretical issues (for
example, no mathematical proofs are given), and we also cannot give much room to the
discussion of alternative, or cutting edge numerical methods, for which other textbooks
exist. Our goal is to provide all students with a sufficient working knowledge to solve
simple research problems by reusing the Matlab codes introduced in problem sets, or by
writing their own software. The basic insights into numerical analysis that are conveyed
in this class should also help make students educated and empowered users and developers of more complex, existing community software.
CHAPTER 1. PREFACE
1.2
Acknowledgments
Parts of the original course notes are inspired by, or partially follow very closely, the treatment in the numerical analysis lecture notes by Spiegelman (2004), the notes by Schmeling
(1994), and the textbook by Press et al. (1993) on numerical analysis, and the textbook by
Hughes (2000) on finite element methods.
Some of the finite difference exercises and parts of the scaling homework assignment
CHAPTER 1. PREFACE
1.3
Abbreviations used
BC Boundary conditions
FD Finite differences
FE Finite elements
IC Initial condition
ODE Ordinary differential equation
PDE Partial differential equation
PDE Partial differential equation
ODE Ordinary differential equation
BC Boundary conditions
1.4
Typesetting conventions
Mathematical symbols are denoted by a for scalars, a for vectors, and A for tensors/matrices.
1.5
Other resources
This text is meant to be fairly self-contained, but there is some related materail which
we refer to often. This includes the following online resources:
Myths and Methods in Modeling by Spiegelman (2004);
Matlab Introduction by Spencer and Ware (2008);
Elsevier Treatise article on Numerical methods in mantle convection by Zhong et al.
(2007).
When used for a class, some accompanying textbooks we recommend are:
Numerical Recipes by Press et al. (1993), 2nd or 3rd edition;
USC GEOL557: Modeling Earth Systems
10
CHAPTER 1. PREFACE
Geodynamics by Turcotte and Schubert (2002) for background on geodynamics;
The finite element method by Hughes (2000), for further detailes on the finite element
method.
For finite elements, for example, there are, of course, a number of good textbooks.
Those include Kwon and Bang (1996), which provides a clear, step-by-step, introduction
with many Matlab program examples, and the classic by Bathe (2007) for a comprehensive
reference. For computational geodynamics, there is now Ismail-Zadeh and Tackley (2010)
for a broader, but less-detailed overview of general methods and Gerya (2009) for more
details on finite difference approaches.
Background material Short discussions of basic math, continuum mechanics, and Matlab are found in secs. 6, 7, and 8, respectively. Readers not familiar with this material may
wish to review those chapters.
Availability and contact A PDF of the lecture notes and Matlab exercises as used for a
graduate class at USC (GEOL557) can be found on course web site
http://geodynamics.usc.edu/~becker/teaching-557.html
For any questions, please contact
Thorsten W. Becker, University of Southern California: twb-at-usc-edu.
11
Part I
Introduction
12
Chapter 2
Introduction to numerical geodynamics
2.1
2.1.1
Philosophy
Avoid black boxes (e.g. commercial codes) in general. They may or may not do
what you like them to do; if they dont, youre out of luck because if you cannot
modify the source code. Exception for good black boxes are matrix solver and
linear algebra packages, generally speaking (but see sec. 5.4).
Create, or understand, as much code and theory as possible yourself, no matter if
you are geophysicist or geologist.
There are no Easy or Model my field data buttons, but you dont have to be a
math-whiz either!
2.1.2
Goals
Provide you with a basic understanding of numerical modeling, using solid Earth
science problems as an example.
Allow you to solve simple research problems using tools presented here, and, more
importantly, allow you to write new programs and solve different scientific questions yourself independently.
Help you become an informed, empowered user of sophisticated numerical codes.
Introduce some math and computer science along the way.
This text cannot
13
2.1.3
In general, numerical methods are important for forward and inverse problems. In particular, we may focus on
Differential equations of the partial (PDE) or ordinary (ODE) kind, which can be solved
with
finite difference methods
integral methods, such as finite elements and spectral methods.
Inverse problems where a structural or physical model of the Earth is inferred from (a
potentially very large) set of data. Methods may include
linear matrix inversion, least squares (with challenges related to those in finite
element methods)
Monte Carlo, simulated annealing
Genetic Algorithms
14
Figure 2.1: Estimated slip distribution on southern California faults for shear stress (left) and
Coulomb stress free, simultaneous slip, boundary element method computations (modified from
Becker and Schott, 2002). This method (e.g. Crouch and Starfield, 1983) uses Greens functions (here
computed following Okada, 1992) and either summation for estimating given slip distributions,
u, on faults, or solution of a large, linear system of equations to infer u for specified stress on the
faults.
15
Figure 2.2: Spherical, visco-plastic mantle convection computation results showing plate-like surface motions (left: velocity vectors on top of viscosity, right: cold temperature isosurface in the interior showing one-sided subduction due to slab rollback), modified from Foley and Becker (2009).
We use the CitcomS (Zhong et al., 2000) finite element software to solve the Stokes and energy
equations for an infinite Prantl number, incompressible fluid (cf. Zhong et al., 2007).
16
Figure 2.3: Global mantle circulation computation using mantle tomography to infer density distributions in the mantle and solving Stokes equation (modified from Becker and Faccenna, 2011),
see (cf. Hager and OConnell, 1981; Zhong et al., 2000; Becker, 2006). Visualization with Paraview
(Kitware, Inc., 2006).
17
2.1.4
Forward Problem
1. formulate model
2. identify theoretical description
3. solve
dimensional analysis
analytical solution
18
2.2
2.2.1
2.2.2
Examples:
y
= f (y)
t
x
= v
t
(2.1)
(2.2)
2.2.3
Many problems in the Earth sciences can be described by linear partial differential equations of second order. For constant coefficients k, we can write a general equation
k1
2 f
2 f
2 f
2 f
+
k
+
k
+
k
+
2
3
4
x2
y2
z2
t2
f
f
f
f
p1
+ p2 + p3 + p4
+
x
y
z
t
f ( x, y, z, t) = g( x, y, z, t).
(2.3)
(2.4)
(2.5)
19
f
n
f
n
= f n,
need to be specified.
k 2 T + H = 0,
(2.7)
2 = 4G.
(2.8)
For an isotropic and homogeneous medium, these equations correspond to the Poisson
2 f
2 f
2 f
f = 2 + 2 + 2 = g( x, y, z),
x
y
z
(2.9)
2 f = 0.
(2.10)
20
2 f = g( x, y, z, t) +
2 f
f
+
,
t
t2
(2.11)
where boundary conditions may also be a function of time t, and we need additional
initial conditions which provide f ( x, y, z, t0 ) = ( x, y, z).
For = 0, this is a parabolic PDE, with the classic example of the time-dependent heat
equation, an example of a diffusion equation
k 2 T + H = c p
T
,
t
(2.12)
k
.
c p
(2.13)
which yields
f = F ( x, y, z)eit ,
(2.15)
2 F = c2 2 F.
(2.16)
The resulting frequencies are the eigenfrequencies, e.g. of the vibrational modes of the
whole Earth induced by earthquakes.
In case both 6= 0 and 6= 0, we have a damped wave equation. In this case, two
initial conditions are needed,
f ( x, y, z, t0 ) = ( x, y, z)
f
( x, y, z, t0 ) = ( x, y, z)
t
21
(2.17)
(2.18)
2.2.4
x
which can be written as
2 u
+ s = 0.
(2.20)
x2
We may approximate this equation with finite differences as
ui+1 2ui + ui1
(x )2
= si .
(2.21)
Pros
conceptually simple, approximates the PDE
Cons
bad for sharp contrasts
bad for complicated geometries
code usually needs to be written from scratch for new problems
Finite Elements (FE)
The FE method is complicated conceptually, and provides an approximate solution to the
solutions, rather than the equations themselves. It is an integral method, where we take
eq. (2.20), multiply by a virtual displacement w and integrate over x
Z b
a
2 u
w 2
x
Z b
a
ws = 0,
(2.22)
x x
= hw(b) +
Z b
a
ws,
(2.23)
where h = u
x ( b ). This is the weak form of the PDE, and picking w as a low order polynomial forms the basis of the FE method.
USC GEOL557: Modeling Earth Systems
22
a j eijx
bj eijx
(2.25)
(2.26)
(2.27)
from which
a j j2 eijx = bj eijx ,
(2.28)
bj
aj = 2 .
j
(2.29)
The approach then consists in solving by computing b j by FFT of s, then use eq. (2.29),
then find f from inverse FFT of a j .
Pros
23
24
2.3
Computing
Here, we very briefly review some hardware related issues, give a few general programming tips, and then move on to get started programming using the Matlab language in
the next section. You can also refer to the hardware notes of Press et al. (1993) for some
background on machine architecture.
2.3.1
Hardware issues
At a low level, a computer stores information in the binary system, i.e. in bits that can
hold the values of either zero or one. You can then use a byte (8 bits) to encode numbers
from 0 to 28 1 = 255 using the binary system. For floating point or larger integers,
more memory is required. A single precision float take up four bytes and is accurate up
to 5 107 , a double precision float up to 5 1015 . With a 32 bit operating system,
the largest number you can represent is 231 1 2.1 billion. (Aside: this might seem like
a big number but is not, as it corresponds roughly to a bit more then 8003 resolution.)
25
2.3.2
run interpreted
Examples: Matlab - numerical computations
Octave (a free Matlab clone)
Mathematica for symbolic math
Python for programming and scripting
Pros:
rapid prototyping, convenient abstractions
convenient debugging
easy access to visualization (key for validation)
Cons:
interpreted at run time, can be slow
may require paying license fees
Libraries
NETLIB
BLAS
LAPACK
PETSc
Low level languages
26
2.3.3
Heres a non-sensical program written in the Matlab language to illustrate a few concepts.
% This is the main program. Notice the % symbol - it means this line is
% a comment and will be ignored at run time.
i = 0;
% assign integer variable for loop
n = 100;
% some number of elements
x = zeros(n,1);
% allocate and initialize a vector x[] with n elements
y = 1;
for i = 1:n
% loop from i = 1, 2, ..., n
USC GEOL557: Modeling Earth Systems
27
2.3.4
28
2.3.5
1. Avoid reading and writing intermediate steps to file, i.e. on the hard drive (Input/Output
or IO) if at all possible.
2. Use nested loops that are sorted by the fastest/major index, because memory access
is faster that way. The storage depends on the computer larguage (C vrs. FORTRAN). e.g. in Matlab, you would write
for i = 1:n
% increment i across all rows (slow index)
for j = 1:m
% row i computations across all columns j first
x(i,j) = x(i,j) * y(i,j);
end
end
to multiply x elements by those of y and NOT the other way around,
for j = 1:m
for i = 1:n
29
if optional and usually zero, comment it out using pre-processor directives. I.e. in
C, you would write the code like so
#ifdef DEBUG
% code here for debugging version of program
#else
% code here for the regular version of program
#end
depending on if you want those statements to be executed when the program runs.
4. Pre-compute common factors to avoid redundant computations.
For example, instead of
30
It is better to do
fac = pi/180;
for i = 1:n
x(i) = x(i)*fac;
end
because it entails one less division per step. In Matlab, its better still to use the
vectorized version, x=x.*fac.
5. Share the code!
The more eyes, the less bugs, and the better the performance.
6. Use hardware optimized packages for standard tasks, e.g.
LAPACK for linear algebra
This package is available highly optimized for several architectures.
FFTW for FFT,
an automatically adapting package.
Different hardware makes certain chunks of memory sized ( cache ) operations
highly efficient (see, e.g. Dabrowski et al., 2008, as used later in class).
7. Use version control!
Use version control packages (such as subversion, RCS) during code development,
as this might safe you an immense amount of time when youre trying to track down
where and when that bug crept into the code.
31
2.4
Reading
Spiegelman (2004), sec. 1.4
Turcotte and Schubert (2002), Google, and Wikipedia for reference and material parameters
2.4.1
Scaling analysis
Scaling analysis refers to order of magnitude estimates on how different processes work
together and control a system. While this is a text on numerical analysis, such theoretical
considerations are very useful if we are interested in getting a quick idea of the values that
are of relevance for a problem, and for the order of magnitude for solutions. Comparing
these estimates with the numerical results is always good practice and part of a basic set
of plausibility checks that have to be conducted.
For example, shear stress (in units of Pa) for a Newtonian viscous rheology with
viscosity (in units of Pa s) is given by the simple constitutive law
= 2
(2.30)
where is the strain-rate (in units of s1 ). Say, we wish to estimate the typical amplitudes
of shear stress in a part of the crust that we know is being sheared at some (e.g. plate-)
velocity u over a zone of width L. The strain-rate in 3-D is really a tensor, ,
with 3 3
components that depends on the spatial derivatives of the velocity like so
!
1 ui u j
+
,
(2.31)
= ij =
2 x j
xi
and has to be either constrained by kinematics or inferred for the full solution. However,
for our problem, we only need a characteristic value, i.e. correct up to a factor of ten
or so. Strain-rate is physically the change in velocity over length, and the characteristic
strain-rate is then given by
v
(2.32)
L
where means proportional to, or scales as, to indicate that eq. (2.32) is not exact.
Assuming we know the viscosity , we can then estimate the typical stress in the shear
zone to be
v
(2.33)
2 .
L
32
2.4.2
Non-dimensionalization
A complementary approach that also takes into account the order of magnitude of variables is to simplify the governing equations by defining characteristic quantities and
then dividing all properties by those to make them non-dimensional. This way, the
non-dimensional quantities that enter the equation on their own should all be of order
unity so that the resulting collection of parameters in some part of the equation measures
their relative importance.
A classic example for this is based on the Navier Stokes equation for an incompressible, Newtonian fluid. When body forces driving flow are due to temperature T fluctuations in (the Earths) gravitational field
Dv
= pd + 2 v + 0 Tg
Dt
where D is the total, Lagrangian derivative operator
(2.34)
=
+ v ,
(2.35)
Dt
t
v velocity, the Nabla derivative operator = {/x, /y, /z}, t time, pd the dynamic pressure (without the hydrostatic part), the viscosity, 0 reference density, , and
g gravitational acceleration. One can now choose (as mentioned before for the Lorenz
equations) typical quantities that can be derived from the given parameters such as a T
temperature difference, a fluid box height d, and some choice for the timescale. All other
characteristic values for physical properties can then be derived from those choices (see,
e.g., discussion in Ricard, 2007).
Let us assume that we are dealing with a box heated from below and cooled from
above, i.e. held at constant temperature difference of T = Ttop Tbot , with no internal
heating (Rayleigh-Benard problem). A typical choice for a characteristic timescale is to
use the diffusion time that can be constructed from the thermal diffusivity, , in the energy
equation
DT
= 2 T
(2.36)
Dt
1 We
will always use SI units unless its inconvenient for Earth applications, where we might use multiples of SI units such as cm/yr instead of m/s for velocities. Also note that one year has roughly 107 s
(accurate up to 0.5%), i.e. 1 cm/yr is 3.2 1010 m/s, and that you should account for leap years for
geological time conversions, meaning that 365.25 24 60 60 is the right number of seconds per year.
33
by dimensional analysis. This relationship is hugely important for all diffusional processes.
Using the characteristic quantities f c which result from this scaling and using l = d,
for all variables in eq. (2.34) and eq. (2.36), all other properties can be derived, e.g.
vc =
d
tc
c =
vc
d
c = c
Tc = T
(2.38)
we divide all variables (spatial and temporal derivatives are dealt with like space and
time variables) to make them unit-less, non-dimensional f 0 = f / f c , and eq. (2.34) can
then be written as
1 D 0 v0
= 0 p0 + (0 )2 v0 RaT 0 ez
(2.39)
0
0
Pr D t
where weve used g = gez . I.e., all material parameters have been collected in two unitless numbers after non-dimensionalization, the Prandlt number,
(2.40)
0 gTd3
.
(2.41)
Pr =
and the Rayleigh number 2
Ra =
Exercise: Verify this recasting of the Navier-Stokes equation by plugging in the nondimensionalized quantities.
Often, we then just drop the primes and write the equation like so
1 Dv
= p + 2 v RaTez
Pr Dt
(2.42)
where it is implied that all quantities are used non-dimensionalized. This equation may
still be hard to solve, but at least we now have sorted all material parameters into two
numbers, Ra and Pr.
Note I: The non-dimensional versions of the equations are also the best choice if you
want to write a computer program for a physical problems. Using non-dimensionalized
2 In
the derivation above, we have assumed that the system is heated from below and viscosity is constant. The Rayleigh number is therefore valid for this bottom-heated case only. In Earths mantle, internal
heating (due to decay of radioactive elements in the mantle) is probably at least equally important (Jaupart
et al., 2007; Lay et al., 2008), and the Rayleigh-number in this case is defined differently. Also, rock viscosity
depends on a range of quantities, including temperature and strain-rate, making it imperative to properly
(log) average viscosity when computing effective Rayleigh numbers (e.g. Christensen, 1984).
34
(2.43)
Both Pr and Ra are discussed below. Fluid dynamics is full of these non-dimensional
numbers which are usually named after some famous person because they are so powerful. Any fluid that has the same Ra and Pr number as another fluid will behave exactly
the same way in terms of the overall style of dynamics, such as the resulting average
temperature structure and up and downwelling morphology.
The actual time scales of convection, e.g., may, however, be very different for two
systems at the same Rayleigh number (because of vc being different). This behavior allows, for example, to conduct analog, laboratory experiments of mantle convection (e.g.
Jacoby and Schmeling, 1981; Faccenna et al., 1999). When conducting such experiments,
care needs to be taken that all relevant non-dimensional numbers agree between the real
Earth problem and the laboratory experiment (e.g. Weijermars and Schmeling, 1986). Also,
when changing length scales and material, different physical effects such as surface tension may matter in the lab, while they are irrelevant for mantle convection in general (see,
e.g., sec. 6.7 of Ricard, 2007, for a discussion of Mahagoni convection).
From an analytical point of view, if the non-dimensional quantities are either very
large or very small, we can simplify the full equations to more tractable special cases. For
a nice and more comprehensive treatment of this section, you may want to refer to Ricard
(2007).
2.4.3
Problems
1. For all of the following non-dimensional numbers, discuss briefly (2-3 sentences)
the processes which these numbers measure, e.g. by contrasting system behavior for
Th = 0 and Th = , where Th is some non-dimensional number.
For each number, give numerical estimates for the Earth, at the present day. Document your choices (i.e. providing references) for individual parameters before comUSC GEOL557: Modeling Earth Systems
35
tr
tp
(2.46)
tM =
(2.47)
for the relaxation time tr , and t p is the time scale of observation. The Maxwell
time measures the visco-elastic relaxation time of a body with viscosity and
shear modulus (think post-glacial rebound).
What are characteristic Maxwell times for the crust? The upper mantle?
USC GEOL557: Modeling Earth Systems
36
(2.48)
(2.49)
for Newtonian creep as assumed above. (These equations are written sloppily
and dont have the right units. For correct units, consider a relationship like
where is a material parameter, but you may use eq. (2.48)
(/)n1 = ,
for the scaling analysis.)
(d) Estimate the rise velocity of a plume head large enough to cause the Deccan
traps.
3. You are moving the top of a fluid layer of height d at constant speed v(z = d) = v0 ,
and the fluid is held fixed at the bottom at z = 0. In this case, the laminar solution
for the flow velocity is a linear decrease of velocity with depth to v(0) = 0 at the
bottom.
(a) What material parameters set the stress in the fluid? What determines the
strain-rate and how does it vary with depth?
(b) Now consider two fluid layers, with the top fluid viscosity larger than the bottom one by a factor of two. Sketch the solution for the dependence of v(z).
37
v
H h
m
4. Using dimensional analysis, such as used above for the Stokes sinker, estimate the
velocity of a volcanic eruption (see Figure below for parameters).
Hint: You might want to proceed by first using the equations for laminar, pressuredriven (look up Hagen-Poiseuille) flow in a pipe of radius R, and then estimate
the pressure difference from Figure 2.4.
38
Part II
Ordinary differential equations
39
Chapter 3
Solution of ordinary differential
equations
3.1
Introduction
Reading: Press et al. (1993), Chap. 17; Spiegelman (2004), Chap. 4; Spencer and Ware (2008),
sec. 16.
ODE An equation that involves the derivative of the function we want to solve for, and
that has only one independent variable (else its a PDE).
For example:
dy
= f ( x ), which can be solved by integration
dx
Z
y=
f ( x ) dx + C
(3.1)
(3.2)
(3.3)
is second order. However, we can always reduce ODEs to sets of first order equations.
For eq. (3.3), define
dy
= z( x ), then
dx
dz
= r ( x ) q ( x ) z ( x ).
dx
40
(3.4)
(3.5)
or
dy
= f ( x, y)
dx
(3.6)
is a system for N coupled ODEs, all dependent on the independent variable x, which is
typically time, t. y is the solution vector we want to solve for. The actual solution of ODEs
will depend on the types of boundary conditions on y and the initial conditions.
We can distinguish between initial value and two point boundary values problems.
3.1.1
We focus here on initial value problems, where y is known for some x = x0 , and the
system evolves from there to some x f (final time).
Examples are
spring slider systems
d
= k ( v v0 )
= kx
dt
= f (v, 1 , 2 , . . .)
di
= f (v, i )
dt
(Hookes law)
(friction law)
(state variable evolution)
y( x, t) =
yi ( t ) f i ( x )
n =1
(harmonic basis functions for spatial solution (problem set will deal with those))
parametrized convection models
dT
Q = c p M
= H (t) Qc (t) = H (t) f ( T, t)
dt
(3.7)
particle tracking
dc
= f ( x, t)
dt
dx
=v
dt
USC GEOL557: Modeling Earth Systems
41
(3.8)
(3.9)
3.2
(3.10)
(3.11)
Z t
f
t0
(3.12)
We can break down the integral into step sizes h from ti to ti + h with n = (t f t0 )/h
partial integrals such that we only need to solve
I=
Z ti + h
ti
f (t, y(t)) dt
(3.13)
(from (3.12))
(3.14)
becomes the rule to advance y from ti to ti + h. This is the Euler method, and a really bad
idea. Consider the graphical representation in Figure 3.1, which shows that (3.14) is just
a simple extrapolation of y based on the slope at ti , which is given by equation (3.11). If y
has some curvature to it, the Euler scheme will lead to large errors quickly!
We can Taylor expand (eq. 6.4) y around t0 to get
y ( t ) y ( t0 ) + ( t t0 )
(3.15)
to gain some mathematical insight into the accuracy of the Euler scheme. For our problem, (3.15) becomes
y ( t i + h ) y ( t i ) + h f ( y ( t0 ), t0 ) +
h2 d2 y
+...
2 dt2
(3.16)
Notice that the error of the Euler scheme goes as O (order of)(h2 ), and the scheme itself
is only accurate to first order. This means that tiny time steps would have to be taken for
a good solution. There are several improvements to the Euler method.
USC GEOL557: Modeling Earth Systems
42
1. The midpoint method of Figure 3.2 evaluates the derivative of y w.r.t. to t first at
half the Euler step
dy
dy
h
t + h/2, y (ti ) +
(3.17)
(t )
dt i
dt i 2
and then advances y by that slope
dy
y ( ti + h ) = y ( ti ) + h
dt
dy
h
ti + h/2, y (ti ) +
( ti )
dt
2
(3.18)
written in terms of f
y ( ti + h ) = y ( ti ) + h f
USC GEOL557: Modeling Earth Systems
43
h
h
ti + , y ( ti ) + f ( ti , yi )
2
2
(3.19)
(3.20)
(3.21)
(3.22)
and this method is second order accurate. Note that higher accuracy has come at a
cost, f now needs to be evaluated twice and once at a y value different from yi , and
there are overall more operations per time step. However, since the error is now
O h3 , we can take larger time steps.
There are several avenues to refine the midpoint method further, but in general the
2. 4th order Runge-Kutta works well. The rules are
k 1 = h f ( ti , yi )
h
k1
k 2 = h f ti + , yi +
2
2
h
k2
k 3 = h f ti + , yi +
2
2
k4 = h f (ti + h, yi + k3 )
k
k2 k3 k4
y i +1 = y i + 1 +
+ + + O h5 .
6
3
3
6
(3.23)
The next improvement to the Runge Kutta method is to adapt the step size h during
forward integration, according to an a comparison of an on-the-fly error estimate with
some desired accuracy (Press et al., 1993, sec. 16.2). If you have a simple problem and
want to implement your own method, as in the problem set below, one way to test the
behavior of the forward routine is to successively half h and keep track of the deviations
of |y| at x f to make sure things converge. This is of course assuming that the parameters
for f remain within a reasonable range as used for the test, and adaptive step size is
preferred.
Moreover, especially tricky functions f require special methods, and Press et al. (1993),
chap. 16, discusses these. Some of the more fancy methods are implemented in Matlab,
read the help material for how to use the built-in ODE solvers. Matlab implementation of
ODE solvers are discussed in Spencer and Ware (2008), sec. 16.5. Typically, you want to try
ode45, and if that fails, ode113, or ode155.
3.2.1
Here, y is given at both ends of the interval, x0 and x f . We will not deal with those kinds
of problems here. They generally involve iteration to find the right solution based on
USC GEOL557: Modeling Earth Systems
44
3.3
Reading
Spiegelman (2004), chap. 4
Press et al. (1993), chap. 17 (16 in 2nd ed.)
Spencer and Ware (2008), sec. 16
We previously discussed the 4th order Runge Kutta method as a simple method to
solve initial value problems where the task is to forward integrate a vector y(t) from an
initial condition y0 (t = t0 ) to some time t f while the time derivatives of y are given by
dy
(t) = f (t, y, C )
dt
(3.24)
(3.25)
3.3.1
45
3.3.2
For an incompressible fluid, conservation of mass, energy, and momentum for the convection problem can
be written as
v
T
+ v T
t
v
+ (v ) v
t
= 0
(3.26)
= 2 T
(3.27)
= 2 v
P + g.
0
0
(3.28)
Here, = /0 is dynamic viscosity, v velocity, T temperature, thermal diffusivity, g gravitational acceleration, density, and P pressure. In the Boussinesq approximation, ( T ) = 0 (1 ( T T0 )), where is
thermal expansivity and 0 and T0 reference density and temperature, respectively.
If we assume two-dimensionality (2-D) in x and z direction, and a bottom-heated box of fluid, the
box height d provides a typical length scale. If g only acts in z direction and all quantities are nondimensionalized by d, the diffusion time, d2 /, and the temperature contrast between top and bottom
T, we can write
T 0
+ v0 T 0
0
t
1
0
+ v
Pr t0
= 2 T 0
= 2 Ra
(3.29)
T 0
,
x 0
(3.30)
where the primed quantities are non-dimensionalized (more on this later). Eq. (3.30) is eq. (3.28) rewritten
in terms of vorticity , such that 2 = where is the stream-function, which relates to velocity as
v = k = {/z, /x }
(3.31)
and enforces incompressibility (mass conservation). The important part here are the two new non-dimensional
quantities that arise, the Prandtl and the Rayleigh numbers, which were discussed previously (eqs. 2.40 and
2.41).
Lorenz (1963) used a very low order spectral expansion to solve the convection equations. He assumed
that
(3.32)
(3.33)
for convective cells with wavelength 2/a. This is an example of a spectral method where spatial variations
in properties such as T are dealt with in the frequency domain, here with one harmonic. Such an analysis
is also common when examining barely super-critical convective instabilities.
3.3.3
Problems
The resulting equations for the time dependent parameters of the approximate Lorenz
convection equations are
dW
= Pr ( T1 W )
dt
dT1
= WT2 + rW T1
dt
dT2
= WT1 bT2
dt
USC GEOL557: Modeling Earth Systems
46
(3.34)
47
50
45
40
35
30
25
20
15
10
5
0
30
20
20
15
10
10
5
0
5
10
T1
20
10
15
W
Figure 3.3: Solution to one of the problem set questions visualizing the behavior of the Lorenz
equations (the Lorenz attractor).
For help with making simple plots with Matlab, see Spencer and Ware (2008), for example.
3.3.4
Additional examples
1. If you are curious about additional Earth Science applications of ODEs, the literature
of geochemical modeling is full of it because it is often easiest, or most appropriate,
to consider fluxes between reservoirs of different chemical species with averages
properties, so-called box models (e.g. Albarede, 1995).
2. A classic example from magneto-hydrodynamics is the 3-D Rikitake dynamo model
that consists of two conducting, coupled rotating disks in a background magnetic
field. The Rikitake dynamo shows behavior similar to the Lorenz system and serves
as an analog for magnetic field reversal. The equations are
dx
= mx + yz
dt
dy
= my + (z a) x
dt
dz
= 1 xy
dt
(3.35)
48
function dy = rkstep(.... )
%
%
% perform one 4th order Runge Kutta timestep and return
% the increment on y(t_n) by evaluating func(time,y,parameters)
%
% ... parts need to be filled in
%
%
% input values:
% h: time step
% t: time
% y: vector with variables at time = t which are to be advanced
% func: function which computes dy/dt
% parameters: structure with any parameters the func function might need
% save computations
h2=h/2;
k1 = h .* dydt(...);
k2 = h .* dydt(...);
....
% return the y_{n+1} timestep
dy = ....
Figure 3.4: Suggested program structure for the Lorenz equation ODE solver exercise. Available
online as lorenz.m, rkstep.m, and dydt.m.
49
Tgh3
(3.36)
Q
= aRa
cT
(3.37)
(with some debate about , see, e.g. Korenaga, 2008, for a review). The energy balance
for the mantle is
dT
= H (t) Q
(3.38)
Cp
dt
where C p is the total heat capacity, H the time-dependent heat production through
radiogenic elements, and Q the heat loss through the surface. If viscosity is a function of temperature,
H
= 0 exp
(3.39)
RT
then the equations couple such that
dT
Cp
= H ( t ) Q0
dt
T
T0
1+
( T0 )
(T )
.
(3.40)
50
Figure 3.5: Poincare sections in y for the period doubling sequence to chaos for the spring-slider
system, eq. (3.41), as a function of normalized spring stiffness, 0 . Bottom figure shows zoom into
the dashed rectangular region highlighted on top (modified from Becker, 2000).
x =
(3.41)
51
Part III
Partial differential equations
52
Chapter 4
Finite differences
4.1
We now turn to the solution of partial differential equations (PDEs), and the first method
that will be discussed is finite differences (FD). The solution of PDEs by means of FD is
based on approximating derivatives of continuous functions, i.e. the actual partial differential equation, by discretized versions of the derivatives based on discrete points of the
functions of interest.
4.1.1
Finite difference approximations to PDEs can be derived through the use of Taylor series
expansions. Suppose we have a function f ( x ), which is continuous and differentiable
over the range of interest. Lets also assume we know the value f ( x0 ) and all the derivatives at x = x0 . The forward Taylor-series (eq. 6.4) expansion for f ( x0 + x ), away from
the point x0 by a small amount h (sometimes here also denoted by x), gives
f ( x0 )
h +
x
2 f ( x0 ) h2 3 f ( x0 ) h3
n f ( x0 ) h n
+
+
.
.
.
+
+
2!
3!
x n n!
x2
x3
O(hn+1 ).
f ( x0 + h ) = f ( x0 ) +
(4.1)
...
x
h
3!
x2 2!
x3
(4.2)
If we now only compute the first term of this equation as an approximation, we can write
a discretized version
f ( xi )
f
fi
= i +1
+ Oh
(4.3)
x
h
53
2 f ( x0 ) h2 3 f ( x0 ) h3
f ( x0 )
h+
+ ...
x
2!
3!
x2
x3
(4.4)
(4.5)
=
=
f i0+1 f i0
+ O(h)
h
f i +2 f i +1
f i+1h f i
h
+ O(h)
h
f i +2 2 f i +1 + f i
+ O(h)
h2
(4.7)
(4.8)
(4.9)
which is the first order accurate, forward difference approximation for second order derivatives around f i+1 .
If we wish to improve on accuracy, we can proceed by taking higher order terms of
the Taylor expansion, and using first order accurate estimates for the derivatives. For
example,
f ( x + h) f ( x ) h 00
f (x) + . . .
h
2
f ( x + h) f ( x )
=
h
h f ( x + 2h) 2 f ( x + h) + f ( x )
+ O(h) + O(h2 )
2
h2
f i +2 + 4 f i +1 3 f i
=
+ O(h2 ).
2h
f 0 (x) =
f i0+1
54
(4.10)
or
(4.11)
f i +1 f i 1
+ O(h2 )
2h
(4.12)
f i +1 2 f i + f i 1
+ O(h2 ).
h2
(4.13)
A different way to derive the second derivative of second order accuracy is by computing, by central differences which we now know should yield second accuracy, the first
derivatives (theoretically!) as evaluated at the points in between, i + 1/2 and i 1/2,
and then computing the second derivative at i from this by using the central difference of
those two first derivatives:
f i0+1/2 =
f i01/2 =
f i00 =
f i +1 f i
h
f i f i 1
h
0
f i+1/2 f i01/2
h
f i +1 f i
h
f i f i 1
x
f i +1 2 f i + f i 1
h2
(4.14)
(This is important for derivatives with variable coefficients, cf. sec. 4.1.3.) If h is not constant, it should be computed as xi+1 xi . The second order derivative in this case is
identical to the equations above with xi+1 xi = xi xi1 = h.
Similarly, we can derive higher order derivatives, and higher order accuracy (but only
if f is of polynomial form). Both require more input values, a larger stencil. A general
approach to forming interpolations of f and dn f /dx n can be found in Fornberg (1996).
Note that the highest order derivative that usually occurs in geodynamics is the 4th -order
derivative.
55
4.1.2
The following equations are common finite difference approximations of derivatives which
are here provided for reference. Central differences with second order accuracy are typically good choices and highlighted in bold face. One of the few cases where you want
to use first order derivatives is for advection, where second order central is a very poor
choice because it introduces large artificial diffusion.
Left-sided first derivative, first order
u
u u i 1
= i
+ O(h)
x i1/2
h
Right-sided first derivative, first order
u
u ui
+ O(h)
= i +1
x i+1/2
h
Central first derivative, second order
u i +1 u i 1
u
+ O(h2 )
=
x i
2h
Central first derivative, fourth order
u
ui+2 8ui+1 + 8ui1 ui2
+ O(h4 )
=
x i
12h
Central second derivative, second order
2 u
ui+1 2ui + ui1
+ O(h2 )
=
2
x i
h2
Central second derivative, fourth order
2 u
ui+2 + 16ui+1 30ui + 16ui1 ui2
+ O(h4 )
=
2
x i
12h2
Central third derivative, second order
3 u
ui+2 + 2ui+1 2ui1 + ui2
+ O(h2 )
=
3
3
x i
2h
Central third derivative, fourth order
3 u
ui+3 8ui+2 + 13ui+1 13ui1 + 8ui2 ui3
+ O(h4 )
=
3
x i
8h3
Central fourth derivative, second order
4 u
ui+2 4ui+1 + 6ui 4ui1 + ui2
=
+ O(h2 )
4
4
x i
h
USC GEOL557: Modeling Earth Systems
56
(4.15)
(4.16)
(4.17)
(4.18)
(4.19)
(4.20)
(4.21)
(4.22)
(4.23)
4.1.3
u
k( x)
,
x
x
(4.24)
u
k( x)
x
u u
u u
k i+1/2 i+1h i k i1/2 i h i1
+ O(h2 ),
=
h
i
(4.25)
where k i1/2 is evaluated between ui and ui1 , to maintain the second order accuracy of
the central difference approach for second derivatives (eq. 4.14)
h
0
f 0 ( x + x
2 ) f (x 2 )
f =
,
h
00
(4.26)
i.e. the first derivatives are premultiplied with the cofficients in between the nodes. If k
is spatially varying, the following, common approximations are therefore inadequate to
maintain second order accuracy:
u u
u u
k i+1 i+1h i k i i h i1
u
k
=
x i
h
u
ui+1 2ui + ui1
k
= ki
x
x i
h2
Note: If k has strong jumps from one grid point to another that are not aligned with
the grid-nodes, most second-order methods will show first order accuracy at best.
57
4.2
Finite difference methods are perhaps best understood with an example. Consider the
one-dimensional, transient (i.e. time-dependent) heat conduction equation without heat
generating sources
T
T
c p
=
k
(4.27)
t
x
x
where is density, c p heat capacity, k thermal conductivity, T temperature, x distance, and
t time. If the thermal conductivity, density and heat capacity are constant over the model
domain, the equation can be simplified to
2 T
T
= 2
t
x
where
=
(4.28)
k
c p
(4.29)
is the thermal diffusivity (a common value for rocks is = 106 m2 s1 ; also see discussion
in sec. 2.4).
We are interested in the temperature evolution versus time, T ( x, t), which satisfies
eq. (4.28), given an initial temperature distribution (Fig. 4.1A). An example would be the
intrusion of a basaltic dike in cooler country rocks. How long does it take to cool the
dike to a certain temperature? What is the maximum temperature that the country rock
experiences?
The first step in the finite differences method is to construct a grid with points on
which we are interested in solving the equation (this is called discretization, see Fig. 4.1B).
The next step is to replace the continuous derivatives of eq. (4.28) with their finite difference approximations. The derivative of temperature versus time T
t can be approximated
with a forward finite difference approximation as
T n+1 Tin
Tin+1 Tin
Tinew Ticurrent
T
in+1
=
=
.
t
t
t
t
tn
(4.30)
Here, n represents the temperature at the current time step whereas n + 1 represents the
new (future) temperature. The subscript i refers to the location (Fig. 4.1B). Both n and i
are integers; n varies from 1 to nt (total number of time steps) and i varies from 1 to n x
(total number of grid points in x-direction). The spatial derivative of eq. (4.28) is replaced
by a central finite difference approximation (cf. sec. 4.1.2), i.e.
2 T
=
2
x
x
T
x
Tin+1 Tin
x
Tin Tin1
x
58
(4.31)
country rock
dike
boundary nodes
i,n+1
i,n
i-1,n
i+1,n
time
T(x,0)
i,n-1
Dt
Dx
space
Figure 4.1: A) Setup of the thermal cooling model considered here. A hot basaltic dike intrudes
cooler country rocks. Only variations in x-direction are considered; properties in the other directions are assumed to be constant. The initial temperature distribution T ( x, 0) has a step-like
perturbation, centered around the origin with [W/2; W/2] B) Finite difference discretization of
the 1D heat equation. The finite difference method approximates the temperature at given grid
points, with spacing x. The time-evolution is also computed at given times with time step t.
.
(4.32)
The third and last step is a rearrangement of the discretized equation, so that all known
quantities (i.e. temperature at time n) are on the right hand side and the unknown quantities on the left-hand side (properties at n + 1). This results in:
n
Ti+1 2Tin + Tin1
n +1
n
Ti
= Ti + t
(4.33)
(x )2
Because the temperature at the current time step (n) is known, we can use eq. (4.33) to
compute the new temperature without solving any additional equations. Such a scheme
is and explicit finite difference method and was made possible by the choice to evaluate
the temporal derivative with forward differences. We know that this numerical scheme
will converge to the exact solution for small x and t because it has been shown to
be consistent that its discretization process can be reversed, through a Taylor series
expansion, to recover the governing partial differential equation and because it is stable
for certain values of t and x: any spontaneous perturbations in the solution (such as
round-off error) will either be bounded or will decay.
USC GEOL557: Modeling Earth Systems
59
(4.34)
(4.35)
In addition we assume that the temperature far away from the dike center (at | L/2|) remains at a constant temperature. The boundary conditions are thus
T ( x = L/2, t) = 300
T ( x = L/2, t) = 300
(4.36)
(4.37)
The MATLAB code in Figure 4.2, heat1Dexplicit.m, shows an example in which the
grid is initialized, and a time loop is performed. In the exercise, you will fill in the question marks and obtain a working code that solves eq. (4.33).
4.2.1
Exercises
1. Open MATLAB and an editor and type the Matlab script in an empty file; alternatively use the template provided on the web if you need inspiration. Save the file
under the name heat1Dexplicit.m. If starting from the template, fill in the question
marks and then run the file by typing heat1Dexplicit in the MATLAB command
window (make sure youre in the correct directory). (Alternatively, type F5 to run
from within the editor.)
2. Study the time evolution of the spatial solution using a variable y-axis that adjusts
to the peak temperature, and a fixed axis with range axis([-L/2 L/2 0 Tmagma]).
Comment on the nature of the solution. What parameter determines the relationship
between two spatial solutions at different times?
Does the temperature of the country rock matter for the nature of the solution? What
about if there is a background gradient in temperature such that the country rock
temperature increases from 300 at x = L/2 to 600 at x = L/2?
3. Vary the parameters (e.g. use more grid points, a larger or smaller time step). Compare the results for small x and t with those for larger x and t. How are these
solutions different? Why? Notice also that if the time step is increased beyond a
certain value, the numerical method becomes unstable and does not converge it
grows without bounds and exhibits non-physical features.
Investigate which parameters affect stability, and find out what ratio of these parameters delimits this schemes stability region. This is called the CFL condition,
see von Neumann stability analysis in (cf. chap 5 of Spiegelman, 2004).
60
%
%
%
%
%
%
%
parameters
201;
%
500;
%
L/(nx-1);
%
-L/2:dx:L/2;%
[m]
[C]
[C]
[m2/s]
[m]
[s]
0;
% Timestep loop
Figure 4.2: MATLAB script heat1Dexplicit.m to solve eq. (4.28) (once the blanks indicated by the
questions marks are filled in . . . ).
4. Record and plot the temperature evolution versus time at a distance of 5 m from
the dikecountry rock contact. What is the maximum temperature the country rock
experiences at this location and when is it reached? Assume that the country rock
was composed of shales, and that those shales were transformed to hornfels above
a temperature of 600 C. What is the width of the metamorphic aureole?
5. Think about how one would write a non-dimensionalized version of the temperature solver.
6. Add a test with an analytical solution for diffusion and plot error vrs. resolution. A
good reference for analytical solutions for heat conduction problems is Carslaw and
Jaeger (1959), or see sec. 4.8.
The spatial discretization should be second order for a second order scheme.
7. Derive a finite-difference approximation for variable k (and variable x allowing for
USC GEOL557: Modeling Earth Systems
61
62
4.3
Reading
Press et al. (1993), sec. 19.2
Spiegelman (2004), sec. 6.1-6.5
Limited stability and numerical aliasing/dissipation are two major drawbacks of explicit finite difference codes such as the one presented in sec. 4.2. Next, we will discuss
methods that do not have these limitations.
4.3.1
Previously, we solved the transient (time-dependent) heat equation in 1D. In the absence
of heat sources, the governing equation is
2 T
T
= 2
t
x
(4.38)
1
or
t
for given x.
(4.41)
2
(x )2
If this condition is not satisfied, the solution becomes unstable, starts to wildly oscillate,
or blow up.
USC GEOL557: Modeling Earth Systems
63
Figure 4.3: A) Explicit finite difference discretization. B) Implicit finite difference discretization.
C) Crank-Nicolson finite difference discretization.
This can be shown by von Neumann stability analysis (Press et al., 1993, chap. 19.2),
analyzing the growth of of eigenmodes of the finite difference equation. However, physically, the stability condition eq. (4.41) means that the maximum time step needs to be
smaller than the time it takes for an anomaly to diffuse across the grid (nodal) spacing x
(cf. diffusion time in sec. 3.3). The explicit solution, eq. (4.40), is an example of a conditionally stable method that only leads to well behaved solutions if a criterion like eq. (4.41) is
satisfied.
Note that eq. (4.41) can only hold for t > 0; having a negative diffusivity, or using
a time-reversed t < 0, will invariably lead to blow up since small features will get emphasized rather than smoothed out. This is an issue if one wishes to reconstruct diffusiveadvective processes (such as mantle convection), going from the present-day temperature
field back in time (cf. Ismail-Zadeh and Tackley, 2010).
We will revisit an FTCS scheme similar to eq. (4.39) for advection that involves single derivatives in space later. Unlike eq. (4.39), the FTCS scheme for advection is always
unstable. Not a good idea.
Even if the FTCS for diffusion can be made stable, the stability condition leads to
numerical convenience issues. Given that we are typically interested in spatial features
with wavelength, , within the solution that are much larger than x, x, because
we want to resolve the solution features at least with a few nodes, the explicit scheme,
eq. (4.39), will require
2
1
(4.42)
x
steps per relevant time scale for the evolution of features, which is usually prohibitive.
An alternative approach is an implicit finite difference scheme, where the spatial derivatives 2 T/x2 are evaluated (at least partially) at the new time step. The simplest implicit
discretization of eq. (4.38) is
Tin++11 2Tin+1 + Tin+11
Tin+1 Tin
=
,
t
(x )2
USC GEOL557: Modeling Earth Systems
64
(4.43)
(4.44)
where
s=
t
.
(x )2
(4.45)
Note that in this case we no longer have an explicit relationship for Tin+11 , Tin+1 and Tin++11 .
Instead, we have to solve a linear system of equations, which is discussed further below.
k( x) T
x
(4.46)
as for the case of the laterally varying conductivity in the explicit FD exercise for the heat
equation, then
rkr Tin++11 + [1 + r (k l + kr )] Tin+1 rk l Tin+11 = Tin
(4.47)
has to be used instead of eq. (4.44). Here, r = t/(x )2 and k l and kr are the material
parameters to the left (xi1/2 ) and right (xi+1/2 ), respectively.
The main advantage of implicit methods is that there are no restrictions on the time
step, the fully implicit scheme is unconditionally stable. This does not mean that it is accurate. Taking large time steps may result in an inaccurate solution for features with small
spatial scales. For any application, it is therefore always a good idea to check the results
by decreasing the time step until the solution does not change anymore (this is called a
convergence check), and to ensure the method can deal with small and large scale features
robustly at the same time.
Eq. (4.44) is also suited to understand the overall behavior of an implicit method for
large time steps. If we let t , and then divide eq. (4.44) by s, we get
Ti+1 2Ti + Ti1 = 0,
(4.48)
which is a central difference approximation of the steady state solution of eq. (4.38),
2 T
= 0.
x2
(4.49)
Therefore, the fully implicit scheme will always yield the right equilibrium solution but
may not capture small scale, transient features.
It turns out that the fully implicit method described by eq. (4.43) is second order
accurate in space but only first order accurate in time, i.e. O((x )2 , t). It is possible
to write down a scheme which is second order accurate both in time and in space (i.e.
USC GEOL557: Modeling Earth Systems
65
O((x )2 , (t)2 )). One such scheme is the Crank-Nicolson scheme (see exercises, Fig. 4.3C),
which is unconditionally stable. Note the analogy with the previous derivation of spatial derivatives: forward or backward differences were only first order accurate, while
the central difference approach achieved second order accuracy O((x )2 ). The CrankNicolson method is the time analog of central spatial differences. However, any partially
implicit method is more tricky to compute as we need to infer the future solution at time
n + 1 by solution (inversion) of a system of linear equations based on the known solution
at time n. This is discussed next.
4.4
4.4.1
T
=
c p
t
x
T
k
x
(4.50)
on the domain L/2 x L/2 subject to the following boundary conditions for fixed
temperature
T ( x = L/2, t) = Tle f t
T ( x = L/2, t) = Tright
(4.51)
(4.52)
(4.53)
where we have again assumed a hot dike intrusion for W/2 x W/2.
Boundary conditions (BCs, see also sec. 2.2.3) for PDEs that specify values of the solution function (here T) to be constant, such as eq. (4.51), are called Dirichlet boundary
conditions. We can also choose to specify the gradient of the solution function, e.g. T/x
(Neumann boundary condition). This gradient boundary condition corresponds to heat flux
for the heat equation and we might choose, e.g., zero flux in and out of the domain (isolated BCs):
T
( x = L/2, t) = 0
x
T
( x = L/2, t) = 0.
x
66
(4.54)
4.4.2
As before, the first step is to discretize the spatial domain with n x finite difference points.
The implicit finite difference discretization of the temperature equation within the medium
where we wish to obtain the solution is eq. (4.44). Starting with fixed temperature BCs
(eq. 4.51), the boundary condition on the left boundary gives
T1 = Tle f t
(4.55)
Tnx = Tright .
(4.56)
(4.57)
1
0
0
0
0
0
s (1 + 2s)
s
0
0
0
s
(
1
+
2s
)
s
0
0
A=
0
0
s
(1 + 2s)
s
0
0
0
0
s
(1 + 2s) s
0
0
0
0
0
1
(4.58)
x=
b=
T1n+1
T2n+1
T3n+1
T4n+1
T5n+1
T6n+1
Tle f t
T2n
T3n
T4n
T5n
Tright
(4.59)
(4.60)
Note that matrix A will have a unity entry on the diagonal and zero else for each node
where Dirichlet (fixed temperature) boundary conditions apply; see derivation below and
eqs. (4.72) and (4.73) for how to implement Neumann boundary conditions.
USC GEOL557: Modeling Earth Systems
67
4.4.3
Matlab implementation
Within Matlab, we declare matrix A to be sparse by initializing it with the sparse function.
This will ensure a computationally efficient internal treatment within Matlab. Once the
coefficient matrix A and the right-hand-side vector b have been constructed, MATLAB
functions can be used to obtain the solution x and you will not have to worry about
choosing a proper matrix solver for now.
First, however, we have to construct the matrices and vectors. The coefficient matrix
A can be constructed with a simple loop:
A = sparse(nx,nx);
for i=2:nx-1
A(i,i-1) = -s;
A(i,i ) = (1+2*s);
A(i,i+1) = -s;
end
and the boundary conditions are set by:
A(1 ,1 ) = 1;
A(nx,nx) = 1;
(Exercise: Improve on the loop formulation for A assembly by using Matlab vector functionality.)
Once the coefficient matrix has been constructed, its structure can be visualized with
the command
>>spy(A)
(Try it, for example by putting a break-point into the Matlab code below after assembly.)
The right-hand-side vector b can be constructed with
b = zeros(nx,1);
b(2:nx-1) = Told(2:nx-1);
b(1) = Tleft; b(nx) = Tright;
The only thing that remains to be done is to solve the system of equations and find x.
MATLAB does this with
USC GEOL557: Modeling Earth Systems
68
4.4.4
Exercises
Note: Eq. (4.62) can be derived using a similarity variable, x = x/xc with xc t.
Looks familiar?
3. A steady-state temperature profile is obtained if the time derivative T/t in the
heat equation (eq. 4.38) is zero. There are two ways to do this.
(a) Wait until the temperature does not change anymore.
(b) Write down a finite difference discretization of 2 T/x2 = 0 and solve it. (See
the limit case consideration above.)
USC GEOL557: Modeling Earth Systems
69
2T
+
T
+
T
Ti
Ti
i +1
i
i 1
i +1
i
i 1
.
=
(4.64)
2
t
2
(x )
This scheme should generally yield the best performance for any diffusion problem,
it is second order time and space accurate, because the averaging of fully explicit
and fully implicit methods to obtain the time derivative corresponds to evaluating
the derivative centered on n + 1/2. Such centered evaluation also lead to second
order accuracy for the spatial derivatives.
Compare the accuracy of the Crank-Nicolson scheme with that of the FTCS and fully
implicit schemes for the cases explored in the two previous problems, and for ideal
values of t and x, and for large values of t that are near the instability region of
FTCS.
Hint: Proceed by writing out eq. (4.64) and sorting terms into those that depend on
the solution at time step n + 1 and those at time step n, as for eq. (4.44).
6. Bonus question: Write a codefor the thermal equation with variable thermal con
T
ductivity k: c p T
t = x k x . Assume that the grid spacing x is constant. For
extra bonus, allow for variable grid spacing and variable conductivity.
70
Figure 4.4: Discretization of the numerical domain with fictitious boundary points, that are employed to set flux boundary conditions.
4.5
(4.65)
(4.66)
Tnx +1 Tnx 1
= c2 .
2x
(4.67)
and at i = n x by
The problem is, of course, that the expressions above involve points that are not part of
the original numerical grid (T0n+1 and Tnnx++11 ). These points are called fictitious boundary
points (Figure 4.4). A way around this can be found by noting that the equation for the
center nodes is given by
Tin++11 2Tin+1 + Tin+11
Tin+1 Tin
.
=
t
(x )2
(4.68)
71
(4.69)
(4.70)
i.e. we are simply extrapolating from T2 to T0 with the slope given by c1 . Substituting into
eq. (4.69) yields
T1n+1 T1n
2T n+1 2T1n+1 2xc1
= 2
.
(4.71)
t
(x )2
To apply this formulation in a fully explicit scheme, we can again rearrange terms to bring
known quantities on the right-hand-side:
(4.72)
(4.73)
These equations now only involves grid points that are part of the computational grid,
and eqs. (4.72) and (4.73) can be incorporated into the matrix A and right-hand-side b
(compare with eq. 4.44).
72
4.6
So far, we considered linear partial differential equations, where the coefficients in the
equations are either constant or only spatially variable, but are independent of time or
the solution itself. If the coefficients are dependent on the solution, a nonlinear problem
results.
There are a number of ways to solve such nonlinear problems. The easiest, rough
and ready way, which works in many cases, is to replace the nonlinear PDE by a linear
one, guess initial values for the solution and the parameters that depend on it, and then
perform iterations until the solution converges (Picard iterations).
Whether this method will converge will depend on the quality of the initial guess,
which becomes harder when the non-linearities are strong. More sophisticated methods
exist; the most important of which is linearization of the nonlinear terms and solution of
the (more complicated) PDE (e.g. Newton-Rhapson iterations). This method is converges
quadratically, as long as the initial guess is close to the final solution. It is, however, more
difficult to implement and will therefore not be discussed here.
4.6.1
Example
We consider a case of fluid flow in a porous media (governed by the Darcy equation)
whose diffusivity is a function of the fluid pressure (high fluid pressure increases permeability, p ). In a 1-D, vertical (z) column the governing equation shall be
P
P
=
( P)
(4.74)
t
z
z
where P is the fluid pressure, and ( P) the hydraulic diffusivity. The equation is nonlinear
because the diffusivity can be written as a function of the fluid pressure P, which is related
to the effect of dilation and cracking under enhanced fluid pressure.
To solve eq. (4.74), we need a constitutive law, and we assume that the hydraulic diffusivity is given by
( P) = 0 + cPm
(4.75)
P n +1 P n +1
1
1
i +1
i
i
i 1
in++1/2
in+1/2
Pin+1 Pin
x
x
=
(4.76)
t
x
where the material parameters are evaluated in between nodes, for example by computing an average
1
in+1/2
in+1 + in+11
=
.
2
73
(4.77)
(4.78)
for Pn+1 . The problem, however, is that depends on Pn+1 . Therefore we have to perform
iterations for the true Pn+1 and recompute A at each time step before advancing time. The
general recipe is
1
1. Use the pressure Pn to compute the diffusivities in+1/2
using eqs. (4.75) and (4.77).
error =
(4.79)
If convergence is reached (e.g. relative error < 104 ), continue to the next time step.
Exercise
Write a program that solves the equations described above on the domain z [0; 1]
from t = 0 to t = 0.2. Assume that we have zero flux boundary conditions (i.e.
gradient P/z = 0 on top and bottom). Use non-dimensional parameter values
0 = 0.05, c = 1, m = 2 and time-step 0.005. The initial pressure is to be unity
within [0.4; 0.6] and zero else. At each time step, compare the nonlinear solution to
the linear one, obtained by setting c = 0, to visualize the effect of the non-linear
terms.
74
i+1,j
i,j
i,j-1
i,j+1
i-1,j
Dz
Dx
L
x
4.7
We now revisit the transient heat equation, this time with sources/sinks, as an example
for two-dimensional FD problem. In 2D ({ x, z} space), we can write
T
T
c p
=
kx
+
kz
+Q
(4.80)
t
x
x
z
z
where, is density, c p heat capacity, k x,z the thermal conductivities in x and z direction,
and Q radiogenic heat production.
If the thermal conductivity is isostropic (k x = k z ) and constant, we can rewrite
T
=
t
4.7.1
2 T 2 T
+ 2
x2
z
Q
.
c p
(4.81)
Explicit method
The simplest way to discretize eq. (4.81) on a domain, e.g. a box with width L and height
H, is to employ an FTCS, explicit method like in 1-D
n +1
n
Ti,j
Ti,j
n
n
n
Ti,j
+1 2Ti,j + Ti,j1
(x )2
75
n + Tn
Tin+1,j 2Ti,j
i 1,j
(z)2
n
Qi,j
c p
(4.82)
n
Ti,j
+ sx
n
Ti,j
+1
n
2Ti,j
n
Ti,j
1
+ sz
Tin+1,j
n
2Ti,j
Tin1,j
n t
Qi,j
c p
(4.83)
where
t
t
and sz =
.
(4.84)
2
(x )
(z)2
Boundary conditions can be set the usual way. A constant (Dirichlet) temperature on
the left-hand side of the domain (at j = 1), for example, is given by
sx =
Ti,j=1 = Tle f t
for all i.
(4.85)
A constant flux (Neumann BC) on the same boundary at {i, j = 1} is set through fictitious
boundary points
T
= c1
x
Ti,2 Ti,0
= c1
2x
Ti,0 = Ti,2 2xc1
(4.86)
which can then be plugged into eq. (4.83) so that for j = 1, for example,
n +1
n
n
n
Ti,1
= Ti,1
+ s x 2Ti,2
2( Ti,1
+ xc1 )
Qn t
n
+ sz Tin+1,1 2Ti,1
+ Tin1,1 + i,1 .
c p
(4.87)
The implementation of this approach is straightforward as T can be represented as a matrix with Matlab, to be initialized, for example, for nz and n x rows and columns, respectively, as
T = zeros(nz, nx);
(4.88)
and then accessed as T(i,j) for Ti,j . The major disadvantage of fully explicit schemes is,
of course, that they are only stable if
2t
1.
min((x )2 , (z)2 )
4.7.2
(4.89)
2T
+
T
T
2T
+
T
Qi,j
+1
i +1,j
i,j
i 1,j
i,j
i,j1
=
+
+
.
(4.90)
t
c p
(x )2
(z)2
USC GEOL557: Modeling Earth Systems
76
nz
29
30
31
32
33
34
35
22
23
24
25
26
27
28
15
16
17
18
19
20
21
10
11
12
13
14
7
nx
x
Figure 4.6: Numbering scheme for a 2D grid with n x = 7 and nz = 5.
Rearranging terms with n + 1 on the left and terms with n on the right hand side gives
sz Tin++1,j1
n +1
s x Ti,j
+1
n +1
+ (1 + 2sz + 2s x ) Ti,j
sz Tin+1,j1
n +1
s x Ti,j
1
n
Ti,j
n t
Qi,j
c p
(4.91)
As in the 1D case, we have to write these equations in a matrix A and a vector b (and
use Matlab x = A\b to solve for T n+1 ). From a practical point of view, this is a bit more
complicated than in the 1D case, since we have to deal with book-keeping issues, i.e.
the mapping of Ti,j to the entries of a temperature vector T(k) (as opposed to the more
intuitive matrix T(i,j) we could use for the explicit scheme).
If a 2D temperature field is to be solved for with an equivalent vector T, the nodes
have to be numbered continuously, for example as in Figure 4.6. The derivative versus
x-direction is then e.g.
1
2 T
|i=3,j=4 =
( T 2T18 + T17 ) ,
2
x
(x )2 19
(4.92)
(4.93)
If n x are the number of grid points in x-direction and nz the number of points in z-
77
2T
+
T
i,j
( i 1) n x + j
( i 2) n x + j .
z2
(z)2 inx + j
(4.94)
(4.95)
... 0 0
... 0 0
sz . . . s x (1 + 2s x + 2sz )
s x
. . . sz 0
0 0
0 0
A=
.
0 sz . . .
s x
(1 + 2s x + 2sz ) s x . . . sz
0 0
0 0
. .
.. ..
.. ..
. .
0 0 ... 0
0
0
0
0
0
0
0 ... 1 0
0 0 ... 0
0
0
0
0
0
0
0 ... 0 1
(4.96)
Note that we now have five diagonals filled with non-zero entries as opposed to three
diagonals in the 1D case. The solution vector x is given by
T1n+1 = T1,1
T2n+1 = T1,2
.
.
T n +1
= Ti,j
( i 1) n x + j
x = n +1
(4.97)
,
T(i1)n + j+1 = Ti,j+1
x
..
n
+
1
Tn n 1 = Tnz ,nx 1
x z
Tnnx+n1z = Tnz ,nx
1
0
..
.
0 ...
1 ...
..
.
0
0
0
0
0
0
0
0
0
0
0
0
and the load (right hand side) vector is given by (Q = 0 for simplicity)
Tbottom
Tbottom
..
T(ni1)n + j
x
.
b= n
T
( i 1) n x + j +1
..
Ttop
Ttop
USC GEOL557: Modeling Earth Systems
78
0
0
0
0
(4.98)
4.7.3
Other methods
The fully implicit method discussed above works fine, but is only first order accurate
in time (sec. 4.3). A simple modification is to employ a Crank-Nicolson time step discretization which is second order accurate in time. In practice, this often does not make a
big difference, but Crank-Nicolson is often preferred and does not cost much in terms of
additional programming. You may consider using it for diffusion-type equations.
A different, and more serious, issue is the fact that the cost of solving x = A\b is a
strong function of the size of A. This size depends on the number of grid points in x- (n x )
and z-direction (nz ). For a 2D problem with n x nz internal points, (n x nz )2 (n x nz )2
equations have to be solved at every time step. This quickly fills the computer memory
(especially if going to 3D cases).
For the special case of the temperature equation, different techniques have therefore
been developed. One such technique, is the alternating direction implicit (ADI) method.
It basically consists of solving the 2D equations half-explicit and half-implicit along 1D
profiles (what you do is the following: (1) discretize the heat equation implicitly in the
x-direction and explicit in the z-direction. (2) solve it for time n + 1/2, and (3) repeat
the same but with an implicit discretization in the z-direction). Compared to the other
methods, ADI is fast. However, ADI-methods only work if the governing equations have
time-derivatives, and unfortunately this is often not the case in geodynamics. In the exercises, we therefore focus on the fully implicit formulation. If, however, you have to write
a thermal solver at some point, you may strongly consider to use the ADI method (which
is still very fast in 3D).
4.8
You are to program the diffusion equation in 2D both with an explicit and an implicit discretization scheme, as discussed above. The problem to be considered is that of the thermal structure of a lithosphere of 100 km thickness, with an initial linear thermal gradient
of 13 K/km. Suddenly a plume with T = 1500 C impinges at the bottom of the lithosphere. What happen with the thermal structure of the lithosphere? A related (structural
geology) problem is that of the cooling of batholiths (like the ones in the Sierra Nevada).
1. Fill in the question marks in the script heat2Dexplicit.m (Figure 4.7), by programming the explicit finite difference scheme. Employ zero flux boundary conditions
T
x = 0 on the left and on the right-side of the domain (outside the top and bottom edges), and constant temperature conditions on the top and bottom. Ignore the
effects of radioactive heat.
2. Finish the code heat2Dimplicit.m (Figure 4.8), by programming the implicit finite
difference approximation of the 2D temperature equation.
79
Figure 4.7: MATLAB script heat2D_explicit.m to solve the 2D heat equation using the explicit
approach.
( x2 + z2 )
T ( x, z, t = 0) = Tmax exp
2
(4.99)
80
Figure 4.8: MATLAB script heat2D_explicit.m to solve the 2D heat equation using the implicit
approach.
81
(4.100)
82
4.9
Reading
Spiegelman (2004), chap. 5
Press et al. (1993), sec. 19.1
4.9.1
D
=
+ v ,
(4.101)
Dt
t
where this is equation is for an operator, that applies to a quantity, such as temperature.
In 1-D and in the absence of heat sources, the diffusion-advection equation becomes
(sec. 7)
T
T
T
+ vx
=
k
(4.102)
c p
t
x
x
x
or in 2-D
c p
T
T
T
+ vx
+ vz
t
x
z
=
x
T
k
x
+
z
T
k
z
(4.103)
where v x , vz are velocities in x-, respectively z-direction. If k is constant, the general equation can be written as
T
+ v T = 2 T.
(4.104)
t
USC GEOL557: Modeling Earth Systems
83
Figure 4.9: Snapshots of a bottom heated thermal convection model with a Rayleigh-number of
5 105 and constant viscosity (no internal heating). Temperature is advected through a fixed
(Eulerian) grid (circles) with a velocity (arrows) that is computed with a Stokes solver.
Heat sources would lead to additional terms on the right hand side. Since temperature
variations lead to buoyancy forces, the energy equation is coupled with the Stokes (conservation of momentum) equation from which velocities v can be computed to close the
system needed for a convection algorithm.
Mantle convection codes typically deal with advection of a temperature field assuming that there is significant diffusion at the same time, > 0, and will produce nonphysical artifacts in cases that are advection-dominated. One example would be if a
chemical composition C is to be treated akin to T,
C
+ v C = c 2 C.
t
(4.105)
Chemical diffusivities are for mantle purposes zero, c 0, and special tricks are required
to use field methods to solve
C
+ v C = 0
(4.106)
t
(e.g. Lenardic and Kaula, 1993), as discussed below. Often, one therefore uses tracer-based,
or particle methods where C is assigned to virtual particles that are then advected with
an ODE approach (to be solved with, e.g., Runge Kutta, sec. 3)
dC
=0
dt
and
dxi
=v
dt
(4.107)
where xi is the location of the i-th tracer moving through the fluid. We will return to
a hybrid approach (the semi-Lagrangian scheme) below, but see, e.g., Tackley and King
(2003) for a recent discussion of different tracer approaches. A related method is based
USC GEOL557: Modeling Earth Systems
84
4.9.2
We will return to the combined (combo) solution of both diffusion and advection below,
but for now focus on the advection part. In the absence of diffusion (i.e. k, = 0), the 1-D
equations are
T
T
+ vx
=0
(4.108)
t
x
and
T
T
T
+ vx
+ vz
= 0.
(4.109)
t
x
z
We will now evaluate some options on how to solve these equations with a finite difference scheme on a fixed grid. Even though the equations appear simple, it is quite tricky
to solve them accurately, more so than for the diffusion problem. This is particularly the
case if there are large gradients in the quantity that is to be advected. If not done carefully, one can easily end up with strong numerical artifacts such as wiggles (oscillatory
artifacts) and numerical diffusion (artificial smoothing of the solution).
FTCS method
In 1-D, the simplest way to discretize eq. (4.108) is by employing a central difference
scheme in space, and go forward in time (another example of a forward-time, central
space, FTCS, scheme):
T n Tin1
Tin+1 Tin
= v x,i i+1
,
(4.110)
t
2x
where v x,i is the v x velocity at location i.
Exercise 1 We will consider a 1-D problem, with constant v x velocity in which an exponential pulse of temperature is getting advected along the x axis (see Figure 4.10 and
exercise_1_ftcs.m).
Program the FTCS method in the code of Figure 4.10 and watch what happens.
Change the sign of the velocity.
Change the time step and grid spacing and compute the non-dimensional parameter
|v x |t/x.
When do unstable results occur? Put differently, can you find a t small enough to
avoid blow-up?
USC GEOL557: Modeling Earth Systems
85
As you can see from the exercise, the FTCS method does not work so well . . . In fact, it is
a nice example of a scheme that looks logical on paper, but looks can be deceiving. The
FTCS method is unconditionally unstable, blows up for any t, as can be shown by von
Neumann stability analysis (cf. chap 5 of Spiegelman, 2004). The instability is related to the
fact that this scheme produces negative diffusion, which is numerically unstable.
Lax method
The Lax approach consists of replacing the Tin in the time-derivative of eq. (4.110) with
( Tin+1 + Tin1 )/2. The resulting equation is
Tin+1 Tin1
Tin+1 ( Tin+1 + Tin1 )/2
= v x,i
t
2x
(4.111)
Exercise 2
Program the Lax method by modifying the script of the last exercise.
Try different velocities and t settings and compute the Courant number, , which is
86
v x t
x
(4.112)
n 2 (x )2 n
2 2
n +1
n
T =0
Mx
( Ti
Ti ) + x Ti
x
2
x i
(x )2 x2
(4.113)
87
Figure 4.11: Illustration of the Courant criterion (from Press et al., 1993, chap 19.1).
Note that we have replaced central with forward or backward derivatives, depending on
the flow direction. The idea is that the flux into the local cell at xi will only depend on the
gradient of temperature in the direction upstream, i.e. where the inflowing velocity is
coming from.
Exercise 3
Program the upwind scheme method.
Try different velocity distributions (not just constant) and compute the Courant
numbers .
Is the numerical scheme stable for all Courant numbers?
USC GEOL557: Modeling Earth Systems
88
=0
(4.117)
Setting the mass operator to = 0 gives us the previously seen Crank-Nicolson semiimplicit finite difference discretization, while setting = 61 gives us the finite element
formulation. Below is eq. (4.117) written out with = 16 .
1 1
6 4
t
v
x
Tin+11
1
1 1
t
n +1
1
Ti
+
+
v
Tin++11
3
6 4
x
1 1
t
1
1 1
t
n
n
=
+
v
Ti1 + 1
Ti +
v
Tin+1
6 4
x
3
6 4
x
(4.118)
The finite element Crank-Nicolson advection scheme is stable for 1 and provides
an improvement over previous schemes in that it is accurate to O(t, (x )3 ). This allows
us to reduce the number of grid points to reach the same accuracy as the other schemes
presented, as long as t is kept small enough.
Staggered leapfrog
The explicit discretizations discussed so far were second order accurate in time, but only
first order in space. We can also come up with a scheme that is second order in time and
USC GEOL557: Modeling Earth Systems
89
(a)
Figure 4.12: Illustration of the upwind (a) and leapfrog (b) schemes (from Press et al., 1993,
chap 19.1).
space
T n Tin1
Tin+1 Tin1
= v x,i i+1
,
(4.119)
2t
2x
called staggered leapfrog because of the way its centered in shifted space-time (Figure 4.12b).
The computational inconvenience in this scheme is that two time steps have to be stored,
T n1 and T n .
Exercise 4
Program the staggered leapfrog method (assume that at the first time step T n1 =
T n ).
Try with different values of the Courant number and compare the accuracy and
stability of the different methods.
Also, make the width of the Gaussian curve smaller.
Bonus: Also program the two formulations of the Crank-Nicolson method with =
0 and = 16 .
The staggered leapfrog method works quite well regarding the amplitude and transport phase as long as is close to one. If, however, 1 and the length scale of the
to-be-transported quantity is small compared to the number of grid points (e.g. we have a
thin plume), numerical oscillations again occur (those are due to the lack of communication between cells, which can be remedied by artificial diffusion). The conditions where
USC GEOL557: Modeling Earth Systems
90
91
3. Assume that T (tn+1 , xi ) = T (tn , X ), i.e. temperature has been transported (along
characteristics) without any modification (e.g. due to diffusion).
This scheme assumes that no heat-sources were active during the advection of T from
T (tn , X ) to T (tn+1 , xi ). If heat sources are present and are spatially variable, some extra
care needs to be taken (Spiegelman, 2004, sec. 5.6.1).
Exercise 5
Program the semi-Lagrangian advection scheme illustrated in Figure 4.13A. Is there
a Courant criterion for stability?
Some improvements The algorithm described in Figure 4.13A illustrates the basic idea
of the semi-Lagrangian scheme. However, it has two problems. First it assumes that
velocity is spatially constant (which is clearly not the case in mantle convection simulations). Second, it assumes that velocity does not change between time n and n + 1. We
can overcome both problems by using a more accurate time stepping algorithm (see the
ODE section). An example is an iterative mid-point scheme which works as follows (cf.
Figure 4.13B):
For each point i
1. Use the velocity v x (tn+1 , xi ) to compute the location X 0 at time tn+1/2 (i.e. take half
a time step backward in time).
2. Find the velocity at the location X 0 at half time step tn+1/2 . Assume that the velocity
at the half time step can be computed as
v x (tn+1/2 , xi ) =
v x ( t n +1 , x i ) + v x ( t n , x i )
.
2
(4.120)
92
vx(n+1,i)
n+1
Dt
n
T(n,i-2)
vx(n,i-1)
T(n,i-1)
time
time
n+1
Dt
vx(n,i)
T(n,i)
n+1/2
n vx(n,i-2) x
vx(n,i-1)
space
vx(n+1,i)
vx(n,i)
space
Figure 4.13: Basics of the semi-Lagrangian method. See text for explanation.
Other ODE-motivated methods such as 4th order Runge Kutta are also possible (but
take a bit more work). Note that the various velocity interpolation and iteration schemes
add overhead that is, however, typically made up for by not needing to obey the Courant
criterion.
Exercise 6
Program the semi-Lagrangian advection scheme with the centered midpoint method
as illustrated in Figure 4.13B (cf. Spiegelman, 2004, p. 67).
Some care has to be taken if point X is outside of the computational domain, since
MATLAB will return NaN for the velocity (or temperature) of this point. If no extrapolation is desired, use the velocity v x (tn+1 , xi ) in this case. A pseudo-code is given
by
if isnan(Velocity)
Velocity = Vx(i)
end
2D advection example
The semi-Lagrangian method is likely a good, general advection algorithm (except in the
case of pseudo spectral methods), so this is the one we will implement in 2D.
Assume that velocity is given by
v x ( x, z) = z
vz ( x, z) = x
(4.121)
(4.122)
Moreover, assume that the initial temperature distribution is Gaussian and given by
( x + 0.25)2 + z2
T ( x, z) = 2 exp
0.12
93
(4.123)
4.9.3
(4.124)
for example by using a semi-Lagrangian advection scheme. Then solve the diffusion
equation
T
T
=
k
+ Q.
(4.125)
c p
t
x
x
For this, we assumed that Q is spatially constant; if not, one should consider to slightly
improve the advection scheme by introducing source terms. A good general method
would be to combine Crank-Nicolson for diffusion with a semi-Lagrangian solver for
advection (Spiegelman, 2004, sec. 7.2), but we will try something simpler first:
Exercise 8
Program diffusion-advection in 2D using the semi-Lagrangian advection scheme
coupled with an implicit 2D diffusion code (from last sections exercise). Base your
code on the script of Figure 4.14.
94
clear all
W
sigma
Ampl
nt
dt
=
=
=
=
=
40;
.1;
2;
500;
5e-1;
% width of domain
% number of timesteps
z;
-x;
for itime=1:nt
Vx_n
= Vx;
%
Velocity at time=n
Vx_n1
= Vx;
%
Velocity at time=n+1
Vx_n1_2 = ??;
%
Velocity at time=n+1/2
Vz_n
= ??;
%
Velocity at time=n
Vz_n1
= ??;
%
Velocity at time=n+1
Vz_n1_2 = ??;
%
Velocity at time=n+1/2
Tnew
=
zeros(size(T));
for ix=2:nx-1
for iz=2:nz-1
%
%
%
%
Vx_cen = Vx(iz,ix);
Vz_cen = Vz(iz,ix);
for ??
X =?
Z = ?
%
%
%
%
%
if isnan(Vx_cen)
Vx_cen =
Vx(iz,ix);
end
if isnan(Vz_cen)
Vz_cen =
Vz(iz,ix);
end
%
%
%
end
X = ?;
Z = ?;
% Interpolate temperature on X
T_X = interp2(x,z,?,?,?, cubic);
if isnan(T_X)
T_X = T(iz,ix);
end
Tnew(iz,ix) = T_X;
end
end
Tnew(1,:)
Tnew(nx,:)
Tnew(:,1)
Tnew(:,nx)
=
=
=
=
T(1,:);
T(nx,:);
T(:,1);
T(:,nx);
T
time
=
=
Tnew;
itime*dt;
figure(1),clf
pcolor(x,z,T), shading interp, hold on, colorbar
contour(x,z,T,[.1:.1:2],k),
hold on, quiver(x,z,Vx,Vz,w)
axis equal, axis tight
drawnow
pause
end
95
Figure 4.15: Staggered grid definition. Properties such as viscosity and density inside a control
volume (gray) are assumed to be constant. Moreover, a constant grid spacing in x and z-direction
is assumed.
4.10
4.10.1
Introduction
The basis of basically all mantle convection and lithospheric dynamics codes are the socalled Stokes equations for slowly moving viscous fluids. These equations describe the
balance between buoyancy forces (e.g. due to temperature variations in the fluid) and
viscous drag (sec. 7). Here, we will describe the governing equations. There are several
ways to solve those equations, and the goal of this project is to use a staggered finite
difference approach in primitive variables.
For this, we solve the governing equations for v = {v x ; vz } (velocities) and p (pressure). Staggered finite differences means that the different unknowns v x , vz , p are defined
at physically different grid points. The main challenges of this project are, 1), having several variables instead of only one (e.g. temperature), and, 2), to do the bookkeeping for the
present case that the variables are at different grid points. (While the governing equations
are different, those computational challenges are similar to those arising in the staggered
grid, finite difference approach for wave propagation discussed in sec. 4.12.2.)
4.10.2
Governing equations
It is assumed that the rheology is incompressible and that the rheology is Newtonian
viscous, i.e. = 2 with no function of ,
where is the stress tensor, viscosity, and
strain-rate tensor. In this case, the governing equations in 2D (x and z) are (see sec. 7):
96
v x vz
+
= 0
x
z
xx xz
+
= 0
x
z
xz zz
+
g = 0
x
z
v x
x
vz
= p + 2
z
v x vz
+
,
=
z
x
(4.126)
(4.127)
(4.128)
xx = p + 2
(4.129)
zz
(4.130)
xz
(4.131)
where is density and g = {0, g} the gravitational acceleration. The density is where
these continuum and force balance equations (eqs. 4.126 to 4.128) couple to the the energy
equation, e.g. the diffusion and advection of temperature for mantle convection, discussed
in the previous sections.
It has been suggested that a particularly nice way to solve these equations is to use a
staggered grid (more about this later) and to keep as variables v x , vz and p (Gerya and Yuen,
2003; Gerya, 2009).1 Since there are three variables, we need three equations. Substituting
eqs. (4.129)-(4.131) into eq. (4.127) and eq. (4.128) leads to:
p
v x vz
+
=
x
z
P
v x
v x vz
+2
+
= 0
x
x
x
z
z
x
P
vz
v x vz
+2
+
= g
z
z
z
x
z
x
(4.132)
(4.133)
(4.134)
Note that we added the term P to the incompressibility equations. This is a trick called
the penalty method, which ensures that the system of equations does not become illposed. For this to work, should be sufficiently large ( 104 or so), so that the condition
of incompressibility (conservation of mass, eq. 4.126) is approximately satisfied.
4.10.3
Exercise
97
Figure 4.16: MATLAB script Staggered_Stokes.m that sets up numbering, matrix A and that
solves the incompressibility equations.
98
Figure 4.18: Staggered grid definition with the boundary points. Within the purple domain, the
finite difference scheme for center points can be applied. At the boundaries, we have to apply a
special finite difference scheme which employ fictious boundary nodes.
Add the discretization of the force balance equations (including the effects of gravity) into the equation matrix A. Assume that the viscosity is constant and = 1 in a
first step, but density is variable.
An example is given in how to verify that the incompressibility equation is incorporated correctly. This is done by assuming a given (sinusoidal) function for, lets say,
v x (e.g. v x = cos(x ) cos(z)). From the incompressibility equation (eq. 4.126) a solution for vz than follows. By setting those solutions in the c vector, we can compute
Ac and verify that rhs for those equations is indeed zero.
3. Add free-slip boundary conditions on all sides (which means vz = 0, xz = 0 on
the lower and upper boundaries and xz = 0, v x = 0 on the side boundaries). Use
fictious boundary points to incorporate the xz boundary conditions.
4. Assume a model domain x = [0; 1], z = [0; 1], and assume that the density below
z = 0.1 cos(2x ) + 0.5 is 1, whereas the density above it is 2. Compute the velocity
and pressure, and plot the velocity vectors.
5. Write the code for the case of variable viscosity (which is relevant for the Earth since
rock properties are a strong function of temperature).
99
Figure 4.19: Discretization for the streamfunction approach. The boundary conditions are set
through fictious boundary points.
4.11
4.11.1
Introduction
As was discussed in sec. 4.10, the basis of basically all mantle convection and lithospheric
dynamics codes are the Stokes equations for slowly moving viscous fluids.
There are several ways to solve those equations, and the goal of this exercise is to
use a streamfunction, finite difference approach. Stream function means that there is a
potential field which we solve for, and then obtain velocities from the derivatives of this
field. The advantage of this approach is that the continuity equation for incompressible
flow can be satisfied implicitly, rather than having to use a panelty parameter as for the
primitive variable approach of sec. 4.10. (It is, however, possible to formulate the stream
function method for compressible convection approximations, e.g. ?). For a comparison
of different finite difference approaches, see ?, for example.
The main challenges of this project are, 1), having fairly high-order and mixed derivatives (up to 4th order) and, 2), setting of boundary conditions.
4.11.2
Governing equations
It is assumed that the rheology is incompressible and that the rheology is Newtonian
viscous. In this case, the governing equations are (see sec. 7):
v x vz
+
= 0
x
z
xx xz
+
= 0
x
z
xz zz
+
g = 0
x
z
v x
x
vz
= p + 2
z
v x vz
+
=
z
x
(4.135)
(4.136)
(4.137)
xx = p + 2
(4.138)
zz
(4.139)
xz
(4.140)
By substituting eqs. (4.138)-(4.140) into eqs. (4.135)-(4.137), we obtain (compare sec. 4.10)
v x vz
+
= 0
x
z
v x
v x vz
p
+
= 0
+2
x
x
x
z
z
x
p
vz
v x vz
+2
+
= g
z
z
z
x
z
x
(4.141)
(4.142)
(4.143)
We can eliminate pressure from eqs. (4.142) and (4.143) by taking the derivative of eq. (4.142)
versus z and subtracting eq. (4.143) derived versus x. This results in:
v x
2
vz
2
+
2
xz
x
xz
z
2
2
v x vz
v x vz
+
2
+
= g.
(4.144)
2
z
x
z
x
x
z
x
We can also use the incompressibility constraint (4.141) to simplify things a little bit more:
2
vz
4
+
xz
z
2
v x vz
2
v x vz
+
2
+
= g
(4.145)
2
z
x
z
x
x
z
x
Now we introduce a variable (the stream function) which is defined by its relationship to the velocities as
=
x
vx =
(4.146)
vz
(4.147)
+
xz
xz
2
2
2
2
2
2
= g.
2
2
2
2
2
x
z
z
x
x
z
x
(4.148)
Note that this equation now has 4th order derivatives for (easier to see for constant ,
where we can pull the viscosity out of the derivatives.) The challenge is to solve eq. (4.148)
for given then density gradients.
4.11.3
Exercise
Figure 4.20: Code Streamfunction_Stokes.m that initializes the grid and node numbering for the
2D streamfunction approach.
4.12
Wave propagation
We briefly discuss two examples for solving wave propagation type problems with
finite differences, the acoustic and the seismic problem.
4.12.1
In an isotropically elastic medium, acoustic wave propagation, where we are only taking
care of a single type of wave, can be described by a set of two partial differential equations,
leading to an hyperbolic problem. Firstly, Newtons 2nd law,
1
2 u
= u = 2 p = b2 p
2
(4.149)
(4.150)
(4.151)
(4.152)
v=
Kb =
(4.153)
(4.154)
1
i,j
+
1
i,j
= v2i,j
+
.
t2
h2
h2
(4.158)
(4.159)
h2
.
(4.160)
t2
Then, the pressure or displacement at time step n + 1 can be derived explicitly from time
step n and n 1 as in eq. (4.159), though two solutions have to be stored.
Note that we use 2nd -order second derivatives in eq. (4.159). Two considerations are
required for choosing suitable time step t and spatial step h: grid dispersion and stability.
ai,j = v2i,j
(4.161)
4.12.2
For 2D elastic wave case (P-SV system), we have the equations as:
xx xz
2 u x
=
+
,
2
x
z
t
2 u z
xz zz
=
+
,
x
z
t2
u x
uz
xx = ( + 2)
+
,
x
z
uz
u x
zz = ( + 2)
+
,
z
x
u x uz
xz =
+
.
z
x
and
(4.162)
(4.163)
(4.164)
(4.165)
(4.166)
(4.169)
(4.170)
(4.171)
A typical seismic wave propagation problem needs to deal with medium with variable
Poissons ratio, , which can be defined as
=
.
2( + )
(4.172)
For the special case of = , = 0.25, and many rocks have Poissons ratios not far
from 1/4. For liquids, 0.5. For seismic wave propagation, this is particularly important when ocean water or the outer core of the Earth are needed to be considered in the
problem, which is hard to be resolved with the traditional set up of grid as in Fig. 4.22.
To satisfy both requirements for stability and grid dispersion at those problems, a PSV staggered-grid scheme is applied. Note the structure of the elastic wave problem,
eq. (4.167)-eq. (4.171), they allow the stress and particle velocity to be spatially interlaced
on the grids as in Fig. 4.23. The staggered-grid scheme allows the spatial derivative to be
computed to a much higher accuracy (e.g. Levander, 1988). (This computational aspect is
similar to the staggered grid finite difference approach to the Stokes problem, discussed
in sec. 4.10.)
To add the complexity, the stress and velocity field can also staggered in time. Follow
the explicit scheme, the second order difference equations for Equation (4.167)-(4.171) are:
t k
k
i+1,j i,j
h
t k
+ bi+1/2,j
i+1/2,j+1/2 ik+1/2,j1/2 ,
h
1/2
1/2
uik++1/2,j
= uik+1/2,j
+ bi+1/2,j
(4.173)
t k
i+1/2,j+1/2 ik1/2,j+1/2
h
t k
k
+ bi,j+1/2
i,j+1 i,j
,
h
k+1/2
k1/2
vi,j
+1/2 = vi,j+1/2 + bi,j+1/2
k +1
i,j
k
i,j
t k+1/2
k+1/2
u
ui1/2,j
+ ( + 2)i,j
h i+1/2,j
t k+1/2
k+1/2
+ i,j
vi,j+1/2 vi,j
1/2 ,
h
t k+1/2
k+1/2
k +1
k
i,j
vi,j+1/2 vi,j
= i,j
+ ( + 2)i,j
1/2
h
t
1/2
1/2
+ i,j
uik++1/2,j
vik+1/2,j
,
h
t k+1/2
k+1/2
vi+1,j+1/2 vi,j
+1/2
h
t
1/2
k+1/2
+ i+1/2,j+1/2
uik++1/2,j
u
+1
i +1/2,j .
h
(4.174)
(4.175)
(4.176)
1
k
ik++1/2,j
+1/2 = i +1/2,j+1/2 + i +1/2,j+1/2
(4.177)
t
1
< ,
h
2
where
s
vP =
+ 2
(4.178)
(4.179)
is the P-wave velocity. The stability condition is independent of the S-wave velocity
r
vS =
(4.180)
Chapter 5
Finite elements
5.1
Reading:
Textbooks
The recommended background reading for this, finite element part of the textbook by Hughes (2000). This book is in wide use in mantle convection modeling
and aspects of the codes ConMan (King et al., 1990) and CitcomS (Moresi and Solomatov, 1995; Zhong et al., 2000) (both now maintained and developed by CIG,
geodynamics.org) follow the approach and notation of Hughes (2000) (see also
Zhong et al., 2007).
For additional reference, you might want to consider the Matlab-based finite
element course by Kwon and Bang (1996) and the comprehensive and high-level
treatment by Bathe (2007) and
Hughes (2000), chap. 1, secs. 1.1-1.15
Bathe (2007), sec. 1.2
5.1.1
Consider a boundary value problem (and many physical problems in solid mechanics can
be converted into a boundary value problem) given on a domain with a boundary
= such that a solution u( x) satisfies the PDE:
F (u( x)) = s( x)
where F is some differential operator and s a source term (Figure 5.1).
As boundary conditions, we can have
110
(5.1)
(5.2)
u
= n u = h
xi
(5.3)
5.1.2
Consider
2 u
+s = 0
x2
(5.4)
on the domain [0; 1] where s is given. Eq. (5.4) could be a 1-D steady-state heat equation,
for example, where
2 T
H (x)
= 0.
(5.5)
(Dirichlet)
(5.6)
(Neumann)
(5.7)
and
u(1)
=h
x
boundary conditions (BCs), which closes the system for a two point boundary value problem. This formulation of the PDE with all original derivatives in place is called the strong
form. Eqs. (5.4) and (5.6) can, of course, be solved analytically by integration.
For example, if s = x such that
2 u
+x =0
x2
(5.8)
(5.9)
1
u + x 3 + c1 x + c2 = 0
6
(5.10)
1
u ( x ) = x 3 c1 x c2
6
(5.11)
u(0) = c2 = g;
1
1 3
x+g
u( x ) = x + h +
6
2
(5.12)
(5.13)
The analytical solution (5.13) will be used in the numerical problem set to test the approximate, numerical solutions. For more complicated, realistic problems, typically no
analytical solutions can be found (which is why we do numerical analysis in the first
place).
From the strong form, we will now move to a variation, or weak form. We require
that
(a) the trial solutions of u, among all possible solutions satisfy the essential BC
u (0) = g
(5.14)
dx < ;
(5.15)
(5.16)
(5.17)
2 u
w 2
x
ws = 0
(5.18)
Z 1
w u
0
With
u(1)
x
w
x x
x
1
a b = ab |
b0 a
w s = 0.
(5.19)
(5.20)
x x
= h w (1) +
Z 1
0
w s dx
(5.21)
This is the weak form of the PDE. Equations of this type in mechanics are called virtual work, or virtual displacement formulations (the w are the virtual displacements).
It can be shown that the weak and the strong form are identical (Hughes (2000), sec. 1.4)
and the FE method proceeds from eq. (5.21) by assuming u and w can be taken from a
simplified functional space, typically based on low order polynomials.
It is useful to define a shorthand notation
a(w, u) =
Z 1
w u
0
x x
dx
and
(w, s) =
Z 1
0
w s dx
(5.22)
(5.23)
(w, s) = (s, w)
(5.24)
(5.25)
and bilinear
forms.
USC GEOL557: Modeling Earth Systems 114
5.1.3
Galerkin method
and
w (0) = 0,
(5.26)
(5.27)
where g is a given function such that g (0) = g, which satisfies the BCs because
u (0) = v (0) + g (0) = 0 + g
(5.28)
(5.29)
where we solve for the LHS and the RHS is determined by BCs.
This is an example of a weighted residual method, there are other approaches such as the
Petrov-Galerkin method. The Galerkin method is the simplest because it assumes that v
and w are from the same function space, i.e. the same shape functions (see below) are used for
the solution u and the weights w .
5.1.4
Lets assume that there are n nodes such that we can write the weighting functions as
n
w ( x ) =
c A NA ( x )
(5.30)
A =1
(5.31)
(with N1
/ W)
(5.32)
g = g N1
so that g (0) = g.
(5.33)
then
d A NA + g N1
A =2
(5.34)
c A NA , db NB
A
c A NA , s
c A NA (1 )
ha
c A NA , g N1
!
.
(5.35)
Because of bilinearity, we can write A c A G A = 0 with
GA =
a( NA , NB ) dB ( NA , s) NA (1) h + a( NA , N1 ) g.
(5.36)
The Galerkin equation (5.29) is supposed to hold for all w, therefore all c A , which means
that a A = 0. So, for all A
a( NA , NB ) dB = ( NA , s) + NA (1) h a ( NA , N1 ) g.
(5.37)
(5.38)
where K is the stiffness matrix , d is the displacement vector , and F is the force, or load, vector.
Once the Kd = F system is assembled, one may solve for d and then obtain the spatial
solution from
n
u ( x ) =
d A NA ( x ) + g N1 ( x )
(5.39)
A =2
n
u ( x ) =
d A NA ( x )
with d1 = g.
(5.40)
K = K AB = a( NA , NB )
= a( NB , NA ) = K BA = K T ,
(5.41)
(5.42)
or
which facilitates computations, because special numerical solvers can be used depending
on the matrix properties of K. Also, see sec. 5.4 for the solution of large, sparse, linear
systems of equations such as eq. (5.38).
5.2
We now provide a numerical implementation of the previously discussed 1-D FE example. We subdivide the [0; 1] interval into n sub-intervals (elements) delimited by n + 1
nodes or nodal points such that x1 = 0 and xn+1 = 1. The sub-intervals are denoted by
(5.43)
where the element size h A may vary, and a general grid spacing may be defined as h =
max (h A ).
We can then choose interior shape functions for 2 A n as
x A 1 x x A ,
h A1 ( x x A1 ) for
1
(5.44)
NA ( x ) =
for x A x x A+1 ,
h A ( x A +1 x )
0
otherwise.
For the boundaries, we use special shape functions
1
N1 ( x ) =
( x2 x )
h1
n +1 ( x ) = 1 ( x x n )
N
hn
for x1 x xn+1
for xn x xn+1 .
and
(5.45)
(5.46)
An illustration of interior and boundary shape functions is shown in Figure 5.2; note that
NA = 1 at x = x A and zero for other nodes.
With this choice, the shape functions are zero outside the vicinity of A. They have local
support, which means that K is a sparse matrix because the
a( NB , NA ) =
Z 1
NA NB
0
dx
(5.47)
integral is zero for B > A + 1. The K matrix is banded, banded matrix and the bandwidth
depends on how the nodes are numbered (leading to an optimization problem during
USC GEOL557: Modeling Earth Systems 117
(5.48)
5.2.1
It is useful to compare the (., .) and a(., .) operations in local coordinate systems that are
referenced to each element as is shown below in Figure 5.3.
Figure 5.3: Example of 1-D shape functions in global (left, N ( X )) and element-local (right, N ( ).
with [1; 1]) coordinates.
1
( h A + x A + x A +1 )
2
u ( x ) = d A NA ( x )
1
(2x x A x A+1 )
hA
u( ) = N1 ( ) d1 + N2 ( ) d2 .
(x) =
(5.49)
(5.50)
We can express the global shape function NA of eq. (5.44) in a local coordinate system as
Na ( ) =
(i.e. N1 ( ) =
1
(1 );
2
1
(1 + a )
2
N2 ( ) =
for a = 1, 2
1
(1 + )
2
(5.51)
(5.52)
Na ( ) xea
a =1
(5.53)
2
2
(5.54)
x
he
= ,
(5.55)
and
=
x
x e
1
2
.
he
x e
(5.56)
1
Note 2: The choice of shape function is determined by the type of element. E.g. with a
two node element, shape functions can only be linear. If the solution to be approximated is u, then u will vary linearly over the element, and derivatives, x u, will be
constant.
5.2.2
Matrix assembly
K = [K AB ]
F = { FA }
an n 1 vector
(5.57)
Z 1
NA NB
dx
x x
FA = ( NA , s) + h A,n+1 a( NA , N1 ) g
Z 1
0
(5.58)
NA s dx + A,n+1 h g
(5.59)
Z 1
NA N1
0
dx
(5.60)
K=
Ke
with K e = [K eAB ]
(5.61)
e =1
(5.62)
F=
with
F =
{ FAe }
(5.63)
FAe
de
NA NB
dx
x x
(5.64)
NA s dx + h e,n A,n+1 g
Z
e
NA N1
dx
x x
(5.65)
f e = { f a } a 2 1 vector
(5.66)
Kab = a( Na , Nb ) =
Z
e
Na Nb
dx
x x
(5.67)
(5.68)
fa =
Z
e
e g
Ka,1
Na s dx +
0
a,n+1 h
for
for
for
e = 1,
e = 2, . . . , n 1,
e = h.
(5.69)
The assembly proceeds as symbolized in Figure 5.4, and placing the K e element-local
matrix into the global stiffness matrix requires use of an assignment operator or array.
This is discussed in the worked example of the problem set.
USC GEOL557: Modeling Earth Systems 120
5.2.3
Element-local computations
dx f ( x ) =
Z ( x2 )
( x1 )
x ( )
] f ( x ( )) =
d [
Z 2
x
f ( ).
(5.70)
e
Kab
=
(5.71)
(5.72)
we can get
Na ( x ( )) x ( )
Na ( x ( ))
=
Na ( x )
=
x
1
Na ( )
.
1
Z 1 1
x
Na ( ) Nb ( )
=
d
1
1
= e (1) a+b (eq. 5.54)
h
(5.73)
(5.74)
(5.75)
(5.76)
(5.77)
Ke =
Since
Na
1
1 1
1
h e 1
.
(5.78)
independent of the actual nodal values for the solution. The derivatives x
and x do,
however, depend on the element shape and need to be computed for each geometric
(mesh) configuration.
For the source term, we use the approximation
2
s =
sa Na
a =1
(5.79)
Na ( x ) s( x ) dx =
=
Since
R1
Z 1
Na ( x ( )) s( x ( ))
1
Z 1
he 2
b =1 1
x ( )
d
(5.80)
Na ( ) Nb ( ) d sb .
(5.81)
boundary terms
(5.82)
Na Nb = 13 (1 + ab ),
he
s =
6
he
6
2 1
1 2
s1
s2
(5.83)
5.3
2 s1 + s2
s1 + 2 s2
boundary terms
(5.84)
Reading
This finite element example is based on Hughes (2000), sec. 1.1-1.15.
5.3.1
(5.85)
on the domain x [0; 1], u( x ), s( x ), and subject to essential (Dirichlet) boundary condiu(1)
tion u(0) = g on the left, and natural (Neumann) BCs, x = h on the right. Equation
(5.85) may be considered a general version of the steady-state heat equation
2 T
+H=0
x2
(5.86)
a( NA , NB )dB = ( NA , s) + NA (1)h a( NA , N 1 ) g.
B
(5.87)
Z 1
NA NB
dx
x x
= ( NA , s) + NA (1)h a( NA , N 1 ) g
Z 1
Z 1
1
NA N
dx g,
=
NA sdx + A,n+1 h
x x
0
0
0
(5.88)
(5.89)
(5.90)
where we have used the definitions of the bi-linear forms a(, ) and (, ) from before, and
the Kronecker delta
(
1 if i = j
i,j =
(5.91)
0 else
is used for the flux boundary condition (also see Hughes, 2000, chap 1). Note that it is
sometimes helpful to not think about nodes but about elements. The weak form of the
equations are satisfied on average per element, and by constructing an appropriate mapping/numbering we can easily go from a single element to a 1D or 2D domain.
The approximate solution of u after discretization of the weak form is given by
n +1
u ( x ) =
1g =
d A NA ( x ) + N
A =2
d A NA ( x ),
(5.92)
where the latter summation implies choosing the boundary shape function and BC if
needed. The vector d = {d A } values have to be obtained by solution of the matrix equation
Kd = F,
(5.93)
with K = {K AB } and F = { FA }.
We discussed previously how the integration over the domain can be broken down
into summation over integrals over each element (see sec. 3.2). This integration is most
easily performed in a local coordinate system 1 1 between the two nodes of each
element, which has a mapping to the corresponding, global coordinate interval [ x A ; x A+1 ].
We can also express the shape functions as x ( ),
x ( ) =
NA ( ) x A
and
u( ) =
NA ( ) d A .
(5.94)
The global K matrix and the F vector are then assembled by looping over all elements
1 e n and adding each elements contribution for shared nodes. By change of integration variables and the chain rule, those elemental contributions follow as
1
1 1
e
,
(5.95)
k =
1
x 1
USC GEOL557: Modeling Earth Systems 123
2s1 + s2
s1 + 2s2
( k g
for e = 1
a1
+ a,n+1 for e = n
0
else
(5.96)
where we have assumed that the source function s varies linearly over each element, and
s1 and s2 are the contributions from each local node a within the element from s( x ). After
assembly, one needs to ensure that each row of the global K matrix that corresponds to a
fixed value (Dirichlet) boundary condition, will only have a diagonal entry and the other
columns for this row are zero.
5.3.2
Exercises
(a) Download heat1dfe.m, and all helper routines for this section. Read through the
implementation of what is summarized above, heat1dfe.m, and understand this
code.
(b) Fill in the blanks in heat1dfe.m and experiment with a solution of eq. (5.85) for
n = 3 elements.
(a) Print out the stiffness matrix (full(stiffness)) to appreciate its banded structure. Does this look familiar to you?
(b) Choose the Matlab solver (solver=0) and plot the finite element solution at the
nodes, as interpolated within the elements, and compare with the analytical
solution.
(c) Reads the following section on solving linear systems of equations, if you have
time, and work on the examples (optional).
5.4
5.4.1
Direct solvers
For the finite element method, we can always write our problem in the form of eq. (5.97),
where K is a square, n n matrix. A general strategy to solve eq. (5.97) is then LU decomposition
K = LU,
(5.98)
where L and U are lower and upper triangular matrices, respectively, which only have
zeros in the other part of the matrix. The solution of eq. (5.97) can then be obtained
efficiently from
Kd = LUd = F
(5.99)
by solving for y = L1 F and then d = U1 y, because the inverse of U and L are computationally fast to obtain. LU is often how general matrix inversion is implemented on a
computer.
For most FE problems, the K matrix will also be sparse and banded. Special algorithms
exist to exploit this feature such that the run time is ideally dominated by the number of
non-zero entries of K, rather than the full size. Moreover, if K is symmetric and positive
definite, as in our example above, we can use the Cholesky decomposition for which
U = LT and computations are twice as fast as for the general LU case. However, for
complex, 3-D FE problems, current computational limitations often prohibit the use of
direct solvers which is why iterative methods which do not require matrix decomposition
or inversion, are used.
(5.100)
in the sense that |Ax b| = min, i.e. deviations from the true solution are minimized,
for a matrix A that may be under-determined, i.e. not simply invertible. It can be
shown that the general least squares solution x LS is given by
x LS = A A
1
AT d,
(5.101)
1
where AT A
is the generalized inverse (which exists even if the inverse of A,
1
A , does not exist because A is singular). AT A is symmetric and positive definite,
meaning that Cholesky is also the method of choice for direct approaches to find
x LS .
5.4.2
Iterative solvers
Jacobi method
The simplest iterative solution of eq. (5.97) is given by the Jacobi method. If K is LU
decomposed and we write the diagonal matrix (only non-zero along diagonal) of K as D,
then an iterative solution for d starting from an initial guess d1 (e.g. 0) can be obtained
from
Ddi+1 = F (U + L)di ,
(5.102)
where the iteration is over i and is stopped once di+1 is not changing more than some
tolerance from the previous solution estimate di . On an element by element basis, this
can be written as
!
n
1
dij+1 =
Fj K jl dil
(5.103)
K jj
l =1, l 6= j
where the summation is over all l but for l = j. The Jacobi method following eq. (5.103)
is implemented in jacobi.m. It serves mainly illustrative purposes but is guaranteed
USC GEOL557: Modeling Earth Systems 126
for
i = 1, 2, . . . , L,
(5.108)
where b is the base, typically a small number such as 2 or 4. At each ith level, we need
to construct separate stiffness matrices, Ki , and the corresponding force vector where the
resolution for the i = L solution is the best approximation to Kd = F, and the forcing is
only needed to be specified at FL (see below).
An example implementation may proceed like so (see, e.g. Press et al., 1993, sec. 19.6 for
some alternatives): We start at the highest level, L, and perform only a few, fixed number
of GS iterations for an rough approximate d L from
K L d L = FL
(5.109)
to remove the short wavelength misfit starting from an initial guess d L = 0. The residual
is then given by
R L = FL Kd L .
(5.110)
We then project, or restrict, the residual to a coarser grid at L 1 by a projection operator
P
R L1 = PL L1 R L .
(5.111)
P will be some stencil giving more weight to the fine resolution nodes that are closer to
the coarse resolution node to which we project. We next GS iterate
Ki di = Ri
(5.112)
for i = L 1 for another small number of iterations (initializing di again with 0), performing another smoothing step, reducing short wavelength fluctuations. Note that
eq. (5.112) now operates on the residual and not the load vector F such that we are computing corrections of d, d. We then repeat the smoothing and projection steps down to
i = 1 where eq. (5.112) can be solved quickly and exactly. This completes the downward
leg of the V cycle where the longest wavelength residual has been addressed.
USC GEOL557: Modeling Earth Systems 129
(5.114)
(5.115)
(5.116)
(5.117)
with Ri+1 = Ki+1 di+1 and weighting = (Ri+1 Ri+1 )/|Ri+1 |2 . We continue by
projecting di in this fashion up to i = L, where we update d L = d L + d L , which completes the upward leg of the V. The whole V cycle is then repeated until the desired tolerance for d L is reached at which point d L = d. Details of the implementations of the MG
method, such as the smoothing, restriction, and prolongation operations, depend on the
problem and the boundary conditions (e.g. Press et al., 1993; Briggs et al., 2000).
Exercise 3
Download the MG implementation of the 1-D FE example (based on C code by
Zhong, 2008), multigrid.m. Read through the implementation, compare with the
above recipe, and understand the approach.
Compare the number of iterations needed for the MG solver with that of the GS
method for 32, 64, 128, 256 numbers of elements.
Plot the scaling of the number of iterations, or time spent in the multigrid subroutine, with the number of elements.
Temperature
1
0.9
0.9
0.8
0.8
0.7
0.7
0.6
0.6
0.5
0.5
0.4
0.4
0.3
0.3
0.2
0.2
0.1
0.1
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Figure 5.5: Coarse finite element mesh with solution for temperature, allowing for an elliptical
inclusion and a boundary at mid-model height.
5.5
Reading: Hughes (2000) secs. 2.1 - 2.6, 3.1, 3.4, 3.8 - 3.9
We will now consider the solution of 2D boundary value problems using
finiteele
x
x1
ments, which can be easily expanded to three dimensions. We write x =
=
x2
z
for a location vector xi with i = 1, 2 and a normal vector n on the boundary of the domain . As an example problem we will now revisit the linear heat conduction problem.
5.5.1
If we allow for anisotropic diffusivity (which may apply to the oceanic plates), Ficks Law
can be written as
qi = ij
2
T
T
= ij
x j
x j
j =1
(5.118)
= [ij ]
(5.119)
(5.120)
q = H
or
ij T
qi
=
=H
xi
xi x j
(5.121)
for
(Poisson Eq.)
with BCs:
T=g
qi ni = h
USC GEOL557: Modeling Earth Systems 132
on g
on h
and
(5.122)
T
ij
=
=H
xi
x j
xi xi
2
T 2 T
+ 2 =H.
conductivity
x2
z
(5.123)
(5.124)
The weak form representation (first substitute the test function and integrate over the
domain, second integrate by parts) of eq. (5.122) is given by
w
q =
xi i
d wH +
d wh
(5.125)
where the LHS is the diffusion term, the first term on the RHS corresponds to volumetric
heating, and the second term on the RHS is the flux through the boundary. See Hughes
(2000), sec. 2.3 for the derivation. Eq. (5.125) can then be expressed as
a(w, T ) = (w, H ) + (w, h)
(5.126)
with
a(w, T ) =
(w, H ) =
(w, h) =
w
T
ij
xi
x j
d wH
d wh.
(5.127)
(w)T T
with
w
x1
w
x2
w =
!
and
T =
T
x1
T
x2
!
(5.128)
such that
a(w, T ) =
d (w) T T
1 0
with =
0 1
for isotropy in 2-D.
(5.129)
Using the Galerkin approach of choosing the trial and weighting functions from the same
function space, we again posit for the solution
T = v + g
(5.130)
(5.131)
NA ( x ) d A
and
g ( x) =
AI
A ( x) g A
N
(5.132)
AB
where we have again distinguished between interior nodes and shape functionm A
I , and those on the Dirichlet boundary, with A B . Arguing as for the 1-D case, the
following assembly rules result
Kd=F
K = K PQ
(5.133)
K PQ = a( NA , NB ),
(5.134)
where 1 P, Q neq and the number of free equations is given by the total number of
nodes minus the number of nodes on the Dirichlet boundary B .
P and Q can be computed from a 1D array that maps a global node A into a global equation number
P for A I
ID ( A) =
(5.135)
0 for A B
such that P = ID ( A) and Q = ID ( B). d = {dQ } for the solution temperatures
v ( x) =
NA d A
(5.136)
and
F = { Fp }
(5.137)
where
FP = ( NA , H ) + ( NA , h) h
BB
a( NA , NB ) q B
(5.138)
5.5.2
Matrix assembly
K=
Ke
e
K e = {K PQ
}
(5.139)
( NA )T ( NB ) d .
(5.140)
e =1
e
K PQ
= a( NA , NB ) =
Z
e
The RHS in eq. (5.140) corresponds to integrating over each elements area.
nel
Fe
F=
F e = { FPe }
(5.141)
e =1
FPe
Z
e
d NA H +
Z
he
d NA h
a( NA , NB )e q B
(5.142)
BB
where he is the part of the Neumann (flux) boundary within element e, and P = ID ( A), Q =
ID ( B). Within each element we compute for new nodes per element with 1 a, b nen
e
K =
e
}
{Kab
e
Kab
= a( Na , Nb ) =
Z
e
d ( Na ) T ( Nb )
f e = [ f ae ]
fa =
Z
e
(5.143)
(5.144)
Na f a d +
nen
Z
he
Na h d
Kabe gbe
(5.145)
b =1
where gbe = g( xeb ) for prescribed g and zero otherwise. It is convenient to write
e
K =
Z
e
d B T D B
(5.146)
where D is nsd nsd (rows columns); nsd , number of spatial dimensions. In our case
D is 2 2 and D = . B is nsd nen such that B = { B1 , B2 , . . . , Bnen } and
Ba = Na
(5.147)
is nsd 1.
The B and D matrices general meaning is that of a gradient operator and that of a material parameter matrix at an element level, respectively. For example, if the temperatures
at an element level are given by
d1e
de
2
de = {dea } = ..
(5.148)
.
denen
USC GEOL557: Modeling Earth Systems 135
nen
Ba dea
(5.149)
a =1
can be used to compute the heat flux within each element. We will revisit this for the
elastic problem where B converts the nodal displacement solution into the strain.
5.5.3
Isoparametric elements
It is convenient to use elements where the shape functions that are used to map from a
local coordinate system, for example for a four node quad (1 a nen = 4) spanned by
the local coordinates
1
1
1 =
2 =
(5.150)
1
1
1
1
3 =
4 =
,
(5.151)
1
1
x( ) =
Na ( ) xea
(5.152)
a =1
are the same shape functions that are used to represent the solutions
nen
v ( ) =
Na ( ) dea .
a =1
(5.153)
If the mapping from the element local, , to real coordinate space, x, is differentiable, the
determinant j of the Jacobian J
!
x x
x z
z x
(5.154)
j = det J = det
z z
is j( ) > 0 for all within the element. j( ) may, in practice, become very small, which indicates that the element is greatly deformed (two edges almost align, for example) which
is to be avoided.
The practical use of j arises from element-local integration. Recall from the 1-D case
(eq. 5.70)
Z
e
f ( x ) d =
Z 1
1
Z 1
x
d
(5.155)
d f ( x (, ), z(, )) j(, ).
(5.156)
f ( x ( )) d
x
=
f ( x ( ))
f ( x) d =
Z 1
1
Z 1
1
The above equation is a result of the change of variables and can be used to evaluate the
a(., .) type integrals.
5.5.4
Numerical integration
While the integral over simple shape functions (and for non-deformed quadrilaterals)
may be easily evaluated analytically, it is most convenient to perform a numerical integration over the element area or volume e . Also, if the element is deformed, one must
perform numerical integration.
In 1-D, the objective is to optimally approximate (i.e. replace the integral over the element
USC GEOL557: Modeling Earth Systems 137
Z 1
1
d g( )
g(i ) Wi
(5.157)
i =1
for a small number of integration points nint . The Wi are the weights for the function
values at the integration points i . For example, the
Trapezoidal rule corresponds to nint = 2; 1 = 1; 2 = 1; Wi = 1 and is second order
accurate.
Z b
a
f ( x ) dx (b a)
f ( a) + f (b)
2
(5.158)
(1 i2 )
2
P
nint
(i )2
1 i nint
(5.160)
1 n 2
( 1) n .
2n n! n
(5.161)
This rule is O(2nint ) accurate in 1-D, and weights and locations are tabulated (see
below).
In 2-D, we can compute
Z 1
1
Z 1
1
nint nint
d g
g(i , j ) Wi Wj .
(5.162)
i =1 j =1
Finally, we often need to convert the derivatives of the shape functions with respect to the
global coordinates to local coordinates: ( x). By means of the chain rule we obtain
Na
Na
Na
=
+
x
x
Na
Na Na
=
+
z
z
.
z
(5.163)
(5.164)
Na Na
Na Na
,
}={
,
}
x z
!
(5.165)
Na
as well as
Na
ever, the x
type derivatives are not available explicitly. How can we compute them then?
This involves one of the tricks of the FE method, namely by noting that the coordinates of
the element are also approximated by shape functions, in the following manner: We do
know the inverse relationships
nen
x (, ) =
Na (, ) xea
(5.166)
Na (, ) zea
(5.167)
a =1
nen
z(, ) =
a =1
from which we can compute the derivatives of the coordinates versus natural coordinate
as
!
x
J = x =
e.g.
x
=
(5.168)
z
Na
xea ; =
Na e
za .
1
x z
=J =
z
x
j
x z
with
j = det
x z
x z
(5.169)
(5.170)
Therefore
Na Na
,
x z
Na Na
,
J 1
(5.171)
5.5.5
N
(
)
=
=
a
2
2
Quadrature
nint
i
wi
accuracy for integration
R1
1
0
2
2nd order
1 d
1
1
th
2
{ ; } {1,1} 4 order
2 = {1, 1}
4 = {1, 1}
etc. for a = 1, 2, 3, 4
Na ( ) = Na (, ) =
1
(1 + a )(1 + a )
4
(5.172)
(5.173)
(5.174)
(5.175)
Quadrature in 2-D
nint
visual
i
1
{0, 0}
[]
1
2
; 1 }
{
3
3
1
1
{ ; }
3
3
{ 13 ; 13 }
1 1
{
;
}
3
3
wi
4
for integration
R1
R1
d
1
1 d
Hughes (2000) p. 191 discusses the required level of Gaussian quadrature for adequate
convergence for different element types.
t(r, s)
r
r1
r2
r3
= 1rs
= {r, s}
= {1, 0}
= {0, 1}
= {0, 0}
N1 (r, s) = r
N2 (r, s) = s
N3 (r, s) = t = 1 r s
(5.176)
(5.177)
(5.178)
(5.179)
(5.180)
N1 =r (2r 1)
N2 =s(2s 1)
N3 =t(2t 1)
N4 = 4 r s
N5 = 4 s t
N6 = 4 r t
(5.181)
(5.182)
(5.183)
5.5.6
Na ( )xa ,
(5.184)
r =
(5.185)
(5.186)
5.6
Reading
Hughes (2000), sec. 2.3-2.6
Dabrowski et al. (2008), sec. 1-3, 4.1.1, 4.1.3, 4.2.1
This FE exercise and most of the following ones are based on the MILAMIN package
by Dabrowski et al. (2008) which provides a set of efficient, 2-D Matlab-based FE routines
including a thermal and a Stokes fluid solver. Given that the code uses Matlab, MILAMIN
is remarkably efficient and certainly a good choice for simple 2-D research problems that
lend themselves to FE modeling. You may want to consider working on expanding the
MILAMIN capabilities, e.g. by adding advection to the thermal solver and combining it
with the Stokes solver for a convection code.
Over the next sections, we will discuss all of the issues described in Dabrowski et al.
(2008). This paper will be a good additional reference, and the original MILAMIN Matlab
codes can be downloaded from http://milamin.org/ (the latter will not be of help with
the exercises).
5.6.1
We spent the last three sections discussing the fundamentals of finite element analysis
building up to the solution of the 2-D, stationary heat equation, which is given by
T
= H,
(5.187)
x
x
z
dz
T ( x, z) =
NA ( x, z) TA .
(5.188)
A =1
Following, e.g., Hughes (2000), we use the Galerkin approach for which the resulting stiffness matrix components, on an element level, is
Z
Na Nb
e Na Nb
e
+
d.
(5.189)
Kab =
x x
z z
e
Here, a and b are node numbers local to element e, and integration e is over the element
area.
If we express the spatial coordinates x = { x, z} in a node-local coordinate system =
{, } and use Gaussian quadrature with N I NT points and weights Wi for integration,
we need to evaluate terms of the kind
Z 1
Z 1
Na Nb Na Nb
e
+
J 1 j
(5.190)
Kab =
d
d
1
1
N I NT
Na Nb Na Nb
e
+
J 1 j
(5.191)
Kab = Wi i
i
where J 1 is the inverse and j = det(J ) = |J | the determinant of the Jacobian matrix
!
x
J=
(5.192)
respectively.
The load vector F has to be assembled on an element basis as
Fae
Z
e
e
Na Hd Kab
Tb ,
(5.193)
where the terms on the right hand side are due to heat sources, H, and a correction due to
prescribed temperatures on the boundaries T (zero flux BCs need no specific treatment,
see Hughes, 2000, p. 69 and Dabrowski et al. (2008)). The global K and F are assembled by
looping through all elements and adding up the K e and F e contributions, while eliminat are supplied.
ing those rows that belong to nodes where essential boundary conditions (T)
The solution is then obtained from solving
KT = F.
USC GEOL557: Modeling Earth Systems 145
(5.194)
(a) Create a triangular grid using three node triangles for the domain 0 x 1, 0
z 1 using minimum area constraint 0.1 and minimum angle 20 . Create a print
out plot of this mesh highlighting nodes that are on the outer boundary.
(b) Change the area constraint to 0.01, remesh, and replot.
(c) Use second order triangles and an area constraint of 0.005 and minimum angle of
30 .
(d) Using the same quality constraints, create and print out a mesh plot of an elliptical
inclusion of radius 0.2, ellipticity 0.8, and 50 nodes on its perimeter. Color the elements of the inclusion differently from those of the exterior. Denote nodes on the
boundary of the inclusion.
(e) Create and plot a mesh with a circular hole and a circular inclusion of radius 0.1.
USC GEOL557: Modeling Earth Systems 146
Figure 5.15: Stress solution for a sheared, elastic box with an inclusion of different strength (see
problem set for details).
5.7
Reading
Hughes (2000), secs. 2.7, 2.9 - 2.11, 3.10
Dabrowski et al. (2008)
This FE exercise is again based on the MILAMIN package by Dabrowski et al. (2008).
Their mechanical solver (incompressible Stokes fluid, to be discussed in the next section) was rewritten for the elastic problem, and simplified to reduce the dependency on
packages external to Matlab.
A highly optimized version of the code that, for example, uses matrix reordering for
K is available from us (this one is closer to the original Dabrowski et al. (2008) code). When
USC GEOL557: Modeling Earth Systems 148
5.7.1
+ f = 0,
(5.195)
where = ij is the stress tensor and f a body force (such as due to gravity). (Note that
this equation is a general force balance equation in the absence of inertia. You can use it
for static elastic deformation, as we do here, or the Stokes fluid flow problem, as we will
discuss subsequently. The difference arises in the constitutive law.)
Written in component form as PDEs for the finite element domain for each of the
three spatial coordinates i this is
ij
+ fi = 0
x j
on
(5.196)
on
on
gi
hi .
(5.197)
(5.198)
Here, h and hi , and similar for g, denotes that different components of the traction vector
may be specified on different parts of the domain boundary .
In the case of linear, elastic behavior, the constitutive law linking dynamic with kinematic properties is given by the generalized Hookes law
= Ce
or
ij = Cijkl ekl ,
(i,j)
(5.199)
(5.200)
= ii =
ii ,
(5.202)
i =1
E
2
=
1 2
(1 + )(1 2)
with
E = 2(1 + ),
(5.203)
with the Poisson ratio and Youngs modulus E. (There are only two independent
material parameters for isotropic elasticity.) If a block is fixed at the base and loaded
in z-directions without constraints, then measures the deformation in the horizontal
= xx / zz . E measures the stress exerted for the same experiment if the material is not
allowed to give way sideways (free-slip in z direction) by E = zz / zz .
The incompressibility, K, is defined as
p = K = K ii
(5.204)
1
1
ii = ii ,
3
3
(5.205)
3K (1 2)
.
2(1 + )
Note that = for = 1/4, which is often close to values measured for rocks.
(5.206)
(5.207)
(5.208)
with
a(w, u) =
(w, f ) =
Z
Z
(5.209)
d wi f i
(5.210)
(w, h) h =
d wi hi
h
i =1
(5.211)
Note that unlike the thermal problem, the solution function we wish to obtain using the
finite element method is a vector, u, rather than a scalar.
Matrix assembly
In the finite element approximation, we then solve for the nodal displacements d which
approximate u within the elements with shape functions N from
Kd = F.
(5.212)
Z
e
d BaT DBb
(5.213)
where a, b are local node numbers. The elemental force vector at local node a is given by
f ie
Z
e
d Na f i +
d Na hi k ab gb .
he
Na
0
x
a .
Ba = 0 N
z
Na
z
(5.214)
(5.215)
Na
x
We can represent the strain tensor as a strain vector e that can be computed from
displacements u by a gradient operator L, like
e = Lu
or
e j = L jk uk .
(5.216)
xx
x
e = zz = 0
xz
z
ux
uz
,
(5.217)
where the definition of xy = 2 xy simplifies the notation, and it is where the engineering
strain convention arises. Make sure to distinguish it from , i.e. convert with the factor 2
if needed.
Within each finite element the displacements can be obtained by summation over the
shape functions for each node a, Na , times the nodal displacements,
u = uk = Na d a = Na dka
(5.218)
where d a is the displacement at the local node a, and dka is the k-th spatial component of
this displacement. Then,
e = e j = L jk Na dka = Bjka dka = Ba d a
(5.219)
xx
s = zz
xz
(5.220)
(with xz = 2xy in analogy to xy ), then the (symmetric) elasticity matrix D can be used
to obtain stresses from displacements like
s = De = DBa d a .
(5.221)
(5.222)
d e(w) T De(u),
(5.224)
where e(w) indicates applying the gradient operator to the virtual displacements, as opposed to e(u) as in eq. (5.216).
USC GEOL557: Modeling Earth Systems 152
0
1
+ 2
0
1
E (1 )
0
+ 2 0 =
D=
,
1 1
(
1 + )(1 2)
12
0
0 2(1 )
0
0
(5.225)
where plane strain means that no deformation is allowed in the y direction, yy = 0. For
the case of plane stress, where deformation is allowed and yy = 0,
1
+ 2
0
E
+ 2 0 =
D=
1 2
0
0
0 0
with
=
2
.
+ 2
0
0 ,
1
2
(5.226)
(5.227)
From eq. (5.227), it is apparent that plane stress reduces the effective, volumetric stiffness
of a body, for = 1/4, = 2/3, because out of plane deformation is permitted.
Viscous equivalence
The constitutive law for linear viscous flow with viscosity , and deviatoric stress , =
is analogous to the elastic case with = 2, assuming the material is incompressible.
2 ,
The latter can, in theory, be achieved by letting 1/2 for which K/ such that
the linear FE approach can be used to solve simple fluid problems. In practice, however,
special care needs to be taken to allow for the numerical solution of the incompressible
elastic, or the Stokes flow case, which we discuss in sec. 5.8.
Exercises
(a) Make sure you have the Matlab subroutines ip_triangle.m, shp_deriv_triangle.
m, generate_mesh.m, and the triangle binary from last section in your working
directory. Both shape functions and the mesher will be reused.
(b) Download elastic2d_std.m, a simple linear elasticity solver, and calc_el_D.m which
assembles D. Also download the driver routine elastic2d_test.m. You will have
to fill in the blanks.
(c) Inspect elastic2d_std.m, compare with the notes above for linear elasticity, and the
heat solver from sec. 5.6.
(d) Download and inspect det2D.m, inv2D.m, and eig2d.m (for computing the determinant, inverse, and eigen system of 2 2 matrices, respectively). Writing out these
USC GEOL557: Modeling Earth Systems 153
Figure 5.16: Load case sketches for some of the exercises, along with common symbols for kinematic boundary conditions.
(a) Assume the body is fixed at the base (zero displacement u for all z = 0),
and sheared with a uniform u x displacement of u0 = 0.1 at the top (z = 1)
(Load case a of Figure 5.16a). Assume the plane strain approximation and zero
density (i.e. zero body forces). What kind of geologic deformation state does
this correspond to? What kinds of displacements would you expect, and how
should the major (1 ) extensional and the major compressional (2 ) stress axis
align?
5.8
5.8.1
Governing equations
As for the thermal or the elastic problem, we will only consider the static case (but
see sec. 21 of the notes). In the absence of inertia case (infinite Prandtl number),
this reduces the fluid equilibrium (Navier-Stokes) equations to the Stokes equations
(see secs. 4.10 and 7) which are formally similar to the elastic problem considered in
sec. 18.
Since most fluids are (nearly) incompressible, we will revisit the general problem of
elastic deformation.
The ratio of the bulk modulus, or incompressibility, K, and shear, , modulus can be
expressed as a function of Poissons ratio
2(1 + )
K
=
.
3(1 2)
As noted earlier, for the 21 , incompressible case, K .
However, in this case we cannot use the regular, elastic (isotropic, linear) constitutive
law
ij =
because =
2
12
uk
+ 2 ij = kk ij + 2 ij
xk ij
(5.228)
(5.229)
(5.230)
ij = p ij + 2 ij
(5.231)
u =
ui
=0
xi
(5.232)
ij
+ fi = 0
x j
vi
=0
xi
v i = gi
ij n j = hi
(5.233)
(5.234)
(5.235)
(5.236)
where eqs. (5.233) and (5.234) hold in the domain , eqs. (5.235) and (5.236) are boundary
conditions and hold on gi and hi respectively. u and v are displacement and velocity,
respectively, and
!
1 u j ui
ij = u(i,j) =
+
(5.237)
2 xi
x j
!
vi
1 v j
+
ij = v(i,j) =
.
(5.238)
2 xi x j
Note that from eq. (5.232) and by Gau Theorem
Z
u
d i =
xi
d ui ni =
d gi ni = 0
(5.239)
and if there are only displacement/velocity BCs, and f = 0, then pressures are only
determined up to a constant.
5.8.2
Different approaches exist involving Lagrange multipliers, penalty methods (see sec. 4.10),
or Uzawa iterations. See for example, Zhong et al. (2007). All methods typically involve
a stiffening of the deforming structure using some parameter that controls the degree
of compression. would lead to the desired case of u = 0, but may lead to an
ill-conditioned (hard or impossible to invert) matrix. We will pursue a mixed formulation.
Mixed formulation
This is valid both for compressible and incompressible behavior, such that
ij = p ij + 2 ij
p0
ui
+ =0
xi
(5.240)
(5.241)
1
2
ui
xi
ui
xi
= 0.
(5.242)
1
p = ij
3
only for the incompressible case. For the compressible case
2
1
ii = K ii
p = ij = +
3
3
with the incompressible modulus K = +
2
3 ,
p0 = ii .
p0 p and K only for , the nearly incompressible case. The major results are
outlined below.
Equations in strong form
ij
+ fi
x j
p
ui
+
xi
ui
ij n j
=0
on
(5.243)
=0
on
(5.244)
= gi
= hi
on gi
on hi
(5.245)
(5.246)
d w(i,j) ij
d q
ui
p
+
xi
nsd Z
d wi f i +
dhi wi hi
(5.247)
where w, g are virtual displacements and pressures, respectively, and nsd is the number
of dimensions. Special care must be taken in the next step: the choice of shape functions
for pressure and velocities/displacements (see Hughes, 2000, sec. 4.3), but in general, the
pressure shape functions should be lower order (e.g. linear) than the displacements (e.g.
quadratic).
K G
GT M
d
F
=
p
H
(5.248)
where the LHS is symmetric but not positive definite (it has negative eigen values or
zero eigen values for pressure modes), p are the pressures at nodes (e.g. center of element),
d are the displacements at nodes (e.g. edges of elements), F are the body forces, and H is
the divergence source in the boundary conditions.
This is called the segregated d/p form of the equations and is valid for the general
(including finite compressibility) case.
K
G
a (w, d)
( w, p)
(5.249)
(5.250)
GT
(q, v)
p
q,
divergence operator
(5.251)
1
2
and M
(5.252)
(5.253)
GT d + M p = H
(5.254)
solve for p
p = M 1 ( H G T d )
(5.255)
(5.256)
(GT K 1 G) p = GT K 1 F H
K
p =
F
(5.257)
(5.258)
(5.259)
Na (x) da
(5.260)
N a (x) pa
(5.261)
p( x ) =
K Ke
F fe
K e = K e g e (me )1 (g e ) T
f e = f g e (me )1 he
pe = (me )1 (g e ) T d
Z
e
Bb
d BaT D
D here only has deviatoric terms, for the plane strain case
2 0 0
= 0 2 0 ,
D
0 0 1
and B transforms displacements into strains (as before).
fpe =
d Na f i +
Z
h
Na hi k pq gqe
i
(5.262)
(5.263)
Z
e
1
Na Nb
Mixed
(5.264)
(5.265)
ga a =
a
d ( Na e) N
(5.266)
(5.267)
( x) Ba ( x) d a
( x) = Na ( x) p a 1 + D
a
a
0
in each element.
Powell and Hestenes iterations
As detailed in the problem set on the 2-D Matlab implementation (cf. Dabrowski et al.,
2008), iterations are needed to stabilize the solution of the segregated form for the incompressible problem, or for large . Another way to think of it is that we actually solve a
case with a compressible bulk deformation; iterations are performed until the resulting
system is incompressible.
p0 = 0
while max (pi ) > tolerance
di = (K G M 1 GT )1 ( F G pi )
i
p = M
p
i +1
T i
G d
= p + p
i = i+1
quasi-divergence
end
(5.268)
(5.269)
(5.270)
(5.271)
Figure 5.17: Pressure and velocity solution for a sinking, fluid slab impinging on viscosity contrast
problem.
5.9
Reading
Hughes (2000), sec. 4.2-4.4
Dabrowski et al. (2008), sec. 4.1.2, 4.3.1, 4.4-4.7
This FE exercise is again based on the MILAMIN package by Dabrowski et al. (2008).
As for the heat and elasticity problems, we simplified their mechanical, incompressible
Stokes fluid solver to reduce the dependency on packages external to Matlab. Dabrowski
et al. (2008) have a highly optimized version, which you can obtain from us or the original authors; it uses, e.g., reordering of node numbers to improve matrix solutions which
comes an important memory issue for larger problems. The notation here is close to
Dabrowski et al. (2008), for simplicity, but Hughes (2000) has a somewhat clearer exposition.
5.9.1
We are interested in the instantaneous solution of a fluid problem in the absence of inertia
(infinite Prandtl number limit), as is appropriate for the Earths mantle, for example (see
USC GEOL557: Modeling Earth Systems 162
= f = g or
ij
= gi ,
x j
(5.272)
where is the stress tensor, density, and g gravitational acceleration (gi = giz ).
We assume that the medium is incompressible and a linear (Newtonian) fluid constitutive law holds,
ij = pij + 2 0ij ,
(5.273)
where is the viscosity, p pressure, and 0 the deviatoric strain-rate tensor,
!
v j
1 vk
1 vi
1
1 vk
0
+
ij =
ij , or 0 = tr ( ),
ij = v(i,j)
3 xk
2 x j xi
3 xk
3
(5.274)
where v are the velocities, and 0 is the total strain-rate reduced by the isotropic part.
We can define
1
1
1
e = ii = ii = tr ( )
(5.275)
3 i
3
3
in analogy to the pressure
p=
1
ii
3
i
(5.276)
such that deviatoric stress and strain-rate are defined from the isotropic quantities as
ij = ij + pij ,
and
(5.277)
0ij
and
(5.278)
ij ,
= ij e
(5.279)
Using the constitutive law, and assuming 2-D (x-z space), the Stokes equation can be
written as (also see sec. 7)
4 v x 2 vz
v x vz
p
= 0
(5.280)
x
3 x
3 z
z
z
x
x
4 vz 2 v x
v x vz
p
= gz .
(5.281)
z
3 z
3 x
x
z
x
z
Often, we write the constitutive law for deviatoric quantities only,
ij = 2 0ij
with
ij = ij + p = ij kk /3.
(5.282)
v = 0 or
(5.283)
which allows solving eq. (5.272) for the additional unknown, pressure. For v = 0,
tr ( ) = 0
0 = ,
(5.284)
but we made the distinction between deviatoric and total strain-rate because we numerically only approximate the incompressible continuity equation, eq. (5.283), by requiring
the divergence to be smaller than some tolerance.
There are several approaches to do this (e.g. penalty methods (sec. 4.10) or Lagrange
methods) which typically involve iterations to progressively introduce additional stiffness to the medium (sec. 5.8). We shall allow for a finite, large bulk viscosity, , such that
eq. (5.283) is approximated by
p
v x vz
+
= ,
(5.285)
x
z
the right hand side would 0 for . Eq. (5.285) is valid for the incompressible and
the compressible cases. However, for the compressible case, where the constitutive law,
eq. (5.273), is replaced by
v
ij = k ij + 2 ij ,
(5.286)
xk
p cannot be interpreted as the actual pressure, P = ii /3, rather it is a pressure parameter because
v
(5.287)
P = ( + 2/3) i
xi
and
p =
vi
.
xi
(5.288)
Note: The general, compressible case is identical to the elastic formulation where v u
and the constitutive law is
v
ij = k ij + 2 ij .
(5.289)
xk
5.9.2
The (finite element) solution is to be found for the problem stated by eqs. (5.272) and
(5.285),
ij
+ fi = 0
x j
vi
p
+
= 0
xi
(5.290)
(5.291)
on
on
gi
hi
(5.292)
(5.293)
h
i
i
(5.294)
with nsd the number of spatial dimensions. We again use the Galerkin approach, which
leads to the matrix equations.
Matrix assembly
In analogy to the elastic problem, we define a (total) strain-rate vector e = { xx , zz , xz =
2 xz } such that strain-rates on an element level can be computed from
e = Bv,
(5.295)
where v are velocities given at the element-local nodes, and B holds the derivatives, as
before. When expressed for the local node a and shape functions Na ,
Na
0
x
a .
(5.296)
Ba = 0 N
z
Na
z
Na
x
2
3 3 0
4
,
D = 23
(5.297)
3 0
0
0 1
for a plane-strain approximation (compare the elastic case). This allows to express the
stress vector with pressure part as
s = pm + D e,
2 0 0
D0 = 0 2 0 .
0 0 1
USC GEOL557: Modeling Earth Systems 165
(5.298)
(5.299)
Na (x)va .
(5.300)
a =1
Given the incompressibility constraint, special care has to be taken in the choice of shape
functions, and we will use the seven-node, Crouzeix and Raviart (1973) triangle with quadratic
shape functions Na (cf. Dabrowski et al., 2008).
As detailed in Hughes (2000), one can either choose conforming elements for the
problem at hand and get a nice solution for the velocities and pressure right away (which
is what we do here), or choose theoretically inappropriate shape functions and later correct the pressure (e.g. for so-called checkerboard modes). The latter, rough-and-ready
approach may seem less appealing, but works just as well if done properly.
A departure from the elastic problem is that the pressure is treated differently from v,
and we use linear (constant) shape functions for
p( x) =
(5.301)
v = v = Bv ve ,
(5.302)
and pe = Bv ve .
The global system of equations for velocity, V , and pressure, P, at the nodes is given
by
V
F
A QT
=
,
(5.303)
P
H
Q M
where F are the load vectors, e.g. due to body forces, and H is due to the divergence that
may be imposed traction loads for the compressible case (H = 0 for incompressible case).
On an element-level, the stiffness matrix is given by
Z
A
QT
e
(5.304)
kab =
d
Q 1 M
e
T
Z
T
Ba DBb BvT N
=
d
v 1N
T ,
NB
e
a Nb
v, M = N
N
T , and A corresponds to the total stiffness matrix k in the elastic
i.e. Q = NB
case. We have omitted the dependence on the local node number in eq. (5.304). Note
USC GEOL557: Modeling Earth Systems 166
(5.306)
which is to be solved for the nodal velocities V . Here, f = { f e } = {e g e } and (the Schur
complement)
A0 = A + QT M 1 Q.
(5.307)
A0 is now symmetric and positive-definite, and the regular, efficient matrix solution methods can be applied. (Note that the A is only symmetric if the Dirichlet boundary conditions are applied carefully. If implemented straightforwardly, A is not symmetric.)
However, the matrix becomes ill-conditioned (hard to invert) for the desired large values of , which is why iterations for the velocity solution are needed in order to achieve
the incompressibility constraint. Our example code applies Powell and Hestenes iterations for the global velocity and pressure vectors V and P (cf. Dabrowski et al., 2008), as
in
P0 = 0, i = 0
while max(Pi ) > tolerance
V i = (A0 ) 1 ( f Q T P i )
(5.308)
Pi = M 1 QV i
Pi+1 = Pi + Pi
i = i+1
end while
If and when the algorithm converges, the pressure correction Pi = M 1 QV , which depends on the divergence, M 1 QV , goes to zero. Above, all matrices are meant to be the
global, not element-local representation.
5.9.3
Exercises
(a) Make sure you have the common FE Matlab subroutines from the earlier exercises
(ip_-triangle.m, shp_deriv_triangle.m, genereate_mesh.m), and the triangle
binary in your working directory.
USC GEOL557: Modeling Earth Systems 167
5.10
Time-dependent FE methods
So far, we have only considered static solutions for heat and continuum mechanics problems. Finite elements can also be used to solve dynamic, or time evolving problems.
In analogy to our treatment of FD methods, the ODE part of the equations (the timederivative) can be dealt with by implicit or explicit methods.
Reading: Hughes (2000) sec. 7.1, 8.1-8.2
5.10.1
We return to the heat equation as an example of a parabolic PDE (as opposed to hyperbolic, e.g. wave propagation problems).
Strong form of the problem
qi = ij
T
x j
(heat flux)
T+
q =H
t
xi i
T
(c p
k 2 T = H
t
(5.309)
c p
(5.310)
Boundary conditions
T = g on g
qi ni = h on h
(essential)
(natural)
Initial conditions
T ( x, t = 0) = T0 ( x)
(5.311)
(5.312)
(5.313)
Weak form
(5.314)
(5.315)
(5.316)
(5.317)
where we have assumed that the spatial derivatives are now approximated by FE as expressed by v but time is still left continuous,
Matrix assembly
v( x, t) =
NA ( x ) d A ( t )
(5.318)
d (0) = d0
(5.319)
with
assembly from element level me :
local nodes a,b :
mass or capacity matrix :
conductivity matrix :
same as the static case :
F = heat supply vector :
from BCs :
M me
me = [meab ]
meab
Z
e
e
d Na c p Nb
KK
e
K e = [Kab
]
e
Kab
Z
e
(5.321)
d BaT D Bb
F fe
f e = [ f ae ]
f ae
Z
e
(5.322)
Na H +
Initial condition :
(5.320)
Z
h
e
e
dNa h (Kab
gb + m ab g b )
d0 = M d ; d d
de = [dea ]
da =
Z
e
(5.323)
Na c p T0 m ab gbe (0)
5.10.2
Solve
M d + K d = F
with IC d = d0
(5.324)
Note that M , K are symmetric, M is positive definite and K is positive semi-definite (not
pos. def. anymore). A general approach to solve eq. (5.324) is by the generalized trapezoidal method (see Hughes, 2000, p. 459).
n+
dn+1 = dn + t vn+
(5.325)
n +1
(5.326)
= (1 )v + v
where dn and vn are the approximations to d(t = tn ) and d(t = tn ), respectively, with
tn+1 = tn + t
(5.327)
as for the finite difference method. For the following s the methods in the table below
are recovered.
(5.328)
dn+1 = dn + (1 )t vn
(5.329)
(5.330)
(5.331)
(5.332)
dn+1 dn+1
t
(5.333)
The right hand side of eq. (5.332) is fast to compute for diagonal M .
1
2
2
(1 2) h2
(5.334)
where h is the smallest grid spacing in the mesh (h , mesh parameter). For the fully
explicit method ( = 0), we recover
t
2
h2
(5.335)
Part IV
Appendix
175
Chapter 6
Basic calculus and algebra review
This section provides a few brief notes on math notation and concepts needed for this text.
Not all concepts and formula are presented in a mathematically rigorous way, and you
should refer to something like a Math for Engineers text for a more complete treatment.
For most of this text, it will be assumed that the reader is familiar with the material treated
in this chapter.
6.1
6.1.1
Calculus
Full and partial derivatives
In calculus, we are interested in the change or dependence of some quantity, e.g. u, on small
changes in some variable x. If u has value u0 at x0 and changes to u0 + u when x changes
to x0 + x, the incremental change can be written as
u =
u
( x0 )x.
x
(6.1)
The (or sometimes written as capital ) here means that this is a small, but finite quantity. If we let x get asymptotically smaller around x0 , we of course arrive at the partial
derivative, which we denote with like
u
u
( x0 ) =
.
x
x 0 x
lim
(6.2)
The limit in eq. (6.2) will work as long as u doesnt do any funny stuff as a function of x,
like jump around abruptly. When you think of u( x ) as a function (some line on a plot)
that depends on x, u/x is the slope of this line that can be obtained by measuring the
change u over some interval x, and then making the interval progressively smaller.
0
We call u
x (we also write in shorthand x u ( x ) or u ( x ); if the variable is time, t, we also
use u (t) for u/t) the partial derivative, because u might also depend on other variables,
e.g. y and z. If this is the case, the total derivative du at some { x0 , y0 , z0 } (we will drop (i.e.
176
u
u
u
dx +
dy +
dz.
x
y
z
(6.3)
Here, dx and similar are placeholders for infinitesimal changes in the variables. This
means that eq. (6.3) works as long as dx is small enough that a linear relationship between
u and x still holds. In fact, we can perform a Taylor approximation on any u( x ) around
x0 by
u ( x ) = u ( x0 ) +
2 u
( x x0 )2 3 u
( x x0 )3
u
( x0 )( x x0 ) + 2 ( x0 )
+ 3 ( x0 )
...
x
2!
3!
x
x
(6.4)
Here, xu2 is the second derivative, the change of the change of u with x. n! denotes the
factorial, i.e.
n! = 1 2 3 . . . n.
(6.5)
So, as long as dx = x x0 is small, the derivative will work (for well behaved u). For example, if better approximations are needed, e.g.when the strain tensor is not infinitesimal
anymore, quadratic and higher terms like the one that goes with the second derivative
in the series eq. (6.4) and so on need to be taken into account. Finite difference methods
essentially use Taylor approximations to approximate derivatives, as we will see later.
How to compute derivatives
functions:
function f ( x )
derivative f 0 ( x )
comment
xp
px p1
exp( x ) = e x
ln( x )
sin( x )
cos( x )
tan( x )
ex
1/x
cos( x )
sin( x )
sec2 ( x ) = 1/ cos2 ( x )
If you need to take derivatives of combinations of two or more functions, here called
f , g, and h, there are four important rules (with a and b being constants):
Chain rule (inner and outer derivative):
If
f ( x ) = h( g( x ))
f 0 ( x ) = h0 ( g( x )) g0 ( x ),
i.e. derivative of nested functions are given by the outer times the inner derivative.
USC GEOL557: Modeling Earth Systems 177
(6.6)
(6.7)
Product rule:
(6.8)
( f ( x ) g( x ))0 = f 0 ( x ) g( x ) + f ( x ) g0 ( x )
(6.9)
Quotient rule:
If
g( x )
h( x )
g0 ( x ) h( x ) g( x ) h0 ( x )
f 0 (x) =
h ( x )2
f (x) =
(6.10)
(6.11)
If you need higher order derivatives, those are obtained by successively computing
derivatives, e.g. the third derivative of f ( x ) is
3 f ( x )
=
f (x)
.
(6.12)
x x x
x3
Say, f ( x ) = x3 , then
3 x 3
=
3
x
x
6.1.2
3
x
x
=
x
2
3x
x
6x = 6.
x
(6.13)
Operators are mathematical constructs that do something with the entity that is written to
their right. For example, we had earlier introduced the gradient operator, (the del operator is represented by the Nabla symbol ), which takes derivatives in all directions and,
in a Cartesian system, is given by = { x
, y , z }. Note that the operatore is a vector.
When applied to scalar field (a distribution of values that depends on spatial location),
such as a temperature distribution T ( x, y, z) (meaning T is variable with coordinates x, y,
and z, assumed implicitly for all properties from now on), the gradient operation
grad T = T =
T
x
T
y
T
z
(6.14)
generates a vector from the scalar field which points in the direction of the steepest increase in T.
Consider what can do to a vector field (i.e. vectors that vary in space, x). If
v( x) = {v1 ( x), v2 ( x), v3 ( x)}
USC GEOL557: Modeling Earth Systems 178
(6.15)
(6.16)
= V = tr ( ) = ii = 11 + 22 + 33 = v1 + v2 + v3 = v.
4
V
x1 x2 x3
i
(6.17)
(6.22)
(6.23)
6.1.3
Integrals
Taking an integral
F(x) =
f ( x )dx,
(6.24)
f (x)
F
=
(6.26)
( f ( x ) + c ) = f 0 ( x ).
x
x
x
Any general integration of a derivative is thus only determined up to an integration constant, here c, because the derivative, which is the reverse of the integral, of a constant is
zero.
Graphically, the definite (with bounds) integral over f ( x )
Z b
a
f ( x )dx = F (b) F ( a)
(6.27)
along x, adding up the value of f ( x ) over little chunks of dx, from the left x = a to the
right x = b corresponds to the area under the curve f ( x ). This area can be computed by
subtracting the analytical form of the integral at b from that at a, F (b) F ( a). If f ( x ) = c
(c a constant), then
F(x)
F (b)
F ( a)
F (b) F ( a)
=
=
=
=
cx + d
cb + d
ca + d
c ( b a ),
(6.28)
(6.29)
(6.30)
(6.31)
integral F ( x )
comment
xp
ex
1/x
sin( x )
cos( x )
x p +1
p +1 + C
e x +C
ln(| x |) + C
cos( x ) + C
sin( x ) + C
There are also a few very helpful definite integrals without closed-form anti derivatives,
e.g.
x2
e dx =
(6.32)
2
0
USC GEOL557: Modeling Earth Systems 180
R
Notation: Everything after the sign is usually meant to be integratedRover up to the
dx, or the next major mathematical operator if the dx is placed next to the if the context
allows:
Z
Z
(6.33)
( a f ( x ) + bg( x ) + . . .) dx = a f ( x ) + bg( x ) . . . dx
Z
dx f ( x ) =
f ( x )dx
(6.34)
Linearity:
Z b
a
(c f ( x ) + dg( x )) dx = c
Reversal:
Z b
a
Zero length:
Z b
f ( x )dx =
Z a
a
Z a
b
f ( x )dx + d
Z b
a
g( x )
f ( x )dx
f ( x )dx = 0
(6.35)
(6.36)
(6.37)
Additivity:
Z c
a
f ( x )dx =
Z b
a
f ( x )dx +
Z c
b
f ( x )dx
(6.38)
Product rules:
1
( f ( x ))2 + C
2
Z
f 0 ( x ) f ( x )dx =
f 0 ( x ) g( x )dx = f ( x ) g( x )
Quotient rule:
Z
(6.39)
f ( x ) g0 ( x )dx
f 0 (x)
dx = ln | f ( x )| + C
f (x)
(6.40)
(6.41)
Gau theorem The integral over the area of the divergence of a vector field f is equivalent to the boundary integral, , over the local normal (to the boundary), n, dotted with
f:
Z
Z
dA f =
ds n f .
(6.42)
6.2
Linear algebra
TO BE ADDED: Matlab conventions for mathematical operations such as dot and cross
products.
6.2.1
c = ab =
a i bi ,
(6.43)
i =1
where a and b are vectors of dimension n (n-dimensional, geometrical objects with a direction and length, like a velocity) and the outcome of this operation is a scalar (a regular
number), c. In eq. (6.43), in=1 means sum all that follows while increasing the index i
from the lower limit, i = 1, in steps of of unity, to the upper limit, i = n. In the examples
below, we will assume a typical, spatial coordinate system with n = 3 so that
a b = a1 b1 + a2 b2 + a3 b3 ,
(6.44)
where 1, 2, 3 refer to the vector components along x, y, and z axis, respectively (ADD
FIGURE HERE). In the Einstein summation convention, we would rewrite in=1 ai bi
simply as ai bi , where summation over repeated indices is implied, i.e. the is not written.
When we write out the vector components, we put them on top of each other
a1
ax
a = a2 = a y
(6.45)
a3
az
or in a list, maybe with curly brackets, like so: a = { a1 , a2 , a3 }. Here, we will use a bold
font a to denote vectors as opposed to scalar a, but another common form is ~a, and on a
blackboard, you might also see vectors written as a because thats easier.
We can write the amplitude (or: length, L2 norm) of a vector as
s
q
q
n
2
2
2
2
| a| = ai = a1 + a2 + a3 = a2x + a2y + a2z .
(6.46)
i
For instance, all of the basis vectors defining the Cartesian coordinate system, e x , ey , and
ez have unity length by definition, |ei | = 1. Those ei vectors point along the respective
axes of the Cartesian coordinate system so that we can assemble a vector from its components like
a = { a x , ay , az } = a x e x + ay ey + az ez .
(6.47)
For a spherical system, the er , e , and e unity vectors can still be used to express vectors
but the actual Cartesian components of ei depend on the coordinates at which the vectors
are evaluated.
USC GEOL557: Modeling Earth Systems 182
(6.48)
where is the angle between vectors a and b. The meaning of this is that if you want to
know what component of vector a is parallel to b, you just take the dot product. Say, you
have a velocity v and want the normal velocity vn along a vector n with |n| = 1 that is
oriented at a 90 angle (perpendicular) to some plate boundary, you can use vn = v n.
Also, eq. (6.47) only works because the basis vectors ei of any coordinate system are,
by definition, orthogonal (at right angle, perpendicular, at = 90 ) to each other and
ei e j = 0 for all i 6= j. Likewise, ei ei = 1 for all i since a a = | a|2 , and basis vectors
have unity length by definition. Using the Kronecker
ij = 1
for
i = j,
and
ij = 0
for
i 6= j,
(6.49)
6.2.2
(6.50)
(6.51)
that is at a right angle to both a and b (hence the right-hand-rule, with thumb, index, and
middle finger along a, b, and c, respectively). vector cs length is given by
(6.52)
that is, c is largest when a and b are orthogonal, and zero if they are parallel. Compare
this relationship to eq. (6.48).
In 3-D,
a y bz a z by
c = a b = a z b x a x bz
(6.53)
a x by a y b x
(note that there is no i component of a or b in the i component of c, this is the aforementioned orthogonality property).
An example for a cross product is the velocity v at a point with location r in a body
spinning with the rotation vector , v = r. The rotation vector is different from,
e.g., r in that has a spin (a sense of rotation) to it (the other right-hand-rule, where your
thumb points along the vector and your fingers indicate the counter-clockwise motion).
ADD FIGURE
6.2.3
A n m matrix is a rectangular table of elements (or entries) with n rows and m columns
which are filled with numbers. For example, if A is 3 3,
a xx a xy a xz
a11 a12 a13
A = ayx ayy ayz or a21 a22 a23 .
(6.54)
a31 a32 a33
azx azy azz
You will see matrices printed like so A, with the blackboard version being double underlining like A. The elements are referred to as aij where i is the row and j the column.
Matrices can be added and or multiplied.
Multiplication of matrix with a scalar
f a xx
a xx a xy a xz
f A = f aij = f ayx ayy ayz = f ayx
f azx
azx azy azz
f a xy
f ayy
f azy
f a xz
f ayz
f azz
cx
a xx a xy a xz
bx
a xx bx + a xy by + a xz bz
cy = ayx ayy ayz . by = ayx bx + ayy by + ayz bz
cz
azx azy azz
bz
azx bx + azy by + azz bz
or
ci =
aij bj .
(6.55)
(6.56)
(6.57)
(6.58)
(6.59)
where k goes from 1 to the number of columns in A, which has to be equal to the number
of rows in B. Note that, in general, AB 6= BA!
Special types of matrices and matrix operations
Quadratic matrices Have n n rows and columns. All simple physical tensors, such as
stress or strain, can be written as quadratic matrices in 3 3.
Identity matrix = I, iij = ij , i.e. this matrix is unity along the diagonal, and zero for
all other elements.
USC GEOL557: Modeling Earth Systems 184
tr (A) =
aii .
(6.60)
i =1
(6.61)
(6.62)
e x ey ez
a x ay az
(6.63)
b x by bz
Invariants The trace
IA = tr (A) = ai i
(6.64)
I I IA = det(A)
(6.65)
and determinant
of a matrix A are two of the three invariants, i.e. properties of a tensor (expressed as a
matrix) that are independent of a coordinate system. The third is the second invariant,
I IA = a11 a22 + a11 a33 + a22 a33 a212 a213 a223 .
(6.66)
These expressions arise when finding the eigenvectors and values of a tensor, eq. (6.71).
Transpose of a matrix
row and column.
(AT )ij = aijT = a ji , i.e. the transpose has all elements flipped by
(6.67)
If the inverse exists, then (A1 )1 = A, (AT )1 = (A1 ) T , and (AB )1 = B 1 A1 . The
inverse only exists if det(A) 6= 0.
Orthogonal or rotation matrices: For those matrices,
AAT = AT A =
(6.68)
holds.
Eigenvalues and eigen vectors: Any n n symmetric matrix A has n eigen vectors vi
that correspond to real eigenvalues i such that
Avi = i vi
(6.69)
An example is the stress matrix which can be written in the principal axes system, where
the eigen vectors of the Cartesian representation of the stress matrix are the principal axes.
Eigenvalues can be found using
det(A I ) = 0
(6.70)
and eigen vectors subsequently by using the first property, which leads to
det(A I ) = 3 + IA 2 I IA + I I IA = 0.
(6.71)
If a symmetric matrix A is transformed into the principal axes system, A0 , there are no
off-diagonal elements
a xx a xy a xz
a1 0 0
A = ayx ayy ayz A0 = 0 a2 0
(6.72)
azx azy azz
0 0 a3
where the a1 , a2 , and a3 correspond to the three eigenvalues i . (The coordinate system
reference of A0 is then contained in the orientation of the eigen vectors vi .) For a matrix in
the principal axis system, the invariants are very easily computed:
tr (A0 ) = IA0 = IA = a1 + a2 + a3
I IA0 = I IA = a1 a2 + a1 a3 + a2 a3
0
det(A ) = I I IA0 = I I IA = a1 a2 a3 .
(6.73)
(6.74)
(6.75)
See also sec. 7.2 for definitions of invariatns using deviators, such as for the deviatoric
stress tensor.
USC GEOL557: Modeling Earth Systems 186
6.2.4
Tensors
The stress and strain are examples of second order (rank r = 2) tensors which, for
n = 3, 3-D operations, have 3r components and can be written as n n matrices. You will
see tensors printed like so E, and the blackboard version again double underlining like ,
making no distinction between tensors and matrices.
Tensors in a Cartesian space are defined by their properties under coordinate transformation. If a quantity v remains intact under rotation to a new coordinate system v0 such
that
vi0
= Lij v j =
Lij v j
(6.76)
j =1
holds, then v, a vector, is a first order tensor. Lij may be, for example, a rotation matrix. Likewise, a second order tensor T is defined by remaining intact after rotation into
another coordinate system where it is expressed as T 0 such that
Tij0 = Lik Tkl L jl =
Lik Tkl L jl = LT LT
k
(6.77)
Chapter 7
Continuum mechanics review
We will assume some familiarity with continuum mechanics as discussed in the context
of an introductory geodynamics course; a good reference for such problems is Turcotte and
Schubert (2002). However, here is a short and extremely simplified review of basic continuum mechanics as it pertains to the remainder of the class. You may wish to refer to our
math review if notation or concepts appear unfamiliar, and consult chap. 1 of Spiegelman
(2004) for some clean derivations.
TO BE REWRITTEN, MORE DISCUSSION ADDED.
7.1
vi
xi
with
i = 1, 2, 3
implies
xii
i =1
v1 v2 v3
+
+
x1 x2 x3
(7.1)
In a Eulerian frame one uses a reference system for computations that is fixed in
space, for example a computational box in which we solve for advection of temperature T in a velocity field v. Local changes in, e.g., temperature are then given
by
T
T
T
DT
=
+ v T =
+ vi
,
(7.2)
Dt
t
t
xi
where D/Dt is the total derivative that we would experience if we were to ride on
a fluid particle in the convection cell (Lagrangian reference frame). D/Dt takes into
account local changes in a property with time (e.g. due to radioactive heating for T)
as well as advection of temperature anomalies by means of v in and out of our local
observation point.
Tensor = indexed variable + the rule of transformation to another coordinate system.
Traction = a force per unit area acting on a plane (a vector).
Mean stress (= pressure, p): p = = ii /3 = tr ( )/3
Mean strain: = ii /3 = tr ()/3 = (also called dilatation).
Traction/stress sign convention. Compression is negative in physics, but usually
taken positive in geology. Pressure is always positive compressive.
7.2
Stress tensor
11 12
21 22
ij
11 12
21 22
=
31 32
(2D)
13
23 (3D).
33
(7.3)
(7.4)
T(n)i = n = ij n j =
ij n j
(7.5)
j =1
In a model, the stress tensor is usually computed by solving the equilibrium equations.
Note: The number of equilibrium equations is less than the number of unknown
stress tensor components.
Stress deviator
We often decompose the stress tensor, , into a hydrostatic pressure, p, which is
minus the mean stress tensor, , and defined as
I
1
p = = tr ( ) = ii = ,
3
3
3
(7.6)
where I is the first invariant, eq. (6.64). The deviator, or deviatoric stress, is defined
as
ij = ij ij = ij + ij p.
(7.7)
The deviatoric stress tensor invariants of are typically denoted as J (as opposed to
(7.8)
(7.9)
(7.10)
(7.11)
(7.12)
7.3
(7.13)
A matrix, two indexed variables, tensor of rank two, like the stress matrix.
Meaning of the elements: Diagonal elements are elongation (rate), i.e. the relative
changes of length in coordinate axes directions), off-diagonal elements are shears,
i.e. deviations from 90 of the angles between lines coinciding with the coordinate
axes directions before deformation.
Special properties: symmetric.
Strain and strain-rate tensors are a measure of the infinitesimal (small, of order %,
as opposed to finite, i.e. large) deformation (rate). Strain and strain-rates connect to
stress (forces) via the rheological (constitutive) relationships.
Computed from the spatial gradients of displacements u and velocities v for strain
and strain-rate, respectively.
ij
ij
ui u j
+
x j
xi
v j
1 vi
=
+
2 x j xi
1
=
2
1
2
1
2
v1
x1
v2
x1
v3
x1
+
+
(7.14)
(7.15)
1
2
v1
x2
v1
x3
v1
x2 +
v2
x2
1 v3
2 x2 +
v2
x1
v2
x3
1
2
1
2
v1
+
x3
v2
x3 +
v3
x3
v3
x1
v3
x2
(7.16)
7.4
ij
2
+ 2ij
Here, , are elastic moduli (for an isotropic medium, there are two (bulk and shear)
independent moduli which can be related to all other commonly used parameters
such as Poissons ratio). is (dynamic, shear) viscosity, bulk viscosities are usually
assumed infinite. Sometimes, kinematic viscosity = / is used.
To solve a problem starting from the equilibrium equations for force balance, one
can replace stress by strain (rate) via the constitutive law, and then replace strain
(rate) by displacement (velocities). This results in a closed system of equations
in fundamental variables, meaning that the number of equations is equal to the
number of unknowns, the basic displacements (velocities).
Material parameters for solid Earth problems can ideally be obtained by measuring
rheology in the lab. Alternatively, indirect inferences from seismology or geodynamic modeling augmented by constraints such as post-glacial rebound need to be
used.
There are three major classes of rheologies:
Reversible elastic rheology at small stresses and strains over short time scales.
Irreversible fluid flow (creep) at large strains and over long time scales. Examples are Newtonian viscous (rate-independent) or power-law (rate/stress
dependent) rheology; usually thermally activated. Intermediate stress levels.
Rate-independent (instantaneous), catastrophic yielding at large, limit stresses.
Pressure sensitive, often temperature independent. Also called plastic, or frictional (brittle), behavior. Important for cold material over long time-scales.
7.5
7.5.1
(vi )
+ (v) =
+
= 0,
t
t
xi
(7.17)
v = 0 or
(7.18)
In 2D, the incompressibility constraint can be incorporated by solving for a stream function
(see the Lorenz problem) instead of the actual velocities. If, instead, the fundamental
variables v are solved for, special care needs to be taken to ensure eq. (7.18) holds.
Conservation of momentum (equilibrium force balance)
Dv
= + g,
Dt
(7.19)
or
Dvi
=
Dt
vi
v
+ vj i
t
xj
ij
+ gi
x j
(7.20)
qi
= Q
xi
(7.21)
where E is energy, qi the energy flux vector, and Q an energy source (heat production).
7.5.2
Thermodynamic relationships
(7.22)
or
qi = k
T
xi
(7.23)
(7.24)
where c p is heat capacity, and T is temperature. If all material parameters are constant
(homogeneous medium), we can then write conservation of energy as
or
DT
T
=
+ v T = 2 T + H
Dt
t
(7.25)
T
T
2 T
+ vj
=
T+H = 2 +H
t
x j
xi xi
i xi
(7.26)
k
.
c p
(7.27)
Equation of state 2: relationships for the isotropic parts of the stress/strain tensors
= f ( T, p)
(7.28)
7.6
Summary: The general system of equations for a continuum media in the gravity field.
vi
+
= 0
t
xi
!
ij
vi
vi
+ vj
=
+ gi
t
xj
x j
!
q
E
E
+ vj
+ i = Q
t
xj
xi
E = c p T
= f ( T, P)
ij = R( ij , ij )
T
qi = k
xi
(7.30)
(7.31)
(7.32)
(7.33)
(7.34)
(7.35)
(7.36)
7.6.1
0 c p
ij
+ 0 gi = 0
x j
!
T
T
T
+ vj
=
k
+ 0 Q
t
xj
xi
xi
ij
2
ij = pij + ij
ij =
(7.37)
(7.38)
(7.39)
(7.40)
(7.41)
7.6.2
(7.42)
(7.43)
(7.44)
(7.45)
(7.46)
(7.47)
(7.48)
Chapter 8
Introduction to MATLAB
Reading
Spencer and Ware (2008), secs. 1-7, 9-9.3, 12-12.4.
For reference: Matlab online help desk
8.1
Introduction
Matlab is commercial software that provides a computing environment that allows for
sophisticated ways of developing and debugging computer code, executing programs,
and visualizing the output. Matlab is also a computer language (sort of a mix between
C and Fortran) and this exercise for you to work through is mainly concerned with some
of the language aspects that we will use extensively throughout the book. Please read
through the more comprehensive and verbose Matlab Intro and familiarize yourself with
Matlab.
We will assume that your Windows, Mac, or Linux machine has Matlab installed.
After starting up the program with the graphical user interface enabled, you will be presented with a number of windows, including an interactive window (shell) where you
can type in commands as we indicate below. Please also familiarize yourself with the
other components of the development environment, such as the built-in editor for Matlab
programs, which are called m-files, so that you can be more efficient in writing and debugging codes. There are numerous Matlab-provided help resources accessible through
the environment, including video tutorials, access to the help pages, along with extensive
documentation on the web.
Also note that there is a free clone of Matlab called octave. Given that Matlab often
uses freely available computational routines underneath the hood, it was fairly easy to
reproduce the computational basics of Matlab. However, the Matlab people also added
a bunch of proprietary visualization tools which are not available in octave. Another
alternative is to use the freely available Python language and its MatPlotLib package, but
we will not have time to explore such intriguing options.
197
8.2
5 10 17
1 2
D= 4 3
5 6
The transpose (denoted with T ) is given by:
1 4 5
T
D =
2 3 6
5
b T = 10
17
Matrix-vector multiplication:
D T bT =
1 4 5
2 3 6
5
10 = 130
142
17
bb T =
5
5 10 17 10 =
17
414
Matrix-matrix multiplication:
DT D =
1 4 5
2 3 6
1 2
4 3 = 42 44
44 49
5 6
If you dont know whats going on here, and what the rules for such multiplications
are, please consult sec. 6.
USC GEOL557: Modeling Earth Systems 198
8.3
8.3.1
Exploring MATLAB
Getting started
To start the program on the Linux machines type Matlab at the UNIX prompt, or click on
the relevant Windows item. The MATLAB environment, including the command window, starts. (If you want to avoid bringing up the whole environment on Linux, use
matlab -nojvm for no-java-virtual-machine.)
1. Type 2+3. Youll get the answer. Type 2 + 3*9 + 5^2.
2. Type the following commands and note how Matlab deals with vectors
>>x=3
>>x=3;
>>x
>>y=x^2
>>x = [2, 5.6]
>>y=2 * x;
>>y=x^2;
>>y=x.^2
>>y = [3, 4]
>>x * y
>>x * y
>>x .* y
>>pi
>>a=x*pi
3. Type demo and explore some examples. Also note the introductory tutorial videos
you might want to watch later.
4. Type help. You see a list of all help functions. Type help log10 to get information
about the log10 command. Type help logTAB where logTAB means typing log and then
USC GEOL557: Modeling Earth Systems 199
8.3.2
8.3.3
8.3.4
Matlab scripting
By now you must be tired from typing all those commands all the time. Luckily there is a
Matlab script language which basically allows you to type the commands in a text editor.
Matlab scripts are text files that end with the suffix .m.
12. Use the built in editor (or another text editor e.g. Emacs) and create a file mysurf.m.
13. Type the plotting commands from the last section in the text file. A good programming convention is to start the script with clear, which clears the memory of MATLAB.
Another good programming practice is to put lots of comments inside a Matlab script. A
comment can be placed after %, e.g. % this is my first Matlab script.
14. Start the script from within MATLAB by going to the directory where the text file
is saved. Type mysurf from within MATLAB and you should see the plot pop up in a new
figure window. Alternatively, within the Matlab editor, you can press F5 to run. Also
note that there are various debugging features in the editor that are very helpful, such as
real-time syntax checking and addition of breakpoints.
8.3.5
Loops
8.3.6
Cumulative sum
8.3.7
IF command
23. Ask help if. Find maxima of the above array thickness, and compare it with the in
built function max(thickness)
8.3.8
FIND command
24. Ask help find. Find which bed has the maximum thickness:
find(thickness==max(thickness)). Is there a way to do this without invoking the find
command? find out by typing help max
25. Find the number of beds with a maximum thickness less than 0.5.
8.3.9
Matrix operations
26. Exercise: Reproduce the linear algebra exercises in the beginning of this document.
Hint: If you want to solve the system of linear equations Ac=Rhs for c, you can use the
backslash operator: c = A\Rhs
8.3.10
Functions
Matlab allows you to declare functions that return a value and use m-files to store those
functions. If you save
function xs = mysqr(x)
xs = x.^2;
as a mysqr.m in your working directory, you can then use your function just like a regular
Matlab command.
y=[2,3,4]
mysqr(y);
8.3.11
Matlab stores all regular variables as arrays of size 1 1 which are by default of type
double. To write more efficient programs, you might at times consider declaring integers as actual integers.
More importantly, Matlab affords you with the possibility to collect variables that logically belong together into a structure. This variable will hold as many sub-variable as
you want which are each addressed with a .. For example, if dealing with earthquakes,
you might want to use a structure like
quake.lon = 100.1;quake.lat = 120.1;quake.depth = 15;
The benefit of this is that you can now, for example, pass quake to functions and the
function will locally know that quake actually has the components lon, lat, and depth
which can be addressed within the subroutine.
26. Exercise: Write and test function that has two inputs, x and a polynomial. The
polynomial structure should have two entries, the order of the polynomial expansion n
and a vector a with n entries that hold the coefficients such that the function returns
n
y=
a i x n 1
i =1
(8.1)
Chapter 9
Example syllabus as USC GEOL540
2008
As an example for how the textbook can be used for a one semester course, we provide
the syllabus as Numerical Geodynamics was taught at the University of Southern California as GEOL540 in the Fall of 2008. Each week, the class met for a three hour slot
which typically consisted of some formal instruction by means of lectures and joint Matlab problem-set exercises in a computer lab. Some weeks, all class time is spent working
on problem sets. The class culminates in a three week final project part where students are
to either write their own code or combine codes used in class (for example, combine advection and diffusion solvers, and further with a Stokes solver to arrive at a self-contained
convection code).
(a) Introduction (chap. 2)
1.1 Overview of numerical methods in Earth Sciences (sec. 2.1)
1.2 Examples of applications for numerical methods in Earth Sciences (sec. 2.2)
1.3 Computer hardware, Computer Language, Principles of Programming (sec. 2.3)
1.4 Exercise: Matlab programming (sec. 8)
Notes: Introduction Handout, Math Problem set, Matlab
(b) Ordinary differential equations (sec. 3)
2.1 Definition of ODEs (sec. 3.1)
2.2 Initial value problems (sec. 3.2)
2.3 Euler method, Taylor expansions, Accuracy of numerical methods, Midpoint
method, 4th order Runge Kutta. sec. 3.3)
2.4 Exercise: Program and solve Lorentz equations (end of sec. 3.3).
Notes: ODEs Problem set, ODEs
205
Bibliography
Albarede, F. (1995), Introduction to geochemical modeling, Cambridge University Press.
Bathe, K.-J. (2007), Finite Element Procedures, Prentice-Hall, London.
Becker, T. W. (2000), Deterministic chaos in two state-variable friction sliders and the effect of elastic interactions, in GeoComplexity and the physics of earthquakes, Geophys. Monograph, vol. 120, edited by J. B. Rundle, D. L. Turcotte, and W. Klein, pp. 526, American
Geophysical Union, Washington, DC.
Becker, T. W. (2006), On the effect of temperature and strain-rate dependent viscosity on
global mantle flow, net rotation, and plate-driving forces, Geophys. J. Int., 167, 943957.
Becker, T. W., and C. Faccenna (2009), A review of the role of subduction dynamics for regional and global plate motions, in Subduction Zone Geodynamics, edited by F. Funiciello
and S. Lallemand, Int. J. Earth Sci., pp. 334, Springer.
Becker, T. W., and C. Faccenna (2011), Mantle conveyor beneath the Tethyan collisional
belt, Earth Planet. Sci. Lett., 310, 453461.
Becker, T. W., and B. Schott (2002), On boundary-element models of elastic fault interaction (abstract), Eos Trans. AGU, 83(47), NG62A0925.
BIBLIOGRAPHY
Christensen, U. R. (1985), Thermal evolution models for the Earth, J. Geophys. Res., 90,
29953007.
Clayton, R., and H. Engquist (1977), Absorbing boundary conditions for acoustic and
elastic wave equations, Bull. Seismol. Soc. Am., 67, 15291540.
Collino, F., and C. Tsogka (2001), Application of the perfectly matched absorbing layer
model to the linear elastodynamic problem in anisotropic heterogeneous media, Geophysics, 66, 294307.
Crouch, S. L., and A. M. Starfield (1983), Boundary Element Methods in Solid Mechanics. With
Applications in Rock Mechanics, Allen and Unwin, London.
Crouzeix, M., and P. A. Raviart (1973), Conforming and nonconforming finite elements
methods for solving the stationary Stokes equation, Rev. Franc. dAutomat. Informat.
Rech. Oper., 3, 3376.
Dabrowski, M., M. Krotkiewski, and D. W. Schmid (2008), MILAMIN: MATLAB-based
finite element method solver for large problems, Geochem., Geophys., Geosys., 9(Q04030),
doi:10.1029/2007GC001719.
Dahlen, F. A., and J. Tromp (1998), Theoretical Global Seismology, Princeton University
Press, Princeton, New Jersey.
Faccenna, C., D. Giardini, P. Davy, and A. Argentieri (1999), Initiation of subduction at
Atlantic type margins: Insights from laboratory experiments, J. Geophys. Res., 104, 2749
2766.
Feigenbaum, M. J. (1978), Quantitative universality for a class of nonlinear transformations, J. Stat. Phys., 19, 25.
Foley, B., and T. W. Becker (2009), Generation of plate tectonics and mantle heterogeneity from a spherical, visco-plastic convection model, Geochem., Geophys., Geosys.,
10(Q08001), doi:10.1029/2009GC002378.
Fornberg, B. (1996), A practical guide to pseudospectral methods, Cambridge University Press,
Cambridge UK.
Gerya, T. (2009), Introduction to Numerical Geodynamic Modelling, Cambridge University
Press, Cambridge UK.
Gerya, T. V., and D. Yuen (2003), Characteristics-based marker-in-cell method with conservative finite-differences schemes for modeling geological flows with strongly variable
transport properties, Phys. Earth Planet. Inter., 140, 293318.
Golub, G. H., and C. F. Van Loan (1996), Matrix computations, 3 ed., Johns Hopkins University Press.
USC GEOL557: Modeling Earth Systems 209
BIBLIOGRAPHY
Gu, J.-C., J. R. Rice, A. L. Ruina, and S. T. Tse (1984), Slip motion and stability of a single
degree of freedom elastic system with rate and state dependent friction, J. Mech. Phys.
Solids, 32, 167196.
Hager, B. H., and R. J. OConnell (1981), A simple global model of plate dynamics and
mantle convection, J. Geophys. Res., 86, 48434867.
Hughes, T. J. R. (2000), The finite element method, Dover Publications.
Ismail-Zadeh, A., and P. Tackley (2010), Computational Methods for Geodynamics, Cambridge University Press.
Jacoby, W. R., and H. Schmeling (1981), Convection experiments and driving mechanism,
Geol. Rundschau, 24, 217284.
Jaupart, C., S. Labrosse, and J.-C. Marechal (2007), Temperatures, heat and energy in the
mantle of the Earth, in Treatise on Geophysics, edited by G. Schubert and D. Bercovici,
pp. 253303, Elsevier.
King, S. D., D. A. Raefsky, and B. H. Hager (1990), ConMan: vectorizing a finite element
code for incompressible two-dimensional convection in the Earths mantle, Phys. Earth
Planet. Inter., 59, 195207.
Kitware, Inc. (2006), Paraview: Parallel Visualization Application, online at http://www.
paraview.org/, accessed 06/2006.
Korenaga, J. (2008), Urey ratio and the structure and evolution of Earths mantle, Rev.
Geophys., 46, doi:10.1029/2007RG000241.
Kwon, Y. W., and H. Bang (1996), The Finite Element Method Using Matlab, CRC Press.
Lay, T., J. Hernlund, and B. Buffett (2008), Core-mantle boundary heat flow, Nature Geosc.,
1, 2532.
Lenardic, A., and W. M. Kaula (1993), A numerical treatment of geodynamic viscous flow
problems involving the advection of material interfaces, J. Geophys. Res., 98, 82438260.
Levander, A. R. (1988), Fourth-order finite-difference P-SV seismograms, Geophysics, 53,
14251436.
Lorenz, E. N. (1963), Deterministic nonperiodic flow, J. Atmos. Sci., 20, 130.
Loyd, S. J., T. W. Becker, C. P. Conrad, C. Lithgow-Bertelloni, and F. A. Corsetti (2007),
Time-variability in Cenozoic reconstructions of mantle heat flow: plate tectonic cycles
and implications for Earths thermal evolution, Proc. Nat. Acad. Sci., 104, 14,26614,271.
Malvern, L. E. (1977), Introduction to the Mechanics of a Continuous Medium, Prentice-Hall.
USC GEOL557: Modeling Earth Systems 210
BIBLIOGRAPHY
Marone, C. (1998), Laboratory-derived friction laws and their application to seismic faulting, Annu. Rev. Earth Planet. Sci., 26, 643696.
Moresi, L. N., and V. S. Solomatov (1995), Numerical investigations of 2D convection with
extremely large viscosity variations, Phys. Fluids, 7, 21542162.
Okada, Y. (1992), Internal deformation due to shear and tensile faults in a half-space, Bull.
Seismol. Soc. Am., 82, 10181040.
Paige, C. C., and M. A. Saunders (1982), LSQR: an algorithm for sparse linear equations
and sparse least-squares, Trans. Math. Software, 8, 4371.
Press, W. H., S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery (1993), Numerical Recipes
in C: The Art of Scientific Computing, 2 ed., Cambridge University Press, Cambridge.
Ricard, Y. (2007), Physics of mantle convection, in Treatise on Geophysics, edited by G. Schubert and D. Bercovici, Elsevier.
Samuel, H., and M. Evonuk (2010), Modeling advection in geophysical flows with particle
level sets, Geochem., Geophys., Geosys., in press, doi:10.1029/2010GC003081.
MeteoSchmeling, H. (1994), Skriptum: Numerische Methoden in der Geophysik, Institut fur
rologie und Geophysik, Universiat Frankfurt am Main.
Schubert, G., D. Stevenson, and P. Cassen (1980), Whole planet cooling and the radiogenic
heat source contents of the Earth and Moon, J. Geophys. Res., 85, 25312538.
Schubert, G., D. L. Turcotte, and P. Olson (2001), Mantle Convection in the Earth and Planets,
Cambridge University Press.
Shewchuk, J. R. (1994), An introduction to the conjugate gradient method without the agonizing pain, available online at http://www.cs.cmu.edu/~quake-papers/
painless-conjugate-gradient.pdf, accessed 10/2008.
Shewchuk, J. R. (2002), Delaunay refinement algorithms for triangular mesh generation,
Comput. Geom.: Theor. Appl., 22, 2174.
Smolarkiewicz, P. K. (1983), A simple positive definite advection scheme with small implicit diffusion, Mon. Weather Rev., 111, 479486.
Spencer, R. L., and M. Ware (2008), Introduction to Matlab, Brigham Young University,
available online, accessed 07/2008.
Spiegelman, M. (2004), Myths and Methods in Modeling, Columbia University Course Lecture Notes, available online at http://www.ldeo.columbia.edu/~mspieg/mmm/course.
pdf, accessed 06/2006.
BIBLIOGRAPHY
Suckale, J., J.-C. Nave, and B. H. Hager (2010), It takes three to tango 1: Simulating
buoyancy-driven flow in the presence of large viscosity contrasts, J. Geophys. Res., in
press, doi:10.1029/2009JB006916.
Tackley, P. J., and S. D. King (2003), Testing the tracer ratio method for modeling active
compositional fields in mantle convection simulations, Geochem., Geophys., Geosys., 4,
doi:10.1029/2001GC000214.
Turcotte, D. L., and G. Schubert (2002), Geodynamics, 2 ed., Cambridge University Press,
Cambridge.
van Keken, P. E., S. King, H. Schmeling, U. Christensen, D. Neumeister, and M.-P. Doin
(1997), A comparison of methods for the modeling of thermochemical convection, J.
Geophys. Res., 102, 22,47722,495.
Weijermars, R., and H. Schmeling (1986), Scaling of Newtonian and non-Newtonian fluid
dynamics without inertia for quantitative modelling of rock flow due to gravity (including the concept of rheological similarity), Phys. Earth Planet. Inter., 43, 316330.
Zhong, S. (2008), Iterative solutions of PDE, available online at http://anquetil.
colorado.edu/szhong/TEMP/tutorial_mg.tar.gz, accessed 10/2008.
Zhong, S., M. T. Zuber, L. Moresi, and M. Gurnis (2000), Role of temperature-dependent
viscosity and surface plates in spherical shell models of mantle convection, J. Geophys.
Res., 105, 11,06311,082.
Zhong, S. J., D. A. Yuen, and L. N. Moresi (2007), Numerical methods in mantle convection, in Treatise in Geophysics, vol. 7, edited by G. Schubert and D. Bercovici, pp. 227252,
Elsevier.
Index
LU decomposition, 125
P-wave velocity, 109
S-wave velocity, 109
d - form implementation, 173
v - form implementation, 172
alternating direction implicit, 79
normal modes, 21
unconditionally stable, 65
wave equation, 21
Euler method, 42
explicit finite difference, 63
sparseness, 68
Lagrangian reference frame, 189
Newton-Rhapson iterations, 73
Picard iterations, 73
conditionally stable method, 64
explicit finite difference method, 59
plane strain approximation, 153
acoustic wave propagation, 104
adaptive mesh refinement, AMR, 146
advection, 83
Advection equations, 83
anti derivatives, 180
backward difference, 54
banded matrix, 117
bandwidth, 117
big endian, 25
bilinearity, 114
Boundary conditions, 66
boundary conditions, 20
boundary value problems, 20
bulk modulus, 156
INDEX
deviatoric stress, 163
deviatoric stress tensor invariants, 190
diagonally dominant, 127
diffusion, 83
diffusion equation, 21
dilation, 150
Direct solvers, 125
Dirichlet, 20
Dirichlet boundary conditions, 66
discretization, 115
Distributed memory, 25
divergence, 179
divergence operator (finite elements), 159
dot product, 182
dynamic viscosity, 156
eigenmodes, 64
Eigenvalues and eigen vectors, 186
Elastic rheology, 192
elements, 111
elliptic PDEs, 19
engineering strain, 152
equivalent stress, 191
essential boundary conditions, 111
Eulerian (fixed grid) system, 83
Eulerian frame, 189
INDEX
Multigrid method, 128
Multiplication of a matrix with a vector, 184
Multiplication of matrix with a scalar, 184
Multiplication of two matrices, 184
Rayleigh-Benard problem, 33
Reynolds number, 36
Rikitake dynamo, 48
Runge-Kutta, 44
Scaling analysis, 32
Schur complement, 167
second invariant, 185
Semi-Lagrangian approaches, 91
shallow water approximation, 105
Shape functions, 115
shape functions, 111
Shared memory, 25
shear modulus, 150
similarity variable, 69
Simpsons rule, 138
small endian, 25
smoothing, 129
source time function, 109
sparse, 125
sparse matrix, 117
Spectral element methods, 23
Spectral methods, 23
spring sliders, 50
stability, 105
Staggered leapfrog, 89
static condensation, 167
stiffness matrix, 116
Stokes equation, 35
Stokes system of equations, 195
Stokes velocity, 37
strain tensor, 191
stream function, 101
streamfunction, 100
Streamline upwind scheme, 88
Stress deviator, 190
Stress tensor, 189
strong form, 111
Successive Over Relaxation (SOR), 127
Octave, 26
operator splitting, 94
order of accuracy, 42
Ordinary differential equations, 19
parabolic PDEs, 19
parameterized convection, 50
Partial differential equations, 19
particle methods, 84
Peclet number, 36
penalty method, 97
penalty methods, 164
Petrov-Galerkin, 115
PETSc, 26
plane strain, 153
plane stress, 153
plane stress approximation, 153
Poissons ratio, 107, 156
Positive definite, 126
positive definite, 118
Powell and Hestenes, 167
Powell and Hestenes iterations, 161
Prandlt number, 34
principal axes, 186
Product rules, 181
prolongation, 130
propogation of SH waves, 105
Python, 26
Rayleigh number, 34
INDEX
Time-dependent FE methods, 170
time-dependent heat equation, 21
total derivative, 189
Trace, 185
tracer, 84
Trapezoidal rule, 138
trial solutions, 113
tridiagonal, 68
tsunami waves, 105
Two-point Boundary Value Problem, 44
van Mises stress, 191
vectors, 182
visco-elastic rheology, 192
Viscous equivalence, 153
Voigt notation, 150
von Neumann stability, 64
weak form, 114
weak integral form, 111
weighted residual method, 115
Youngs modulus, 150