You are on page 1of 214

Class Notes

MA461/561 Spring 2015


PDE Modeling
Ian Knowles
Department of Mathematics
University of Alabama at Birmingham
Birmingham AL 35294
December 28, 2014

ii
c December 28, 2014 Ian W. Knowles

Contents
Preface

vii

1 Mathematical Models
1.1 What is a Mathematical Model? . . . . . . . . . . . . .
1.2 SI Units . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Some PDE Models . . . . . . . . . . . . . . . . . . . .
1.3.1 Heat Flow . . . . . . . . . . . . . . . . . . . . .
1.3.2 Steady State Temperature Distributions . . . .
1.3.3 Diffusion . . . . . . . . . . . . . . . . . . . . . .
1.3.4 Groundwater Flow . . . . . . . . . . . . . . . .
1.3.5 Guitar/Violin Strings: Waves . . . . . . . . . .
1.3.6 Spectral Theory . . . . . . . . . . . . . . . . . .
1.3.7 Vibrating Membranes: The 2-D Wave Equation

.
.
.
.
.
.
.
.
.
.

1
1
3
4
4
10
11
13
16
19
23

.
.
.
.
.
.
.
.
.
.
.

31
31
35
39
45
48
48
50
52
53
56
57

2 Partial Differential Equations


2.1 Introduction . . . . . . . . . . . . . . . . .
2.2 Finite Difference Methods . . . . . . . . .
2.2.1 Elliptic Equations . . . . . . . . . .
2.2.2 Parabolic Equations . . . . . . . .
2.2.3 Hyperbolic Equations . . . . . . . .
2.3 Finite Element Methods . . . . . . . . . .
2.3.1 Gauss Divergence Theorem in 2D .
2.3.2 Gauss Divergence Theorem in 3D .
2.3.3 Elliptic Equations and the FEM . .
2.3.4 Parabolic Equations and the FEM
2.3.5 Hyperbolic Equations and the FEM
iii

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

iv

CONTENTS

3 MATLAB and COMSOL


3.1 MATLAB . . . . . . . . . . . . . . . . . . . . .
3.1.1 Keeping a Session Record . . . . . . . .
3.1.2 Keyboard Shortcuts . . . . . . . . . . .
3.1.3 MATLAB as a Calculator . . . . . . . .
3.1.4 Standard Functions . . . . . . . . . . . .
3.1.5 Vectors in MATLAB . . . . . . . . . . .
3.1.6 Products, Division and Powers of Vectors
3.1.7 Plotting Elementary Functions . . . . . .
3.1.8 Matrices . . . . . . . . . . . . . . . . . .
3.1.9 Special Matrices . . . . . . . . . . . . . .
3.1.10 Solving Systems of Linear Equations . .
3.1.11 Loops . . . . . . . . . . . . . . . . . . .
3.1.12 m-files . . . . . . . . . . . . . . . . . . .
3.1.13 m-functions . . . . . . . . . . . . . . . .
3.1.14 Reading and Writing Data Files . . . . .
3.2 MATLAB PDE Toolbox . . . . . . . . . . . . .
3.3 COMSOL . . . . . . . . . . . . . . . . . . . . .
4 Continuum Mechanics
4.1 Equations of Motion . . . . . . . . . . . . .
4.2 Linear Elasticity . . . . . . . . . . . . . . .
4.2.1 The Displacement Field . . . . . . .
4.2.2 The Strain Tensor . . . . . . . . . . .
4.2.3 Principal Strains . . . . . . . . . . .
4.2.4 Plane Strain . . . . . . . . . . . . . .
4.2.5 Stress-Strain Relations . . . . . . . .
4.2.6 The Elasticity Equations . . . . . . .
4.3 Fluid Mechanics . . . . . . . . . . . . . . . .
4.3.1 The Stress-Strain Relation . . . . . .
4.3.2 Application to Hull Design . . . . . .
4.3.3 The Navier-Stokes Equations . . . .
4.3.4 Incompressible Fluids . . . . . . . . .
4.3.5 Compressible Fluids . . . . . . . . .
4.3.6 The Reynolds Number and Boundary

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
. . . .
Layers

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

59
59
60
61
61
61
61
63
64
65
66
67
67
68
68
69
71
75

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

77
78
81
82
84
86
87
87
93
96
97
99
101
104
111
113

CONTENTS
5 Classical Electrodynamics
5.1 Electrostatics . . . . . . . . . . . . .
5.1.1 The Electric Field E . . . . .
5.1.2 The Gauss Law . . . . . . . .
5.1.3 Macroscopic Media . . . . . .
5.1.4 Electric Current . . . . . . . .
5.2 Magnetostatics and Faradays Law .
5.2.1 The Biot-Savart-Amp`ere Laws
5.2.2 Macroscopic Magnetostatics .
5.2.3 Stokes Theorem . . . . . . . .
5.2.4 Faraday Law of Induction . .
5.3 The Maxwell Equations . . . . . . .
5.3.1 Vector and Scalar Potentials .
6 Finance
6.1 Random Variables . . . . . . . . . . .
6.1.1 Normal Distribution . . . . .
6.2 Brownian Motion and Diffusion . . .
6.2.1 A Special Diffusion Property .
6.3 Stochastic Processes . . . . . . . . .
6.4 The Ito Integral . . . . . . . . . . . .
6.4.1 Properties of the Ito Integral .
6.4.2 The Ito Formula . . . . . . .
6.5 Asset Prices . . . . . . . . . . . . . .
6.5.1 The Asset Price Model . . . .
6.6 Options and the Black-Scholes PDE .
6.6.1 The European Call Option . .
6.6.2 The Black-Scholes PDE . . .
6.6.3 The Greeks . . . . . . . . . .
6.6.4 Implied Volatility . . . . . . .
6.7 Local Volatility and the Dupire PDE
6.8 Bonds . . . . . . . . . . . . . . . . .
6.8.1 Calculating v with r Known .
6.8.2 Bond Futures . . . . . . . . .
6.8.3 Stochastic Interest Rates . . .
6.8.4 The Bond Pricing Equation .
6.8.5 Bond Options . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

115
. 116
. 117
. 119
. 121
. 123
. 123
. 124
. 129
. 130
. 130
. 132
. 134

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

137
. 137
. 140
. 141
. 144
. 145
. 146
. 149
. 150
. 151
. 153
. 154
. 154
. 155
. 161
. 162
. 164
. 167
. 167
. 169
. 170
. 170
. 171

vi
7 Modeling Projects
7.1 The Planting Box . . . . . . . . . .
7.2 The Mridangam . . . . . . . . . . .
7.3 The Nutwrecker2000 . . . . . . . .
7.4 The Frozen CIDS Problem . . . . .
7.5 Cooling a Computer Chip . . . . .
7.6 Groundwater Modelling . . . . . .
7.7 The Fuel Spill . . . . . . . . . . . .
7.8 The Soap Bubble Problem . . . . .
7.9 Blood Flow . . . . . . . . . . . . .
7.10 The Skin Effect in a Circular Wire
7.11 Hurricanes and Soap Bubbles . . .
7.12 A Rectangular Waveguide . . . . .

CONTENTS

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

173
. 173
. 175
. 176
. 178
. 183
. 185
. 187
. 187
. 189
. 192
. 195
. 197

A Typesetting with TEX


201
A.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Preface
This course is intended to provide an introduction to the mathematical and
computational skills required to build computer models of practical importance. MA227 (Calculus III) is a prerequisite; the courses MA360/560 (Scientific Programming) and MA455/555 (Partial Differential Equations) are
encouraged but not required.
While mathematical models of many different types are worthy of consideration (discrete, ordinary differential equation models from MA252, and
statistical models as considered in MA486/586, come immediately to mind),
we concentrate here exclusively on those involving a partial differential equation (PDE). In particular, we consider a variety of practical examples in
which we follow the trail of
problem formulation, including statement of relevant physical laws and
discussion of relevant material properties,
derivation of the applicable PDE,
solution of the PDE, and
display and processing of solution data.
The initial examples that we consider are the classical favourites: parabolic
equations like the heat equation, the diffusion equation, and the groundwater
flow equation; elliptic equations as exemplified by the steady state heat problem with sources, and hyperbolic equations in the form of the classical wave
equation and the acoustic wave equation. These equations are solved using
the finite element routines in the MATLAB PDE Toolbox and COMSOL.
In chapter 2 we discuss the various classifications of partial differential equations and look at the finite difference solution method for elliptic
equations and, briefly, the finite element solution method that is used by
vii

viii

PREFACE

both MATLAB and COMSOL. The method of finite differences is covered in


greater detail in the course MA465/565 Numerical PDE: Finite Difference
Methods. Chapter 3 provides an introduction to software packages MATLAB
(including the PDE Toolbox) and COMSOL.
In chapter 4 we provide a introduction to the theory of continuum mechanics, which includes parts of the theory of linear elastic solids as well
as a brief sortie into fluid mechanics to derive the Euler and Navier-Stokes
equations that are central to the modelling of fluid flow; the latter topic is
covered more fully in the course MA467/567 Gas Dynamics. In chapter 5 we
consider the Maxwell equations and electromagnetic waves and in chapter 6
we look at the mathematics behind financial derivatives.
Finally, in chapter 7 are given outlines of possible class projects.

Chapter 1
Mathematical Models
1.1

What is a Mathematical Model?

The tenets of the Scientific Method, as espoused by Galileo for example,


hold that one should formulate scientific theories and then test them with
measurement based experiments. A fundamental underpinning to all of this is the
recognition that natural phenomena can be
represented by mathematical equations. A
prime, and simple, example of such an equation is Galileos formula
1
s = gt2
2
governing the distance s travelled by a
falling body in time t. This is also a nice
example of a mathematical model. In common with most mathematical models of natGalileo Galilei 1564-1642
ural phenomena, it comes with underlying
assumptions: here for example, the effects
of air resistance are taken to be negligible.
On an even more fundamental level, Isaac Newton discovered that natural
physical laws, such as his second law of motion for a particle
F = ma,
1

CHAPTER 1. MATHEMATICAL MODELS

lead to differential equations:


mx00 (t) = F.
By solving these differential equations Newton was able, amongst other
things, to precisely model the solar system, confirming and providing a mathematical underpinning for earlier theories of Nicolaus Copernicus and Johannes Kepler that rested upon astronomical data gathered by Tycho Brahe.
Since that time differential equations have become omnipresent in the
world of mathematical modeling. Such models are of central importance in,
for example,
predicting future events (hurricane/typhoon impact zones, such as that
of Katrina in 2005 and Haiyan in 2013 and other weather related traumas, asteroid collisions, and tsunamis, such as the one that destroyed
Natori City in Japan in 2011, earthquakes);

design (very big airplanes, very fast yachts, for example the New Zealand
AC72 class catamaran which is the favorite for the 2013 Americas Cup
trials in San Francisco);

testing theories (high energy physics, epidemiology).

1.2. SI UNITS

In the pages below we gather and discuss in detail some of the classical examples of mathematical models that appear in the form of partial differential
equations or PDEs. But first, a short digression is needed to discuss systems
of units.

1.2

SI Units

SI units (otherwise known as Syst`eme Internationale dunites) are now the


internationally accepted system of units for the measurement of physical
quantities. In this system the unit of length is the meter (m), the unit of
mass is the kilogram (kg), the unit of time is the second (s), the unit of
electric current is the ampere (A), thermodynamic temperature is measured
in kelvins (K), the unit of amount of material is the mole (mol), and the unit
of luminous intensity is the candela (cd).
From these seven base units many derived units appear:
Frequency: hertz, Hz=s1 ;
Force: newton, N=m kg s2 ;
Pressure: pascal, Pa=N/m2 =kg m1 s2 ;
Energy, work, quantity of heat: joule, J=N m;
Power: watt, W=J/s=m2 kg s3 , 1 horsepower 750 watts;
Quantity of electricity, electric charge: coulomb, C=s A;
Capacitance: farad, F=s4 A2 m2 kg1 ;
Electric potential: volt, V=W/A;
Electric resistance: ohm, =V/A;
Electrical conductivity: siemens, S=A/V=kg1 m2 s3 A2 .
Magnetic flux: weber, Wb=V s;
Magnetic flux density: tesla, T=Wb m2 ;
Inductance: henry, H=Wb/A.
We use this system exclusively throughout these notes.

1.3
1.3.1

CHAPTER 1. MATHEMATICAL MODELS

Some PDE Models


Heat Flow

Consider the following problem. A thin metal plate, initially at 0 C (273.15


K) everywhere, is heated with a Bunsen burner at the point (a, b) while the
edge of the plate is kept at 0 C in an ice bath. Our task is to determine the

Figure 1.1: Heating a thin metal plate

temperature u(x, y, t) at any point (x, y) in the plate, at any later time t.
To do this we must first investigate the relationship between how much
heat energy (joules) it takes to cause a given temperature change in a particular body. The reason for this is that we are interested in the temperature
u, but heat energy is the quantity that actually flows around the plate. The
required connection is given by
Q = c.m.T

(1.1)

where Q is the amount of heat (joules) added, c is the specific heat of the
material (J kg1 K1 ), m is the mass of the body (kg), and T is the temperature change (K). Here, the specific heat of a body is the amount of heat
energy needed to raise unit mass of the material one degree of temperature.
So a lower specific heat means that, for a given mass of material, less heat is

1.3. SOME PDE MODELS

required to cause a given temperature change. A table of specific heat values


for some common materials is given below:
Material
water at 25 C
steel
glass
copper
cucumber

Specific Heat (J kg1 K1 )


4181
466
840
385
4060

So, you can see that NASA made a big mistake in not making the Space
Shuttle heat shield out of cucumber!

Figure 1.2: Joseph Fourier


Next, we need the physical law that describes the movement of heat in a
body. This may be stated as the Fourier1
Heat Flux Law:
The heat flux is proportional to the temperature gradient.
Here, if we restrict attention for the moment to heat flowing in the xdirection, the heat flux2 , Fx , is the amount of heat moving through unit
1

Joseph Fourier 1768-1830, French mathematician and physicist; he came up with the
idea of expanding arbitrary functions in a series of sines and cosines, today known as a
Fourier series in his honor
2
from the Latin word fluxus meaning flow

CHAPTER 1. MATHEMATICAL MODELS

area of a plane perpendicular to the x-axis in unit time; the SI units are
J m2 s1 . If u is the temperature then the temperature gradient in the x
direction is u/x. So the above law may be written
Fx = x

u
x

(1.2)

where the positive constant of proportionality x is called the thermal conductivity of the body; its SI units are J m1 K1 s1 . The minus sign indicates
that the heat energy moves oppositely to the temperature gradient, i.e. heat
moves from hot areas to cold areas. This law has been obtained experimentally, and is valid often, but not always. Some typical thermal conductivities
appear in the table below:
Material
Thermal Conductivity (W m1 K1 )
water at 20 C
0.56
steel
50.2
copper
401
glass
0.8
air
0.024
wood
0.04-0.12
The Heat Equation
To derive the PDE satisfied by the temperature function u we consider a
small box surrounding a point P (x, y, z) as shown in Figure 1.3. Given that
ABCD and ABCD are the faces perpendicular to the x-axis, the rate at
which heat enters through the face ABCD is
4dy dz (Fx

Fx
dx),
x

where Fx /x.dx is the change in Fx back to the face ABCD, and the rate
at which heat exits through the face ABCD is
4dy dz (Fx +

Fx
dx),
x

So, the net rate at which heat enters the box through these two faces is
8dx dy dz

Fx
.
x

1.3. SOME PDE MODELS

Figure 1.3: Local heat flow in a box

In similar fashion the net rate at which heat enters the box through the faces
perpendicular to the y- and z-axes are, respectively,
8dx dy dz

Fz
Fy
and 8dx dy dz
.
y
z

In addition, heat can enter the box by way of internal sources, such as the
Bunsen burner in our case. For the moment we let all such internal sources
be represented by the function S(x, y, t) with units of J m3 s1 (heat source
per unit volume per unit time). So the total rate at which the heat energy
increases in the box is
Fx Fy Fz
8dxdydz (
+
+
) + 8dxdydz S(x, y, z, t).
(1.3)
x
y
z
Let (x, y, z) denote the density (mass per unit volume) of the material (the
metal in our case). From (1.1) the rate at which the amount of heat energy
increases in the box is
Q
u
= c.m.
t
t
where m is the mass of material in the box; as m = 8 dxdydz the rate at
which heat increases in the box is
u
8c dxdydz
,
t

CHAPTER 1. MATHEMATICAL MODELS

which we can equate to (1.3), and then divide by 8dxdydz to obtain


c

u
Fx Fy Fz
+(
+
+
) = S(x, y, z, t).
t
x
y
z

Finally, if we use (1.2) and assume the isotropic3 case in which we have
x = y = z = (which may still be a function of x, y, z) we obtain the
heat equation:
c

u
u
u
u
( ( ) +
( ) + ( )) = S(x, y, z, t)
t
x x
y y
z z

(1.4)

This is the equation you would use for three-dimensional heat flow. It is of
parabolic type (see Chapter 2). In our case we can reasonably assume that for
a thin plate the temperature u does not vary appreciably in the z direction,
so u/z = 0, and the functions and S do not depend on z as well. This
leads us to the two-dimensional heat equation for our metal plate:
c

u
u
u
( ( ) +
( )) = S(x, y, t).
t
x x
y y

(1.5)

One could represent the effect of the Bunsen burner with the source function

1 (x, y) in B
S(x, y, t) =
0 (x, y) not in B
where B is a small ball with center (a, b).
If the metal in the plate is uniform we can assume that the coefficients c,
, and K are constants. The equation may then be written
S(x, y, t)
u
ku =
t
c

(1.6)

where k = /c is called the thermal diffusivity with units of m2 s1 , and


u =

2u 2u
+
x2 y 2

is the two-dimensional Laplace operator.


3

i.e. material properties are independent of direction

1.3. SOME PDE MODELS

Initial and Boundary Conditions


The parabolic equations above do not by themselves uniquely specify a solution, as we now make clear from our physical example. More precisely, in
the metal plate problem described above, we are assuming that
u(x, y, t) = 0
for all points (x, y) on the boundary of the metal plate for all time t. This
is called a boundary condition. It seems reasonable that if the values on the
boundary were different, we would end up with a different solution u.
In general, a condition of the form
u(x, y, t) = g(x, y)

(1.7)

for (x, y) in the boundary and all time t, and a given g, is called a Dirichlet4
boundary condition. A condition of the form
u n + au = g
is called a generalized Neumann5 (or Robin) condition. Here, n = (n1 , n2 )T is

Figure 1.4: Dirichlet and Neumann

a unit length column vector outwardly normal (perpendicular) to the bound4


5

German mathematician Gustav Lejeune Dirichlet 1805-1859


German mathematician Carl Neumann 1832-1925

10

CHAPTER 1. MATHEMATICAL MODELS

ary, and

u
x

u =
u
y
is the gradient of u, and the outward normal derivative (this is just the
directional derivative from Calculus III) is
u
u
u
= u n = n1
+ n2 ;
n
x
y
from (1.2) u n represents the outward heat flux in a direction normal
to the boundary. A variant of this boundary condition takes the form
u n = h.(Te u).
This represents the physical situation in which the heat flux is proportional
to the difference between the fixed temperature, Te , of the exterior and the
current temperature, u, of the heated body; h is called a heat transmission
coefficient.
We also know that at time t = 0
u(x, y, 0) = 0

(1.8)

at all points (x, y) in the plate. This is called an initial condition. Again,
the use of different values here would also lead to a different u. It is a
mathematical fact that the two additional conditions (1.7) and (1.8) are
enough to guarantee unique solutions for these parabolic equations.

1.3.2

Steady State Temperature Distributions

If the heat source function S and the boundary conditions do not depend
on time, i.e. S = S(x, y) in 2-D, then it is reasonable to expect that, after
a sufficiently long time, the temperature at each point (x, y) in our plate
should settle down to some steady value. Mathematically, we expect that
lim u(x, y, t) = U (x, y)

where the function U represents the so-called steady state temperature distribution. We can obtain the partial differential equation representing the

1.3. SOME PDE MODELS

11

steady state distribution U by allowing t to approach infinity in (1.5), and


assuming that
u
lim
= 0.
t t
This gives

U
U
(
)
(
) = S(x, y),
x x
y y

(1.9)

an example of an elliptic equation (see Chapter 2). Such equations also occur
in gravitational potential theory, and in electrostatics and magnetostatics, to
name but a few application areas.
Unique solutions are ensured by applying either Dirichlet or Neumann
boundary conditions in the manner discussed above for parabolic equations.
Notice that as time has in effect disappeared here, initial conditions are no
longer needed.

1.3.3

Diffusion

Diffusion is the process by which matter is transported from one part of a


system to another as a result of random molecular motions. It is an important
and fundamental physical effect. In groundwater
modeling, for example, one is often interested in
quantifying the movement of contaminants, and it
is generally assumed that such movement is driven
in part6 by molecular diffusion of the contaminant
species.
Molecular diffusion can be illustrated by the
classical experiment in which a tall cylindrical glass
vessel has its lower part filled with an iodine solution, and a column of clear water is poured on
top, carefully and slowly, so that no convection currents are started. At first the lower colored part is
separated from the upper clear portion by a sharp,
well-defined boundary. Later it is found that the up- Figure 1.5: Adolf Fick
per part becomes colored, the color getting fainter
towards the top, while the lower part becomes cor6

the other mechanism is that of advective dispersion

12

CHAPTER 1. MATHEMATICAL MODELS

respondingly less intensely colored. After a sufficiently long time the iodine
molecules move so as to become uniformly distributed throughout the vessel.
The transfer of heat by conduction is also due to random molecular motions and there is an obvious analogy between the two processes, as was
recognized by Fick7 who, around 1855, adapted the ideas Fourier used in
deriving the equation of heat conduction given above. The relevant physical
law in this case is the
Fick Law of Diffusion:
Diffusive flux is proportional to the concentration gradient.
Here, if we restrict attention for the moment to diffusion in the x-direction,
the diffusive flux, Fx , is the amount of diffusing substance moving through
unit area of a plane perpendicular to the x-axis in unit time; the SI units are
mol m2 s1 . If C is the concentration then the concentration gradient in the
x direction is C/x. So the above law may be written
Fx = Dx

C
x

(1.10)

where the positive constant of proportionality Dx is called the diffusion coefficient of the diffusive material; its SI units are m2 s1 . The minus sign
indicates that the diffusive material moves oppositely to the concentration
gradient. This law has been obtained experimentally, and is valid often, but
not always. Some diffusion coefficients appear in the table below:
Material
Diffusion Coefficient in Water (m2 s1 )

Iodine I2 (20 C)
1.0 109
Oxygen O2
1.97 109
Benzene
1.10 109
Ethylene Dichloride
9.90 1010
Using an analogous, but simpler (no temperature here) argument to that
used in the heat flow problem, we can see that the partial differential equation
for diffusion in 2-D is
C

C
=
(D
)+
(D
)
t
x
x
y
y
7

Adolf Eugen Fick 1829-1901, a German-born physician and physiologist

(1.11)

1.3. SOME PDE MODELS

13

where D = D(x, y) is the diffusion coefficient. In 3-D the equation is


C

C
=
(D
)+
(D
) + (D
)
t
x
x
y
y
z
z

(1.12)

with D = D(x, y, z).


In vector notation both of these equations may be written as
C
= (DC).
t

1.3.4

(1.13)

Groundwater Flow

Much of the potable8 water on the planet lies underground in large and small
geologic formations called aquifers. A common situation of interest occurs
when the groundwater is trapped in a porous medium between two (more
or less) horizontal impervious layers; such a groundwater system is called
a two-dimensional confined aquifer, as is illustrated in Figure 1.6 below.

Figure 1.6: Confined 2-D Aquifer

Sources of water for an aquifer include rainfall, and subsequent seepage under
the influence of gravity, and underground streams. These sources cause the
8

this basically means drinkable

14

CHAPTER 1. MATHEMATICAL MODELS

Figure 1.7: Confined 2-D Aquifer Flow

water to move through the aquifer under pressure. In a well penetrating the
aquifer, the water level will rise to a height in the well, called the piezometric
head, that depends on the pressure of the groundwater in the aquifer at that
point. Analogous to heat flow and diffusion we have
The Experimental Law of Darcy
The discharge per unit width of aquifer is proportional to the
hydraulic gradient.
Here the discharge in say the x-direction, qx , is the volume of water per unit
time crossing unit area of the aquifer normal to the x-direction. If we denote
the piezometric head by , then Darcys Law becomes

qx = Tx
(1.14)
x
where the constant of proportionality, Tx , is called the transmissivity; it
represents the ease with which the water passes through the aquifer region.
Storativity
As the pressure increases in an aquifer, the porous medium tends to expand
somewhat and absorb additional water; conversely, as the pressure decreases,

1.3. SOME PDE MODELS

15

water is expelled from the porous medium matrix. This absorptive/elastic


property of the aquifer material is called the storativity which is defined more
precisely to be the volume of water released from (or added to) storage in
the aquifer per unit horizontal area of the aquifer per unit change in the
(vertically averaged) piezometric head. Thus, if a volume of water w is
released from (or added to) storage in an area A due to a change in
the head, the storativity S is
S=

w
.
A

(1.15)

The Groundwater Flow Equation


Consider the box in (b) of Figure 1.6. As we are assuming that the aquifer
is 2-D, we only study flow in the horizontal xy-plane. In a time dt the net
volume of water entering the box is
dx
dx
, y) qx (x + , y)] +
2
2
dy
dy
b dx[qy (x, y ) qy (x, y + )]} + F (x, y, t).b.dxdydt
2
2
= bS dx dy [(x, y, t + dt) (x, y, t)],
dt{b dy[qx (x

where b is the aquifer thickness and F (x, y, t) (with units of volume per unit
time) represents external recharge (averaged over z) into the system from
various subsurface sources, as well as above ground sources such as rainfall.
If we divide by the product dx dy dt and let each factor tend to zero, we
obtain

b.F b. (qx ) b. (qy ) = bS ,


x
y
t
so that from (1.14)
S

=
(Tx ) +
(Ty ) + F.
t
x
x
y
y

(1.16)

A common assumption (often unjustified, but made anyway) is that the water
always flows in the direction of the pressure gradient; the porous medium
is then called isotropic and Tx = Ty = T (x, y), so that the flow equation
becomes

S
=
(T ) +
(T ) + F.
(1.17)
t
x x
y y

16

CHAPTER 1. MATHEMATICAL MODELS

More generally, for an anisotropic aquifer the generalized Darcy Law holds:
q = T

(1.18)

Here q is the specific flux vector, is the pressure gradient vector, and


T11 T12
T=
.
T12 T22
is the transmissivity matrix. The groundwater flow equation then takes the
form

S
= (T) + F.
t

1.3.5

Guitar/Violin Strings: Waves

When a guitar or violin string is plucked the subsequent rather complicated


oscillatory motion of the string is typically restricted to a single plane containing the fixed string end-points. It is an example of a one dimensional
wave motion.

Figure 1.8: The Stones: Wyman, Jones, Watts, Jagger, Richards circa 1963

Assume that a string at rest is fastened at the points x = 0 and x = L


on the x-axis as shown in Figure 1.9 and then undergoes movement in the

1.3. SOME PDE MODELS

17

y direction in an xy-plane so that the displacement of the part of the string


located at (x, 0) when the string is at rest, is given by y = u(x, t) at a
subsequent time t. Our task here is to determine the partial differential

Figure 1.9: Vibrating string

equation satisfied by the function u.


A number of additional assumptions are to be observed. First, we neglect
the damping effects of air resistance and the weight of the string. We also
assume that the string is so flexible that it takes no effort to bend it; so the
tension forces in the string always act tangentially. Finally we assume that
the motion of the string always involves only small displacements and that
the linear density (mass per unit length) is (x).
Consider now a small part of the string, that between x and x + dx at
time t, as shown in the right hand part of Figure 1.9. At the x end of the
string segment, i.e. the point (x, u(x, t)), there is a tension TR (x, t) pulling
to the right that is balanced9 by the tension force TL (x, t) pulling to the left;
the tension shown is really TL (x, t). Similarly the tension force shown at
the other end, i.e. at the point (x + dx, u(x + dx, t)), is really TR (x + dx, t).
Let T (x, t) = |T(x, t)|. Then the magnitude of the vertical component of
TL (x, t) is v(x, t) = T (x, t) sin and the magnitude of the vertical component
9

assuming that the string does not break!

18

CHAPTER 1. MATHEMATICAL MODELS

of TR (x + dx, t) is v(x + dx, t) = T (x + dx, t) sin( + d). The net vertical


force on the string segment is
v(x + dx, t) v(x, t).
If we assume that the length of the segment is dx (here the small displacement assumption enters) then the mass of the segment is .dx. By Newtons
second law, the net vertical force on the segment equals the mass times the
acceleration of the center of mass of the segment. Thus
v(x + dx, t) v(x, t) = dx

2u
(
x, t)
t2

where x x x + dx. Then


2u
v(x + dx, t) v(x, t)
= 2 (
x, t).
dx
t
If we let dx 0 we arrive at
2u
v
= 2 (x, t).
x
t

(1.19)

Now if h(x, t) denotes the magnitude of the horizontal component of TL (x, t),
then h(x, t) = T (x, t) cos . As we assume that there is no net horizontal motion of the segment, it follows that h(x, t) = h(x + dx, t), and thus h is
independent of x. In fact, as we are assuming only small string displacements, cos 1 and h(x, t) T (x, t), where, again because of the small
displacements, the tension in the string T (x, t) T , a constant. So to a
reasonable approximation we have
v(x, t) = h(x, t) tan = T

u
.
x

Thus from (1.19) we have the 1-D wave equation:


2
2u
2 u
=
a
t2
x2

(1.20)

where a2 = T /. This is an example of a hyperbolic PDE (see MA455/555).


If we allow for an external force of magnitude F units per unit length
acting parallel to the y-axis then a similar derivation leads to the equation
2
2u
F
2 u
=
a
+
t2
x2

1.3. SOME PDE MODELS

19

Initial and Boundary Conditions


The boundary conditions to be applied at the boundary of the space region
are as discussed in the section on the parabolic heat equation. Because
the equation has two time derivatives, two initial conditions are required to
uniquely determine the solution u(x, t). On physical grounds, one needs to
know the initial shape of the string:
u(x, 0) = f (x)

0 x L;

one also needs the initial velocity of the string:


ut (x, 0) = g(x)

0 x L.

It is a mathematical fact that these two conditions, together with the wave
equation and suitable boundary conditions uniquely determine the solution
u.

1.3.6

Spectral Theory

Matrices and Eigenvalues


Let A be an n n matrix and consider solving, for a given scalar , the linear
system
Ax = x,

20

CHAPTER 1. MATHEMATICAL MODELS

with the aim of finding a solution vector x that is not the zero vector. One
learns in Linear Algebra that the values for which this can be done are
quite exceptional. There are at most n such and we call them eigenvalues
of A; the corresponding solutions x are the associated eigenvectors. If we
write the linear system as
(A I)x = 0,
where I denotes the n n identity matrix, from a theorem in Linear Algebra,
if the determinant |A I| =
6 0 we know that the (unique) solution x must
be the zero vector; so
|A I| = 0
is an equation for the eigenvalues of A. One can see that this is a polynomial
equation in of degree n, and so it follows from the Gauss theorem that a
matrix of order n has n eigenvalues, counted according to multiplicity, so
repeated roots are counted separately.
If we regard the matrix A as a linear operator on Rn that takes the vector
x to the vector Ax, then the set of eigenvalues is called the spectrum of this
linear operator. The word spectrum comes originally from physical optics
wherein visible light was separated into a color spectrum by a prism (or, in
the case of the rainbow above, by small droplets of water). We connect these
ideas below.
Eigenvalues and Vibration Modes
Consider a guitar string stretched between x = 0 and x = 1. As we saw
earlier, if the string is plucked and we denote the displacement at time t of
the part of the string located at x by u(x, t), then the function u satisfies
(assuming appropriate units are chosen for the string density and tension)
the wave equation
utt = uxx .
We now look for musical (see below) solutions of the form
u(x, t) = U (x).eit .
Our wave equation above now becomes
Uxx = (i)2 U (x) = 2 U (x) = U (x),

(1.21)

1.3. SOME PDE MODELS

21

if we set = 2 . As we assume the ends of our guitar string are permanently


fixed, we can also assume that U (0) = U (1) = 0. It follows from (1.21) that
U (x) = A cos(x) + B sin(x),
for some constants A and B. Inserting the condition U (0) = 0 forces A = 0;
from U (1) = 0 we then see that B sin() = 0, so, in order to obtain nontrivial solutions (B 6= 0) we must have = n, i.e.
= n2 2 ,

n = 0, 1, 2, . . .

These are the eigenvalues (in this case, of the differential operator A that
takes a function U to minus its second derivative) and for each n the corresponding eigenfunction is
Un (x) = sin(nx).
It is instructive to look at the first three eigenfunctions, using n = 1, 2, 3,
listed in order below. The first eigenfunction motion can be seen by plucking
the string exactly at its midpoint. If you touch (i.e. dampen) a moving string
exactly at the midpoint, you will see a vibration like the second eigenfunction.
If you repeat this by touching the string exactly at the one-third point, you
will see the third eigenfunction in the resulting vibration.
Figure 1.10: The first three eigenfunctions

(a) n = 1

(b) n = 2

(c) n = 3

Solving the Wave Equation


The eigenfunctions found above can be used to predict the future motion of
the guitar string, given an initial shape and velocity. One accomplishes this

22

CHAPTER 1. MATHEMATICAL MODELS

by solving the above wave equation with initial conditions


u(x, 0) = f (x),
ut (x, 0) = g(x).
We look for the solution u(x, t) in the form
u(x, t) =

int

Cn Un (x)e

n=1

Cn sin(nx)eint .

n=1

Notice that we automatically satisfy the boundary conditions


u(0, t) = u(1, t) = 0
for all time. The complex numbers Cn can be found using a Fourier series technique (see MA455/555). As the eventual motion of the string is
completely determined by the eigenfunctions Un we naturally call these the
fundamental vibration modes. The eigenvalues n = n2 2 are related to
frequencies as follows. The angular frequency n = n is related to the
period n of the sine function by
n =

2
2
2
= .
=
n
n
n

Now, as one cycle takes n seconds, one second corresponds to 1/n cycles,
so that the frequency fn = 1/n . So the frequencies fn are
fn =

n
,
2

n = 1, 2, 3, . . .

These frequencies correspond to pure notes.


The Color Spectrum
In the same way, a prism breaks natural light into its constituent pure colors.
Light is basically an energy wave motion. Each fundamental color represents
a simple wave motion with a fixed frequency.

1.3. SOME PDE MODELS

1.3.7

23

Vibrating Membranes: The 2-D Wave Equation

In similar fashion, if one considers the vibrations of a drum, or more generally,


any vibrating elastic membrane, we end up with the wave equation on a 2-D
region :
2
2u
2u
2 u
= a ( 2 + 2 ) = a2 u,
(1.22)
2
t
x
y
where a2 = T / and now is the mass per unit area of the drum membrane
and T is again the constant magnitude of tension. The initial and boundary
conditions for the 2-D wave equation are specified in an analogous manner
to the above in that Dirichlet or Neumann conditions are applied at the
boundary of the membrane region, and the initial shape and velocity must
also be specified:
u(x, y, t0 ) = u0 (x, y),

ut (x, y, 0) = v0 (x, y),

(x, y) in .

A Wave Animation
We use the MATLAB PDE Toolbox to produce an animation of a membrane
wave. Specifically, consider the equation
2u
u = 0
t2
on the square region with opposite corners at (1, 1) and (1, 1). The
membrane is assumed to be fixed on the left and right sides and free on the
upper and lower sides:
u(1, y) = u(1, y) = 0
u
u
(x, 1) =
(x, 1) = 0.
y
y
We assume initial conditions of the form

u(x, y, 0) = tan1 (cos( x))


2
sin( 2 y)
ut (x, y, 0) = 3 sin(x)e
Draw the region and set the boundary conditions in the MATLAB PDE
Toolbox. Initialize the mesh. Open the PDE Specification dialog box

24

CHAPTER 1. MATHEMATICAL MODELS

(a) u(x, y, 0)

(b) ut (x, y, 0)

with the menu choice PDEPDE Specification and select the hyperbolic type and set the PDE coefficients c = 1, a = 0, f = 0, and d = 1.
Then go the solve menu and select the SolveSolve Parameters dialog
box and enter, as a list of times, linspace(0,5,31) and also enter, as initial
functions,
atan(cos(pi/2*x))
for u, and
3*sin(pi*x).*exp(sin(pi/2*y))
for ut (take careful note of the dot-star separating the two functions here if you omit the dot, MATLAB will bite you). Finally, press the plot button
and select Color, as well as Height (3-D plot), and Animation and
Plot in x-y grid and close the dialog box.
Press the  button to solve and animate the membrane wave. You will
notice that first each frame of the animation is computed separately, and
then they are sequenced, and then the movie is played a number of times
specified in the animation Options.
This demonstration shows clearly that the wave equation really does represent certain types of wave motion.
Musical and Non-musical Sounds
When we hear a sound, our eardrums pick up the alternate compressions and
rarefactions of air produced by the vibrations of the source. For this sound
to be musical (melodious) it must possess two characteristics: pitch and
timbre.

1.3. SOME PDE MODELS

25

(a) Non-periodic (i.e. no pitch)

(b) Periodic waveform

Figure 1.12: Pitch


For the sensation of pitch the waveform must be periodic, and then the
pitch is the frequency, i.e. the rate at which the waveform repeats itself,
measured in cycles per second. Timbre refers to the quality of the sound,
and depends on the shape of the individual periods of the waveform. Most

(a) Tuning fork

(b) Clarinet

Figure 1.13: Timbre


complex waveforms are combinations (superpositions) of waves of one fundamental frequency and of higher frequencies called overtones. For the resultant
waveform to be periodic the overtones should be integral multiples of the fundamental frequency, and they are then called harmonics. Thus, for a note to
be musical to our ears the overtones must be harmonic.
Drums like the western Bongo drum, consisting of a circular membrane
with constant density are not harmonic. To explain this in more detail,
recall first that the displacement u(x, y, t) of the circular membrane satisfies
the wave equation
T
utt = u,

on the circle = {(x, y) : x2 + y 2 1}, where T is the tension in the


membrane, a constant, and is the areal density function (mass per unit

26

CHAPTER 1. MATHEMATICAL MODELS

area), assumed here to be a function only of the radius r. If we look for


solutions vibrating with (angular) frequency they take the form
u(x, y, t) = U (x, y)eit
If this is substituted into the above wave equation we find that the function
U satisfies the reduced wave equation or Helmholz equation
U =

2
U,
T

where U , like u, must vanish on the boundary of the circle . It is a deep


mathematical fact that for most values of , U = 0 is the only solution of
this boundary value problem; the exceptions, an infinite sequence of values
n , give non-trivial solutions U that determine the allowed vibration modes
of the membrane.
We assume for convenience that T = 1 and set = 2 . Then we seek
values such that
U = U
where U = 0 on the boundary. Values for which there is a non-zero
solution U are called eigenvalues and the corresponding solutions U are called
eigenfunctions. Notice that these eigenvalues are related to the actual
frequencies of vibration as follows. As eit = cos t + i sin t the angular
frequency satisfies = 2 where is the period of the trigonometric
function cos t (and sin t). As the period is the reciprocal of the frequency
f = 1/ , we have that

=
.
f=
2
2
These eigenvalues can be found with the MATLAB PDE Toolbox as follows. The general form is
cU + aU = dU.
The above problem is solved with c = 1, a = 0, and d = 20 to simulate a
constant areal density function = 20.
This can be seen from the theory given in MA455 using the zeros of
Bessel functions, or by using the Eigenmodes option in the MATLAB PDE
Toolbox as follows. First start MATLAB and then PDE Toolbox as indicated
earlier. Choose OptionsGrid and then OptionsSnap to set a drawing

1.3. SOME PDE MODELS

27

grid which locks any boundary curve to a nearby grid point. Then click on
the circle+ icon (fourth from left at the top) and, by clicking on the point
(0, 0), and holding, you can drag out a circular domain
= {(x, y) : x2 + y 2 1}.
We do not need to set the boundary condition here as we use u = 0 on
and that is the default. Next, we set the PDE type and coefficients. To
do this click the PDE button and choose Eigenmodes and set d to be 20
and press OK; we use the default c=1 and a=0 here, by the way. Next, to
set the computational grid (also called a mesh), click the mesh button (next
to PDE with a triangle on it); this sets up a coarse triangular grid over
our circular region . Refine this grid by pressing the refine mesh button
(look for a triangle in a triangle) once. This makes the computations more
accurate, at the expense of greater calculation time. You may now press the
button to compute the eigenmodes. From the MATLAB menus at the
top choose SolveExport Solution... and click OK in the dialog box
that appears. Among other things, this sends the eigenvalues to the main
MATLAB screen in the form of the column vector l (this is an ell here)
as you can check by typing l at the MATLAB prompt in the Command
Window. Again at the MATLAB prompt enter

Figure 1.14: The mridangam drum from Southern India

f = sqrt(l)/(2 pi)
to see the associated vibration frequencies, and
f = f/f(1)

28

CHAPTER 1. MATHEMATICAL MODELS

to check for the existence of harmonics. It should be clear that in this case
the higher frequencies are not integer multiples of the lowest frequency f(1),
so there are no harmonics in this case.
The Mridangam Drum
The mridangam drum from southern India consists of a radially variable density membrane stretched tightly over a circular frame as pictured below. It
has the unusual property of being harmonic, i.e. the frequencies of vibration of the membrane are integer multiples of the lowest, or fundamental,
frequency.
There are several approximate forms of with which one can investigate
the harmonic properties of the mridangam. Consider first using a two-part

Figure 1.15: Two-part density mridangam

density function

(r) =

1
2

for 0 r < a,
for a r < b,

as illustrated above. Here we define


r
1
=
,
2

a
k= ,
b

and note that real world drums usually have


3 < < 4,
0.45 < k < 0.55.

1.3. SOME PDE MODELS

29

The values = 3.15 and k = 0.401 are optimal.


In order to use this function with the PDE Toolbox, you have to make
it into a MATLAB function. This is done via a source file rho.m that you
write and store in the directory from which you are running MATLAB. One
can set b = 1, and a = k = 0.401, and 2 = 1 and 1 = 2 = 9.9225. The file
should thus contain the following MATLAB code:
function [y]=rho(x)
% radial density function
a=0.401;
rho1=9.9225;
y = ones(size(x));
idx = find( (0.0 <= x) & (x < a) );
y(idx) = rho1;
idx = find( (a <= x) & (x < 1.0) );
y(idx) = 1.0;
end
Then, in PDE Toolbox choose PDEPDE Specification and select Eigenmodes; in the dialog box for d type
rho(sqrt(x.^2+y.^2))
Notice the . here in x.2 here; in MATLAB, all variables are treated as
vectors and the . means that all components of x are to be squared. Without
the dot, MATLAB attempts to perform a matrix product, which is illegal
here.
To investigate the harmonic properties of a drum whose membrane density is given by rho(r) you will need to export the eigenvalues from the
PDE Toolbox to MATLAB, using SolveExport Solution..., so that
you can use MATLAB to determine the underlying frequencies f according
to the above formula connecting and f . Is this discrepancy important for
human listeners?
One can consider also the three-part density case

1 for 0 r < a
2 for a r < b
(r) =

3 for b r < l.

30

CHAPTER 1. MATHEMATICAL MODELS

Figure 1.16: Three-part density mridangam

illustrated above. Here, we define


r
1
,
=
2
a
q= ,
b

r
=

2
,
3

b
k= .
l

The values = 2.74, = 1.14, k = 0.476, and q = 0.513 appear to produce


excellent results.

Chapter 2
Partial Differential Equations
2.1

Introduction

A partial differential equation or PDE is an equation for an unknown multivariable function in terms of its partial derivatives. There are many approaches to classifying different types of PDEs. As with ODEs one primarily
has the order of the equation which is the order of the highest derivative
appearing. An example of a first order PDE is
L[u] =

u u
+
=1
x y

(2.1)

for the unknown function u = u(x, y). Another first order equation is
 2  2
u
u
+
=1
(2.2)
N [u] =
x
y
While these equations share a common order, they are quite different in
another important respect. In the first equation the operator L describing
the left side has the following property:
(u + v) (u + v)
+
x
y
= L[u] + L[v].

L[u + v] =

We call such an operator linear, and the equation (2.1) is said to be a linear
partial differential equation. The operator N is not linear, and the equation
(2.2) is an example of a nonlinear partial differential equation.
31

32

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

We have already encountered some second order linear partial differential


equations. The equation
2u 2u
+
= g(x, y)
x2 y 2

(2.3)

is called the Poisson1 equation in two variables; if g = 0 it is called the


Laplace2 equation and describes the steady state temperature distribution in
a metal plate. The heat equation in one space variable is
2u
u
=
t
x2

(2.4)

and governs heat flow in one space dimension. Finally, the wave equation in
one space variable is given by
2u
2u
=
t2
x2

(2.5)

arises in connection with waves in one space dimension, for example a guitar
string.
While these equations share linearity and order and the number of independent variables, their properties differ markedly when one considers the
kinds of boundary and initial conditions needed to assure unique solutions.
These equations are also special in that if we concentrate on second order
linear equations in two variables, essentially all such equations behave like
one of these.
Classification of Second Order Linear PDEs
Consider the more general second order linear differential equation
A

2u
2u
u
u
2u
+
B
+
C
=D
+E ,
2
2
t
xt
x
t
x

(2.6)

where A, B, C, D, and E are given constants, and investigate the consequences of making the transformation of coordinates
= x + t,
= x + t.
1
2

French mathematician and physicist Simeon Denis Poisson, 1781-1840


French mathematician and astronomer Pierre-Simon Laplace, 1749-1827

2.1. INTRODUCTION

33

It is known that using = 2, = 2, = 2, and = 2 the wave equation


(2.5) transforms to the simple equation
2u
= 0,

(2.7)

from which the solution is seen to be u(x, y) = p() + q(), for arbitrary
differentiable functions of one variable p and q. So it is reasonable to seek a
similar simplification for the general equation (2.6).
Now, setting U (, ) = u(x, t), the above coordinate change applied to
(2.6) produces
2U
2U
+
(2A
+
B(
+
)
+
2C)
2

2
U
U
U
+ (D + E)
.
+ (A 2 + B + C 2 ) 2 = (D + E)

(A 2 + B + C2 )

We need
A 2 + B + C2 = 0,
A 2 + B + C 2 = 0,

(2.8)

and if A = C = 0 we are already there via = x and = t. So assume


that A 6= 0 (with a similar argument if C 6= 0). Here we must look to
6= 0 because if = 0 then = 0 and there is no transformation of the
desired type. Similarly we assume 6= 0. On dividing the above equations
by 2 and 2 respectively, we get identical quadratic equations for the ratios
/ and / and given that these ratios must be different in order that the
transformation be non-singular, we end up with
i

1 h
=
B + B 2 4AC ,

2A
i

1 h
=
B B 2 4AC .

2A
There are now three cases. If
B 2 4AC > 0,

34

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

the transformation of (2.6) to (2.7) exists; in this case we say that the equation (2.6) is of hyperbolic type. The transformation is given by

= 2Ax + [B + B 2 4AC]t,

= 2Ax + [B B 2 4AC]t.
and all of these equations behave similarly to the wave equation. If B 2
4AC = 0, we say that the equation (2.6) is of parabolic type. In this case
/ = B/2A makes the coefficient of 2 u/ 2 vanish, and from the identity B/2A = 2C/B the coefficient of 2 u/ also vanishes and so the
transformation
= 2Ax Bt,
= t,
basically turns (2.6) into a heat equation,
2U
U
U
= A 2 + D
.
(2AD EB)

If
B 2 4AC < 0
we say that equation (2.6) is of elliptic type. Here there are no real solutions
of the quadratic equations and no real choice of / or / makes the coefficients of 2 u/ 2 and 2 u/ 2 both vanish. It is true however that the
transformation
2Ax Bt
,
=
4AC B 2
= t,
turns (2.6) into the Laplace equation
2u 2u
+ 2 = 0.
2

as 4AC B 2 > 0 and A 6= 0.


We note finally that, after a completing of the square process on the
second order terms, the quadratic equation
At2 + Bxt + Cx2 = t + x +

2.2. FINITE DIFFERENCE METHODS

35

plots in the xt-plane as a hyperbola, parabola, or ellipse according as the


discriminant B 2 4AC is positive, zero, or negative, and motivates the names
of the above classes of partial differential equations.
For further material on the theory of PDE and for explicit solution techniques you should look to the course MA455. Given that most PDEs cannot
be solved explicitly we now turn to a brief review of the commonly used
methods for the computer solution of these equations.

2.2

Finite Difference Methods

In order to approximate solutions of partial differential equations one must


convert the differential equations into a form more amenable to the computer,
typically a system of algebraic equations. In finite difference methods, one
overlays a rectangular grid on the domain,
and then approximates (some or all of) the
derivatives in the PDE with difference expressions that involve values of the solution
of the PDE at the grid points. We illustrate
the ideas in the two dimensional case; the 3D case is analogous but more complicated.
The starting point for the finite difference
formulae is the 2-D Taylor3 theorem stated
here with a fourth-order remainder term:
Taylor Theorem.
For a function u with continuous fifth order partial derivatives, and assuming that
we have 0 < C1 h/k C2 (no skinny
rectangles)
u(x + h, y + k) = u(x, y) + hux (x, y) + kuy (x, y)
+ 2!1 [h2 uxx (x, y) + 2hkuxy (x, y) + k 2 uyy (x, y)]
+ 3!1 [h3 uxxx (x, y) + 3h2 kuxxy (x, y)
+3hk 2 uxyy (x, y) + k 3 uyyy ] + O(h4 + k 4 ).
(2.9)
3

named after the English mathematician Brook Taylor, 1685-1731

36

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Here, the last term, which is usually called the remainder term, R(h, k), is
of order h4 + k 4 ; i.e. there is a constant K such that
|R(h, k)| K.(h4 + k 4 ).
Observe that, on replacing h by h and k by k, we find that
u(x h, y k) = u(x, y) hux (x, y) kuy (x, y)
+ 2!1 [h2 uxx (x, y) + 2hkuxy (x, y) + k 2 uyy (x, y)]
3!1 [h3 uxxx (x, y) + 3h2 kuxxy (x, y)
+3hk 2 uxyy (x, y) + k 3 uyyy ] + O(h4 + k 4 ).
(2.10)
From a rearrangement of equation (2.9) first with k = 0, and then with
h = 0, we find the
Forward Difference Formulae:
u(x + h, y) u(x, y)
+ O(h)
h
u(x, y + k) u(x, y)
uy (x, y) =
+ O(k)
k

ux (x, y) =

(2.11)
(2.12)

Similiarly, from (2.10), we have


Backward Difference Formulae:
u(x, y) u(x h, y)
+ O(h)
h
u(x, y) u(x, y k)
+ O(k).
uy (x, y) =
k

ux (x, y) =

(2.13)
(2.14)

We can also subtract the identities (2.9) and (2.10) to obtain


u(x+h, y +k)u(xh, y k) = 2hux (x, y)+2kuy (x, y)+O(h3 +k 3 ). (2.15)
If we again first set k = 0 and later h = 0, we obtain the more accurate

2.2. FINITE DIFFERENCE METHODS

37

Central Difference Formulae:


u(x + h, y) u(x h, y)
+ O(h2 )
2h
u(x, y + k) u(x, y k)
+ O(k 2 ).
uy (x, y) =
2k

ux (x, y) =

(2.16)
(2.17)

Difference formulae for second order derivatives may also be determined.


First, by adding (2.9) and (2.10) we find that
u(x + h, y + k) + u(x h, y k)
= 2u(x, y) + (h2 uxx (x, y) + 2hkuxy (x, y) + k 2 uyy (x, y)) + O(h4 + k 4 ).
(2.18)
from which we obtain
Second derivative difference formulae
u(x + h, y) 2u(x, y) + u(x h, y)
+ O(h2 )
2
h
u(x, y + k) 2u(x, y) + u(x, y k)
uyy (x, y) =
+ O(k 2 ).
k2

uxx (x, y) =

(2.19)
(2.20)

Finally, from (2.9) replacing h with h we get


u(x h, y + k) = u(x, y) hux (x, y) + kuy (x, y)
+ 2!1 [h2 uxx (x, y) 2hkuxy (x, y) + k 2 uyy (x, y)]
+ 3!1 [h3 uxxx (x, y) + 3h2 kuxxy (x, y)
3hk 2 uxyy (x, y) + k 3 uyyy ] + O(h4 + k 4 ),
(2.21)
and, replacing k with k,
u(x + h, y k) = u(x, y) + hux (x, y) kuy (x, y)
+ 2!1 [h2 uxx (x, y) 2hkuxy (x, y) + k 2 uyy (x, y)]
+ 3!1 [h3 uxxx (x, y) 3h2 kuxxy (x, y)
+3hk 2 uxyy (x, y) k 3 uyyy ] + O(h4 + k 4 ).
(2.22)
On adding (2.21) and (2.22) we have
u(x h, y + k) + u(x + h, y k)
= 2u(x, y) + (h2 uxx (x, y) 2hkuxy (x, y) + k 2 uyy (x, y)) + O(h4 + k 4 ).
(2.23)

38

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Then from (2.18) and (2.23) we have


u(x + h, y + k) u(x h, y + k) u(x + h, y k) + u(x h, y k)
= 4hkuxy (x, y) + O(h4 + k 4 )
From this we finally have (assuming h/k and k/h are O(1)) the
Second mixed derivative difference formula
uxy (x, y)
u(x + h, y + k) u(x h, y + k) u(x + h, y k) + u(x h, y k)
=
4hk
+O(h2 + k 2 ).
(2.24)
In general, finite difference methods are best applied when the boundary
domain of the PDE is a polygon with sides parallel to the coordinate axes.
This, of course includes squares and rectangles, but as we see below, also
ell-shaped regions, and the like. For regions with curved boundaries the
finite element method is recommended (see the next section). If the PDE

Figure 2.1: Rectangular grid


region is overlain with a Cartesian grid formed by vertical lines x = xr ,
0 r n, and horizontal lines y = ys , 0 s m, and we let ur,s = u(xr , ys )

2.2. FINITE DIFFERENCE METHODS

39

denote the PDE solution values at the node points (see Figure 2.1), then at
the node point (xr , ys ) we have from (2.19) and (2.20)
ur1,s 2urs + ur+1,s
+ O(h2 )
h2
ur,s1 2urs + ur,s+1
uyy (xr , ys ) =
+ O(k 2 )
k2

uxx (xr , ys ) =

2.2.1

(2.25)
(2.26)

Elliptic Equations

We illustrate the general approach by means of some examples based upon


the following two dimensional region :

Figure 2.2: Grid for region

40

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Problem 1
Consider first the following boundary value problem. Find the solution u of
the Laplace equation
uxx + uyy = 0

(2.27)

satisfying the boundary condition


u(x, 0) = 100,

0 x 1,

and u = 0 on the remaining sides of the L-shaped region shown above in


Figure 2.2.
We use the grid shown in which h = k = 0.25; we take
u0,0
u0,1
u1,4
u2,2
u4,1

= u1,0
= u0,2
= u2,4
= u3,2
=0

= u2,0
= u0,3
= u2,3
= u4,2

= u3,0 = u4,0 = 100


= u0,4 = 0
=0
=0
(2.28)

and we ignore the exterior grid points (x5 , y1 ), (x1 , y1 ),(x1 , y2 ), and (x1 , y3 ),
for the moment. The unknown grid values are u1,3 , u1,2 , u1,1 , u2,1 , u3,1 ; at each
of these grid points we substitute the derivative approximations (2.25) and

Figure 2.3: Five point stencil

2.2. FINITE DIFFERENCE METHODS

41

(2.26) into the PDE (2.27) to obtain the equations:


(x1 , y1 )
(x2 , y1 )
(x3 , y1 )
(x1 , y2 )
(x1 , y3 )

u1,2 + u1,0 + u0,1 + u2,1 4u1,1


u2,2 + u2,0 + u1,1 + u3,1 4u2,1
u3,2 + u3,0 + u2,1 + u4,1 4u3,1
u1,3 + u1,1 + u0,2 + u2,2 4u1,2
u1,4 + u1,2 + u0,3 + u2,3 4u1,3

:
:
:
:
:

=0
=0
=0
=0
= 0.

Notice that at each of the five grid points one can obtain the equation by
considering the so-called five-point stencil (see Figure 2.3) and using a weight
of 1 at each of the blue nodes, and -4 at the center.
Using the boundary values (2.28), we arrive at the system
u1,2 + u2,1 4u1,1
u1,1 + u3,1 4u2,1
u2,1 4u3,1
u1,3 + u1,1 4u1,2
u1,2 4u1,3

=
=
=
=
=

100
100
100
0
0.

Notice that the solutions urs of these equations are now (in general) only
approximations of the solutions values u(xr , ys ).
If we make the assignments (using row ordering)
u1 u1,1 ,

u2 u2,1 ,

u3 u3,1 ,

u4 u1,2 ,

u5 u1,3 ,

(2.29)

equivalent to providing an ordering for the unknowns, the above system of


linear equations may be written in matrix form as

100
4
1
0
1
0
u1
1 4

1
0
0

u2 100
0

1 4
0
0
(2.30)

u3 = 100
1
0
0 4
1 u4
0
u5
0
0
0
0
1 4
and this system can be solved with MATLAB.
Problem 2
Consider next the problem of finding the solution u of the Laplace equation
uxx + uyy = 0

(2.31)

42

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

over the same region as above and subject to the mixed Dirichlet and
Neumann boundary conditions
u(x, 0)
u
(0, y)
x
u
(1, y)
x
u

= 100,

0 x 1,

(2.32)

= 0,

0 y 1,

(2.33)

= 0,

0 y 0.5,

(2.34)

= 0,

elsewhere on the boundary.

(2.35)

The presence of the Neumann conditions necessitates some non-trivial changes


in our approach. First, we introduce the ghost grid points at (x5 , y1 ),
(x1 , y1 ), (x1 , y2 ), and (x1 , y3 ) as shown in Figure 2.4. As before

Figure 2.4: ghost grid points for


u0,0 = u1,0 = u2,0 = u3,0 = u4,0 = 100
u0,4 = u1,4 = u2,4 = u2,3 = 0
u2,2 = u3,2 = u4,2 = 0.

(2.36)

In addition to the internal unknown solution values u1,1 , u1,2 , u1,3 , u2,1 , and
u3,1 , we now have to determine approximations for the solution at the bound-

2.2. FINITE DIFFERENCE METHODS

43

ary points u0,1 , u0,2 , u0,3 , u4,1 , and the ghost grid values u1,1 , u1,2 , u1,3 ,
and u5,1 , thirteen unknowns in all.
At the grid point (x4 , y1 ) we use a central difference approximation of the
derivative ux (x4 , y1 ) to satisfy the Neumann condition (2.34):
ux (x4 , y1 )

u5,1 u3,1
= 0.
2h

This formula is O(h2 ) accurate, in line with the other approximations that
we are making. In similar fashion, using the Neumann data at the grid points
(x0 , y1 ), (x0 , y2 ), and (x0 , y3 ) we obtain the equations
u5,1
u1,1
u1,2
u1,1

=
=
=
=

u3,1
u1,1
u1,2
u1,3

(2.37)

At the non-ghost grid points, we also approximate the differential equation.


For example, at (x4 , y1 ) we have
uxx (x4 , y1 ) + uyy (x4 , y1 ) =

u3,1 2u4,1 + u5,1 u4,0 2u4,1 + u4,2


+
= 0,
h2
k2

which, when combined with (2.37) gives


u4,2 + u4,0 + 2u3,1 4u4,1 = 0.
In similar fashion we obtain from (x0 , y1 ), (x0 , y2 ), and (x0 , y3 )
u0,2 + u0,0 + 2u1,1 4u0,1 = 0
u0,3 + u0,1 + 2u1,2 4u0,2 = 0
u0,4 + u0,2 + 2u1,3 4u0,2 = 0
When the boundary conditions (2.36) are incorporated, we have nine equa-

44

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

tions for the non-ghost grid points:


u0,2 + 2u1,1 4u0,1
u0,3 + u0,1 + 2u1,2 4u0,2
u0,2 + 2u1,3 4u0,3
u1,2 + u0,1 + u2,1 4u1,1
u1,3 + u1,1 + u0,2 4u1,2
u0,3 + u1,2 4u1,3
u1,1 + u3,1 4u2,1
u2,1 + u4,1 4u3,1
2u3,1 4u4,1

=
=
=
=
=
=
=
=
=

100
0
0
100
0
0
100
100
100
(2.38)

in the nine (non-ghost) unknowns u0,1 , u0,2 , u0,3 , u1,1 , u1,2 , u1,3 , u2,1 , u3,1 , u4,1 .
To produce a matrix system, we make the (column ordered) assignments
u0,1 = u1 ,
u1,1 = u4 ,
u2,1 = u7 ,

u0,2 = u2 ,
u1,2 = u5 ,
u3,1 = u8 ,

u0,3 = u3 ,
u1,3 = u6 ,
u4,1 = u9 .

The above equations then become


u2 + 2u4 4u1
u3 + u1 + 2u5 4u2
u2 + 2u6 4u3
u5 + u1 + u7 4u4
u6 + u4 + u2 4u5
u3 + u5 4u6
u4 + u8 4u7
u7 + u9 4u8
2u8 4u9

=
=
=
=
=
=
=
=
=

100
0
0
100
0
0
100
100
100

2.2. FINITE DIFFERENCE METHODS


or, in matrix form

4
1
0
2
0
0
0
0
0
1 4
1
0
2
0
0
0
0

0
1 4
0
0
2
0
0
0

1
0
0
4
1
0
1
0
0

0
1
0
1 4
1
0
0
0

0
0
1
0
1
4
0
0
0

0
0
0
1
0
0 4
1
0

0
0
0
0
0
0
1 4
1
0
0
0
0
0
0
0
2 4

45

u1
u2
u3
u4
u5
u6
u7
u8
u9

100
0
0
100
0
0
100
100
100

(2.39)

and, again, this system is easily solved with MATLAB.

2.2.2

Parabolic Equations

Consider the parabolic equation


ut = uxx + uyy

(2.40)

on a 2-D region bounded by a polygon with sides parallel to the coordinate


axes. We assume an initial condition
u(x, y, 0) = f (x, y),

for (x, y) in ,

and also that u satisfies a Dirichlet boundary condition. As before we overlay


a rectangular grid on . Then, at each grid point (xr , ys ) we set
ur,s (t) = u(xr , ys , t).
If we approximate the derivatives uxx and uyy in (2.40) at each point (xr , ys )
using the formulae (2.25) and (2.26) we obtain the ordinary differential equations
ur1,s (t) + ur+1,s (t) 2ur,s (t)
dur,s
(t) =
dt
h2
ur,s1 (t) + ur,s+1 (t) 2ur,s (t)
+
, (2.41)
k2
where
ur,s (0) = f (xr , ys ).

(2.42)

46

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

This ODE initial value system can now be solved with standard ODE solver
routines.
In the case that Neumann boundary conditions are present, one can employ the technique of ghost boundary points, as in the elliptic case, and then
proceed as above.
This approach to solving parabolic equations is called the Method of Lines
and is the recommended technique for the following reason. The typical alternative method involves approximating the time derivative ut in the parabolic
equation by a finite difference formula using a uniform t-mesh. One then
finds that, in certain situations (generally unknown in advance) the method
requires very small time steps for stability of the algorithm.
The reason for this is not hard to find. It is known (and should be expected anyway) that some ODE solutions have small gradients in parts of
their domain, intermixed with regions where the solution gradient is very
large. In the latter region, one must use small time-steps to ensure an accurate solution. The problem here is that if the time-step is uniform on
the whole domain, you will be wasting computing resources in those regions
that have small gradient, because a larger time-step is permissible for those
regions.
The good ODE solvers have long ago solved this problem by employing
adaptive stepsize control, i.e. the solver uses large time-steps when it can,
and small time-steps when it must. These solvers are very robust and have
been working well for decades. So they are exactly the correct resource for
these parabolic problems.
As an example, consider the above equation with the square domain
overlain with the grid shown in Figure 2.5 below and assuming the Dirichlet
boundary condition given by,

u(x, 0) = 100, 0 x 1
u(x, y) = 0, elsewhere on the boundary of .

and the initial condition u(x, y, 0) = 0. If we apply the difference formulae


at the interior grid points (x1 , y1 ), (x1 , y2 ), (x2 , y1 ), and (x2 , y2 ) we obtain

2.2. FINITE DIFFERENCE METHODS

47

Figure 2.5: Square Domain

the equations
du1,1
dt
du
1,2
h2
dt
du
2,1
h2
dt
du2,2
h2
dt

h2

= 4u1,1 (t) + u2,1 (t) + u1,2 (t) + 100


= 4u1,2 (t) + u2,2 (t) + u1,1 (t)
= 4u2,1 (t) + u1,1 (t) + u2,2 (t) + 100
= 4u2,2 (t) + u2,1 (t) + u1,2 (t)

subject to the initial conditions


u1,1 (0) = 0,

u1,2 (0) = 0,

u2,1 (0) = 0,

u2,2 (0) = 0.

This ODE system can be solved with, for example, the subroutine xodeint.f
used in MA360, or the ODE subroutines available in MATLAB.

48

2.2.3

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Hyperbolic Equations

The method of lines may also be applied to hyperbolic equations. For example, the hyperbolic equation
utt = uxx + uyy

(2.43)

can be solved on a 2-D region bounded by a polygon with sides parallel to


the coordinate axes. We assume initial conditions
u(x, y, 0) = f (x, y),
ut (x, y, 0) = g(x, y),

for (x, y) in ,
for (x, y) in .

(2.44)
(2.45)

and that u satisfies a Dirichlet boundary condition. We again overlay a


rectangular grid on , and at each grid point (xr , ys ) we set
ur,s (t) = u(xr , ys , t).
If we approximate the derivatives uxx and uyy in (2.40) at each point (xr , ys )
using the formulae (2.25) and (2.26) we obtain the ordinary differential equations
d2 ur,s
ur1,s (t) + ur+1,s (t) 2ur,s (t)
(t) =
2
dt
h2
ur,s1 (t) + ur,s+1 (t) 2ur,s (t)
+
+ Br,s , (2.46)
k2
where
ur,s (0) = f (xr , ys ),
dur,s
(0) = g(xr , ys ),
dt

(2.47)
(2.48)

and Br,s again denotes the contributions from the Dirichlet boundary data
(if any). This ODE initial value system can now be solved with standard
ODE solver routines, after first transforming each second order equation to
a subsystem of two first order equations (see MA360, for example).

2.3

Finite Element Methods

If the PDE domain boundary is not a polygon with sides parallel to the
coordinate axes, finite difference methods tend to be not only more cum-

2.3. FINITE ELEMENT METHODS

49

Figure 2.6: Triangular mesh and a continuous piecewise linear function

bersome, but more inaccurate. In some situations, such as the lake region
shown below, the use of finite differences would be something of a nightmare
to implement. A better choice under these circumstances is the finite element method (FEM). We content ourselves here with a brief overview of the
essential ideas involved in the 2-D case.
In the finite element approach, we first approximate the computational
domain with a union of simple geometrical objects, usually either triangles
(see Figure 2.6) or rectangles; in the MATLAB PDE Toolbox for example,
triangles are used. The triangles form a mesh, and each triangle vertex is
called a node. If greater accuracy is desired, the mesh can be refined by
further subdividing each triangle into smaller triangles, either uniformly on
the domain, or adaptively in appropriate sub-domains, until the mesh is fine
enough to achieve the desired accuracy.
Next, the approximate solution is chosen to take a simple form on each
triangle. Polynomials are a widely favored choice; they are easy to evaluate,
and have good approximation properties on small domains. MATLAB uses
functions that are linear on each triangle, and continuous across each triangle
boundary, as can be seen in Figure 2.6; such functions are called continuous

50

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Figure 2.7: Triangular mesh for a lake region

piecewise linear functions.


Before we introduce the mathematical basis of the finite element method,
we digress to consider (from Calculus III MA227, or Vector Analysis MA444)
the

2.3.1

Gauss Divergence Theorem in 2D

For a vector function F(x, y) = (F1 (x, y), F2 (x, y))T defined on a plane region
= B with boundary = C having parametric form (x(t), y(t)), a t b,
we have from Greens theorem in Calculus III,

2.3. FINITE ELEMENT METHODS

51

Figure 2.8: Unit outward normal n(x, y)

Z
B

F1 (x, y) F2 (x, y)
+
dxdy =
x
y

Z
F2 (x, y) dx + F1 (x, y) dy
C
Z b

F(x(t), y(t)) (y 0 (t), x0 (t)) dt

p
F(x(t), y(t)) n x0 (t)2 + y 0 (t)2 dt.

where

F1 F2
+
x
y
is the divergence of the vector function F, and
F=

(y 0 (t), x0 (t))
n(x, y) = p
x0 (t)2 + y 0 (t)2
is the unit outward normal vector located at each point (x, y) in the boundary
C = of B = . Here, one can see that n is outward by checking the four
cases
x0
x0
x0
x0

> 0, y 0
> 0, y 0
< 0, y 0
< 0, y 0

>0
<0
>0
<0

52

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

separately. The 2D Gauss Divergence Theorem


Z
Z
F(x, y) dxdy =
F(x, y) n(x, y) ds

follows.
If we use this formula with F = v.cu then as
F = (v.cu) = cu v + v (cu),
we have
Z
Z
v(x, y)c(x, y)u n ds = (c(x, y)u v + v(x, y) (c(x, y)u)) dxdy,

so that

Z
v (cu) =

Z
vcu n

cu v.

(2.49)

This theorem is a multi-dimensional analogue of the familiar integration by


parts formula
Z b
Z b
0 0
0 b
cu0 v 0
v(cu ) = [vcu ]a
a

from Calculus II.

2.3.2

Gauss Divergence Theorem in 3D

For a vector function F defined on a region in R3 with boundary we


have
Z
Z
F(x, y, z) dxdydz =
F(x, y, z) n(x, y, z) dS,

where F(x, y, z) = (F1 (x, y, z), F2 (x, y, z), F3 (x, y, z))T , and
F=

F1 F2 F3
+
+
x
y
z

is the divergence of the vector function F, and n(x, y, z) is the unit outward
normal vector at each point (x, y, z) in the boundary, , of .
If we use this formula with F = v.cu then as
F = (v.cu) = cu v + v (cu),

2.3. FINITE ELEMENT METHODS

53

Figure 2.9: Unit outward normal n(x, y, z)

we have
Z
Z
v(x, y, z)c(x, y, z)un dS = (c(x, y, z)uv+v(x, y, z)(c(x, y, z)u)) dxdydz,

so that

Z
v (cu) =

2.3.3

Z
vcu n

cu v.

(2.50)

Elliptic Equations and the FEM

Consider the solution u of an elliptic equation


(c(x, y)u) + a(x, y)u = f (x, y)

(2.51)

on a region satisfying the Neumann condition


cu n + qu = g

(2.52)

on the boundary.
The FEM rests upon the mathematical idea of a weak solution of a PDE,
which is a cornerstone of the modern theory of partial differential equations.

54

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

The idea here is that one can take a function v (often called a test function)
and multiply it through equation (2.51) and integrate the result over the
region to get
Z
( (c(x, y)u) + au f ).v(x, y) dxdy = 0.
(2.53)

Then using the integration by parts formula (2.50) we have that


Z
Z
Z
v(x, y) (cu) dxdy =
v.cu n ds c(x, y)u v dxdy,

so that (2.53) becomes


Z
Z
(cu v + auv) dxdy

Z
n (cu)v ds

f v dxdy = 0.

Finally, using the boundary condition (2.52) we arrive at


Z
Z
Z
Z
(cuv +auv) dxdy +
quv dxdy
gv ds f v dxdy = 0. (2.54)

Any function u such that (2.54) holds for all test functions v is said to
be a weak solution of the above elliptic boundary value problem. Notice
that as long as the function c is bounded all is well. In particular c can
be discontinuous. This is important in many modeling situations involving
material interfaces.

Figure 2.10: hat function

2.3. FINITE ELEMENT METHODS

55

If we restrict the solution u and the test functions v to lie in a finitedimensional space of functions then we can use the above weak formulation
of the boundary value problem to obtain an approximate solution. There
are many choices that one can make for the finite dimensional space of test
functions. The MATLAB PDE Toolbox uses the set of piecewise linear hat
functions i , 1 i N , where N is the number of mesh nodes. Each function
i (x, y) is linear (i.e. of the form i (x, y) = ai + bi x + ci y) on each triangle
containing the i-th vertex and takes the value 0 at all nodes (xj , jj ) except
for the node (xi , yi ) where the value is 1. In particular, i is identically zero
on all triangles that do not contain the node (xi , yi ).
Setting v = i in (2.54) gives (for 1 i N )

f i dxdy = 0. (2.55)

gi ds

qui ds

(cui +aui ) dxdy+

We look for an approximate solution u of (2.55) of the form

u(x, y) =

N
X

Uj j (x, y).

j=1

Notice that
u(xi , yi ) =

N
X

Uj j (xi , yi ) = Ui ,

j=1

i.e. the values Ui are exactly the nodal values of the approximate solution of
the boundary value problem.
On substituting this u into (2.55) we obtain the system of equations
Z
N Z
X
( cj i + ai j dxdy +
j=1

Z
qj i ds)Uj =

Z
f i dxdy +

gi ds

56

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

over 1 i N for the nodal values Ui of the approximate solution. We set


Z
Kij =
cj i dxdy, (Stiffness matrix)

Z
Mij =
aj i dxdy, (Mass matrix)

Z
qj i ds
Qij =
Z
Fi =
f i dxdy

Z
Gi =
gi ds.

The system can be rewritten in the form


(K + M + Q)U = F + G
and solved for U = (Ui ).

2.3.4

Parabolic Equations and the FEM

As in the analogous finite difference case, we can again make use of the
method of lines. For the equation
d(x, y)

u
(c(x, y)u) + a(x, y)u = f (x, y)
t

(2.56)

on a region satisfying the Neumann condition


cu n + qu = g

(2.57)

on the boundary, and the initial condition


u(x, y, 0) = u0 (x, y),

(x, y) in ,

and using the hat functions i (x, y) defined in the elliptic case above, we seek
a solution u(x, y, t) in the form
X
u(x, y, t) =
Ui (t)i (x, y).
i

2.3. FINITE ELEMENT METHODS

57

If this expression is substituted into the PDE (2.56) and the FEM is applied
as in the elliptic case, one arrives at the ODE system
dU
+ KU = F.
dt
The initial values for this system are given by
M

Ui (0) = u0 (xi , yi ),

1 i N,

where the points (xi , yi ) are the mesh nodes. The ODE system is solved by
the MATLAB ODE Suite which uses adaptive stepsize control to control the
ill conditioning in the ODE system.

2.3.5

Hyperbolic Equations and the FEM

We again consider the method of lines. For the equation


2u
(c(x, y)u) + a(x, y)u = f (x, y)
t2
on a region satisfying the Neumann condition
d(x, y)

cu n + qu = g

(2.58)

(2.59)

on the boundary, and the initial condition


u
(x, y, 0) = v0 (x, y) (x, y) in .
t
and using the hat functions i (x, y) defined above, we seek a solution u(x, y, t)
in the form
X
u(x, y, t) =
Ui (t)i (x, y).
u(x, y, 0) = u0 (x, y),

If this expression is substituted into the PDE (2.58) and the FEM is applied
as above, one arrives at the ODE system
d2 U
+ KU = F.
dt2
The initial values for this system are given by
M

d
Ui (0) = v0 (xi , yi )
dt
where the points (xi , yi ) are the mesh nodes. The ODE system is again solved
by the MATLAB ODE Suite.
Ui (0) = u0 (xi , yi ),

58

CHAPTER 2. PARTIAL DIFFERENTIAL EQUATIONS

Chapter 3
MATLAB and COMSOL
3.1

MATLAB

MATLAB is commercially available software built around the MATLAB


language, that provides an easy interface facilitating, among other things,
matrix and vector manipulations, the solution of linear systems, and other numerical procedures such as the solution of ordinary and partial differential equations and
optimization, together with accompanying
graphics. MATLAB also permits interfacing with other languages such as C and
Fortran. The first version was written by
Cleve Moler, one of the authors of the public domain numerical linear algebra packages LINPACK and EISPACK, in the late
1970s as a device to give his students access to these tools without the need to learn
Fortran! Needless to say the idea took off
big time, and MATLAB was eventually rewritten in C and went commercial in 1984.
There are viable free clones of MATLAB available: you can check out Scilab
at http://www.scilab.org, or Octave at http://www.octave.org, or FreeMat
at http://freemat.sourceforge.net. MATLAB is available on the MacBook
Pro laptop machines in the mathematics department Mac Lab in HHB221.
59

60

CHAPTER 3. MATLAB AND COMSOL

Start MATLAB by double-clicking the MATLAB icon

in the MacBook Dock. If you need MATLAB on your home machine, check
out the Student Edition its cheap1 (relatively speaking) and fully functional.
You can download the MATLAB tutorial, written by David F. Griffiths
of the University of Dundee, Scotland, from the class website
http://people.cas.uab.edu/iknowles/ma461/matlab/MatlabNotes.pdf
We will work through parts of this now. First, start MATLAB. You will
notice a rather busy scene with lots of windows. Find the one marked Command Window. At the top left of this window click the rectangle (marked
Maximize Command Window) to temporarily get rid of the rest (you can
click the same switch to restore things if you like the clutter). You can type
MATLAB commands at the >> prompt, followed by pressing the return
key. It is important to notice that one can always suppress MATLAB output
by typing ; at the end of your command. You will need this for example
when you create a vector or matrix that is too large to display on your screen,
and you wish to keep things tidy.

3.1.1

Keeping a Session Record

The command
>> diary freddie
will cause all subsequent text that appears on the screen to be written to a
file called freddie in the current directory. Terminate the session with
>> diary off
1

down the road they hope to recoup their losses from your eventual employer!

3.1. MATLAB

61

The file freddie is a text file and may be edited with jedit if you need to
do some clean up.

3.1.2

Keyboard Shortcuts

You can recall previous MATLAB commands by using the key, and reverse
your path through the command list with the key. Once a prior command
has been recalled, it can be edited (if needed) and then re-executed.

3.1.3

MATLAB as a Calculator

The basic arithmetic symbols are +,-,*,/, and the usual rules of precedence apply. So, by way of example, 2+3/4*5 really means 2+(3/4)*5 as
can be checked by typing either at the MATLAB prompt:
>> 2+3/4*5
ans =
5.7500

3.1.4

Standard Functions

MATLAB knows about the trigonometric functions sin,cos,tan, where


arguments must always be in radians:
>> cos(pi/3)
ans =
0.500
The inverse trigonometric functions are asin, acos, atan. Other standard
functions include sqrt, exp, log, log10,abs; see Table 2, page 32 of Griffiths for more.

3.1.5

Vectors in MATLAB

The entries in a vector are usually called elements or components, and


the number of such elements is called the length of the vector. In MATLAB
vectors are always enclosed with square brackets.

62

CHAPTER 3. MATLAB AND COMSOL

Row Vectors
MATLAB treats row vectors (1 n matrices) quite differently from column
vectors (n 1 matrices). Consider the 1 3 row vector v is defined by
>> v = [1,3,sqrt(5)]
v =
1.0000
3.0000
>> length(v)
ans =
3

2.2361

Here the elements of the row vector can be separated by spaces, if you prefer.
Vectors of the same type and length can be added; vectors can also multiplied
by scalars. One can also build row vectors from existing pieces:
>> u=[-1,v,-2]
u =
-1.0000 1.0000 3.0000 2.2361 -2.0000
The colon notation provides a shortcut for making certain row vectors:
>> z = 0.32:0.1:0.8
z =
0.3200 0.4200 0.5200 0.6200 0.7200
Here, the row vector has first element 0.32 and this is incremented by 0.1
up to 0.72 (it will not go beyond 0.8 in this case). Negative increments also
work. One can also extract parts of a vector as in
>> z(3:4)
ans =
0.5200 0.6200
or
>> z(1:2:5)
ans =
0.3200 0.5200 0.7200
Consider also the linspace command. For example linspace(a,b,n) produces a linearly spaced row vector of length n with first element a and last
element b. For example

3.1. MATLAB

63

>> v=linspace(1,2,5)
v =
1.0000
1.2500

1.5000

1.7500

2.0000

Column Vectors
The construction is similar to row vectors, except that semicolon (or newline)
is used as the separator for the elements. So we have
>> c = [1; 3; sqrt(5)]
c =
1.0000
3.0000
2.2361
>> c1 = [3
4
5]
c1 =
3
4
5
To convert a row vector to a column vector (or vice versa) use the transpose
operator as in
>> c
ans =
3

>> v
ans =
1.0000
3.0000
2.2361

3.1.6

Products, Division and Powers of Vectors

On p. 10 of Griffiths, may be found various useful ways to combine two vectors. Included here are the standard dot product, with more subtle variations

64

CHAPTER 3. MATLAB AND COMSOL

such as elementwise products (with .*), elementwise division (with ./) and
elementwise powers (with . ). Check them out.

3.1.7

Plotting Elementary Functions

To plot (for example) the function y = sin(3x) over [0, 1] we first sample
the function at a large enough number of points, and then get MATLAB to
make a plot by joining these points consecutively by straight lines. This is
done so
>> N=10; h=1/N; x=0:h:1;
where the row vector x contains the values x = 0, h, 2h, . . . , 1, and the corresponding row vector y of y-values is made thus
>> y = sin(3*pi*x);
Notice that the constant in MATLAB is pi and that when the sin function
acts on a row vector, it produces another row vector. This is an important
trick to absorb here. The plot is now carried out with
>>

plot(x,y)

You can improve the plot by increasing the value of N to 100 and re-executing
the above steps (use the key!) You can print on your local printer by using
the command print (for other plotting options see Griffiths p. 6).
One can also plot surfaces, for example graphs of function of two variables.
First create a grid of x and y points:
>> points=linspace(-1,1,40);
>> [X,Y]=meshgrid(points,points);
Then define the function Z = f (X, Y ) noting the use of .* for function
multiplication
>> Z=3*sin(pi*X).*exp(sin(pi/2*Y));
Finally create the surface plot using first figure to make the plot appear in
a new window, and then the surf command
>> figure;
>> surf(X,Y,Z)
to produce

3.1. MATLAB

65

Figure 3.1: f (x, y) = 3 sin(x)e 2 y

3.1.8

Matrices

A matrix is a rectangular array of numbers. In particular an n m matrix


has n rows and m columns. To enter a 2 3 matrix


1 2 3
A=
4 5 6
into MATLAB one would simply use
>>

[1
4

2
5

1
4

3
6]

2
5

3
6

or even
>>

[1

3;

6]

You can also patch together various vectors as in


>> B
B =

[1:5;

1
6
11

2
7
13

6:10;
3
8
15

11:2:20]
4
9
17

5
10
19

66

CHAPTER 3. MATLAB AND COMSOL

3.1.9

Special Matrices

The command ones(n,m) makes an n m matrix of ones. This includes of


course row vectors (1 n matrices) and column vectors (n 1 matrices).
The command zeros(n,m) does the same thing with zeros. For a given row
vector d of length n the command diag(d) creates an n n diagonal matrix
with the elements of d on the main diagonal, and all other elements set to
zero. To create a tridiagonal matrix, first make three column vectors `,d,u
with the same length n (only the first n-1 elements in ` are used, together
with the last n-1 elements of u). We then use the spdiags() command as
shown below:

>>
>>
>>
>>
ans

n=5;
l = -(2:n+1); d = (1:n); u = ((n+1):-1:2);
B = spdiags([l,d,u],-1:1,n,n);
full(B)
=
1
5
0
0
0
-2
2
4
0
0
0
-3
3
3
0
0
0
-4
4
2
0
0
0
-5
5

Here, the second argument -1:1 in the spdiags() call makes ` the -1 (i.e.
the lower) diagonal, d the 0 (i.e. the main) diagonal, and u the 1 (upper)
diagonal. The last two arguments indicate the size of the resulting matrix.
One can modify this command to produce matrices with any chosen diagonal
structure. The command full() converts the sparse matrix output coming
from spdiags() to standard row/column matrix notation. This is used here
only for cosmetic reasons, and would not normally be needed for m-file (see
later) code.

3.1. MATLAB

3.1.10

67

Solving Systems of Linear Equations

Define the column vector r by

r=

1
0
0
0
2

To solve the tridiagonal system of linear equations


Bx = r
we set up the column vector r of length 5 with
>> r = zeros(3,1);
>> r = [-1;r;-2];
The solution vector x is now found, as a column vector, from
>> x
x =

B\r
-0.4167
-0.1167
-0.1500
0.0333
-0.3667

3.1.11

Loops

Not surprisingly, MATLAB also allows various looping constructs. The most
common is the for loop. For example f30 , the thirtieth member of the
Fibonacci sequence {fn }
n=0 defined by f1 = 0, f2 = 1, and
fn = fn1 + fn2
for n 3, may be computed by populating the vector f via
>>
>>

>>

f(1)=0; f(2)=1;
for i=3:30
f(i)=f(i-1)+f(i-2);
end
f(30)

68

CHAPTER 3. MATLAB AND COMSOL

One can also employ while loops (see p. 22 of Griffiths) and MATLAB also
has if ... then ... else ... end constructs as well.

3.1.12

m-files

MATLAB allows you to place a collection of commands into a file, and then
execute them with one command. Such a file must be given a .m extension,
and if the file is called freddie.m the commands in the file can be executed
by typing freddie at the MATLAB prompt. For example, create such a file
containing the commands below
n=5;
l = -(2:n+1); d = (1:n); u = ((n+1):-1:2);
B = spdiags([l,d,u],-1:1,n,n);
r = zeros(3,1);
r = [-1;r;-2];
x = B\r
and save the file as freddie.m (or some other name, if you prefer, but it
must also end with .m). If you now type freddie at the MATLAB prompt,
you should then see the above solution x of the system Bx=r.

3.1.13

m-functions

Function m-files (or m-functions) are a combination of the ideas of m-file and
mathematical functions. We are now going to turn the last example into an
m-function. Here we have the variables n (the size of the square matrix B),
the columns `, d, and u of length n making up the diagonals of the matrix B,
and the right hand side column r, also of length n. The solution x of Bx=r
depends on these five variables. We make a function m-file (m-function)
called trisolve.m with the following content:
function [x]=trisolve(n,l,d,u,r)
% This function solves the tridiagonal system Bx=r
% with vectors l,d,u as the diagonals of B.
B = spdiags([l,d,u],-1:1,n,n);
x = B\r;

3.1. MATLAB

69

Here the lines that begin with % are comment lines; it is always a good idea
to write these letters to your later self. You can then solve the system above
with the single function call
>>

trisolve(n,l,d,u,r)

typed at the MATLAB prompt, assuming of course that n,l,d,u,r have


been previously set up as above.

3.1.14

Reading and Writing Data Files

In general it is infeasible to use the screen and keyboard when large amounts
of data, e.g. thousands, or even millions, of numbers resulting from measurements accumulated in scientific experiments, are involved. MATLAB
has several commands for handling data. First, if the data is in array form,
the importdata() command is useful for reading the contents of a data file
into MATLAB. Consider the file dump (see the matlab directory in the class
website)containing two columns of (x, y) function data output from the ODE
solver odeint.f in MA360. We have (using right quotes around the filename
dump)
>> A
A =

0
0.1000
0.2000
0.3000
0.4000
0.5000
0.6000
0.7000
0.8000
0.9000
1.0000

importdata(dump)

0
0
0.0002
0.0018
0.0072
0.0200
0.0450
0.0882
0.1569
0.2597
0.4072

Inside MATLAB the matrix A can be manipulated to plot the original DE


solution. We first call on MATLAB to determine the number of rows in
A, and then isolate the columns of A and send them to the MATLAB plot
command:

70

CHAPTER 3. MATLAB AND COMSOL

>> size(A)
ans =
11
2
>> plot(A(1:11,1),A(1:11,2))
The same data can be written to a file dump.dat via
>> fid = fopen(dump.dat,w);
>> for i=1:11
fprintf(fid,%f%f\n,A(i,1),A(i,2));
end
>> fclose(fid);
Note here the right single quotes around both the filename and the w; the
latter indicates that the file is being opened for writing. This usage of
fprintf() here is very similar to that in C; perhaps not surprising as MATLAB is written in C.
Is is quite common for data to arrive in the form of an Excel (spreadsheet,
or *.xls) file and our MATLAB does not handle these very well. Fortunately,
inside Excel one can use the Save as ... facility and produce a new file in
the Comma Separated Values (.csv) format which MATLAB does handle
readily. This latter file format (unlike Excel) is a universally useful way
to store scientific data, by the way. To load the file cpi.csv (containing
Consumer Price Index data, obtainable from the class website, or FRED,
the Federal Reserve Economic Database) into MATLAB proceed as follows:
type in
>> A=cvsread(cpi.csv,11,0)
and MATLAB responds with
A =
207.6030
207.6670
..
.
217.4630
219.0160

3.2. MATLAB PDE TOOLBOX

71

Here, MATLAB reads the file starting at the spreadsheet position (row 12,
column 2) and one has to note that the first row is labelled 0 and the first
column is labelled 0; this is an unfortunate holdover from the C language
convention of using zero to label the first component of a vector ). There is
a similar MATLAB command csvwrite() for writing MATLAB data out to
a csv file.

3.2

MATLAB PDE Toolbox

The PDE Toolbox in MATLAB provides a convenient GUI interface for solving 2D linear partial differential equations of parabolic, elliptic, or hyperbolic
type. You may download the PDE Toolbox manual from
http://people.cas.uab.edu/iknowles/ma461/matlab/pde.pdf
Problem Types
The PDE Toolbox can handle the following problem types:
1. Elliptic PDE
(c(x)u) + a(x)u = f (x),

x ,

over a bounded plane domain with the coefficients c, a, f and the


solution function u being scalar complex-valued functions on ; c can
be a 2 2 matrix.
2. Parabolic PDE
d(x)

u
(c(x)u) + a(x)u = f (x),
t

where the coefficients d, c, a, f can also depend on time.


3. Hyperbolic PDE
d(x)

2u
(c(x)u) + a(x)u = f (x),
t2

where the coefficients d, c, a, f can also depend on time.

72

CHAPTER 3. MATLAB AND COMSOL


4. Eigenvalue Problem
(c(x)u) + a(x)u = d(x).u,
where d = d(x) is a complex-valued function on , and is an unknown
eigenvalue.
5. Certain systems of PDEs as well as certain nonlinear equations may
also be solved. We defer to the manual for details.
6. For scalar u the following boundary conditions are supported:
Dirichlet: hu = r on the boundary .
Generalized Neumann: n (cu) + qu = g on .

Solving a Problem
As an example we will use the MATLAB PDE Toolbox to solve one of the
problems studied earlier via finite differences. Specifically consider the elliptic
PDE
uxx + uyy = 0, x ,
over the L-shaped region given below in Figure 3.2 and subject to the
mixed Dirichlet and Neumann boundary conditions
u(x, 0)
u
(0, y)
x
u
(1, y)
x
u

= 100,

0 x 1,

(3.1)

= 0,

0 y 1,

(3.2)

= 0,

0 y 0.5,

(3.3)

= 0,

elsewhere on the boundary.

(3.4)

In order to numerically solve a given PDE with the MATLAB PDE Toolbox
one must carry out the following sequence of steps:
Create the 2D region using the Draw mode.
Specify the boundary conditions using Boundary mode.
Specify and refine the FEM computational grid using Mesh mode.
Specify the PDE coefficients using the PDE mode.

3.2. MATLAB PDE TOOLBOX

73

Figure 3.2: Grid for

Choose plot parameters using the Plot mode.


Run the solver using the Solve mode.
To start the GUI, first start MATLAB as described above, and then in the
Command Window enter
pdetool
at the MATLAB >> prompt, and proceed as follows.
1. Under Options in the menu bar at the top of your screen choose
Axis Limits ... with X-axis range [0.5 1.5] and Y-axis range
[0.5 1.5] (typically we make these slightly larger than the domain to
be drawn); choose Snap and Grid. To draw the domain, under Draw

74

CHAPTER 3. MATLAB AND COMSOL


choose Polygon and move the mouse pointer to the point (0, 0) and
click and drag to start the polygon. Lift off the clicker at the point
(1, 0) to signify a vertex, and then drag to the point (1, 0.5) and lift off
again to signify the next vertex. Proceed like this around the region
and return to (0, 0). The drawing program will call this region P1 and
color it grey.
2. Next we set the boundary conditions. Under Boundary choose Boundary Mode and then choose Show Edge Labels; each boundary
edge now has a number. Then choose EditSelect All and under
Boundary choose Specify Boundary Conditions...; in the dialog
box choose Dirichlet and set h=1 and r=0. This temporarily places
zero Dirichlet data on each boundary; we now change some of them.
Choose the bottom boundary line (labelled 1) by placing the mouse
pointer on it and clicking once. If you now double-click it will bring
up a dialog box; keep the Dirichlet choice but change the value of r to
r=100. On the left boundary (labelled 6) click and then double-click
and change this to a Neumann condition; we will leave q=g=0. Do the
same for the right boundary (labelled 2) where 0 y 0.5.
3. To set the computational mesh choose MeshMesh Mode; we can
also refine the mesh at this stage, but leave it for now.
4. We next choose the PDE coefficient functions. Under PDE choose
PDE Mode and PDE Specification... and in the dialog box choose
Elliptic and c=1,a=0,f=0.
5. To choose the plot parameters use PlotParameters... and select
Color and Height and Plot in x-y grid and click the Close
button.
6. Finally chose SolveSolve PDE to start the solver (or just click on
the  button). If you wish to mess with the plot parameters, you can
do so, and then just press the Plot button in that dialog box. By the
way this plot can be rotated by clicking and dragging with the mouse
pointer.

3.3. COMSOL

3.3

75

COMSOL

COMSOL is a large2 commercial grade PDE solver capable of handling a


wide variety of both 2D and 3D problems. The company was started in
Sweden by a group of students of the mathematician and numerical analyst
Germund Dahlquist at KTH3 by writing the software behind the MATLAB
PDE Toolbox under license to MathWorks. Later they produced an expanded
3D version called FEMLAB, still tightly associated with MathWorks. When
they tried to break away, MathWorks sued them in an American court and
won a large settlement4 , almost bankrupting the fledgling COMSOL. They
survived to become one of the major players in the area of 3D multi-physics
modeling including computational fluid dynamics (CFD), electromagnetism,
acoustics, chemical engineering models, deformation of solids and structural
analysis, microfluids, plasma models, heat transfer, and geophysics modeling.
You may download the COMSOL user manual from
http://people.cas.uab.edu/iknowles/ma461/comsol/ComsolUserGuide.pdf
In the Mac Lab HHB221 you can start COMSOL by double-clicking the
COMSOL icon

in the MacBook Dock.


Creating a New Model in COMSOL
Typically one works through the following sequence of steps that are not
unlike the MATLAB PDE Toolbox steps used above, but this is happening
on a much bigger stage.
1. Work through the COMSOL Model Wizard which will require you
to select the coordinate system for the model (2d or 3d, etc) , the
2

the user manual is 839 pages, just for starters!


the Royal Institute of Technology in Stockholm
4
north of ten million dollars
3

76

CHAPTER 3. MATLAB AND COMSOL


relevant physics for the problem, and the type of study you wish to
perform (time dependent or stationary).
2. Define the parameters, equations and variables pertinent to the model
(Global Definitions).
3. Define the geometry of the model, i.e. draw the region (Geometry).
4. Select the materials you wish to use in your model (Materials).
5. Select the boundary, bulk and initial conditions for your system for
each physics you are using. This will be entered separately for each
different physics you are using, so for example, you will need to enter
these for Laminar Flow and again for Heat Transfer if you are using
both.
6. Choose the element size to be used, i.e. set the computational mesh
for the problem (Mesh).
7. Adjust solver parameters and compute (Study).
8. Display the desired results in the most meaningful way, i.e. set the plot
parameters (Results).

Not all of these steps are always necessary when building a model. The order
is also variable depending on the complexity of the model. As an example
try constructing a heat flow model by following the detailed instructions in
http://www.math.uab.edu/knowles/ma461/comsol/tutorial.pdf
Be aware here that on Mac machines, right-click means control -click while
left-click means click, and in the setting of boundary conditions, if you
wish to set a common condition for several boundary pieces at once, you
should click on the first piece (it should turn red) and then command -click
on the rest to add them to the first piece.

Chapter 4
Continuum Mechanics
We present here a basic introduction to the mechanics of continuous matter.
In modelling certain behaviours of matter it is advantageous to regard the
matter as a continuum, i.e. a material that is divisible down to the smallest
length scales, a point of view that originated with the philosophers of ancient
Greece. Science has of course since embraced the atomistic view of matter,
a theory that also dates back to the Greeks! Nonetheless, for many areas of
interest including such macroscopic concerns as fluid flow and the defor-

Figure 4.1: French mathematician Augustin-Louis Cauchy, 1789-1857


mation of solid objects, the continuum approach has proven, and continues
to prove, exceptionally fruitful. We follow the line of work begun by Cauchy
that continues unabated today.
77

78

CHAPTER 4. CONTINUUM MECHANICS

It is common to distinguish four states of matter: solid, liquid, gas, and


plasma. Determining exactly which of these four states best describes a given
piece of matter can be a highly non-trivial process, which we do not pursue
here. We also do not discuss the plasma state. In solids, the constituent particles are disinclined to move relative to one another, whereas such movement
is the norm for liquids and gases. For convenience, in the present context we
regard liquids and gases as fluids.

4.1

Equations of Motion

The basic equation of motion governing the flow of solids and fluids is embodied in Newtons second law: the rate of change of momentum equals the
sum of the applied forces.
The applied forces separate into two categories. There are body forces
b, like gravity, with units of force per unit mass, acting on each continuum
volume element: the force per unit volume is b where is the mass density
(mass per unit volume). The second category of force for a continuum is
that which acts on surface elements. The idea here is that one can imagine a
blob of material acted upon, and surrounded by, the rest of the material.
This action takes place at the surface of our blob, directed toward the interior
of the blob. By Newtons third law there is an equal reactive force directed
outwardly, away from the blob. Such effects are expressed as force per unit
surface area and can be directed normally to the surface, as in the inflation
of a balloon, but need not be, as one can see when a cylinder is immersed
and rotated in different fluids. The stickier (more viscous) fluid requires
more torque to achieve the same angular velocity.
In general the surface force per unit area acting on a surface with normal
n has both normal and tangential components. One can describe the force
per unit area through any surface passing through a point x by means of the
stress matrix (tensor)

11 12 13
= 21 22 23 .
31 32 33
Here, T(e1 ) = 11 (x)e1 +12 (x)e2 +13 (x))e3 represents the components (one
normal and two shear) of the force per unit area acting on the plane through
x normal to the x-axis, T(e2 ) = 21 (x)e1 +22 (x)e2 +23 (x))e3 represents the

4.1. EQUATIONS OF MOTION

79

Figure 4.2: Stress tensor and Cauchy tetrahedron

components of the force per unit area acting on the plane through x normal
to the y-axis, and T(e3 ) = 31 (x)e1 + 32 (x)e2 + 33 (x))e3 represents the
components of the force per unit area acting on the plane through x normal
to the z-axis. Then, the force per unit area acting on the plane through x
with unit normal n is T(n) = T n and
!
3
3
3
X
X
X
(n)
(e1 )
(e2 )
(e3 )
T = n1 T +n2 T +n3 T
=
ni
ij ej =
(j n)ej (4.1)
i=1

j=1

j=1

where j denotes the j-th column of .


If we choose a basis m = {m1 , m2 , m3 } of three dimensional space so
that the stress matrix becomes diagonal

(m)

1 0 0
(m)
2 0 ,
= (ij ) = 0
0 0
3

the three components


1 >
2 >
3 are called the principal stresses; they
are the eigenvalues of the matrix . If one of the principal stresses is zero
the material is said to deform in a state of plane stress, as may be seen in
Figure 4.3 where we have chosen
3 = 0. In that case i3 = 0, 1 i 3, and
the stresses do not vary significantly throughout the thickness of the plate

80

CHAPTER 4. CONTINUUM MECHANICS

Figure 4.3: Plane stress

If we look at a volume V of the material and let v be its velocity, then,


given that is the mass density (mass per unit volume), v is the momentum
density (momentum per unit volume) and the total momentum is
Z
v dxdydz.
V

Also, as b is the force per unit volume (the force density) the total body
force on our volume V is
Z
b dxdydz.
V

Finally, from (4.1) the j-th component of the total stress (i.e. internal) force
acting on the boundary of V is
Z
Z
j n dS =
j dxdydz
V

from the Gauss divergence theorem. Consequently if we define


= ( 1 ) e1 + ( 2 ) e2 + ( 3 ) e3 ,
we have from Newtons second law that
Z
Z
Z

v dxdydz =
(v) dxdydz = ( + b) dxdydz.
t V
V t
V

4.2. LINEAR ELASTICITY

81

Thus for every volume V of the material, small or large, we have


Z
(a b) dxdydz = 0.
V

where, we have assumed that the density does not depend on time, and
set a = v/t as the acceleration vector. The above can only happen if the
integrand is identically zero at all points of our material. So we have the
following equation of motion:
a = + b.

(4.2)

This is a crucially important equation for us, but at this stage of the
development, it is not very practical. Even if we assume that the body force
b is known, we have twelve unknown functions ( has nine components and
a has three) and there are only three equations here.
Further physical properties and principles are needed. For example, if
angular momentum is conserved1 , then one can show that = T , which
reduces somewhat the number of unknown functions. For further progress, we
have to be more specific about what sort of material we are modelling. This
is usually accomplished by specifying a constitutive law of the material.
These cannot be given arbitrarily, as possible forms of the stress tensor are
limited by, for example, frame indifference, the principle that the results of
any experiment should be independent of the coordinate axes used to make
the measurements.
The fact that we cannot proceed further until a constitutive law has been
specified indicates that at this point our general continuum theory begins to
separate along different branches. In the sequel we explore separately the
theories for elastic solids and fluids.

4.2

Linear Elasticity

The basic idea here is that when a solid is deformed by the application of
a force, the change in a characteristic length in the solid is proportional to
the applied force, a principle commonly known as Hookes law. For small
deformations, this law has a solid experimental foundation.
1

it need not be so; volumetric body torque can exist, for example, in ferromagnetic
liquids

82

CHAPTER 4. CONTINUUM MECHANICS

Conceptually, it is easy to grasp what is happening when the solid is a


one-dimensional object, such as a thin wire or a spring stretching from `0 to
` = `0 + : The engineering strain e defined by
e =

l l0

=
l0
l0

is used to quantify the amount of stretch in a specimen.

4.2.1

The Displacement Field

When three-dimensional objects are under consideration, the deformation


is considerably more complicated. The appropriate generalization of 1-D
strain makes use of the displacement field u = (u1 , u2 , u3 )T which is a vector
function of three variables that describes the movement of each point in a
solid. As shown in Figure 4.4 a point x = (x1 , x2 , x3 ) in the undeformed solid

Figure 4.4: Displacement field u(x1 , x2 , x3 )

moves to a new position y where


y = x + u(x).
The displacement field completely specifies the change of shape of the solid.
If you imagine a straight line in the undeformed solid being deformed into
a curved line, as shown in Figure 4.4, we can assume that the curve is made

4.2. LINEAR ELASTICITY

83

from a number of short straight line segments dw (we can call these line
elements), each of which has resulted from the deformation of a line element
dx as in Figure 4.5. Each line element dx is both stretched and rotated to
its final form dw. Notice the vector equation

Figure 4.5: Deformed line elements

dw = x + dx + u(x + dx) x u(x).


From the Taylor theorem for u we have, to first order terms, that
u(x + dx) = u(x) + u dx
where u denotes the matrix of gradients (also called the displacement gradient tensor):

u1 u1 u1
x x x
1
2
3

u u u
2
2
2
u =

.
x1 x2 x3
u u u
3
3
3
x1 x2 x3
We assume in this section that all elements of the deformation gradient matrix u are considerably smaller than one in absolute value. So we have
the vector identity (accurate to first order terms)
dw = dx + u dx.

(4.3)

84

4.2.2

CHAPTER 4. CONTINUUM MECHANICS

The Strain Tensor

We are now in a position to generalize the 1-D strain measure discussed


earlier. Suppose that we mark out an imaginary tensile specimen with a

Figure 4.6: Engineering strain

very short length l0 and with direction specified by the unit vector m = (mi )
as shown in Figure 4.6. The engineering strain e of the specimen is given by
e =

l l0
.
l0

So dx = l0 m, and using (4.3) we have that


l2 = |dw|2 = l02 (m + u m) (m + u m)
= l02 (1 + 2u m m)
after ignoring terms that are products of small values. Thus

l
e (m) = 1 = 1 + 2u m m 1 = u m m
l0

to first order accuracy, using the linear approximation 1 + x 1 + x/2


which is valid for x small.
Now, for any unit vector m = (mi ),
m u m =

3
X
j=1

mj [u m]j =

3
X
j=1

mj

3
X
uj
i=1

xi

mi

4.2. LINEAR ELASTICITY

85

and
m u m =

3
X

mi [u m]i =

i=1

3
X
i=1

3
X
ui
mi
mj .
xj
j=1

So
3
3
X
1X
uj
ui
m u m =
mj mi (
+
)=
mj mi ij
2 i,j=1
xi xj
i,j=1

where the terms


1 uj
ui
ij = (
+
)
2 xi xj
make up the strain tensor E = (ij ).
2D Strain Tensor: Physical Interpretation
The terms in the strain tensor closely relate to physical deformations. We
illustrate this connection in the 2-D case using Figure 4.7. If we let dx = e1 ,

Figure 4.7: 2-D Strains

then the engineering strain e = 11 ; i.e. in Figure 4.7 xx = 11 , with a similar
interpretation for 22 ; these are called the direct strains. The shear strain,
denoted as the angle xy complementary to the angle between OA0 and OB 0 ,
satisfies
xy
yx
12 = 21 =
=
.
2
2

86

CHAPTER 4. CONTINUUM MECHANICS

To see this observe that


OA0 OB0 = |OA0 | |OB0 | cos(/2 xy )
= l02 (1 + 11 )(1 + 22 ) sin xy
= l02 xy ,
where we have used the fact that sin x x for x small, and ignored products
of small terms, as usual. Otherwise, using (4.3) we find that
OA0 OB0 = l02 (e1 + u e1 ) (e2 + u e2 )
= l02 (u e1 e2 + u e2 e1 )
u1 u2
= l02 (
+
)
x2 x1
= 2l02 12 ,
ignoring products of small terms again. Thus 12 = xy /2, as stated above.
Another useful observation is that if we define W = (wij ) where
1 ui
uj
wij = (

)
2 xj
xi
then it can be shown that
dw = dx + u dx = Edx + (dx + Wdx)
where Edx is a pure strain, and dx + Wdx is a pure rotation.

4.2.3

Principal Strains

The strain matrix E is symmetric, so one can always find a new basis m =
{m1 , m2 , m3 } of three dimensional space so that E becomes

e1 0 0
(m)
E(m) = (ij = 0 e2 0 ,
0 0 e3
a diagonal matrix. The quantities e1 > e2 > e3 are called principal strains.
The principal strains are the eigenvalues of the matrix E.

4.2. LINEAR ELASTICITY

87

Figure 4.8: Plain strain

4.2.4

Plane Strain

A solid is said to deform in a state of plane strain if one of the principal


strains is zero. By way of example, one can imagine as in Figure 4.8 that the
solid is prevented from expanding axially by rigid frictionless walls, and the
loading on its lateral boundary is independent of x3 . Every x1 x2 -plane in the
solid deforms the same way, so that stresses and strains are independent of
x3 and 3i = i3 = 0.

4.2.5

Stress-Strain Relations

We obtain a three dimensional generalization of Hookes law by insisting that


the components of the stress tensor be linear functions of the components of
the strain tensor. An elastic solid in which the stresses are linear functions
of the strains is called a linear elastic solid or a Hookean material. For
small deformations most materials are Hookean. For larger deformations
many materials, for example rubber and many biomaterials and metals, are
non-Hookean and require alternate theories. Being Hookean means that the
stress-strain relations take the (nine equation) form
11 = C1111 11 + + C1133 33
12 = C1211 11 + + C1233 33
..
.
33 = C3311 11 + + C3333 33
In component form
ij =

3
X
k,l=1

Cijkl kl

(4.4)

88

CHAPTER 4. CONTINUUM MECHANICS

for 1 i, j 3. The components Cijkl make up the fourth order elastic


tensor which nominally has 81 components. The strain matrix is symmetric;
if we assume that the stress matrix is also symmetric then it follows that
Cijkl = Cjikl ,

(4.5)

for all indices i, j, k, l. If we further assume that the material is isotropic


so that its mechanical properties can be described without reference to direction, as illustrated in Figure 4.9, then the components Cijkl must remain

Figure 4.9: Isotropic solid

unchanged with respect to all rotations of the coordinate axes (i.e with respect to all choices of orthogonal basis sets in three dimensional space). We
now show that isotropy combined with the symmetry from (4.5) reduces the
effective number of components in the elasticity tensor to two.
Notice first that if we change from the Cartesian coordinate system generated by the standard unit vectors {e1 , e2 , e3 } to a new one generated by the
orthogonal matrix A (whose columns constitute the new basis set), then the
new coordinates of a point x would be x0 = Ax. Furthermore, for any unit
normal vector n the stress force at a point x in a surface with normal n is
T = n. Under the above change of coordinates the stress force at x0 = Ax
(the same point, but with the new coordinates) relative to the new normal
n0 = An is T0 = 0 n0 . Physical reality dictates that the stress force does not
depend on our choice of Cartesian coordinate system, so for all choices of n,
we have (in the new coordinates)
An = AT = T0 = 0 n0 = 0 An.
This leads to the matrix identity A = 0 A or 0 = AAt , where At = A1
is the transpose of the orthogonal change of basis matrix A. If A = (aij )

4.2. LINEAR ELASTICITY

89

then the components ij0 of in the new coordinate system are given by the
formula
3
3
3
X
X
X
0
ij =
air
rs ajs =
air ajs rs .
r=1

s=1

r,s=1

An entity that transforms in this manner under a change of basis is called a


tensor of type (2,0) or more loosely as a second order tensor; we can think
of as just a matrix.
Following on, we next note that under the same change of basis we have
from (4.4) that the elasticity tensor C transforms to the components
0
Cijkl

3
X

Cpqrs aip ajq akr als ,

p,q,r,s=1

so that C is a fourth order tensor. If we assume that the material is isotropic


then the elasticity tensor must have the same components in all sets of rotated
Cartesian axes, so
Cijkl =

3
X

Cpqrs aip ajq akr als ,

(4.6)

p,q,r,s=1

for all 1 i, j, k, l 3. It follows from these equations that the 81 quantities


Cijkl reduce to just three. To see this we first rewrite (4.4) in the form
= P1 11 + P2 22 + P3 33 + Q1 23 + Q2 31 + Q3 12 ,

(4.7)

where the Pi , Qi are 3 3 symmetric matrices. At this stage we effectively


have 36 unknown components in these six matrices.
Consider now the special case

1 0 0
A1 = 0 0 1
0 1 0
which corresponds to rotating the original axes through /2 about the e1
axis. Then for  = (ij ) we have

11
13 12
33 23
0 = A1 At1 = 13
12 23 22

90

CHAPTER 4. CONTINUUM MECHANICS

so that
011 = 11 ,

022 = 33 ,

033 = 22 ,

023 = 23 ,

031 = 12 ,

012 = 31 .
(4.8)

The isotropy condition (4.6) now informs us that


0 = A1 At1 ,

(4.9)

and on combining this with (4.7) and (4.8) we have


A1 P1 At1 11 +A1 P2 At1 22 +A1 P3 At1 33 +A1 Q1 At1 23 +A1 Q2 At1 31 +A1 Q3 At1 12
= P1 11 + P2 33 + P3 22 Q1 23 Q2 12 + Q3 31 . (4.10)
If we equate the terms in

p11

p12
P1 =
p13

11 we see that P1 = A1 P1 At1 . It follows that


p12 p13
p11 p13 p12
p22 p23 = p13 p33 p23
p23 p33
p12 p23 p22

so that p12 = p13 and p12 = p13 , which means that p12 = p13 = 0, and
p23 = p23 , so that p23 = 0 as well. We also have p22 = p33 and p11 is free,
so P1 has the form

0 0
P1 = 0 0
0 0
where and are free parameters. A similar argument

0 0 1
0 1

1 0
0 1 0
A2 =
and A3 =
1 0 0
0 0

using

0
0
1

gives, successively,

0 0
0 0
P2 = 0 0 and P3 = 0 0 .
0 0
0 0
Next we equate the terms in 23 in (4.10) to get A1 Q1 At1
that

q11 q12 q13


q11
q13

q12 q22 q23


q13
q33
Q1 =
=
q13 q23 q33
q12 q23

= Q1 . This means

q12
q23 .
q22

4.2. LINEAR ELASTICITY

91

So, q11 = q11 and thus q11 = 0. Also q12 = q13 and q12 = q13 so that
q12 = q13 = 0. Finally q22 = q33 and q23 is free, giving Q1 the form

0 0 0
Q1 = 0 ,
0
where and are again free parameters. In like manner, using the coordinate
rotations A2 and A3 one obtains, respectively,

0
0
Q2 = 0 0 0 and Q3 = 0 .
0
0 0 0
Finally, equating the
from which it follows

0 0

0 0
Q1 =
0

coefficients of 12 in (4.10) then gives


that = 0, and we have

0
0 0
0

0 0 0 , Q3 =

, Q2 =
0
0 0
0

Q2 = A1 Q3 At1

0
0 0 .
0 0

We eliminate the parameter as follows. Consider the coordinate rotations

cos sin 0
A = sin cos 0 .
0
0
1
From (4.9) we have that
0
11
= (A At )11
= 11 cos2 + 212 sin cos + 22 sin2
= (11 + 22 + 33 ) cos2 + 212 sin cos
+(11 + 22 + 33 ) sin2 .

But from (4.7), 11 = 11 + 22 + 33 , and thus


0
= 011 + 022 + 033
11
= (11 cos2 + 212 sin cos + 22 sin2 )
+(11 sin2 212 sin cos + 22 cos2 ) + 33 .

92

CHAPTER 4. CONTINUUM MECHANICS

Equating the terms in 12 in the previous two identities we see that =
and we have now reduced the effective number of components in the elasticity
tensor to two, as we can replace with +. We set = 2 and = . Here,
is the Lame modulus and is the shear modulus; these two parameters are
collectively known as the Lame parameters. The stress-strain relation then
takes the matrix form

11
+ 2

0 0 0
11
22

+ 2

0 0 0


22
33

+ 2 0 0 0


33
12 =

0
0
0
2 0 0 12

13
0
0
0
0 2 0 13
23
0
0
0
0 0 2
23
assuming that no change in temperature takes place in the material. Alternately, this may be written in component form as
ij = ij

3
X

kk + 2ij ,

(4.11)

k=1

where


ij =

1 if i = j,
0 if i 6= j

are the components of the identity matrix, also called the Kronecker delta.
In practical problems, other elastic parameters that can appear include
Youngs modulus
(3 + 2)
E=
+
and with units of Nm2 and the dimensionless Poissons ratio

=
.
2( + )
Youngs modulus is the slope of the stress-strain curve in uniaxial tension and
represents the stiffness of the solid with larger values for more stiff materials.
The Poisson ratio is the ratio of lateral to longitudinal strain in uniaxial
tensile stress, and typically ranges from 0.2 to 0.49. It is a measure of the
compressibility of the solid, with = 0.5 representing an incompressible
solid. If = 0 then stretching the solid causes no lateral contraction; there
are some bizarre materials with < 0, so that on stretching a round bar of
the material, the bar increases in diameter!

4.2. LINEAR ELASTICITY

93

Figure 4.10: Youngs modulus and Poissons ratio

4.2.6

The Elasticity Equations

The equation of motion for an elastic body undergoing a deformation u may


now be found by combining equations 4.11 and 4.2 with the fact that a = utt .
Here from (4.2) for fixed i
3

X ji
2 ui
,
2 = i + bi = bi +
t
xj
j=1
where from (4.11) for 1 j 3,
ji = ji

3
X
k=1

kk + 2ji = ji

3
X
uk
k=1

xk


+

ui uj
+
xj
xi


.

So
(

)
3
3
X
X
2 ui

uk
ui uj
2 =
ji
+
+
+ bi
t
x
x
x
x
j
k
j
i
j=1
k=1
( 3
)
 

3
X
X

uk
ui uj
=

+
+ bi
xi
xk
xj
xj
xi
j=1
k=1
3
3
X
X

uj

uj

ui
=
(
(
)+
(
)) +
(
) + bi(4.12)
xi xj
xj xi
xj xj
j=1
j=1

for 1 i 3, where b = (bi ) represents the body force.

94

CHAPTER 4. CONTINUUM MECHANICS

These equations arise in various arenas. In the study of rock vibrations


caused by seismic events, they are known as the seismic wave equations.
More generally they are known as the equations of elastodynamics and they
may be specialized in several ways. If the solid is in static equilibrium for
example, one can assume that utt = 0. Otherwise, there is the useful special
case involving
Plane Stress.
As discussed earlier, in this case we may assume that 33 = 13 = 23 = 0,
and the other stress components do not depend on the z coordinate. We first
note that from (4.11) 33 = 0 = 233 + (11 + 22 + 33 ), so that
(2 + )33 + (11 + 22 ) = 0,
where we note that 33 need not be zero. Also
(3 + 2)
E
=
1 2
2( + )2
(3 + 2)
=
2( + )2
2
=
,
+ 2

4( + )2
4( + )2 2
4( + )2

( + 2)(3 + 2)

and
( + 2)(11 + 22 + 33 ) = ( + 2)(11 + 22 ) (11 + 22 ) = 2(11 + 22 ),
so that
(11 + 22 + 33 ) =

2
E
(11 + 22 ) =
(11 + 22 ).
+ 2
1 2

Thus, for 1 i, j 2, noting that


E
(3 + 2) 2( + )
=

= 2,
1+
+
3 + 2
we have
ij = 2ij +

2
E
E
ij (11 + 22 ) =
ij +
ij (11 + 22 )
+ 2
1+
1 2

4.2. LINEAR ELASTICITY

95

or

11
2 +

0
11
22 =

2 + 0 22
12
0
0
2
12

1
0
11
E
1
0 22 ,
=
1 2
0 0 1
12

(4.13)

where = 2/( + 2). Consequently from (4.2) and (4.13) we have

2 u1
= 1 + b1
t2
2
X
j1
=
+ b1
x
j
j=1

{(2 + )11 + 22 } +


{212 } + b1
x1
x2

u1
u2

u1 u2
=
((2 + )
+
)+
((
+
)) + b1
x1
x1
x2
x2
x2 x1

Similarly,

2 u2
u1 u2

u2
u1
=
((
+
)) +
((2 + )
+
) + b2
2
t
x1
x2 x1
x2
x2
x1

An inspection of these equation shows that they may be rewritten as


2 u1
2 = (c11 u1 + c12 u2 ) + b1
t
2 u2
2 = (c21 u1 + c22 u2 ) + b2
t

(4.14)
(4.15)

where

c11 =

2 + 0
0


c12 =

0
0


c21 =

0
0


c11 =

0
0 2 +


.

This is the form used by the PDEToolbox in the application mode called
Structural Mechanics - Plane Stress. Here the shear modulus is written
as G, and the quantity that we have called is written as in the form

96

CHAPTER 4. CONTINUUM MECHANICS

G/(1 ) where is the Poisson ratio; the body force term b is given as
k and the equilibrium form of the equation is written in the tensor form
(c u) = k

(4.16)

where c is the rank four tensor



c=
and


c u =

4.3

c11 c12
c21 c22

c11 u1 + c12 u2
c21 u1 + c22 u2


.

Fluid Mechanics

We are quite literally surrounded by fluids, from the atmosphere above to the
rivers, lakes and oceans that we are so dependent upon; moreover, given that
human beings are approximately ninety percent H2 O, in a very real way, we
are fluids! So it should come as no surprise that a significant fraction of all
PDE modeling involves some kind of fluid flow.

Figure 4.11: Swiss mathematician Leonhard Euler, 1707-1783


The usual method for describing a fluid flow involves the expression
u = u(x, t)
for the flow velocity vector u = (u1 , u2 , u3 )T of the fluid at any point x and
at any time t. Notice that, in this description one is concentrating attention

4.3. FLUID MECHANICS

97

on what is happening at particular points x, over time, and thus one is


not following a particular fluid particle, as one might do in studying, say,
planetary motion. The former approach, and the one that we use exclusively,
is usually called the Eulerian specification of fluid motion, while the latter
idea (also due to Euler!) is termed the Lagrangian specification.
Once u is known we know what the fluid particles are doing and when they
are doing it. Notice that the basic object of study here is quite different from
the u of elasticity which represents the tiny movements inside a deforming
solid; there is no insistence a priori that the changes in the flow velocity of a
fluid be small in any way.

4.3.1

The Stress-Strain Relation

It is known that in a fluid at rest, the stress (force per unit area) exerted
on a blob of fluid by the surrounding fluid across a plane surface with unit
normal n is pn where the scalar function
1
p = (11 + 22 + 33 )
3

(4.17)

is the pressure, which is here defined2 as the average normal stress. So


ij = p ij
This follows roughly because any deviation from this stress would lead to
deformations of the fluid that would necessarily contradict the fluid being at
rest.
Given this fact, it is reasonable to write the stress for a general fluid (i.e.
one not necessarily at rest) in the form
ij =

pij
| {z }

normal stress tensor

ij
|{z}

viscous stress tensor

where the term ij is called the deviatoric, or viscous, part of the stress tensor
and bears further investigation.
From many experimental observations it has been noted that the terms
ij vary linearly with the imposed velocity and inversely with the length scale
of the apparatus used to study various flows. In such a case, it is reasonable
2

there are other ways to do this, for example via the concept of thermodynamic pressure

98

CHAPTER 4. CONTINUUM MECHANICS

to infer that the ij are linear functions of the velocity gradients ui /xj , in
which case we call the fluid a Newtonian fluid, and we can write
ij =

3
X

Aij

,=1

u
x

where Aij has to be an isotropic tensor because in a typical3 fluid there


are no physically preferred directions. This means that Aij must have the
same components in all sets of rotated Cartesian axes. This together with
the assumed symmetry of the stress tensor ij and the argument employed
above in the elasticity case means that
Aij = ij + i j + i j
for scalar functions , the bulk viscosity and , the dynamic shear viscosity.
Consequently
3
X
ui uj
uk
ij = ij
+ (
+
)
x
x
x
k
j
i
k=1
from which follows the constitutive equation (i.e stress-strain relation) for a
Newtonian fluid
ij = pij + ij

3
X
uk
k=1

xk

+ (

ui uj
+
)
xj
xi

(4.18)

that we have been seeking. The dynamic shear viscosity measures the
response of the fluid to shearing forces, and the bulk viscosity indicates the
response to changes of volume. Using the definition of pressure as average
normal stress as given in (4.17) we see that the trace of the tensor must be
zero. We therefore also have
(3 + 2)

3
X
uk
k=1

xk

= 11 + 22 + 33 = 0.

So = (2/3) and (4.18) becomes


3

ui uj
2 X uk
+
)
ij
ij = pij + (
| {z }
xj
xi
3
xk
k=1
normal stress
|
{z
}
viscous stress

not all fluids are isotropic

(4.19)

4.3. FLUID MECHANICS

4.3.2

99

Application to Hull Design

Consider, by way of example, an Americas Cup yacht moving through the


water. Let represent the hull of the yacht and w be the part of the hull
in contact with the water (usually called the wetting surface). We consider
the stress at a certain point x in w , where the normal to the hull surface
is n, as representing the force per unit area at x across the surface w . As
we know from above, this stress has two parts the normal stress (represented
by the fluid pressure p) and the viscous stress which has a volume part and
a shearing part. Integrating a stress over the wetted surface of the boat
hull gives a force. Specifically we have the pressure drag Dp defined by
ZZ

p dS, for 3d,

w
Z
(4.20)
Dp =

p ds for 2d,

where p is the fluid pressure, the viscosity pressure drag Dvp defined by
ZZ

n ndS, for 3d,

w
Z
(4.21)
Dvp =

n nds, for 2d,

and the friction drag Df defined by


ZZ

n tdS, for 3d,

w
Z
Df =

n tds, for 2d,

(4.22)

where t is normal to n (and horizontal, in the 3d case). The total drag D (at
a certain fixed time and for a given velocity) is
D = Dp + Dvp + Df .

100

CHAPTER 4. CONTINUUM MECHANICS

In earlier times, naval architects and ship designers were forced to construct scale models of proposed hulls and tow them in water tanks4 to ascertain the drag resistance of a hull. This was expensive and time consuming, and often produced poor results when the process did not scale up
properly (compare your bathtub rubber ducky with a battleship). The
modern approach is to make a life-size hull in the computer, work out the
flow around the hull by solving the Navier-Stokes PDE (see below) and then
compute the drag from something like the above formulae. For example,
in the 2D case, once u = (u(x, y), v(x, y))T , n = (nx(x, y), ny(x, y))T , and
t = (ny(x, t), nx(x, y))T are known we have
 

11 12
n t = (11 nx + 12 ny)ny (12 nx + 22 ny)nx
12 22
= (11 22 )ny.nx + 12 (ny 2 nx2 ).
Here

u v
4 u 2 v
+

,
=
11
x y
3 x
3 y


u v
12 =
+
,
y x
2 u 4 v
22 =
+
,
3 x
3 y
so that 11 22 = 2(ux vy) and the 2D friction drag Df becomes
Z
.(2(ux vy)nx.ny + (uy + vx)(ny 2 nx2 )) ds.
u 2

= 2
x
3

In like fashion,

 
11 12
n n = (11 nx + 12 ny)nx + (12 nx + 22 ny)ny
12 22
= 11 nx2 + 22 )ny 2 + 212 nx.ny
4
2
= .[nx2 ( ux vy)
3
3
2
4
2
+ny ( ux + vy) + 2(uy + vx)]
3
3
4

We will adopt much the same approach in the Aussie Cup class boat race later in the
course.

4.3. FLUID MECHANICS

101

and the 2D viscosity pressure drag Dvp becomes


Z

2
2
4
4
.[nx2 ( ux vy) + ny 2 ( ux + vy) + 2(uy + vx)] ds.
3
3
3
3

We note here that for water the shear (or dynamic) viscosity = 8.90 104
Pa-s, so both Df and Dvp are expected to be quite small relative to the
pressure drag.
This process can be done repeatedly to optimize certain design variables
(such as maximizing speed by minimizing drag in the case of Americas
Cup yachts). Similar techniques were used to design the Boeing and Airbus jumbo-sized jets. We note in passing that the main reason that we do
not have a supersonic version of these airplanes is that the Navier-Stokes
equations break down in the transonic region between subsonic and supersonic, and the modeling fails. This is a decades-old unsolved problem looking
for some genius to come forth and crack it.

4.3.3

The Navier-Stokes Equations

Before we appeal to the continuum equation of motion found earlier, an important issue regarding the acceleration of a fluid particle has to be resolved.
Because we are using the Eulerian approach to fluid motion, the term u/t
is, in general, not the acceleration of the fluid particle at x at time t. This

Figure 4.12: Claude-Louis Navier, 1785-1836 and George Stokes, 1849-1903


is because the fluid element at position x and time t is located at position

102

CHAPTER 4. CONTINUUM MECHANICS

x + ut at time t + t, so the change in velocity over the small time interval


t is
u(x + ut, t + t) u(x, t) = u(x + ut, t + t) u(x + ut, t)
+u(x + ut, t) u(x, t)


u
u
u
u
+ u1 t
+ u2 t
+ u3 t
= t
t
x1
x2
x3
2
+O(t )


u
= t
+ (u ) u + O(t2 ),
t
and thus on dividing by t and letting t 0 we see that
a(x, t) =

u
+ (u ) u.
t

(4.23)

From (4.19) and (4.23) substituted into the equation of motion (4.2) and
assuming that u = (ui ) we have for 1 i 3 the equations
3

p X
ui
ui uj
2
+ (u ) ui ) =
(
+
((
+
))
( u) + bi .
t
xi j=1 xj
xj
xi
3 xi
(4.24)
This system of three equations originates in Newtons second law. If we
presume that the body force b and the shear viscosity are known, we seek
five unknowns: u1 , u2 , u3 , the pressure p, and the density .
Another equation, the conservation of mass equation is found by the
following argument. Consider a blob of fluid that occupies the region V , with
surface S. The total mass of fluid in V at time t is
Z
(x, t) dxdydz.
V

If we presume that fluid material is not added to, or subtracted from, the
interior of V through the presence of source or sink points, then all
material must leave or enter V through the surface S of V . Let us calculate
the amount of material that would pass through a small piece of surface
S in time t. To do this we must first recognize that the component of u
tangential to the surface cannot contribute to fluid particles moving through
S, so we restrict attention to the normal component of u, u n. In this time a

4.3. FLUID MECHANICS

103

fluid particle would travel a distance u nt, and you can imagine a cylinder
of fluid particles with base area S and height u nt being filled with these
particles. The total mass of these particles is u ntS and the rate of exit
through S is u nS. The rate at which fluid material exits V is then
Z

Z
u n dS =

(u) dxdydz
V

after applying the Gauss divergence theorem. Consequently we may equate


two expressions for the the rate of change of fluid mass in V to get

Z
(x, t) dxdydz =

(u) dxdydz.
V

This rewrites to
Z
(
V

+ (u)) dxdydz = 0
t

which must hold for all blobs V . This leads to the conservation of mass
equation

+ (u) = 0.
(4.25)
t
The two equations (4.24) and (4.25) are called the Navier-Stokes equations
for compressible viscous fluid flow for the five unknown scalar functions u, p,
and .
As they stand these four equations are still incomplete. At this level
of generality, one must make further assumptions. For example one could
assume the perfect gas law
p = RT
where R is the universal gas constant and T is the temperature. If T is constant, one can then solve this system; if not, one must add another equation,
the energy equation to complete the system.
As an alternative to the approach of the last paragraph, one can also
choose to make further simplifying assumptions, and these can take many
forms, as we see below.

104

4.3.4

CHAPTER 4. CONTINUUM MECHANICS

Incompressible Fluids

A fluid is incompressible if the density is constant. It follows from the


conservation of mass equation (4.25) that
u = 0.

(4.26)

As a general rule liquids, such as water, tend to be incompressible, while


gases, such as air, tend to be compressible.
Incompressible Viscous Fluid
The assumption of incompressibility leads, via (4.26), to a considerable simplification of the equation of motion (4.24).
We assume for convenience that the viscosities and are constant. In
consequence (4.24) may be written in the vector form
(

3
3
X
2u
X uj
u
+ (u )u) = p +
+ ( u) + b
+

2
t
x
x
x
i
j
j
j=1
j=1

= p + ( + )( u) + 2 u + b
where
2 =
and
u = u1

2
2
2
+
+
.
x21 x22 x23

+ u2
+ u3
.
x1
x2
x3

From (4.26) it is clear that


u
1
+ (u )u = p + 2 u + b
t

(4.27)

where = / is called the kinematic viscosity. The equations (4.26) and


(4.27) are the Navier-Stokes equations for an incompressible viscous fluid.
There are four equations for the four unknowns u1 , u2 , u3 and the pressure p.
This system forms the starting point for many industrial modeling projects.
The equations require suitable initial and boundary conditions consisting
of specifying p(x, 0) and u(x, 0) together with the requirement that at any
solid boundary in the flow the flow velocity be identical to that of the boundary; in particular, at stationary boundaries, the requirement is that u = 0,
the so-called no-slip condition.

4.3. FLUID MECHANICS

105

Hagen-Poiseuille Flow
The flow of an incompressible viscous fluid through a pipe of uniform circular
cross-section is known as Hagen-Poiseuille flow after Gotthilf Hagen5 and
Jean Louis Marie Poiseuille6 who independently investigated this type of
flow experimentally; the latter was interested in the flow of human blood in
narrow tubes.
One usually makes the following assumptions. Consider cylindrical polar
coordinates, and u = (ur , u , uz )T . Furthermore
the flow is steady, so u/t = 0;
the radial and swirl components are zero, so ur = u = 0;
the flow is axisymmetric, so uz / = 0, and fully developed in the
sense that uz /z = 0 as well.
also p/r = p/ = 0, so p = p(z) and b = 0.
Under these conditions and using the cylindrical polar form of the Laplacian
we have that


uz
1 p
1
,
r
=
r r
r
z
from which we see that

uz
r
c1
=
pz +
r
2
r

and hence

1 p 2
r + c1 log r + c2 .
4 z
Given that uz is finite at r = 0 we have c1 = 0 and from the no-slip
condition at the boundary r = R we see that c2 = (p/z)R2 /(4), so that
uz =

uz =

1 p 2
(R r2 ).
4 z

In particular, as one might expect, the maximum velocity occurs at the pipe
centerline (r = 0):


R2
p
uz,max =

.
4
z
5
6

German physicist and hydraulic engineer, 1797-1884


French physician and physiologist, 1797-1869

106

CHAPTER 4. CONTINUUM MECHANICS

The average pipe velocity can be obtained by integrating over the pipe crosssection C:
ZZ
1
uz,avg =
uz dS
R2
C
Z 2 Z R
1
uz r drd
=
R2 0
0
Z R
2
=
uz .r dr
R2 0
Z R
pz
=
(R2 r2 )r dr
2R2 0
R
pz  2
(R r2 )2 0
=
2
8R
uz,max
=
.
2
Assume now that the pressure decreases linearly down the length of the pipe,
so that if p represents the pressure change down a pipe of length L we have
(p/z) = p/L and, setting D = 2R as the pipe diameter we get
uz,avg =

D2 p
,
32 L

which rearranges to
32Luz,avg
.
D2
This is known as the Hagen-Poiseuille formula (or law) which was derived
experimentally. It is a nice confirmation of the validity of the Navier-Stokes
equations in this case.
p =

Incompressible Inviscid Fluid


An inviscid fluid is one in which the dynamic shear viscosity and the bulk
viscosity are both identically zero. An incompressible and inviscid fluid is
also called an ideal fluid. Such a fluid does not exist in practice of course,
but under certain circumstances fluids like water may be approximated in
this way. For an ideal fluid the vector equation (4.27) takes the form
u
1
+ (u )u = p + b.
t

(4.28)

4.3. FLUID MECHANICS

107

Equations (4.26) and (4.28) are usually known as the Euler equations. The
Euler equation of motion (4.28) may be expanded as the system
u1
u1
u1
u1
1 p
+ u1
+ u2
+ u3
=
+ b1
t
x1
x2
x3
x1
u2
u2
u2
u2
1 p
+ u1
+ u2
+ u3
=
+ b2
t
x1
x2
x3
x2
1 p
u3
u3
u3
u3
+ u1
+ u2
+ u3
=
+ b3
t
x1
x2
x3
x3
of three non-linear first order partial differential equations.
These equations are simpler than the full Navier-Stokes equations, but
their use requires careful attention to their sometimes fatal deficiencies. It is
a general fact that the act of omitting terms that may appear small but that
result in a lowering of the order in a differential equation is an inherently risky
proposition, and the omission of the viscosity terms in the Navier-Stokes to
obtain the Euler equations further underlines this. For example, one can no
longer insist on the no-slip boundary condition in the Euler case; instead, one
can at best insist that there is no flow normal to the boundary. This means
that one cannot in general extract, for example, lift and drag information for
air- and hydro-foils from the Euler equation formulation. As a working rule,
one should be careful in interpreting the results of Euler equation calculations
in the parts of the domain that are in close proximity to a boundary.
If the body force is that of gravity (the most common choice) then we
have that
b = ()
where = gx3 , provided that we take x3 to be the vertical direction. Here, in
writing the gravity force in this way, we are observing that it is a conservative
force, i.e. it can be written as the gradient of a scalar function, called a
potential function.
A streamline is a curve that is everywhere parallel the the velocity vector
u of the fluid. We say that the fluid is undergoing steady flow if the velocity
u does not depend on time. Then the Euler equation becomes
p
(u )u + ( + ) = 0.

From the vector identity


1
(u )u = ( u) u + ( u u)
2

108

CHAPTER 4. CONTINUUM MECHANICS

the Euler equation above may be rewritten as


( u) u = H

(4.29)

where H = p + 12 u u + . As u ( u) u = 0 we have that u H = 0,


so that the directional derivative of the scalar function H is always zero in
the direction of u, i.e. along streamlines. This leads us to the
Bernoulli Streamline Theorem
For steady flow of an ideal fluid the scalar function
H=

p 1
+ uu+
2

(4.30)

is constant along streamlines.


Notice that, in general, the constant will be different along different
steamlines. This result is useful for determining the pressure p once that
velocity u is known.
Incompressible Irrotational Fluid
A fluid with velocity u is irrotational if u = 0. More generally, we define
= u to be the vorticity of the fluid. Physically, the vector provides a
measure of the local rotation, or spin, of fluid elements; it is of fundamental
importance to both theoretical and computational fluid mechanics. An inspection of (4.29) shows that for an ideal fluid undergoing steady irrotational
flow the quantity H defined by (4.30) is now a constant throughout the whole
flow region; this is the Bernoulli theorem for irrotational flow and provides a
direct calculation of p provided that u can be determined.
In order to compute u we first observe that, from a theorem in vector
analysis (see for example MA444) as u = 0 there exists a scalar function
, called the velocity potential with
u = .

(4.31)

This is an extraordinary property! It means that instead of having to solve


three equations for the three unknown functions u1 , u2 , u3 we now only need
to find one function, the velocity potential , and then use (4.31) to compute
u. The relevant equation for follows from (4.26):
2 = 0.

4.3. FLUID MECHANICS

109

Again, one cannot impose no-slip boundary conditions here; typically one
imposes conditions amounting to enforcing no flow through the boundary.
As an example consider Newtonian fluid flow through the tapered pipe
or bottleneck shown below: it is assumed that the flow is incompressible,

Figure 4.13: Flow through a bottle-neck

inviscid, irrotational, and steady. In this case there exists a scalar function
such that the fluid velocity vector u may be written as
u =
and the Navier-Stokes equations reduce to
2 2 2
+
+
= 0.
x21 x22 x23
Assuming that the axis of the tapered pipe is x1 , we convert to cylindrical
coordinates defined by (x1 , r, ) where x2 = r cos and x3 = r sin and
1 2
2 2 1
+
+
+
= 0,
x21
r2
r r r2 2
and we continue to use to represent the velocity potential. It may be
assumed that the flow is symmetric with respect to the axis x1 so that there
is no variation of the potential function in . The cylindrical Laplace
equation then becomes
2 2 1
+ 2 +
= 0,
x21
r
r r

110

CHAPTER 4. CONTINUUM MECHANICS

which rearranges to

x1






r
+
r
= 0.
x1
r
r

Figure 4.14: Polygonal region: y is the radial distance


Finally, if we set x = x1 and y = r we can use the PDEtoolbox to solve
(y) = 0
for the potential (x, y) over the polygonal region of the xy-plane indicated
by the shaded portion of the diagram above, and under boundary conditions
discussed below.
The boundary condition on the top three sides of the polygon recognizes
that the velocity of the fluid in the direction normal to the boundary vanishes;
so we use the Neumann condition
n (y) = 0.
On the lower side we note that the flow should be symmetrical about the x
axis, with no flow across this axis; so the above Neumann condition is also
valid here. At the vertical boundary on the left we assume that the fluid flows
in, parallel to the x axis, at v0 = 0.01 meters per second; as n = (1, 0) on
this boundary, we have the Neumann condition
n (y) = 0.01y

4.3. FLUID MECHANICS

111

holding here. Finally, at the vertical exit boundary on the right side of
the region, we do not know the velocity, but we may assume laminar flow
away from the bottle-neck and we can fix the potential to any constant; it is
convenient to choose the Dirichlet condition = 0 here.
For inviscid, incompressible, irrotational, but unsteady flow we note that
p 1
+ + ||2
t
2
is a function of time only. This may be used to compute p from in an
analogous fashion.

4.3.5

Compressible Fluids

Because of the difficulties associated with solving the full system for compressible viscous flow, which generally means that one has to include temperature and internal energy effects, it is often convenient to make further
simplifying assumptions.
Compressible Inviscid Fluids
As the viscosities of gases tend to be a great deal lower that those of liquids,
and gases tend to be compressible while most liquids are incompressible, the
assumption of compressible inviscid flow is frequently quite acceptable in the
gas case. The Navier-Stokes equations (4.24) become
1
u
+ (u )u = p + b,
t

(4.32)

and of course we have as before the conservation of mass equation

+ (u) = 0.
t

(4.33)

In general, this approximation is valid for applications in which expansion


and compression of the fluid take place so rapidly that the heat loss and gain
do not have time to be conducted to neighboring fluid particles. Such is the
case, for example, in acoustics. These assumptions can be shown to imply
that
p = K ,

112

CHAPTER 4. CONTINUUM MECHANICS

where is the ratio of specific heats at constant pressure and constant volume, respectively. For air 1.4. Such an equation is called an equation
of state and we now have five equations for the five unknowns u1 , u2 , u3 , p, ;
these are the equations of compressible inviscid flow.
In general, we can assume that p = f (), or even p = f (, S) where S
is the specific entropy; although we do not treat the latter case specifically,
the approach is essentially the same. In the case of sound moving in air, for
example, we can make further simplifications.
The Acoustic Wave Equation
Sound is a compression and rarefaction disturbance that can travel through
a fluid medium such as air. This disturbance can be modeled by determining
the pressure variations p0 around a base pressure p0 :
p = p0 + p0
In the same way we can represent the density in terms of variations 0 around
a base density 0 , = 0 + 0 . In line with the fact that most sound disturbances involve very small variations, we may assume that p0 and 0 and the
velocity u0 = u are all small functions, together with their derivatives. If we
substitute these forms into the Euler equation (4.32) and ignore products of
small terms and set b = 0, we obtain the linearized Euler equation
u0
+ p0 = 0.
0
t
In similar fashion, the linearized mass equation (4.25) becomes
0
+ 0 u0 = 0.
t
Finally, if we differentiate the equation of state p = f () at = 0 we get
p0
f
0
=
(0 )
t

t
Then if we define the speed of sound c by
c2 =

f
(0 )

4.3. FLUID MECHANICS

113

we have


2 0
2 p0
u0
u0
2
2
2
= c 0
= c2 p0
=c
= c 0
t2
t2
t
t
If we now ignore the base pressure p0 and rewrite p for p0 we arrive at the
acoustic wave equation
2p
= c2 p.
(4.34)
t2
for the pressure variations in a sound wave travelling through a gas.

4.3.6

The Reynolds Number and Boundary Layers

The study of viscous flow contains an inherent dilemma. It is better to use


the full Navier-Stokes equations but these are very difficult to deal with under
typical circumstances. We could use the Euler inviscid equations but they
are questionable near the boundary. In general, to examine viscous effects
close to a solid boundary, an effective approach is to decide which terms in
the Navier-Stokes equation are important by carefully analyzing their relative
sizes.
This process is most easily accomplished by the standard process of using
dimensionless variables in the equations. By this we mean linearly scaling
each of the variables so as to end with the situation in which all variables,
dependent as well as independent, are dimensionless.
For example, let us assume that the typical lengths and velocities in
the flow are represented by the constants L and U . Set
t=

L 0
t,
U

x = Lx0 ,

u = U u0 ,

p = U 2 p0 .

where the new variables t0 , x0 , u0 , p0 are dimensionless. Then the NavierStokes equations (4.26) and (4.27) become, after dropping the primes on the
new variables,
u = 0
u
1 2
+ (u )u = p +
u,
t
Re
where the Reynolds number Re is defined by
Re =

LU
.

114

CHAPTER 4. CONTINUUM MECHANICS

This change to dimensionless variables has many uses. One can see that
once a solution for a particular flow field is known and expressed in dimensionless form, a triply-infinite family of solutions may be obtained from it
by choosing values of , L, U, in such a way that Re is unchanged. All
those flows that satisfy the same boundary and initial conditions when expressed in non-dimensional form and for which the values of , L, U , and
differ without the combination LU/ being different, are described by the
same non-dimensional solution; such flows are said to be dynamically similar.
This observation is quite useful in practice. For example hydraulic engineers
might wish to predict the rate at which small solid particles would settle in
water, but is it difficult to perform such measurements. One can however
perform such an experiment with a larger sphere falling in say glycerine or
motor oil, with the size of the sphere so chosen that the value Re is the same
as that for the small solid particle falling in water.
Experiments have shown that at low Reynolds number, the flows are
smooth and stable, a regime usually called laminar flow. As the speed
(Reynolds number) increases there reaches a point, depending on the fluid,
when the flow becomes highly eddied and unstable, usually termed turbulent
flow and generally present when the Reynolds number is a few thousand, or
so.
For flows with Reynolds number values much greater than one, but still
laminar, it has been shown that the flow is essentially inviscid, unless we
are within a distance of the order of L/ Re of a solid boundary. In this
regime, the boundary layer, viscous effects are extremely important and
cannot be ignored. This knowledge allows the Navier-Stokes equations to be
simplified in many case of interest, including the important case of obtaining
drag information on slender bodies such as aerofoils as was done by Prandtl
in 1904 when he introduced the concept of a boundary layer. The idea has
since been applied to many problems, including shock waves and chemical
reactions.

Chapter 5
Classical Electrodynamics
While electrical and magnetic events have been observed in various forms, including lightning and magnetic rocks such as lodestone, since ancient times,
the precise quantitative electromagnetic theory that we have today is of relatively recent origins. From the remarkable experiments of Cavendish in
electrostatics, dating from around 1771, to the appearance of the equations
of Maxwell in 1862 and the experimental confirmation by Hertz in 1888 of

Figure 5.1: Henry Cavendish, James Maxwell, and Heinrich Hertz


the existence of electromagnetic waves, theory and experiment were more or
less in agreement in a little over one hundred years1 . We describe this theory, usually called the classical theory of electrodynamics, below. The theory
1

It is worth a note in passing that in the period following this remarkable century,
there followed perhaps the most productive era of scientific discovery in human history.

115

116

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

gives us the equations that are used to describe most of the macroscopic2
electrical and magnetic properties that we generally encounter.
In this chapter, we consider first electrostatics and then magnetostatics,
finally reaching the objective of the equations of Maxwell for time-varying
electromagnetic systems. A good reference for this material is the book
Classical Electrodynamics, Third Edition, by J. D. Jackson (Wiley, 1999).

5.1

Electrostatics

The theory of electricity begins with the study of single charges and their effects on other charges. The experiments of first Cavendish and later Coulomb
indicated that the force between two small charged bodies separated by a dis-

Figure 5.2: French physicist Charles-Augustin de Coulomb, 1736-1806


tance large compared with their dimensions in a vacuum or medium of small
susceptibility
varies directly as the magnitude of each charge;
varies inversely as the square of their separation distance;
is directed along the line joining the charges;
is attractive if the bodies are oppositely charged, and repulsive if not.
Momentous discoveries here include quantum theory, of which quantum electrodynamics
is but one part, and relativity, which both complement and extend the classical theories.
2
i.e. not microscopic

5.1. ELECTROSTATICS

117

In addition, the total force produced on one small charged body by several
small charged bodies is the vector sum of the individual two-body forces
between the first body and each of the others.
These empirical properties are collectively known as Coulombs Law. The
second of the properties, the inverse square property, has been the subject of
extensive experimental verification over the last two centuries or so and is now
known to be true to an extraordinarily small degree of error. Theoretically,
its truth is equivalent to the mass of a photon of light being zero, an assertion
of great importance in quantum contexts. Collectively Coulombs Law may
be written in formula form as follows: let F be the force on a point charge
q coulombs located at x due to another point charge q1 coulombs located at
x1 . Then
x x1
F = kqq1
|x x1 |3
where in SI units the constant k = (40 )1 and 0 = 8.854 1012 farads
per meter is called the permittivity of free space (or vacuum).

5.1.1

The Electric Field E

Consider a charge q1 located at x1 . The electric field intensity E(x) due to


the charge q1 is the force per unit charge at the point x. Some care must be
exercised here however. One would not necessarily experience this force if
one were to place a unit charge at x, because the presence of this test charge
could alter the charge configuration. So one actually defines3 E(x) from
dF
F
=
.
q0 q
dq

E = lim

In effect the idea here is that E is like a force per unit charge density, so
that to find the force, one integrates Edq.
From Coulombs law the electric field due to a point charge q1 at x1 is
E(x) =
3

1
x x1
q1
.
40 |x x1 |3

(5.1)

Technically speaking, this limit cannot be taken because electric charge is quantized,
i.e. there is a smallest charge; this is an example of a mathematical idealization not unlike
the type used in continuum mechanics that we saw earlier.

118

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

By linear superposition4 , the field due to a collection of point charges qi at


xi is the vector sum
E(x) =

1 X x xi
qi
.
40 i
|x xi |3

(5.2)

Note that, for positions x not occupied by a charge, and any i, we have from
the divergence product rule for a scalar function and a vector function F,
(F) = . F + F,
that

x xi
= |x xi |3 (x xi ) 3|x xi |5 (x xi ) (x xi )
|x xi |3
= 0

Consequently, from (5.2) we have that


E(x) = 0

(5.3)

for all points x not occupied by a charge.


If the charges are small and so numerous that they can be described by a
charge density (x) then the amount of charge in a small volume dV is dV
and
Z
x x0
1
(x0 )
dx0
(5.4)
E(x) =
40
|x x0 |3
Z
1
(x0 )
=
x
dx0
(5.5)
40
|x x0 |
on using the fact that
x x0
1
=

(
).
x
|x x0 |3
|x x0 |

(5.6)

This means that


E(x) = (x)
4

There is considerable experimental evidence that linear superposition is a valid assumption.

5.1. ELECTROSTATICS

119

where

Z
(x0 )
1
dx0
(x) =
40
|x x0 |
is said to be a potential function for E. Notice also that, as A = 0 for
any vector A, we have
E=0
(5.7)

5.1.2

The Gauss Law

The Gauss Law is a formula for the total flux of the vector field E due to
a point charge q across a closed surface S. There are two cases. First, if
the charge is located outside the region D enclosed by S, we have from the

Figure 5.3: Carl Friedrich Gauss, 1777-1855

divergence theorem and (5.3) that


Z
Z
E n ds =
Edx = 0.
S

On the other hand, if the charge is located inside the region enclosed by S
(as in the figure below) then one can find a small sphere centered on the
charge with boundary Se completely contained in D. Then , by (5.3) again,
if we denote the sphere with boundary Se by B,
Z
Z
Z
Z
E n ds =
Edx =
Edx =
E n ds
S

Se

from two applications of the divergence theorem. We assume that B has


radius R and center the origin. From (5.1) and switching to spherical polar

120

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

Figure 5.4: Gauss Law

coordinates over Se
r(, ) = (R sin cos , R sin sin , R cos ),

0 2,

0 ,

so that |r r | = R2 sin , we have


Z
Z
Z 2 Z
q x
q
x
q
E n ds =

ds =
.R2 sin dd = .
3
2
|x|
0
Se 40 |x|
Se
0
0 40 R
Hence

 q
0 if q is inside S,
E n da =
0 if q is outside S.
S

This is the Gauss law for a point charge in a vacuum.


For a system of charges qi , the corresponding law is
Z
1 X
E n da =
qi ,
0
S
where the sum is to be taken over all charges qi that lie inside S. For a charge
density the Gauss law becomes
Z
Z
1
(x) dx
E n da =
0 V
S
where V is the volume enclosed by the closed surface S. This can be further
refined by appealing to the Gauss divergence theorem:
Z
Z
E n da =
E dV,
S

5.1. ELECTROSTATICS

121

which leads to the condition that


Z

( E ) dV = 0
0
V
for all volumes V . In consequence we arrive at the so-called differential form
of the Gauss law:

E=
(5.8)
0
valid for charges and thin conductors in a vacuum.

5.1.3

Macroscopic Media

Thus far we have only considered electrostatic fields in the presence of charges
and conductors either in vacuo, or something close thereto, such as air; in
general, the presence of a ponderable medium complicates matters.
When an electric field is applied to a medium made up of a large number of atoms or molecules, the charges associated with each molecule will
respond to the applied field and will execute perturbed motions. The most
common situation involves molecular dipoles, i.e. molecules that carry a
positive charge at one end and a negative charge at the other and that consequently tend to line up parallel with an applied field. The general effect is
that there is produced in the medium an electric polarization P representing
the dipole moment per unit volume in the dielectric medium.
The end result is that the Gauss law becomes
E=

1
0

[ P]
| {z }

modified charge density

or, rearranging slightly,


(0 E + P) = .
It is usual to define the electric displacement D by
D = 0 E + P,
in which case we obtain the Gauss law for a dielectric medium:
D = .

(5.9)

We shall see later that this is the first of the Maxwell equations. Note that
to proceed further, one needs a constitutive relation connecting D and E. It

122

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

is common here to assume that the medium is isotropic and linear5 , so that
P is parallel to E with a coefficient of proportionality that is independent of
direction:
P = 0 e E.
Then
D = E
where  = 0 (1 + e ) is the electric permittivity. If the dielectric medium is
not only isotropic but also uniform, then the Gauss law becomes
E=

and in such cases, electrostatic problems may be treated in much the same
way as the vacuum case, except that 0 is replaced with .
As we discuss in detail presently, magnetic fields may be generated by
moving charges. So a short digression to consider time varying electric currents is in order.

Figure 5.5: Current flow in a wire

This excludes ferroelectric materials, for example.

5.2. MAGNETOSTATICS AND FARADAYS LAW

5.1.4

123

Electric Current

A current corresponds to charges in motion and is described by the current


density vector J which represents the units of positive charge crossing unit
area per unit time, with the direction of motion of the charges providing the
direction of J. In SI units J has units of amperes per square metre, A m2 .
For a conductor with cross-section a, the current, I, is given by the surface
integral
Z
J n dS.

I=
a

In SI units current is measured in amperes.


In direct analogy with the conservation of mass equation in fluid mechanics, we have the charge conservation equation for the charge density

+ J = 0,
t

(5.10)

with a similar derivation. In magnetostatics, we set the time derivative to


zero, to obtain
J = 0.

5.2

Magnetostatics and Faradays Law

Magnetic phenomena have attracted attention throughout the ages. The


mariners compass and the study of the earth as a large magnet are more
recent activities. In contrast to electrostatics, the basic laws of magnetic
fields did not follow easily from mans first contact with magnetic materials.
Magnetostatics is the study of magnetic fields in systems where the currents
are steady, i.e. not changing in time. It is the magnetic analogue of electrostatics where the charges are stationary. Note that the magnetization need
not be static here.
One fundamental difference is that unlike in electrostatics where there
are free electric charges, there are no free magnetic charges6 , and magnetic
monopoles as they are sometimes called only occur in combination with their
opposites in the form of magnetic dipoles. Some materials are naturally
magnetic, as illustrated by the bar magnet in the figure above. Such a
6

At least none have ever been detected, despite the best efforts of many experimental
physicists over the last two centuries.

124

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

Figure 5.6: Bar magnet with magnetic dipole field

material may be considered to be constructed as an aligned collection of


elementary magnets.
We can work by analogy with the case of an electric dipole consisting of
two opposite but equal charges +e at ( a2 , 0, 0) and e at ( a2 , 0, 0) separated
by the distance a and giving rise to an electric dipole vector (dipole moment)
p with magnitude ea and directed from the negative charge to the positive
one and generating an electric field E = , where
px
.
(x) =
|x|2
In this analogy, we assume that the bar magnet has a magnetic dipole moment m that generates a magnetic-flux density7 field B in a similar fashion,
as indicated in the figure above. The direction of B(x) is the direction a
suitably small permanent magnetic test needle would point if placed in the
magnetic field at x.

5.2.1

The Biot-Savart-Amp`
ere Laws

In 1819 Oersted observed that wires carrying electric currents produced deflections of permanent magnet needles placed nearby. Thus the currents were
7

also called the magnetic induction

5.2. MAGNETOSTATICS AND FARADAYS LAW

125

Figure 5.7: Jean-Baptiste Biot, Felix Savart, and Andre


-Marie Amp`ere
sources of magnetic-flux density. Biot and his assistant Savart in 1820, and
later Amp`ere (1820-1825) in more detailed experiments, established the basic
experimental laws that relate the magnetic induction B to the currents, and
established the law of force involved.
The first of these laws, generally called the Biot-Savart8 law states that
the magnetic field produced by an element of a conductor is proportional to
the current and inversely proportional to the square of the distance. More
precisely, there is a constant k such that
dB(x) = kI

d` x
|x|3

(5.11)

where the terms are shown in the figure below. In particular, Id` is the
current element. The corresponding law for forces on charged particles, also
determined empirically and known as Amp`eres first law, is given by
dF(x) = kId` B(x).

(5.12)

In SI units the constant k = 0 /4 = 107 newtons per square ampere, or


henry per meter, 0 is the magnetic permeability of free space, and B has
the units newtons per ampere-meter. We note in passing that
1

c = (0 0 ) 2

(5.13)

where c is the speed of light, assumed to be a universal constant. It has


been checked experimentally that to a high accuracy the speed of light in a
8

the mathematical form of this is actually due to Laplace

126

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

Figure 5.8: Biot-Savart-Amp`ere law

vacuum is independent of frequency from very low frequencies up to at least


= 1024 Hz.
One must be cautious in interpreting (5.11) and (5.12). To obtain B, for
example, one must integrate dB, which amounts to integrating (5.11) around
the current-carrying wire loop. In particular, observing that Id` = Jda d`
we obtain
Z
x x0
0
0
J(x )
dx0 .
B(x) =
0
3
4 wire volume
|x x |
This is the magnetic analogue of the formula (5.4) for the electric field E.
Some typical magnetic fields may be seen in the figures below, including the
straight wire case, and the field for a closed circular loop.
In order to obtain the differential equation equivalent of the last formula,
we first note that


Z
1
0
0
J(x ) x
dx0
B(x) =
4
|x x0 |


Z
0
1
=
x
J(x0 ) dx0 .
4
|x x0 |
from the identity (5.6). As the x here only involves differentiation with
respect to the x variables and thus x J(x0 ) = 0, we have from the vector
identity
(A) = . A + A

5.2. MAGNETOSTATICS AND FARADAYS LAW

Figure 5.9: Magnetic field lines in a linear wire

Figure 5.10: Magnetic dipole field for a circular wire

that

x

J(x0 )
|x x0 |


= x

and hence
0
B(x) =
x
4

1
|x x0 |

J(x0 ),

J(x0 )
dx0 .
|x x0 |

As ( A) = 0 for all A, we have immediately that


B = 0.
This is one of the basic equations of magnetostatics.

127

128

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

The other is a little harder to uncover. First,


Z
J(x0 )
0
x B(x) =
x x
dx0 .
4
|x x0 |
Next, the standard vector identities, ( A) = ( A) A and
(C) = C + C applied to the right hand side gives


Z
Z
1
0
0
1
0
0
x x
J(x ) dx
) dx0
x B(x) =
J(x0 )x (
0
4
|x x |
4
|x x0 |

Z
Z
0
0
1
1
0
0
0
=

x
)
dx
) dx0
J(x ) x (
J(x
)
(
x
4
|x x0 |
4
|x x0 |
The two standard identities stated below are now crucial. First,
x (

1
1
) = x0 (
),
0
|x x |
|x x0 |

and then

1
) = 4(x x0 ).
|x x0 |
The latter property involves the Dirac delta function9 . This function has
the interesting property that for any function f
Z
f (x0 )(x x0 ) dx0 = f (x).
x (

From this it now follows that


Z
0
1
x B(x) = x J(x0 ) x0 (
) dx0 + 0 J(x),
4
|x x0 |
and after an integration by parts we arrive at
Z
0
x0 J(x0 ) 0
x B(x) = 0 J(x) +
x
dx .
4
|x x0 |
As J = 0 from the conservation of charge equation above, we see that
B = 0 J.

(5.14)

This the second equation of magnetostatics, and corresponds to the equation


E = /0 in electrostatics. It is known as Amp`eres second law, or
Oersteds law.
9

Actually, it is not a function, but a measure, so its properties are a little weird when
first seen.

5.2. MAGNETOSTATICS AND FARADAYS LAW

5.2.2

129

Macroscopic Magnetostatics

Thus far the magnetic phenomena have been assumed to occur in a vacuum
or at least a medium that does not contribute magnetic effects. When this
is not the case, one must go through a similar process to that used in the
electrostatic case. An appropriate argument indicates that the equation
B=0
still holds for a ponderable medium.
With regard to the other equation, we note that the atoms in matter
have electrons that give rise to effective atomic currents, the current density
of which is a rapidly fluctuating quantity. These electrons also contribute
intrinsic magnetic moments in addition to those from their orbital motion. It
can be deduced that the end result is that there is macroscopic magnetization
or magnetic moment density M due to the medium and this contributes an
effective current density
JM = M,
in such a way that Amp`eres second law becomes
B = 0 [J + M].
If we define an new macroscopic field H called the magnetic field by
H=

1
BM
0

then the macroscopic equations for magnetostatics become


H = J
B = 0.

(5.15)
(5.16)

The second of these equations is another of the Maxwell equations that we


will meet later, while the first is almost a Maxwell equation; we return
to this in the next section. For isotropic diamagnetic and paramagnetic
substances we have the linear constitutive relation
B = H
where is the magnetic permeability.

130

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

5.2.3

Stokes Theorem

Consider an oriented piecewise smooth surface S in three-dimensional space


with outward unit normal n and with a simple closed piecewise smooth
boundary C as shown below. Let F be a vector function with continuous

partial derivatives on an open set containing the surface S. The following


identity is usually known as Stokes theorem:
Z
ZZ
F dr =
F n dS.
(5.17)
C

Before considering the full Maxwell equations, we need to first discuss the
justifiably famous

5.2.4

Faraday Law of Induction

As far as we know the first quantitative observations of note relating timedependent electric and magnetic fields were made by Michael Faraday in
1831. Faraday was perhaps the finest and most accurate of the early experimentalists. He was described by Ernest Rutherford10 as one of the greatest
scientific discoverers of all time. After many experiments Faraday concluded
that a transient current is induced (started) in a circuit if
the steady current flowing in an adjacent circuit is turned on or off; or
the adjacent circuit with a steady current flowing is moved relative to
the first circuit; or
10

Another famous physicist

5.2. MAGNETOSTATICS AND FARADAYS LAW

131

Figure 5.11: English physicist Michael Faraday, 1791-1867


a permanent magnet is thrust into or out of the circuit.
No current flows unless either the adjacent current changes or there is relative
motion. The changing flux induces an electric field in the circuit, the line
integral of which is called the electromotive force, E. The electromotive force
causes a current flow according to Ohms law, E = IR. Consider the figure
below. Let the circuit C bound an open surface S with unit normal n, and
assume that the magnetic induction in the neighborhood of the circuit is B.
The magnetic flux F linking the circuit is given by
Z
F =
B n da.
S

The electromotive force E around the circuit is


Z
E=
E dl
C

where E is the electric field at the element d` of the circuit C. Faradays


observations are that the induced electromotive force around the circuit is
proportional to the time rate of change of magnetic flux linking the circuit,
i.e.
dF
.
E = k
dt
The sign is specified by Lenzs law that states that the induced current (and
the accompanying magnetic flux) is in such a direction as to oppose the

132

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

Figure 5.12: Magnetic flux

change of flux through the circuit. For SI units k = 1. It follows from the
above comments that
Z
Z
Z
d
B n da =
E dl =
E n da

dt S
C
S
by Stokes theorem. Thus
Z
( E +
S

B
) n da = 0
t

for all surfaces S, and we arrive at the Faraday Law of Induction:


B
= 0.
t
This is another of our Maxwell equations.
E+

5.3

(5.18)

The Maxwell Equations

We have dealt thus far with steady-state problems in electricity and magnetism as more or less separate topics. As may be inferred from the Faraday

5.3. THE MAXWELL EQUATIONS

133

law, the move to time-varying problems signals an entirely new regime: timevarying magnetic fields give rise to electric fields, and time-varying electric
fields produce magnetic fields. In this case we must speak of electromagnetic
fields rather than separate electric or magnetic fields.
The basic laws of electricity and magnetism discussed above are summarized by the following four (not yet Maxwell) equations:
D=

Coulomb law

H=J
Faraday law
E + B = 0
t
Absence of free magnetic poles
B=0
`re law
Ampe

There is of course no reason to believe that, with the exception of the Faraday
law, these equations continue to hold for time dependent problems. The
interesting part of the story here is that they are actually not far from the
correct equations, but it took the genius of James Clerk Maxwell11 to notice
that there was a slight inconsistency with these laws and the continuity
equation

= 0.
J+
t
What Maxwell noticed was that while
J = ( H) = 0
must hold for steady-state problems by the Ampere law, this is inconsistent
with the continuity equation in the time-varying case. More importantly, he
also noticed that if one appeals to Coulombs law it follows that
D

= (J +
)=0
t
t
and the continuity equation is thereby written in a vanishing-divergence form.
So, he reasoned, to arrive at the appropriate form for the time-varying equations, one should merely replace the term J in the system above with its
generalization
D
JJ+
,
t
J+

11

Yet another Scotsman, joining a distinguished band of 19th century Scottish visionaries that included the likes of James Watt, Alexander Graham Bell, and John Logie Baird,
each of whose work changed the world.

134

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

where D is the electric displacement. In particular the Amp`ere law now


becomes
D
H=J+
.
t
Maxwell called the additional term added to J the displacement current. Its
presence means that a changing electric field causes a magnetic field, even
without a current, the converse of the Faraday law. The set of four equations
D=

H = J + D
t

B=0

E + B = 0
t

(5.19)

are known as the Maxwell equations; they form the basis of all classical electromagnetic phenomena. When combined with the Lorentz force equation
F = q(E + v B)
and Newtons second law of motion, these equations provide a complete description of the classical dynamics of interacting charged particles and electromagnetic fields.
In many instances it is valid to assume the constitutive relations
D = E

B = H

where  is the electric permittivity and is the magnetic permeability. The


generalized Ohms law
J = E
where is the electrical conductivity, is also a valid assumptions in many
situations.

5.3.1

Vector and Scalar Potentials

As B = 0 we know that there exists a vector function A for which


B = A.
The function A is called a vector potential for the magnetic induction B. If
this is substituted into the Faraday law, we find that
(E +

A
) = 0.
t

5.3. THE MAXWELL EQUATIONS

135

This in turn means that there is a scalar potential such that


E+

A
= ,
t

which is usually written in the form


E=

A
.
t

The presence of these potentials allow us to rewrite the Maxwell equations


in various forms, and indeed, to solve them numerically under certain circumstances.
For simplicity of exposition, consider the corresponding Maxwell equations in vacuo, where we assume the reduced consititutive relations D = 0 E
and B = 0 H, leading to the equations

E =
0
1 E
B 2
= 0 J.
c t
where c2 = (0 0 )1 from (5.13). Then, in terms of the scalar and vector
potentials and A, the free space Maxwell equations become

( A) =
t
0
2
1 A
1
A 2 2 ( A + 2
) = 0 J.
c t
c t
+

In this fashion, the original system has now been reduced to two coupled
equations for the potentials A and .
These equations may be uncoupled by taking advantage in the fact that
the potential functions are not uniquely defined. For example, the magnetic
induction B is unchanged by replacing A by
A0 = A +
where is, for now, any (differentiable) scalar function whatsoever! Under
this change in A, for the electric field to remain unchanged as well, the scalar
potential must be transformed to
0 =

.
t

136

CHAPTER 5. CLASSICAL ELECTRODYNAMICS

The function is called a gauge function and the above transformation of


A and is called a gauge transformation.
Let us now choose potentials A0 and 0 in such a way that the Lorenz
condition
1 0
=0
A0 + 2
c t
is satisfied. This can be done, for example, by choosing the gauge function
as the solution of the equation
1 2
1
2 2 = ( A + 2
),
c t
c t
where A and are the initially selected potential functions.
For such a function the Maxwell equations reduce to the pair of inhomogeneous wave equations
1 2 0

c2 t2
0
2 0
1 A
A0 2
= 0 J.
c t2
0

(5.20)
(5.21)

Chapter 6
Finance
In financial circles it is currently popular to use probability theory1 , specifically the theory of so-called random variables, to model the behavior of
macroeconomic quantities such as equities (stocks) and associated financial
derivatives. We study some of these ideas now, with our main target the
justifiably famous, and Nobel prize winning, equation of Fischer Black and
Myron Scholes for the fair price of an option contract.

6.1

Random Variables

If we roll a fair die, each of the six possible results, called outcomes, is equally

Some of the randomness in economics is likely better modeled using chaos and differential equations; in particular the current probabilistically-based mainstream economic
theory has little predictive capability they are substantially worse than the weather guys
who can at least tell you if a hurricane is coming, even if their timing is a tad off!

137

138

CHAPTER 6. FINANCE

likely, and thus each has probablity 1/6. If we denote the individual outcomes
by i , 1 i 6 (so that i is the outcome that an i is thrown), then the
set
= {i , 1 i 6}
is called the sample space. The die throwing activity is represented mathematically by a discrete random variable X : {i : 1 i 6} with the
property that
X(i ) = i, 1 i 6.
A subset of is called an event and each event has a certain probability of
occurring. By way of example, if the event is X is even then the probability
of this happening is 1/2.
In general, a discrete random variable X takes values values {x1 , x2 , . . . , xm }
(i.e. = {1 , . . . , m } where X(i ) = xi ) and the probability of X being xi
is pi where
pi 0, 1 i m,
m
X
pi = 1.
i=1

The expected value of a discrete random variable X is


E(X) =

m
X

xi p i ,

i=1

and, as its name indicates, is the X-value one might expect to see on average
after a large number of trials. For our dice above,
E(X) =

6
X
i=1

7
1
= .
6
2

The variance of X is

var(X) = E (X E(X))2 .
Continuous Random Variables
In many situations, we encounter the need for our random variable X to
have more than a finite number of values, i.e. infinitely many outcomes are

6.1. RANDOM VARIABLES

139

Figure 6.1: The Spinner


possible. For example, in a spinner (see above) the spinning needle can
come to rest at any angle in the interval [0, 2). For such situations we
introduce the continuous random variable X : R for an appropriate
sample space .
At this stage in a fully rigorous treatment of probability theory, one would
select from the sample space a certain sub-collection of subsets and designate them as measurable (the good sets that can represent events) and
associate with each of them with a probability value. In this way we define a
probability measure on . It is expedient for now to avoid this approach.
Instead, we concentrate on the values that X assumes and define the
density function for the continuous random variable X (if it exists) as follows.
A real valued function f satisfying
f (x) 0, x R,
Z
f (x) dx = 1,

(6.1)
(6.2)

is said to be a density function for the random variable X if the probability


that a X b, written P (a X b), is given by
Z b
P (a X b) =
f (x) dx.
a

The expected value of X is


Z

E(X) =

xf (x) dx,

and the variance of X is


var(X) = E((X E(X))2 ),

140

CHAPTER 6. FINANCE

as before. The standard deviation of X is


p
std(X) = var(X).
Independence of Random Variables
We say that two variables X and Y are independent if for all functions
g : R R and h : R R we have
E(g(X)h(Y )) = E(g(X)).E(h(Y )).
The idea here is that values taken by Y do not depend on the values taken
by X and vice versa; so Y = X 2 and X would not be independent.

6.1.1

Normal Distribution

If X is a random variable with density function

x2
1
f (x) = e 2
2

we say that X has the standard normal distribution, and we write this in

Figure 6.2: N (0, 1) distribution


2

the famous bell curve; to some, including the philosopher and one-time securities
trader Nassim Taleb, inventor of the Black Swan, its pre-eminent position in financial
modeling is greatly overblown, even dangerous.

6.2. BROWNIAN MOTION AND DIFFUSION

141

the form X N (0, 1). Notice that for such X one can show that E(X) = 0
and var(X) = 1. The graph of f is given above, with its maximum at
(2)1/2 0.4. If X has the more general density function
f (x) =

1
2 2

(x)2
2 2

we write X N (, 2 ); here, E(X) = and var(X) = 2 so that std(X) =


. We also note that
(i) If X N (, 2 ) then
X
N (0, 1).

(ii) If Y N (0, 1) then Y + N (, 2 ).


(iii) If X1 N (1 , 12 ) and X2 N (2 , 22 ) and X1 and X2 are independent,
then
X1 + X2 N (1 + 2 , 12 + 22 ).

6.2

Brownian Motion and Diffusion

Robert Brown3 was a Scottish Botanist who in 1827 observed the irregular
motion of pollen particles suspended in water. He observed that
the paths are very irregular, in fact continuous but non-differentiable;
the motions of distinct particles appear to be independent.
This form of transport is known as molecular diffusion. In one dimension,
one can imagine a long thin tube parallel to the x-axis and filled with pure
water into which we inject, at time t = 0, a unit amount of ink at the location
x = 0. The diffusion of these ink particles has the same molecular origins as
the pollen movement observed by Brown.
If f (x, t) is the density of ink particles at a location x and time t 0 we
have that
f (x, 0) = (x),
3

He was quite adventurous he accompanied the explorer Matthew Flinders who was
the first to circumnavigate Australia and, in his expedition of 1801, mapped much of the
coastline of southern Australia using not much more than a large rowboat.

142

CHAPTER 6. FINANCE

Figure 6.3: Robert Brown, 1773-1858, Scottish Botanist


where is the Dirac delta function representing unit mass at the single point
x = 0. It was found by William Sutherland (1904) and Albert Einstein
(1905) by means of a random walk argument that the density of ink particles
satisfies the equation
D 2f
f
=
t
2 x2
known as the Sutherland-Einstein4 diffusion equation. Here, D is called
the diffusion constant. We encountered this same equation in Chapter 1 (see
equation (1.13)). There we used the phenomenological approach via Ficks
Law; the above work is much deeper, and derives the equation by considering
molecular interactions.
One can check by differentiation that the solution is given by
f (x, t) =

x2
1
e 2Dt .
1/2
(2Dt)

If one interprets f as a probability density at time t, then the ink particles


are normally distributed N (0, Dt), i.e. with mean 0 and variance Dt, so as
time progresses the ink particles become increasingly smeared out.
This connection between Brownian motion and probability theory was
actually noticed first by Louis Bachelier in his 1901 PhD thesis, so his work
4

Sutherland, who was born in Scotland but emigrated to Australia as a child, found it
before Einstein, but his work went unnoticed.

6.2. BROWNIAN MOTION AND DIFFUSION

143

Figure 6.4: Louis Bachelier, 1870-1946; William Sutherland, 1859-1911; Albert Einstein 1879-1955

predates5 both Sutherland and Einstein. In fact his ideas, completely underappreciated for much of his life, predate many others. For example, his idea
that one can find a deterministic PDE (the diffusion equation) for the time
evolution of probability distributions representing various physical systems
later became known as the Fokker-Planck (or forward Kolmogorov) equation.
Bachelier was attempting to model the erratic behavior of stock and
derivative prices on the Paris Stock Exchange. The asset price model that
we consider presently is a direct result of his work. We mention in passing
that Einstein found that the diffusion constant D may be computed via the
formula
D=

RT
,
NA h

where R is the gas constant, T is the absolute temperature, h is the friction


coefficient, and NA is Avogadros number. In 1909 Perrin used this formula
to compute NA 6 1023 , confirming the atomic theory of matter.

Bachelier is today known as the father of modern mathematical finance; the Bachelier
Society was formed in his honor.

144

CHAPTER 6. FINANCE

6.2.1

A Special Diffusion Property

Consider again ink diffusing in water. An ink molecule is much6 larger than
a water molecule. The water molecules bombard an ink molecule randomly,
so that the ink molecule movement is the sum of a large number of random
collisions.
Suppose that in a small time t the ink molecules typically move a small
distance s. Then we have
s2 2Dt,
(6.3)
so that the distance moved is proportional to the square root of the time.
To see this we define C(x) to be the concentration of ink molecules (the
number of molecules per unit length of tube) and J(x) to be the flow per unit
time (the number of ink molecules crossing x, to the right, per unit time).
We also assume Ficks Law:
J(x) = DC 0 (x).
Consider the perpendicular plane P passing through a point x0 and across
which diffusion is occurring. Let xr and xs be points chosen so that
xr < x0 < xs
and x0 xr = xs x0 = s. As the ink molecule movement is random, particles
move either left or right with equal probability. Thus half the particles in
the left zone [xr , x0 ] cross P . Let the concentration in this zone be Cr , so
that the number of ink particles is
cCr
.
2
Now, the total flow across from the left zone to the right zone is the flow per
unit time Jr time the time t. So
Jr =

sCr 1
.
2
t

Similarly in the right zone we have


Js =
6

sCs 1
.
2
t

nanometers versus thousands of nanometers

6.3. STOCHASTIC PROCESSES

145

Thus the net flow to the right per unit time across P is
Cs Cr
2t

Cs Cr
s2
.
=
t
s
2
s
.(C 0 (x0 ).

J = Js Jr = s.

So, from Ficks law we have s2 2Dt and we are done.

6.3

Stochastic Processes

If, for each t 0 we are given a random variable Xt defined on a fixed sample
space for all t, we call the collection
{Xt }t0
a stochastic process. For each the mapping
t 7 Xt ()
is a sample path.
The idea here is that if we run an experiment and observe the random
values of Xt as time evolves, we are actually looking at a sample path {Xt () :
t 0} for some fixed . If we re-run the experiment, we will in general
observe a different path {Xt (
) : t 0} represented by, say,
.
While there are many stochastic processes, we only concern ourselves with
one:
The Wiener (Brownian Motion) Process
Let Bt () be the position at time t of the pollen grain . Then {Bt ()}t0
forms a stochastic process. Here
= {pollen grains}.
It is not uncommon for the phrase Brownian motion to refer to the physical
experiment, while Wiener process refers to the mathematical model that
we develop below. We choose not to make such distinction here.

146

CHAPTER 6. FINANCE

While we shall not formally construct our Brownian motion process, there
are some properties that are worth listing and we do so here. First, for
t s 0 we expect that the displacement Bt Bs to be the sum of a
huge number of small independent identically distributed collisions. By the
central limit theorem from probability theory, Bt Bs should be normal.
Also, there is no reason that collisions in one direction should be more likely
than in another, so
E(Bt Bs ) = 0
for all t s 0. Finally, the probability distribution for Bt Bs should not
depend separately on t, s, only on their difference t s. So we must have
Bt Bs N (0, t s).
There is no reason that the displacements imparted over non-overlapping
time intervals should be related. So, for times
0 < t0 < t1 < < tk ,
the increments
{Bt1 Bt0 , Bt2 Bt1 , . . . , Btk Btk1 }
are independent. Also, as the subtraction of B0 does not change any of the
above increments, we can assume that B0 = 0. Finally, we assume that each
sample path is continuous.

6.4

The It
o Integral

Before we discuss how to model the price of a stock, it is convenient to discuss


the idea of integrating with respect to a Brownian motion stochastic process.
Consider first the standard Riemann integral. For a function f defined on
an interval [a, b] we define the Riemann integral of f over [a, b],
Z b
f (t) dt,
a

to be the limit, as the mesh of the partition


a = t0 < t1 < t2 . . . < tn = b

INTEGRAL
6.4. THE ITO

147

tends to zero, of the Riemann sum


n1
X

f (ti )(ti+1 ti ),

i=0

where, for each i, ti ti ti+1 , and provided that such a limit exists.
For a function f defined on an interval [a, b] and a function g we define the
Riemann-Stieltjes integral of f over [a, b] with respect to g,
Z b
f (t) dg(t),
a

to be the limit, as the mesh of the partition


a = t0 < t1 < t2 . . . < tn = b
tends to zero, of the Riemann-Stieltjes sum
n1
X

f (ti )(g(ti+1 ) g(ti )),

i=0

where, for each i, ti ti ti+1 , and provided once again that such a limit
exists.
Here, it is known that if the function g is continuously differentiable, then
Z b
Z b
f (t) dg(t) =
f (t)g 0 (t) dt
a

and the Riemann-Stieltjes integral gives us nothing we cannot handle with


the standard Riemann integral. The new thing here is in situations in which
g is continuous but not differentiable. In particular we would like to make
sense of integrals of the form
Z b
f (t) dBt (),
a

where Bt () is the Brownian motion process considered above, which is


known to be continuous, but not differentiable.
The Japanese mathematician Kiyoshi Ito did just this in the 1940s and
provided just the right tool for the financial mathematics that followed

148

CHAPTER 6. FINANCE

Figure 6.5: Kiyoshi Ito, 1915-2008


decades later. The Ito integral is formed as follows. For a fixed ,
to create
Z b

f (t, ) dBt ()
a

we consider, as above, the limit, as the mesh of the partition


a = t0 < t1 < t2 . . . < tn = b
tends to zero, of the sum
n1
X

f (ti , )(Bti+1 () Bti ()).

i=0

Here is where it gets a little weird. For Riemann integrals it is known that
the result does not depend on the choice of the values ti where
ti ti ti+1 .
In the stochastic case this is no longer true. In fact we get different limits if
we set ti = ti (this gives the Ito integral below) compared to ti = (ti +ti+1 )/2,
which gives the so-called Stratonovich integral.
We also need to be careful which stochastic integrands f (t, ) we use.
In particular, a stochastic process gt is called non-anticipating if its value
at time t depends only on information available at or before time t. So,
for any deterministic function F : R2 R the process gt = F (t, Bt ) is
non-anticipating, whereas gt = B2t is not. We now have

INTEGRAL
6.4. THE ITO

149

Definition 6.1 Let f (t, ) be a non-anticipating function. We define the


Ito integral
Z b
f (t, ) dBt ()
a

to be the limit, as the mesh of the partition


a = t0 < t1 < t2 . . . < tn = b
tends to zero, of the sum
n1
X

f (ti , )(Bti+1 () Bti ()),

i=0

if such a limit exists.

6.4.1

Properties of the It
o Integral

Assume that f (t, ) and g(t, ) are non-anticipating.


(i) For A c b,
Z b
Z c
Z b
f (t, ) dBt =
f (t, ) dBt +
f (t, ) dBt .
a

(ii) For constants and


Z b
Z c
Z b
f (t, ) + g(t, ) dBt =
f (t, ) dBt +
g(t, ) dBt .
a

(iii)
Z
E


f (t, ) dBt

= 0.

We also have
Definition 6.2 Let u(t, ) and v(t, ) be non-anticipating functions.
stochastic process Xt of the form
Z t
Z t
Xt = X0 +
u(s, ) ds +
v(s, ) dBs
0

is called an Ito process.

150

CHAPTER 6. FINANCE

As a convenient shorthand notation, we also write the above equation, in


differential form, as
dXt = u dt + v dBt .
We next consider the famous

6.4.2

The It
o Formula

Observe that if the deterministic function X(t) satisfies the differential equation
dX
= u(t, X)
dt
and Y (t) = g(t, X(t)) then by the chain rule
dY
g g dX
g
g
=
+
=
+
u,
dt
t x dt
t X
or, in differential form,

dY =

g
g
+
u
t X


dt.

(6.4)

Given this, the next theorem is quite surprising; it is the basis of much of
modern financial mathematics.
Theorem 1 (It
o formula) Let Xt be an Ito process,
dXt = u dt + v dBt ,
where u and v are non-anticipating, and let g(t, x) be twice continuously
differentiable. Then
Yt = g(t, Xt )
is also an Ito process and


g
1 2g 2
g
g
+
u+
v dt +
v dBt .
dYt =
2
t X
2 x
x

(6.5)

Compared to the corresponding deterministic calculation (6.4), the third


term in the square brackets in new and surprising, a direct result of the
stochastic side of the problem.
We note also the following stochastic analogue of the usual integration
by parts formula.

6.5. ASSET PRICES

151

Theorem 2 Suppose f (s, ) is continuous and of bounded variation for s


[0, t]. Then
Z t
Z t
Bs () df (s).
f (s, ) dBs = f (t, )Bt
0

6.5

Asset Prices

An asset refers to a financial object whose value is known in the present, but
is liable to change in the future. By way of examples we have
one share in a company;
a fixed amount of a commodity: one ounce of gold, one barrel of oil,
one gross of soybeans;
currencies: the value of one euro in US dollars.
We shall be interested in other financial instruments, called options, that are
derivatives of (i.e. depend on) these assets; such an asset is then called an
underlying security or more simply, an underlying.
The asset model we consider rests upon several assumptions, principal
among these being the Efficient Market Hypothesis that
The current asset price reflects all past information.
In general the asset price is a measure of investor confidence, which in turn
depends on news (good and bad), rumor and suchlike, so this is not unreasonable if one believes that the market responds instantaneously to external
influences and there would be no advantage from reading the charts, and
our model need only use the asset price at time t to predict the price at time
t + t. We mention in passing that many7 believe that this hypothesis is
flawed, but it does give us a start!
Other assumptions include
the asset price may take any non-negative value;
buying and selling may take place at any time;
7

The market is quick to digest earnings data but grossly inefficient in valuing stuff
Michael Lewis, author and sometime bond trader, 1989

152

CHAPTER 6. FINANCE

one can buy or sell any amount of asset;


the price for buying equals the price for selling (i.e. the bid-ask spread
is zero;
there are no transaction costs;
there are no dividends, or stock splits;
one can hold a negative amount of asset (called short selling);
there is a constant risk-free interest rate for any amount borrowed from
or deposited into a bank.
Consider now the price of a typical asset S(ti ), such as the price at the
end of business day i of one share of stock in International Business Machines
(IBM). As one can see from the Figure below this price varies erratically. One

Figure 6.6: Daily IBM share price May 2012 to April 2013
can begin to ascertain the underlying statistical behaviour by computing the
numbers
S(ti+1 ) S(ti )
ridaily =
S(ti )

6.5. ASSET PRICES

153

that are known as the daily returns. Over a fixed time frame one could
compute the mean and variance of the returns and then normalize the
data to
ridaily
daily
ri
=

When this normalized data is compared to data from an N (0, 1) pseudorandom number generator, as may be seen from the quantile plots below, the
match is least accurate at the extremes, i.e for low probability events; this is
the famous fat tail problem wherein the use of Gaussian distributions seems
to be incorrect for certain financial events of low probability. Nonetheless,
by assuming our daily stock return data is normally distributed we appear
to be in something like the correct ball park, at least some of the time.

Figure 6.7: Fat tails

6.5.1

The Asset Price Model

Let the asset price at time t be S(t). Over a small time interval [t, t + dt] the
asset price S(t) changes by dS. The relative change (i.e. the daily or weekly

154

CHAPTER 6. FINANCE

returns) may be written as


dS
S
|{z}

= dt + dBt ,
| {z }
|{z}

asset return

drift

(6.6)

fluctuations

where the drift


relates to the trend of the asset and is the volatility.
Here Bt = tZ where Z N (0, 1) is Brownian motion and the term dBt
represents the unpredictable fluctuations that one typically sees in price data.
Note that on integrating (6.6) we obtain
Z t
Z t
S(t) = S(0) +
S(r) dr +
S(r) dBr .
0

Also
(log S(t))0 =

S 0 (t)
,
S(t)

so that the Brownian motion statistics really apply to log S(t) rather than
S(t) itself. It is for this reason that we say the asset prices follow a log-normal
distribution. One can show that if and are constant, then the stochastic
differential equation (6.6) has solution
S(t) = S(0)e(

6.6

2
)t+Bt
2

Options and the Black-Scholes PDE

We are concerned here with the fair value of certain financial entities called
derivatives. These are financial instruments that depend on a base asset in
various, possibly complicated, ways. As an example we have

6.6.1

The European Call Option

This is a contract that gives the holder the right, but not the obligation, to
purchase from the writer a prescribed asset for a prescribed price (the strike,
or exercise, price) at a prescribed future time (the maturity).
As an example, suppose that Professor A (the writer) creates a European
call option contract that gives you (the holder) the right to buy 100 shares
of IBM stock (the underlying asset) for US$1000 three months from now on
June 17. At that time

6.6. OPTIONS AND THE BLACK-SCHOLES PDE

155

(i) if the actual value of 100 IBM shares is greater than US$1000, you
would exercise the option, and then sell for a profit; or
(ii) if the value is less than or equal to US$1000, do nothing.
Because you are not obliged to purchase the shares, you either gain (possibly
substantially) in (i), or neither gain nor lose in (ii). Professor A, in contrast,
who has to give you the shares at the exercise price, would incur a loss,
possibly huge, in (i). To compensate for this risk imbalance you would pay
Professor A an amount of money now, called the price of the option.
The key question is: how does Professor A work out how much he should
charge, i.e. what is the fair value now of this option? Here fair means
that Professor A neither makes, nor loses, money; he is a very altruistic
fellow!
Assume now that the prevailing risk-free interest rate is r > 0 for a call
option on an asset with price S(t) and strike price p and maturity T . In this
situation, $1 placed in the bank at time t = 0 becomes erT at time t = T , or
$1 at t = T is worth only erT at t = 0.
As a first guess should not the price of our call option be
erT E((S(T ) p)+ )?
The rationale here is that if S(T ) p the option is worthless. On the other
hand, if S(T ) > p we can buy the asset at p and sell at S(T ) and make a
profit (S(T ) p)+ ; so one should average this over all sample paths to get
the value.
Unfortunately this is wrong in general. In particular, the important missing factor concerns the possibility of arbitrage, the generation of risk-free profits. So, one must price the option so as to not create arbitrage opportunities
for others. This is done by hedging, in that one creates a portfolio consisting
of one option and a (continually changing) number of asset shares. The idea
here is that the hedge instrument duplicates the gains in a bank line-of-credit
used to finance the hedge under a no arbitrage assumption. This is the core
of the idea of Black and Scholes for solving the pricing problem via a certain
deterministic PDE of parabolic type.

6.6.2

The Black-Scholes PDE

For 0 t T and s 0 let u(t, s) denote the price of a call option at time t,
given that S(t) = s. So we seek u(0, S(0)). The function u(t, s) must satisfy

156

CHAPTER 6. FINANCE

Figure 6.8: Economists Fisher Black, 1938-1995 and Myron Scholes, 1941the following conditions. First the final condition
u(T, s) = (s p)+

(6.7)

for all s 0. Then the boundary conditions


u(t, 0) = 0
u(t, s) s, as s ,

(6.8)
(6.9)

for 0 t T . The first of these follows because if the asset price is zero,
so is the option price; as for the second, if the asset price increases without
bound, the value of the exercise price p becomes irrelevant.
The Hedge Portfolio
Let the underlying asset have value S(t), where 0 t T , and consider
the value H(t) of a portfolio constructed with one call option with value
C(t) = u(t, S(t)) and N (t) asset shares:
H(t) = C(t) + N (t).S(t)
where this is financed by a line of credit. The N (t) will be chosen below.
Noting that from (6.6) we have that in the time interval [t, t + dt] the change
in the asset price ds is given by
ds = s dt + s dBt

6.6. OPTIONS AND THE BLACK-SCHOLES PDE

157

and from the Ito theorem (6.5) the corresponding change in the option price
dC is
1
dC = (ut + sus + 2 s2 uss ) dt. + sus dBt
2
It follows that in the time interval [t, t+dt] the gain (which could be negative)
in this portfolio is
1
dC + N (t)ds = (ut + sus + 2 s2 uss ) dt + sus dBt
2
+ N (t)(s dt + s dBt ).
If we choose N (t) = us (t, S(t)) then we have that the gain is
1
dC + N (t)ds = (ut + 2 s2 uss ) dt,
2
which is riskless (no dBt ) and thus must be the same as the gain in the
line of credit account over the same period. So, as
rH(t) dt = r[u(t, S(t)) + N (t)S(t)] dt = r[u(t, S(t)) us (t, S(t)).S(t)] dt
and

1
r[u(t, S(t)) us (t, S(t)).S(t)] dt = (ut + 2 s2 uss ) dt,
2
it follows that
u 1 2 2 2 u
u
+ s
+ rs
ru = 0.
(6.10)
2
t
2
s
s
This is the equation of Black and Scholes. We note in passing that the
equation does not explicitly involve the drift , and the volatility need
not be a constant for this derivation to hold. However, if both and r are
constant, then the equation can be solved explicitly as we demonstrate next.
Solving the Constant Coefficient Black-Scholes PDE
We solve (6.10) under the final condition (6.7) and the boundary conditions
(6.8) and (6.9), assuming and r are positive constants. By the variable
change (t, s) (, x) defined by
s = pex

t=T 1 2

2
u(t, s) = pv(, x),

(6.11)

158

CHAPTER 6. FINANCE

the Black-Scholes equation (6.10) becomes


v = vxx + (k1 1)vx k1 v,

(6.12)

where k1 = 2r/ 2 and


v(0, x) =

1
1
s
u(T, s) = max (s p, 0) = max ( 1, 0) = max (ex 1, 0).
p
p
p

This simplifies further with the change of dependent variable given by


v(, x) = ex+ w(, x)
where and are to be specified presently. The equation (6.12) now becomes
w + w = (2 w + 2wx + wxx ) + (k1 1)(w + wx ) k1 w,
and if we choose and so that
= 2 + (k1 1) k1
0 = 2 + (k1 1),
i.e. = (k1 1)/2 and = (k1 + 1)2 /4, the terms in w and wx disappear,
giving
1
1
2
v = e 2 (k1 1)x 4 (k1 +1) w,
and, for < x < and > 0,
w
2w
=
,

x2
where

(6.13)

w(0, x) = w0 (x) = max (e 2 (k1 +1)x e 2 (k1 1)x , 0).


One can check directly that
f (, x) =

x2
1
e 4
4

satisfies (6.13), and f (0, x) = (x). So, if we set


Z

w(, x) =

(xy)2
4

e
w0 (y)

dy,

(6.14)

6.6. OPTIONS AND THE BLACK-SCHOLES PDE

159

then
w
=

[f (, x y)] dy =

and

2
2w
[f
(,
x

y)]
dy
=
,
x2
x2

w0 (y)(x y) dy = w0 (x).

w(0, x) =

The solution (6.14) simplifies.In the integral substitute


z
=
(x

y)/
2 for

y. Then, noting that w0 (x 2 z) = 0 for z x/ 2 ,


Z

1
2
w0 (x 2 z)ez /2 dz
w(, x) =
2
Z x/2

1
1
1
2
=
(e 2 (k1 +1)(x 2 z) e 2 (k1 1)(x 2 z) ) ez /2 dz
2
= I1 I2 ,
where on noting that
!2
(k1 + 1) 2
z+
,
2

1
1
1
(z 2 + (k1 + 1) 2 z) = (k1 + 1)2
2
4
2

I1

1
=
2

x/ 2

e 2 (k1 +1)(x

1 1
= e 2 (k1 +1)x
2

x/ 2

2 z) z 2 /2

e 2 (k1 +1)

1
1 1
2
= e 2 (k1 +1)x+ 4 (k1 +1)
2

1
1 1
2
= e 2 (k1 +1)x+ 4 (k1 +1)
2

x/ 2

2 z 12 z 2

e 2 (z+

x
2

dz

(k1 +1)
2 )2
2

(k1 +1)
2
2

dz

1 02

e 2 z dz 0

via the substitution z 0 = z +


1

dz

(k1 + 1)
2 ,
2

= e 2 (k1 +1)x+ 4 (k1 +1) N (d1 ),


where

x
(k1 + 1)
d1 = +
2 ,
2
2

(6.15)

160

CHAPTER 6. FINANCE

and

1
N (x) =
2

ez

2 /2

dz

is the N (0, 1) distribution function. Similarly,


I2

1
=
2

x/ 2

e 2 (k1 1)(x

1 1
= e 2 (k1 1)x
2

x/ 2

2 z) z 2 /2

e 2 (k1 1)

1
1 1
2
= e 2 (k1 1)x+ 4 (k1 1)
2

1
1 1
2
= e 2 (k1 1)x+ 4 (k1 1)
2

x/ 2

2 z 12 z 2

e 2 (z+

x
2

dz

(k1 1)
2 )2
2

(k1 1)
2
2

dz

1 02

e 2 z dz 0

via the substitution z 0 = z +


1

dz

(k1 1)
2 ,
2

= e 2 (k1 1)x+ 4 (k1 1) N (d2 ),


where

(k1 1)
x
d2 = +
2 .
(6.16)
2
2
Having obtained w we now work our way back through the variable
changes to obtain the option price u. First,
v(, x)
1

= e 2 (k1 1)x 4 (k1 +1) w(, x)


1

= e 2 (k1 1)x 4 (k1 +1) (e 2 (k1 +1)x+ 4 (k1 +1) N (d1 ) e 2 (k1 1)x+ 4 (k1 1) N (d2 ))
= ex N (d1 ) ek1 N (d2 ).
Finally, using (6.11), we have
u(t, s) = p{ex N (d1 ) ek1 N (d2 )}
= sN (d1 ) per(T t) N (d2 ).
This means that
u(0, S(0)) = S(0)N (d1 ) perT N (d2 ),

(6.17)

6.6. OPTIONS AND THE BLACK-SCHOLES PDE

161

where
x
(k1 + 1)
d1 = +
2
2
2
r
log(s/p) ( 12 2 + 1)

=
+
2
2
2
log(s/p) + ( 1 r2 + 1) 12 .2
2
=
2
log(s/p) + (r + 21 2 )(T t)

=
T t
and
log(s/p) + (r 12 2 )(T t)

d2 =
.
T t

6.6.3

(6.18)

The Greeks

No, we are not talking about struggling European economies, but interestingly enough, due to the likes of Goldman-Sachs the these particular Greeks
did have a role to play in that saga8 .
The value of a European call option u derived above depends not only on
s and t, but also on the strike price p, the interest rate r, and the volatility
of the underlying and also, as we see later, the maturity T . So, ignoring T
for the moment,
u = u(t, s; p, r, ) = sN (d1 ) per(T t) N (d2 ).
The financial sector is interested in the sensitivity of the option value u to
changes in each of these parameters, and this can be determined by calcu8

Goldman-Sachs created certain complicated derivative instruments that cleverly allowed the Greek government to circumvent EU deficit spending rules, leading directly to
their current predicament

162

CHAPTER 6. FINANCE

lating the various partial derivatives. We have


u
= N (d1 )
s
2u
N 0 (d1 )
Gamma : = 2 =
s
s T t
u
rho : =
= (T t)per(T t) N (d2 )
r
s
u
=
rper(T t) N (d2 )
Theta : =
t
2 T t

u
vega : vega =
= s T tN 0 (d1 ).

Delta : =

(6.19)
(6.20)
(6.21)
(6.22)
(6.23)

We have already met Delta in the hedging formula used to derive the BlackScholes formula, and we run into vega in the next section on implied volatilities.

6.6.4

Implied Volatility

The value of our European call u depends on s, t, p, r, T , and . Of these


quantities, all but are either assumed known or can be observed directly
at a given time t. Given that there are quoted market option prices readily
available, one idea is to used these numbers in the Black-Scholes formula
(6.17) to determine as the solution of a non-linear algebraic equation.
Values of obtained in this fashion are called implied volatilities. Implied
volatility (see the black graph below) is an indicator of future stock volatility
based on price changes in an option. In contrast, historical volatility is the
annualized standard deviation of past stock movements (see the lighter graph
below).
More precisely, we assume that u (the option price), together with
p, r, T, s, t are known, and we suppose that u = u() and try to solve
u() = u
from the formula (6.17). Such a solution is an implied volatiltiy.
Note first that as , d1 and thus we have N (d1 ) 1, and
d2 and so N (d2 ) 0. Consequently
lim u() = s.

6.6. OPTIONS AND THE BLACK-SCHOLES PDE

163

Figure 6.9: SPX Implied Volatility vs Historical Volatility Aug 09 - Aug 11


Now we consider what happens to the option price u when 0+. There
are three cases. If s per(T t) > 0 then
log(s/p) + r(T t) > 0
and so as 0+ both d1 , so N (d1 ) 1, and d2 , so N (d2 ) 1
and we have u() s per(T t) . If s per(T t) < 0 then
log(s/p) + r(T t) < 0
and so as 0+ both d1 , so N (d1 ) 0, and d2 , so
N (d2 ) 0 and we have u() 0. Finally, if s per(T t) = 0 then
log(s/p) + r(T t) = 0
and so as 0+ both d1 0, so N (d1 ) 1/2, and d2 0, so N (d2 )
1/2, and we have u() (s per(T t) )/2 = 0. Thus
lim u() = max (s per(T t) , 0).

0+

Now, from the previous section, vega = u > 0, so the function u() is
increasing and, for 0 < the values of u() satisfy
max (s per(T t) , 0) u() < s.
In particular the equation u() = u if the above inequality holds, and the
solution is unique if it exists.

164

CHAPTER 6. FINANCE

A major assumption underlying the Black-Scholes theory is the the volatility is constant. In reality, this is rarely so, as the graph below indicates
and this behavior is quite typical. We note that the derivation of the BlackScholes PDE in fact does not require the constancy of , although the nice
formula (6.17) is no longer valid. We explore what happens when we assume
= (t, s),
in the asset price stochastic equation (6.6) in the next section.

Figure 6.10: Implied Volatility Smile, EUREX DAX Option 01/04/99

6.7

Local Volatility and the Dupire PDE

Assume now that the asset price S(t) satisfies the stochastic equation
dS
= (t, S(t)) dt + (t, S(t)) dBt ,
S(t)

(6.24)

where the drift = (t, s) relates to the trend of the asset and = (t, s)
is the volatility. If we consider a European call option on this underlying,
the corresponding Black-Scholes PDE for the fair price u(t, s) of the option
is
u 1
2u
u
+ (t, s)2 s2 2 + rs
ru = 0.
(6.25)
t
2
s
s
subject to the conditions (6.7), (6.8), and (6.9) as before.
Now, without the benefit of the Black-Scholes formula (6.17) it is a much
more difficult problem to recover the volatility (now a function) from a
knowledge of the option prices u. This is the so-called inverse volatility
problem which we discuss next. The recovered volatility function is called

6.7. LOCAL VOLATILITY AND THE DUPIRE PDE

165

the local volatility, in order to distinguish it clearly from the implied volatility
discussed above.
First we observe that the option price u depends here on the four variables,
s the asset price, t the current time, K the strike price, and T the maturity
or time to expiry,
u = u(t, s; T, K).
(6.26)
Typically one knows at a certain time t0 and asset price s0 = S(t0 ) the option
prices u(t0 , s0 ; T, K) for a number of strikes K and maturities T . Now while
the volatility appears in the Black-Scholes equation (6.25) it is not clear
how it might be extracted, as the data involves K and T and the PDE uses
the variables s and t. What is needed here is a differential equation for u
that involves the other variables K and T in (6.26). In 1994 such an equation
was found by Bruno Dupire, a French mathematician then working for the
banking and financial services giant Societe General in Paris.

Figure 6.11: Bruno Dupire, Applied Mathematician and Derivatives Analyst


While Dupire used the Fokker-Planck equation for his derivation, we favor
another approach devised by Isakov and Bouchouev. Let u = u(t, s; T, K)
be the solution of the Black-Scholes equation (6.25) satisfying the conditions
(6.7), (6.8), and (6.9), and set
u1, (t, s; T, K) =

1
[u(t, s; T, K + ) u(t, s; T, K)] .


Then u1, also satisfies the PDE (6.25) in the variables s, t for any  6= 0.

166

CHAPTER 6. FINANCE

Observe also that from (6.7), u1, satisfies the final condition

if s (0, K]
0
1
(K

s)
if
s (K, K + )
u1, (T, s; T, K) =

1
if s [K + , )
If we let  0 we have that u1, tends to uK , and
uK (T, s; T, K) = H(s K),
where H(s) is the Heaviside step function. In like fashion, set
u2, =

1
[u(t, s; T, K + ) 2u(t, s; T, K) + u(t, s; T, K )]
2

Again, u2, also satisfies the PDE (6.25) in the variables s, t for any  6= 0.
Observe also that from (6.7), u2, satisfies the final condition

0
if s (0, K ]

1
( + s K) if s (K , K]
2
u2, (T, s; T, K) =
1
( s + K) if s (K, K + )

2
0
if s [K + , )
where the right hand side is a hat function. If we let  0 we have that
u2, tends to uKK , and
uKK (T, s; T, K) = (s K),
where (s) denotes the Dirac delta function. This means that
G(t, s; T, K) = uKK (t, s; T, K)
is a so-called fundamental solution for the parabolic PDE (6.25). Such solutions have the special property that, as a function of the variables K, T , the
function G satisfies the so-called adjoint equation
1 2

G
=
(K 2 (K, T )2 G)
(rKG) rG.
2
T
2 K
K
So we know that the function u(t, s; T, K) satisfies
1 2
uKK

2
2
=
(K
(K,
T
)
u
)

(rKuKK ) ruKK .
KK
T
2 K 2
K

6.8. BONDS

167

Finally we integrate this equation twice over [K, ), assuming that


u, uT , uKT , KuK , KuKK , K 2 uKKK ,
all approach zero as K . Note that in this process, the second term on
the right can be integrated directly as
 2 
Z 2
Z
Z Z
u
u
u
u

u
2 d = K
2 dd =
+
d = K
u.

K K
K
K
K

We then arrive at the Dupire PDE for the call price function u(t, s; T, K) in
the variables K, T :
u
1
2u
u
= K 2 (K, T )2
rK
.
2
T
2
K
K

6.8

(6.27)

Bonds

A bond is a contract, paid for up-front, that pays a known amount on a known
date in the future, called the maturity date. The bond may also pay a known
cash dividend, called the coupon at fixed times during the life of the contract;
if there is no coupon the bond is known as a zero-coupon bond. Bonds are
issued by both governments and companies typically with the intention of
raising capital, and the up-front premium should be considered a loan to the
issuer.
The problem of valuing/pricing a bond boils down to answering the following question: how much should one pay now to receive a guaranteed $1 in
T years time? The fair value v of such a contract at any given time t depends
upon t, the maturity time T , and also the prevailing short-term interest rate
r(t); so v = v(r, t; T ). As the maturity time T can be large, T = 10 years is
not uncommon, one can no longer assume a constant interest rate as we did
above. We begin first by assuming that r = r(t) is a deterministic function
known in advance; later we study a stochastic interest rate model.

6.8.1

Calculating v with r Known

We now calculate v = v(r, t; T ), assuming that the interest rate r(t) and the
coupon payment schedule k(t) are both known in advance. We assume also
that
v(r, T ; T ) = Z,
(6.28)

168

CHAPTER 6. FINANCE

the nominal, principal, par, or face amount of the bond. At time t < T the
change of value of the bond over the time interval [t, t + dt] is


v
+ k(t) dt,
t
given that the coupon payment over this time interval is k(t)dt. To avoid
arbitrage possibilities, this must equal the corresponding return on a short
term bank deposit, r(t)v.dt, so that
v
r(t)v = k(t).
t
This first order linear equation may be solved using (6.28) and an integrating
factor to give


Z T
R
R
pT r( ),d
tT r( ),d
v(r, t; T ) = e
Z+
k(p)e
dp .
t

Note that, for a zero coupon bond, k = 0 and thus

Figure 6.12: US Treasury Yield Curve November 29, 2013

r( ) d = log(
t

v(r, t; T
),
v(r, T ; T )

(6.29)

6.8. BONDS

169

from which we have

v
1
.
v(r, t; T ) T
Taking a cue from (6.29) we define the yield Y (t; T ) to be
r(T ) =

Y (t; T ) =

log(v(r, t : T )/v(r, T ; T ))
.
T t

For fixed t (the present) the yield is a measure of the future value, r(T ),
of interest rates. The plot of Y against Tt is known as a yield curve; the
dependence of the yield on the time to maturity T t is called the term
structure of interest rates. Actual market data tends to produce yield curves
that are increasing, indicating that future interest rates will be higher than
shorter term rates, since it should be more rewarding to tie up money for the
longer periods. Occasionally, the yield curve will be decreasing (or humped);
such curves are called inverted yield curves. An example of this can seen in
the figure below. Strongly inverted yield curves have historically preceded

Figure 6.13: British Pound Yield Curves 2004-6


economic depressions.

6.8.2

Bond Futures

A bond futures contract is an agreement to buy or sell a bond at a price F


agreed upon up-front (the futures, or strike, price) with delivery and payment

170

CHAPTER 6. FINANCE

occurring at a specified future date T , the delivery date. If the interest rate
r(t) is known, the futures price is
F (t) = v(r, t; T )e

RT
t

r( ) d

Who purchases a futures contract? Buying a futures contract is an indirect method of buying (going long in) the underlying and conversely, selling
a futures contract allows one to indirectly sell (short) the underlying. The
traditional idea is that, for example, an airline could buy a jet fuel futures
contract to guard against a catastrophic future rise in fuel prices. Who would
sell such a contract? A speculator might see a future with fuel prices falling
(due insider knowledge about a future oversupply, for example), which would
support the selling of such a futures contract to lock in a profit. In general
hedgers seek to reduce risk, and speculators seek to take advantage of it.
When a party establishes a position in (buys) a futures contract, it can
either run this position to maturity or close out the position between the
trade date and the maturity date. If a position is closed out the party will
have either a profit or loss to book. If a position is held until maturity, the
party who is long futures will take delivery of the underlying asset (bond) at
the settlement price; the party who is short futures will deliver the underlying
asset. This is referred to as physical settlement.

6.8.3

Stochastic Interest Rates

In practice the interest rate r is not known in advance, but we can try to
model it using a similar random variable technique to that used above for
stock prices. In particular we assume that the short-term spot interest
rate r is determined by a stochastic equation
dr = u(r, t) dt + w(r, t) dBt ,

(6.30)

where u and w are to be determined, and Bt is the Brownian motion stochastic process considered earlier.

6.8.4

The Bond Pricing Equation

Determining the appropriate partial differential equation for arbitrage free


bond pricing is quite different from the Black-Scholes case because in the
bond case one does not have an underlying stock with which to engage in

6.8. BONDS

171

hedging as we did before. Instead, we make use of a portfolio containing one


bond v1 with maturity T1 and of the bond v2 with maturity T2 . So the
value of the portfolio at time t is = v1 v2 , and in time dt this changes
by


v1
1 2 2 v1
v2
1 2 2 v2
v1
v2
dt+
dr+ w
dt +
dr + w
d =
dt
dt = rdt
t
r
2
r2
t
r
2
r2
by Itos lemma. We eliminate the random component by setting

v1 v2
=
.
r
r
Consequently


v1 1 2 2 v1 v1 /r
+ w

t
2
r2
v1 /r

v2 1 2 2 v2
+ w
t
2
r2


dt


v1
= r v1
r

v2
r


dt.

Rearranging gives




v2 1 2 2 v2
v1 1 2 2 v1
v1
v2
+ w
rv1
=
+ w
rv2
= a(r, t),
2
2
t
2
r
r
t
2
r
r
as the first term above is a function of T1 but not T2 , and the second term is a
function of T2 and not T1 . It follows that the price v(r, t; T ) of a zero-coupon
bond satisfies the partial differential equation
v 1 2 2 v
v
+ w
+ a(r, t)
rv = 0,
2
t 2 r
r

(6.31)

together with the final condition for the payoff at maturity


v(r, T ; T ) = Z.

6.8.5

(6.32)

Bond Options

A European bond call (put) option is a contract that gives the owner the
right, but not the obligation, to purchase (sell) one bond (maturing at TB )
at a specified price K (the exercise, or strike, price) at a specified future

172

CHAPTER 6. FINANCE

date T < TB (the expiry date). In common with its equity analogue the
fair (arbitrage free) price c = c(r, t; K, T ; TB ) satisfies a partial differential
equation that we now derive.
Notice first that one can apply the above bond pricing argument with a
portfolio consisting of one bond v1 maturing at T1 together with options.
Again eliminating the random part gives

v1 c
,
=
r
r
followed by




c 1 2 2 c
c
v1 1 2 2 v1
v1
+ w
rv1
=
+ w
rc
= a(r, t).
2
2
t
2
r
r
t 2 r
r
It follows that the price c(r, t; K, T ; TB ) of a zero-coupon bond satisfies the
partial differential equation
c 1 2 2 c
c
+ w
+ a(r, t) rc = 0,
2
t 2 r
r

(6.33)

together with the final condition for the payoff at maturity given by

max(v(r, T ; TB ) K, 0) for a European bond call option
c(r, T ; K, T ; TB ) =
max(K v(r, T ; TB ), 0) for a European bond put option,
and appropriate boundary conditions.

Chapter 7
Modeling Projects
The questions raised in each of the projects listed below are only a guide;
you are free to ask and answer your own questions (or not).

7.1

The Planting Box

A contractor wishes to plant a tree in a planting box that is located close


to an underground steam pipe. She has asked you to advise her on the
advantages of lining one side and the bottom of the planting box with an
insulation material. She would like to see a plot of the isotherms with an
without the insulation in place. The physical parameters are given in the
Table below:
Material
steel
concrete
insulation
soil

Density
Specific Heat Thermal conductivity
3
(lbm ft ) (Btu lbm1 F1 )
(Btu hr1 ft1 F1 )
489.01
0.11
30.62
150.00
0.25
0.79
8.5
0.18
0.03
85.0
0.21
0.90

Assume that the temperature of the steam on the inner surface of the
pipe is 400 F and that the pipe has an inner diameter of 10 inches and an
outer diameter of 11.5 inches. The insulation around the pipe is 2 inches
thick and is assumed to be in place for both calculations. There is a concrete
walk over the area which is 4 inches thick; the concrete box is 5 inches thick
and 40 inches wide on a side as an outside dimension. The center of the
173

174

CHAPTER 7. MODELING PROJECTS

Figure 7.1: Cross-section of box and steam pipe

pipe is 36 inches from the outer edge of the side of the box and 36 inches
from the surface of the concrete walk. The insulation used as a lining of
the one side and bottom of the box is 6 inches thick. The temperature of
the air is 90 F and the coefficient of thermal convection into the air is 0.88
Btu hr1 ft2 F1 .
This is a steady-state heat conduction problem for the temperature T (x, y)
over the region given in the Figure. The equation is

kT = 0

where k is the thermal conductivity which varies from material to material,


as given in the table.
Use a no-flow Neumann condition for the soil at a distance from the steam
pipe and box and a Dirichlet condition on the inner surface of the pipe; all
other boundaries involve heat loss from the region to the air. Specifically,

7.2. THE MRIDANGAM

175

the boundary conditions are:


T
y
T
0.03
y
T
0.90
y
T
T
x
T
y
0.79

= 0.88(T 90) on DE and F G


= 0.88(T 90) on EA
= 0.88(T 90) on AF
= 400 on the inner surface of the pipe
= 0 on DH and GI
= 0 on HI.

In addition to finding the maximum temperatures in the planting box


with and without insulation, investigate the effects of lining the side CF
with insulation, or increasing the thickness of the insulation around the steam
pipe. How much heat can the typical tree take?

7.2

The Mridangam

The mridangam drum from southern India consists of a radially variable density membrane stretched tightly over a circular frame as pictured below. It
has the unusual property of being harmonic, i.e. the frequencies of vibration of the membrane are integer multiples of the lowest, or fundamental,
frequency.
There are several approximate forms of with which one can investigate
the harmonic properties of the mridangam. The alternate continuous density
function

a ln(0.68 r) + b for 0.0 r < 0.62


1
for 0.62 r < 0.93
(r) =
d.r
ce
for 0.93 r 1
is another possibility for a suitable choice of the constants a, b, c, d. Investigate the various choices for the constants a, b, c, d to define this (r) so that
it works properly and produces (at least for the lower frequencies) the proper
harmonic behaviour.

176

CHAPTER 7. MODELING PROJECTS

Figure 7.2: The mridangam drum from Southern India

Figure 7.3: Continuous loading (r)

7.3

The Nutwrecker2000

A tool manufacturer has given you the specifications of their new spanner,
the Nutwrecker2000, shown below, and they are requesting your input as to
whether the spanner should be put into production. Specifically, assuming

Figure 7.4: The Nutwrecker2000

that a typical mechanic could exert at most a downward pressure of 150 psi
(pounds per square inch) on the handle, would the Nutwrecker2000 be liable

7.3. THE NUTWRECKER2000

177

to break under such conditions?


Choose the Structural Mechanics, Plane Stress application mode
in the PDE Toolbox. The graphics are built as follows. All coordinates are
in inches. Select OptionsAxes Equal and OptionsSnap, and also

Figure 7.5: Graphics construction for the spanner

OptionsAxes Limits with [-1 5] for the x-axis and [-1 1] for the yaxis. Next, make the selection OptionsGrid Spacing and set the x-axis
extra points to [-1 0 0.2 0.4 0.7657 5] and the y-axis extra points to
[-0.4 0 0.4 0.4828]. From the Draw menu create the rectangle R1 with
opposite corners at (0, 0) and (5, 0.4). Create the circle C1 with center
(0, 0) and radius 0.2, and the circle C2 with the same center and radius
0.4. The rectangle R2 is first formed with opposite corners at (0.2, 0) and
(0.2, 0.4828). This rectangle is then rotated 45 using DrawRotate; type
the angle into the dialog box, and also the rotation point, which is typed as 0
0 representing the origin (do not use center of mass rotation here). Draw
the square SQ1 with opposite corners at (0, 0) and (0.4, 0.4), and then rotate it about 0 0 by 45 . The rectangle R3 has opposite corners (0.4, 0)
and (0.7657, 0.4828). Finally, turn off the snap option with OptionsSnap
again, and form the circle E1 with center (0.7657, 0.4828) with radius such

178

CHAPTER 7. MODELING PROJECTS

that this circle touches the rectangles R1 and R3.


The spanner is created using the set formula
R1 + C2 + SQ1 + R3 (R2 + C1 + E1)
in the Set Formula line near the top of the PDEtoolbox screen. You also
need to select BoundaryBoundary Mode and BoundaryRemove
All Subdomain Borders to clean things up a bit.
Next, make sure you have selected the Structural Mechanics, Plane
Stress application mode, and return to Boundary mode. You will use a
Dirichlet condition on the claw part of the spanner that surrounds the
nut; as this is the default (in red) you need not change these boundary segments. The flat part of the handle at the top is assigned a traction of 150
psi as follows: left click on this section to highlight it, and then double left
click to bring up the boundary dialog; leave q=0 and set g1=-150*nx and
g2=-150*ny, explaining precisely why the negative signs are needed here.
The remaining boundaries are free (no normal stress), and thus take a Neuman condition with q=0 and g=0.
The material properties are set under PDEPDE Specification. Here
we have Youngs modulus E = 3.7e7 psi and the Poisson ratio = 0.3. One
should also set the adaptive mesh control under SolveSolution Parameters... by activating Adaptive mode. Finally from PlotParameters...
select Color and under Property select von Mises effective stress
Assuming that the spanner is made of steel with a yield strength of 50,000
psi determine if any yielding occurs because of the assigned load. If so determine precisely how the manufacturer should re-design the spanner to function
properly under these conditions.

7.4

The Frozen CIDS Problem

The concrete island drilling system (CIDS) is a platform composed of cellular


concrete modules stacked on top of each other, and these in turn support a
large barge-mounted drilling rig (see Figure 7.6 and Figure 7.7 for a cutaway
view under the ice). The modules can be stacked for siting in water of depths
of 6 to 20 metres.
The concrete honeycomb forms a high-strength, durable structure capable of withstanding cold temperatures and ice loads. The drilling unit is

7.4. THE FROZEN CIDS PROBLEM

179

Figure 7.6: Exxon Mobil CIDS platform Orlan drilling off the coast of Russia

Figure 7.7: Concrete island drilling system cutaway view

mounted on one of the two deck storage barges and is designed with a 25, 000foot drilling capability. There are quarters for 80 people and 10 months of
supplies for long-term operations. The entire system, with drilling rig intact,
can be relocated by pumping out the saltwater ballast and towing the CIDS
to a new site. A drilling contractor using a CIDS in the Arctic Ocean is
concerned that the water ballast in the outer ring of cells in the barge will
freeze and fracture the concrete walls of the honeycomb module. An insulation salesperson suggests insulating the outer walls of each of the cells with
roughly 10 inches of insulation, as illustrated in Figure 7.8. The water in the
cells that do not border on the perimeter of the barge is kept warm by the
drilling activity.

180

CHAPTER 7. MODELING PROJECTS

Figure 7.8: Cross-section of cells, with insulation

You are to investigate the salespersons suggestion. He observes that


the heat flow across the walls between cells is zero, and the temperature
at one end is -60 F (the ambient outside temperature) and at the other
45 F. Assume also that the thickness of the outer concrete wall between
the insulation and the -60 F seawater is 14 inches. Some relevant material
properties are given in SI units below. You do not need to convert the
dimensions in Figure 7.8 above to the relevant SI dimensions (why?)
Thermal conductivity
W m1 K1
concrete
0.114
water
0.048
insulation
0.00404

Specific Heat Density


J kg1 K1 kg m3
1050
2400
4190
1000
754
136

7.4. THE FROZEN CIDS PROBLEM

181

You can assume that the temperature function u(x, y) satisfies the 2D steady
state (elliptic) heat equation
((x, y)u) =

u
((x, y) ) +
((x, y) ) = 0
x
x
y
y

where is the thermal conductivity function. This equation can be solved


using the MATLAB PDE Toolbox:
Specifying the Domain
Choose OptionsGrid and OptionsSnap and set up your axes by initially specifying the X range as [150, 150] and the Y range as [40, 40] using
OptionsAxis Limits... Finally place extra X-ticks at 114, 90, and
80 and place extra Y -ticks at 28 using using OptionsGrid Spacing...
and making sure that the Auto box is un-checked in each case.
To create a polygon, first left click the polygon button (it has a polygon
on it) or choose DrawPolygon. Then move the mouse arrow (it turns
to cross-hairs inside the draw area) to the first vertex point; press and hold
the left mouse button and drag the line to the next vertex, and release the
mouse button when the cross-hairs are exactly over the new vertex. Repeat
this for each successive polygon side; the polygon is completed either by
reaching the first vertex, or by double clicking on the last vertex. Create
a polygon P 1 with vertices at (80, 20), (90, 20), (100, 10), (100, 10),
(90, 20), (80, 20), (90, 10), (90, 10). Then create another polygon P 2
with vertices at (90, 20), (100, 10), (100, 10), (90, 20), (80, 20),
and (80, 20). Finally click on the rectangle button (use the one without
the +) and create a rectangle by clicking and holding at (114, 28) and
dragging to (114, 28) The set formula line should read
P 1 + P 2 + R1
at this point.
Specifying the Boundary Conditions
Go to BoundaryRemove Subdomain Boundary and remove the vertical line connecting (80, 20) and (80, 20). Set the appropriate Dirichlet
conditions on the vertical sides of the rectangle, and Neumann conditions
on the horizontal sides by double-clicking on each rectangle boundary line

182

CHAPTER 7. MODELING PROJECTS

to bring up a dialog box. You do not need to set conditions on any of the
internal boundaries.
Specifying the PDE
Choose PDEShow Subdomain Labels. This command places numbers
on the various sub-domains in the domain you have drawn. We can now give
our various coefficient functions different values in the different sub-regions.
For example, choose PDEPDE Specification and select the elliptic
option. Notice that the ballast water region is actually marked as regions
1 and 2 here. In the sub-region marked as 1, first click on that sub-region
to select it; then double-click on it to bring up the dialog box. You will set
a = 0, f = 0, and set c to the value of thermal conductivity determined by
the table above. Repeat this process for all of the sub-regions.
Specifying the Mesh
Press the initialize-mesh button, and do two refinements by pressing the
refine-mesh button twice; you should have around 2928 triangles in this mesh.
Solving and Plotting
First set the plot options by pressing the plot button, or choosing PlotParameters;
press the Contour button (and release the Color button if necessary). This
will give you a contour plot with equal temperature values in the final steady
state appearing on colored lines. Now press the solve button (it looks like
) to solve the problem.
The Report
Write a report detailing your choice of equation and boundary conditions;
explain precisely why in this case there was no problem with the material
properties being given in SI units, while the cell dimensions were given in
inches and degrees centigrade. Include a copy of the contour plot of the 32 F
contour. You can print the contour plot by choosing FilePrint... from
the File menu in PDETool; when the print dialog box comes up check the
Print to File box and print the file as usual.

7.5. COOLING A COMPUTER CHIP

183

Note that If you wish to just plot one contour, this is a little more difficult. You must first export the mesh and the solution to the main MATLAB workscreen using SolveExport Solution... and MeshExport
Mesh... and in the MATLAB workscreen type
pdeplot(p, e, t,0 xydata0 , u,0 contour0 ,0 on0 ,0 levels0 , [32, 32])
to plot the 32 F isotherm, for example; here each of the quote marks above
is a right quote.
Discuss the soundness of the salesmans suggestion. What effect, if any,
will increasing the thickness of the insulation have?
We studied above the difficulties encountered in deploying a concrete
island drilling system (CIDS) off-shore in the arctic ocean. The problem
stated that the seawater was at a temperature of -60 F and we found using
the steady-state version of the heat equation that the ballast in the platform
became a solid lump of ice.
Re-do this problem using the standard heat equation and determine precisely when the ballast begins to freeze after the CIDS is deployed.
There is some question as to whether the arctic ocean can reach a temperature of -60 F. Find how low the seawater temperature actually gets
in practice, and re-do the problem with more reasonable estimates of the
seawater temperature. You may wish to employ the additional fact that the
seawater temperature is in practice not constant, but varies sinusoidally with
the seasons.

7.5

Cooling a Computer Chip

Computer chips work faster if they are not too hot, but operating them
creates heat. In order to dissipate the heat, designers can surround the
(silicon) processing units by a high-conductivity material like copper to act
as a heat sink to conduct the heat away. The cross-section of a typical
configuration is shown in the figure below:

184

CHAPTER 7. MODELING PROJECTS

The temperature obeys the equation


T (x, t)
(k(x)T (x, t)) = Q(x)
t
where k is the conductivity of the material and Q models the heat source.
The (generalized Neumann) boundary conditions are
n (k(x)T (x, t)) = 0
on the insulator boundary, and
n (k(x)T (x, t)) = t(T (x, t) Troom )
on the other boundaries, where n is the unit outward normal direction (i.e.,
orthogonal to the boundary, length 1, and pointing out), h is the heat transfer
coefficient, and Troom is room temperature. This says that there is no heat
flow to the insulator, and that flow to the air depends on the difference in
temperature. Here are the (somewhat realistic) values we will use:

7.6. GROUNDWATER MODELLING

185

The Report
(a) Initialize the mesh and then refine 4 times. Plot the temperature distribution in the domain at time t = 100 when the thickness b = 2 mm.
(See figure above.) Label the plot with the maximum temperature and
identify the point at which it occurs.
(b) Plot the maximum temperature at t = 100 as a function of b [1, 6]
and determine (to 2 significant figures) the smallest thickness for which
the temperature is at most 500K. How accurate do you believe your b
value is? Justify your answer.
Submit your plots, your program, your minimal b value, and your justification.

7.6

Groundwater Modelling

A two-dimensional aquifer system is rectangular, with dimensions 3000 meters by 1500 meters. The aquifer is replenished from a surface-water supplied
swamp area P1 that is 50 meters wide on the eastern side of the line between
(1200, 1500) and (1800, 0) in the Figure below. In addition to the aquifer
area R1, the square areas SQ1 and SQ2 represent pumping regions that are
50 meters square located to the north and east of the points (600, 500) and
(2400, 1000), respectively. In PDE Toolbox the proper set combination is
(R1-(P1+SQ1+SQ2))+P1+SQ1+SQ2.
The piezometric head u(x, y, t) represents the height, in meters above
some standard datum level often taken to be the mean sea water level, of
water in the aquifer at position (x, y) at time t days. The PDE that governs
groundwater flow is
u
(T u) = Q,
S
t
where S is the storativity, which is dimensionless, T is the transmissivity
measured in units of m2 /day, and Q is the inflow or aquifer recharge term,
in units of m3 /day/m2 .
We assume that at the eastern and western boundaries, the head is fixed
at u = 100 and that the remaining boundaries are impervious, so that there
is no groundwater flow across them. The transmissivity in the aquifer is

186

CHAPTER 7. MODELING PROJECTS

Figure 7.9: A transient groundwater model

assumed to be 30 m2 /day, and the storativity S is taken to be 0.003. Assume


also that the swamp region area is recharged at 0.01 m3 /day/m2 , that water
is removed from the pumping area SQ1 at 0.48 m3 /day/m2 and that over
SQ2 water is removed at 0.96 m3 /day/m2 . Finally, assume that initially we
have u = 100 throughout the aquifer, i.e. u(x, y, 0) = 100 for all x and y.
Is this pumping situation a sustainable one? You should test your code
over, say, a 10 day period, and then look at the piezometric surface over
periods up to at least a year (5 years is better!). If you see the surface of
the aquifer going down further and further over time without stabilizing,
the yield is not sustainable, and the aquifer is being emptied! To try for a
sustainable option, you must decrease the pumping. When you have found
sustainable pumping values determine the approximate volume of water per
year that can be pumped from the aquifer in units of ML/year (mega-liters
per year) this is the number your boss, a politician and chair of the local
water board, wants from you.

7.7. THE FUEL SPILL

7.7

187

The Fuel Spill

You live on a long 10 meter wide boat canal, and your neighbor 200 meters
upstream spills one kilogram of boat fuel onto a circular patch of the canal
water surface S of area one square meter. Suppose that at first the current
in the canal is negligible and the fuel is transported on the canal surface only
by diffusion, so that the concentration C(x, y, t) of fuel at position (x, y) in
the canal from the spill at time t seconds later satisfies
C
= D.C,
t

(x, y) R2 ,

t > 0,

where the diffusion constant is D = 0.04 m2 s1 and



1 if (x, y) S,
C(x, y, 0) =
0 otherwise.

(7.1)

Find the first time at which the fuel concentration reaches 5105 Kg/m2 .
Find also the maximum surface concentration reached by the fuel in the
vicinity of your house.
Later you find that, due to upstream run-off, the canal water surface was
actually moving at 0.01 m/s. In this case the concentration C(x, y, t) actually
satisfies the convective diffusion equation
C
= D.C v C,
t

(x, y) R2 ,

t > 0,

where v denotes the velocity of the canal water, together with the same
initial condition (7.1). Redo the above calculations in this case.
If one assumes that the canal current is reversed and actually flows from
your house toward the spill point, is it possible that the fuel never reaches
your house in the sense that the concentration at your house never exceeds
5 105 Kg/m2 ?

7.8

The Soap Bubble Problem

A soap film bounded by a wire frame has the shape determined by the minimization of its internal energy. The shape of the film is described by the
height u(x, y) over a given domain in the xy-plane, assuming that the
height is fixed at the domain boundary. So a wire fram consisting of parallel

188

CHAPTER 7. MODELING PROJECTS


Color: u Height: u
1

0.9
1

0.8

0.8

0.7

0.6

0.6

0.5

0.4

0.4

0.2

0.3
0
1
0.2
1

0.5
0.8

0.6

0.1

0.4

0.5
0.2
1

Figure 7.10: A soap film

semi-circular pieces joined and perpendicular to horizontal straight pieces


would have a soap film as shown in the Figure below.
In general, if the film is homogeneous (as are most soap films), minimizing
the internal energy is equivalent to minimizing the area, which is the integral
of
p
s(u) = 1 + |u|2
From the theory of minimal surfaces we then have that such a surface u
satisfies
u
) = 0, inside ,
s(u)
u(x, y) = g(x, y), on the boundary of .

This equation is non-linear in the solution u, and cannot be solved in PDE


toolbox in the usual way.
Such problems can be solved as in the following example. Set up a
rectangle with its lower left corner at (0, 1) and its upper right corner
at (2, 1). Define Dirichlet data on this rectangle as follows: on the y-axis let

7.9. BLOOD FLOW

189

p
p
g(0, y) = 1 y 2 ; on the line x = 2 let g(2, y) = 1 y 2 ; on the remaining lines let g(x, 1) = g(x, 1) = 0. Under PDE Specification choose
elliptic and set c to be
1./sqrt(1.+ ux.^2 + uy.^2)
and a=f=0. Under SolveParameters... select Use nonlinear solver
and set the Jacobian option to Full.
Experiment with this film: does it break if the length is increased beyond
two? Can you make other films? For example you can set up concentric
circles as the wire boundaries, and have the wires at different heights.

7.9

Blood Flow

In the apparatus below, a fluid is flowing through a tube of radius r and


length l under the influence of the gravity-driven pressure gradient resulting
from the head of fluid of height h in the tank. This apparatus models many

Figure 7.11: Incompressible viscous flow

interesting flows, include that of blood flow through arteries and veins in the
human body.

190

CHAPTER 7. MODELING PROJECTS

The PDE
As always denote the fluid velocity vector by u = (u1 , u2 , u3 ). We assume
that the flow is uni-directional, so that u2 = u3 = 0. We also assume that
the velocity is independent of distance in the flow direction, and thus the
acceleration of a fluid particle is u/t, which now has just one non-zero
component. If the flow is steady (i.e. independent of time), the NavierStokes equations then reduce to the single equation
0=

2 u1 2 u1
p
+ ( 2 +
).
x1
x2
x23

If the flow is in the direction of the positive x1 axis and there is a constant
pressure gradient resulting from a pressure p1 at the exit end of the tube and
p2 at the tank end, then we may set
p
p1 p2
=
= G,
x1
l
where G > 0. The Navier-Stokes equation now reduces to the single elliptic
equation
G
2 u1 2 u1
+
=
2
2
x2
x3

over the circular region of radius r for the velocity u1 across any crosssection of the tube.
Use the MATLAB PDEToolbox to compute u1 for three tubes of radius
r = 1, 2, 3 millimetres. You may assume that l is one meter, and that the
pressure drop is 0.01 atmospheres (one atmosphere is 105 Pascals, or about
15 pounds per square inch, if you need some perspective). Assume that the
viscosity of the fluid is 0.001 Nsm2 . Dont forget to change everything to
SI units before starting to set up your geometry in PDEToolbox (see 1.2 in
the notes). Use the no-slip condition
u1 = 0
at the boundary of your circle of radius r.
The Volume Flux
An interesting quantity to compute is the rate at which fluid comes out of the
tube, the volume flux, measured in m3 s1 (cubic meters per second). If we

7.9. BLOOD FLOW

191

consider the volume of fluid that flows through a small part A of in time
t, we can see that it is the amount of fluid in a cylinder of height Ru1 t and
base area A. So the total volume of fluid through in time t is t u1 dA.
Consequently the volume flow rate (volume flux) of fluid coming out of the
pipe is
Z
u1 (x2 , x3 ) dx2 dx3 .

You can compute this quantity for each of the choices of radius r as follows.
When you compute the u1 in PDEToolbox you can choose SolveExport
Solution from the Solve menu and the solution is exported to the MATLAB
screen from which you called PDEToolbox as the array u. Before going
back to the MATLAB screen you need to also export the mesh, by choosing
MeshExport Mesh; the arrays p, e, and t representing, respectively, the
mesh node points, the triangle edges, and the triangle vertices. Now return
to the MATLAB window; you should see at least four new arrays, u, p, e, and
t listed in the top left window. To integrate u over the region (represented
by p and t) we first note that in the finite element method,
u(x2 , x3 ) =

N
X

Ui i (x2 , x3 )

i=1

where N is the number of mesh points in and the functions i are the FEM
hat functions. So
Z
u1 (x2 , x3 ) dx2 dx3 =

N
X
i=1

Z
Ui

i (x2 , x3 ) dx2 dx3 .

As the u that we exported from PDEToolbox is just the vector of the Ui , to


compute the integral we merely need the scalar product of u with the vector
whose components are the integrals in the above sum. Now the integrals
Z
Fi =
f i (x2 , x3 ) dx2 dx3 ,

where f is the right-hand side function in the elliptic PDE (cu)+au =


f , are produced as a standard part of the solution process by the MATLAB
function assema and we now only have to call this function using f = 1 to
obtain the desired integrals. The calling sequence for assema is

192

CHAPTER 7. MODELING PROJECTS


[K,M,F]=assema(p,t,c,a,f)

where c,a,f are the PDE coefficients, p,t are the mesh vectors discussed
above, and the output arrays K,M,F are, respectively, the FEM stiffness matrix, the mass matrix, and the vector of right hand side integrals Fi that we
need here. So at the MATLAB prompt >> type
[K,M,F]=assema(p,t,1,0,1)
and then type F*u to form the scalar product of u and F , thereby computing
the integral of u over . Repeat this for each of the three radii r.
Find the volume flux in each of the three cases, in each case converting
to units of cubic centimeters per second (otherwise known as millilitres per
second). It is known that the volume flux is proportional to a positive integer
power of the radius. Use your data to estimate this power.

7.10

The Skin Effect in a Circular Wire

Alternating current (AC) electromagnetic problems arise in connection with


many industrial problems, including motors, transformers, and the study of
conducting materials. As always, at the center of electromagnetic theory
are the classical Maxwell equations. In the study of conductors carrying
electrical currents one has to concentrate on the following reduced Maxwell
equations, assuming a charge free homogeneous dielectric, so = 0, D = E,
B = H, and
E = 0
H
t
E
H = 
+ J,
t
E =

where E is the electric field with units of volts per meter (V m1 ), H is the
magnetic field with units of amperes per meter (A m1 ), J is the current
density with units of amperes per square meter (A m2 ), is the magnetic
permeability measured in henrys per meter, or m kg s2 A2 , and  is the coefficient of dielectrics (or electric permittivity) measured in farads per meter
or s4 A2 m3 kg1 .

7.10. THE SKIN EFFECT IN A CIRCULAR WIRE

193

It is usually assumed that


J = E,
which is commonly known as the generalized Ohms law; here is the electrical conductivity with units of amperes per volt-meter or AV1 m1 . The
above Maxwell equations then lead to
E

E
2E
 2 = 0.
t
t

jt
One then assumes
that E = Ec e so that the electric field is periodic in
time; here j = 1 is typically used instead of i which is often used for the
current in engineering books. In the PDE toolbox we further assume that
Ec = (0, 0, Ec ) is only varying in one dimension; in consequence we also have
J = (0, 0, Jejt ), where J = Ec , and

H = (Hx , Hy , 0) =

1
Ec .
j

In particular the scalar equation for Ec is


1
( Ec ) + (j 2 )Ec = 0.

This equation is automatically employed in the AC Power Electromagnetics


application mode in PDE toolbox, after you type in the values of the various
coefficients. Notice that the solution is automatically complex valued, so you
can only graph entities like the real part of u, or its imaginary part, or such
like.
The skin effect may be seen when an AC current is carried by a wire
with a circular cross-section. First we set up the PDE toolbox as follows.
Enter the AC Power Electromagnetics mode from the menu under the default
box marked Generic Scalar Equation. Draw a circle with radius 0.1 to
represent a cross-section of the conductor. Then enter boundary mode and
use EditSelect All to set all the parts of the circular boundary at once.
Double left click on the boundary to bring up the boundary dialog box in the
AC Power application mode and enter 1/57E6 into the r field; this sets the
Dirichlet boundary condition of E = (1/57) 106 . Next, press the PDE
button to bring up the PDE Specification dialog and enter data from the
following table:

194

CHAPTER 7. MODELING PROJECTS


Angular frequency
Magnetic permeability
Conductivity
Coeff. of dielectricity

2*pi*50
4*pi*1E-7
57E6
8.8E-12

The angular frequency = 2f = 250 corresponds to a line frequency of


f = 50Hz (one Hertz is one cycle per second), which is the frequency of the
stuff comming into your house. From the plot dialog, choose Height (3-D
Plot) and opposite this, change electric field to current density. Finally, from SolveSolve Parameters activate the Adaptive mode and
set the maximum number of triangle to Inf and the maximum number of
refinements to 1; the latter means that you will have to recompute the solution sometimes to obtain suitably small triangles near the edge of the circle
where the solution gradients will be large.
The toolbox will automatically plot the real part of the solution; you
can choose to plot, for example, imag(u) or abs(u), instead of real(u).
The skin effect can now be seen in that the current density is large near
the outer extremities of the wire, and much lower in the center. The effect
decreases markedly with decreasing frequency and increases with increasing
frequency. Check this by putting values of from 20.01 to 21000000 in
the PDE Specification dialog.
You can plot cross-sections of the solution u as follows. Export the solution u to MATLAB, as well as the mesh data p,e,t. At the MATLAB
prompt type, successively, pressing Enter each time,
x=0:0.001:0.1;
y=x;
uxy=tri2grid(p,t,u(:,1),x,y);
plot(x,real(uxy(1,:)))
and a graph of the cross-section appears. You can look at these cross-sections
for changing . You should realize that these plots are of the solution u = Ec ;
to plot current density J in MATLAB you would need to rescale by J = u.
The interest in this phenomenon is that if one were to transmit high
frequency electromagnetic waves using such a conductor there would be
very high resistance, and thus great heat losses. For this reason microwave
(i.e. megaHertz) transmission is usually done with waveguides (see the next
project).

7.11. HURRICANES AND SOAP BUBBLES

7.11

195

Hurricanes and Soap Bubbles

Physicists at the University of Bordeaux in France recently discovered that


when hemispherical soap bubbles are heated on a metal hotplate, swirling
multi-colored vortices are created and move around in the soap bubble film
in much the same way that hurricanes form and move in the relatively thin

Figure 7.12: Vortex in a soap bubble

film of air that constitutes our own atmosphere. Based upon these soap
bubble experiments, the team developed a promising forecasting model for
predicting the paths of real hurricanes. Rather than using soap, we will
try to use COMSOL to create vortices in a realistically sized hemispherical
shell of air heated sinusoidally at the equator. The COMSOL model file
hurricane3d.mph is available on the class website. Here we use the multiphysics capabilities of COMSOL in that we model air movement with the
Navier-Stokes equations for compressible flow (under Laminar Flow), together with a convective diffusion equation to model the critically important
temperature effects (under Heat Transfer in Fluids). For the fluid flow
we use slip (no flow) conditions on the upper and lower sides of the shell
which is set up as Wall boundary. The flat equatorial side is used as an
Inlet boundary with a set normal velocity of 20 m/s. At the vertical North
Pole boundary (see below) we have an Outlet boundary where the pressure is set at zero. For the temperature conditions, we set the North Pole
boundary to 293.14K and the walls as Thermal Insulation boundaries.
The equatorial boundary temperature is set to

196

CHAPTER 7. MODELING PROJECTS

Figure 7.13: Earths atmosphere in COMSOL

mean*amp*sin(af*t)*sin(atan2(y,x))

to incorporate the night/day heating cycle at the equator. Here, the mean
temperature is set at 333[K], the temperature variation amp is 10[K] and the
angular frequency af is 2/[(24)(3600)] = 0.00007272. The spherical angle
= atan2(y, x), where atan2(y,x) calculates arctan(y/x), but is sensitive
to both the different quadrants involved, and even to the possibility of x being zero. We note that the parameters like mean and amp are defined in the
Global Definitions node under Parameters. One must be quite careful here in naming such parameters. In particular COMSOL uses reserved
names such as u,v,w,x,y,x,t for the Cartesian coordinates and time, and
the fluid velocity components, and combinations like ux,uy,uz,ut and so on
for derivatives, and uxx, ... for higher derivatives. You must not inadvertently use any of these names for one of your parameters (as I have done!).
COMSOL does not do any checking for this kind of stuff, but does give weird
errors like Pointwise constraints for time derivatives are not supported ...
while crashing your program run. Be aware that the time run is currently
set to 104 seconds (about 3 hours) with a computer run time of 47 minutes,
and one really needs to reset this to run for several model days.
It is not clear at this stage whether on not this will work ...

7.12. A RECTANGULAR WAVEGUIDE

197

Figure 7.14: The North Pole in COMSOL

7.12

A Rectangular Waveguide

A waveguide is a rectangular (or cylindrical) metal tube or pipe used to


transmit electromagnetic waves; specific application include microwave communications, broadcasting, and radar installations. An electromagnetic field
can propagate along a waveguide in various ways. In TM-mode, for example, magnetic lines of flux are perpendicular to the axis of the waveguide; in
TE-mode the electric lines of flux are perpendicular to the waveguide axis.
To function properly, a waveguide must have a certain minimum diameter
relative to the wavelength (frequency) of the electromagnetic field. If the
waveguide is too narrow, or if the frequency is too low, the wave will not
propagate.
This project involves a plane TE-wave sent into a wave guide that has a
sharp bend, the size of which is comparable to the wavelength of the wave.
Due to reflections on the walls of the waveguide, the plane wave is scattered.
We are interested to see how the shape of the bend affects the solution at
the exit of the waveguide. In particular, we compute, for three different bend
shapes, the energy of the scattered waves at the exit boundary.
The governing equation, which derives from the classical Maxwell equations, is the wave equation
2U
= U.
t2
If we assume that the wave is periodic (monochromatic), so that U (x, y, t) =
e2ikt u(x, y) then u satisfies the Helmholtz equation
u + 4 2 k 2 u = 0,

198

CHAPTER 7. MODELING PROJECTS

Figure 7.15: A wave guide

where k = 1/ is the wave number, and is the wavelength (period). For


the three waveguides illustrated below, there are three types of boundary
conditions. The entry, which lies on the line x = 0 we imagine the incoming
wave normally being split into an ingoing plane wave e2ikt e2ikx traveling
to the right, and a reflected part that must be absorbed by the choice of
boundary condition at the entry. This leads to the entry boundary condition
n u + 2iku = 4ik.
At the exit, along the line y = 0.8 we need an absorbing boundary condition
to ensures that no part of the exiting wave reflects back into the waveguide.
This requires the boundary condition
n u + 2iku = 0.
On all remaining walls of the waveguide, which are assumed to be perfectly
reflecting, there are no electric field oscillations, so we set the Dirichlet boundary condition u = 0. Finally, we choose the wavelength = 0.2 to be reasonably responsive to the size of the waveguide bend; thus k = 5 in each of
the above Neumann conditions.

7.12. A RECTANGULAR WAVEGUIDE

(a) Waveguide 1

199

(b) Waveguide 2

(c) Waveguide 3

Figure 7.16: Three bends


In addition to contour plotting the waves in the three waveguides, you
can plot the waves at the exit boundary as follows. First for each waveguide
you will need to export the solution u as well as the mesh data p,e,t. Then
return to MATLAB and use the following commands:
index=find( p(2,:)==0.8 );
x=p(1,index);
v=u(index);
Here x contains the grid-points at the exit, while v contains the complex
values of the solution; as the original mesh is unstructured, x and v must
now be sorted then plotted:

200

CHAPTER 7. MODELING PROJECTS

[x,index]=sort(x);
v=v(index);
plot(x,abs(v))
If you save the three bends in vectors v1,v2,v3 they can all be plotted on
one graph. At this stage x and v are vectors containing the grid points and
values in the usual order. The energy of each wave at exit is the integral
Z 0.8
|u|2 (x, 0.8) dx.
0.4

As the energy of each wave on entry to the waveguide is 0.4 (why?), the
energy loss may be computed in MATLAB using the trapezoid quadrature
rule:
N=length(x);
w=abs(v).^2;
E=sum(0.5*(w(2:N)+w(1:N-1).*diff(x))/0.4
Here the MATLAB function diff(x) applied to a vector x=[x(1),x(2),...,x(n)]
gives the (n-1)-vector of differences [x(2)-x(1),...,x(n)-x(n-1)]. Comment on the effectiveness of each waveguide in transmitting energy. Investigate what happens if the wave number k changes.

Appendix A
Typesetting with TEX
From the earliest cave hieroglyphs to the present time it is evident that
we as a society depend in a fundamental way upon the written word, not
just for mere communications, but as the main storage medium for much
of our accumulated knowledge. An important, even crucial, aspect of the
effectiveness of a written document as a vehicle for transmitting information
is the connection between the logical structure of the ideas being presented
in the document and the visual layout of the characters on the pages of
the document. This is especially true when it comes to presenting technical
scientific and engineering material containing a lot of mathematical notation.

In earlier times, all documents were hand-written, mostly by professional


scribes who developed over the centuries layout conventions for the place201

202

APPENDIX A. TYPESETTING WITH TEX

ment of formulae, chapter and section headings, quotations, and the like,
to produce a pleasing and visually effective look to the documents. This
rather loose process was brought strongly into focus by the introduction of
the printing press by Johann Gutenberg (pictured above, with his press) in
the fifteenth century. Now the visual presentation of documents was in the
hands of a new breed of artisans the typographers whose job it was to set
the heavy lead typefaces into a type-rack which was then used to print the
document. If you look at technical books produced in the pre-computer era1
you will see that many of them were beautiful examples of the printed word.
Over the centuries, the typographers had developed to a high art techniques
for the effective visual presentation of complex ideas on the printed page.
Then the computer era dawned, bringing with it word-processing programs like Word Perfect and (ugh!) Word. These programs of course allowed each user to be their own typographer. The user could place characters anywhere they chose on their computer screen and then print the
result. Of course, without much knowledge of the art of typography or help
from the computer program, the results were generally rather shabby, and
only suitable for very simple applications like letters and memos and the
like. Computer programs of this type are called WYSIWYG2 (pronounced
wizzywig) programs, and they
rapidly took over the world of publishing. The old-time typographers
were, it seemed, no longer relevant.
Worse, all their accumulated knowledge as to how to place characters on
the printed page to achieve the beautiful and effective presentation of the
books of their era is not a part of
the WYSIWYG world, and this is all
too apparent in the poor typographical quality of many of the technical books published today. This was
certainly the case in the late 1970s
when this all-too-bleak typographical future became apparent to Donald Knuth, a Stanford computer scientist
1
2

for example, Oxford University Press, which dates back to 1586


This stands for What You See Is What You Get.

A.1. GETTING STARTED

203

who was in the process of writing his seven volume epic The Art of Computing. He tried to have one of the early volumes computer typeset and the
effort was, in his view, a dismal failure. Fortunately for the rest of us, rather
than just admitting defeat, as one of the worlds pre-eminent computer scientists he was in a position to actually do something about the problem.
Over about a ten year period, he read old books on typography, and even
interviewed some of the old typographers. He found that they had lots of
clever tricks, like kerning, ligatures, and adjustable interword spacing. Then
he coded all of this knowledge into a computer typesetting program that he
called TEX (pronounced tek). Finally, he gave the program away! This
last act makes it possible for anyone to download and freely use what is still
today the finest computer typesetting program available. In particular, the
TEX system is installed on the Mac Lab machines in HHB221 (look for the
LATEX icon in the MacBook Dock).
A useful reference for the version that we will use is LATEX: A Document
Preparation System (2nd Edition) by L. Lamport, Addison-Wesley, 1994; you
can obtain used copies easily on Amazon. These very notes you are reading,
by the way, are written in LATEX on my Mac.

A.1

Getting Started

TEX is a typesetting system as opposed to a mere word-processing program.


What does this mean? The short answer is that you, the user, have to prepare
a source file3 that contains not only the words that are to appear in your
document, but also formatting instructions for those words. Thus, some
words are part of the standard text of the document, others form chapter
or section headings, and still other symbols form mathematical formulae. In
effect, TEX is requiring that you, as the user, separate the logical content of
your document from the layout and formatting. Once this is done, TEX then
takes over and handles most of the layout according to its in-built rules for
proper typography.
We start with a simple example. Start TEX by double clicking the
TexShop icon
3

The TEX program is in fact a compiler. It converts files with a .tex extension to
corresponding files with a .pdf extension that contain the formatting information needed
to preview the final printed page on the screen, or to print.

204

APPENDIX A. TYPESETTING WITH TEX

in the Mac Dock. The TexShop editor window (which is basically a frontend to the TEX system) is TEX literate in that it recognizes and highlights
many of the TEX commands. Type the following into a file that you should
save as texample.tex in your USB directory:
% Simple source file texample.tex
% All source files must end in .tex
% Anything on a line after a % symbol is ignored by TeX
\documentclass{article}
\begin{document}
This is a somewhat minimal \TeX\ source file.
It contains this blurb
as well
as the finest formula known
to
the mathematical world.
The great mathematician Leonhard Euler (pronounced
Oiler) discovered the formula $$ e^{i\pi } + 1 = 0 $$
that connects
five of the most interesting quantities
in mathematics, $e$, $\pi$,
$i=\sqrt{-1}$, $1$, and $0$.
Rumour has it that he had this formula inscribed on his
tombstone!
\end{document}
On a Mac running TexShop, to save the file and call up the TEX compiler
(and send a preview version to the screen), just click the Typeset button at

A.1. GETTING STARTED

205

the top left of the TexShop editor screen. The output should look something
like the following:
This is a somewhat minimal TEX source file. It contains this blurb as well
as the finest formula known to the mathematical world.
The great mathematician Leonhard Euler (pronounced Oiler) discovered
the formula
ei + 1 = 0
thatconnects five of the most interesting quantities in mathematics, e, ,
i = 1, 1, and 0. Rumour has it that he had this formula inscribed on his
tombstone!

To print the document click on the printer icon

in the TexShop window.


Next, we look more closely at the source file texample.tex. Observe
first that TEX ignores all material following the % symbol, so this can be
used to add comments to the source. Next, throughout the file are words
that are prefixed by the backslash character, \ ; these are all TEX formatting
commands. Every TEX source file begins with
\documentclass{style-file}
where style-file refers to one of several choices: article is relevant for scientific
journal articles; report is suitable for reports and the like, and book covers
exactly what it says, books, both small and large; there are many other
style choices, including letter, slides for overhead transparency preparation,
and various variations on all of these. Much of the skill of the typgraphic
designer in terms of the myriad of choices of fonts and spacing and the like
is encapsulated in these files.
In similar fashion, every TEX source file must contain the commands
\begin{document}
main body of your document
\end{document}

206

APPENDIX A. TYPESETTING WITH TEX

that indicate to TEX the beginning and the end of your document contents.
Now to the actual contents of the document. The first paragraph is
typeset in 12 point computer modern font as specified in the article style
file. One can change much of this via options to the \documentclass{}
statement. A blank line in the source indicates a new paragraph. Notice that
TEX ignores most of the actual layout of the characters in this paragraphit
is only interested in the words themselves. The formatting command \TeX
produces the name TEX itself; notice that this is followed by a blank space
here which is accomplished via \ i.e. a backslash followed by a blank
character. In the second paragraph we first note Oiler in which to form a
correct pair of double quotation marks, we use two left quotes at the front
and two right quotes at the end.
Further on we have our first mathematical formula. The typographic rules
for mathematical material is a world unto itself and the rules of TEX reflect
this. By enclosing the formula between a pair of double dollar signs, we are
telling TEX that this is not only a mathematical formula, but a displayed
mathematical formula. As such, it must appear centered on a line by itself
with a certain amount of white space above and below. We do not need
to concern ourselves with the details, as TEX will take care of all of this for
us. By enclosing a formula with a pair of single dollar signs, one would be
instructing TEX to treat this as
an inline formula and typeset it as inline
mathematics. The formula i = 1 is one such example.
Finally the formula itself involves the TEX command \pi which is the
Greek letter . The exponent is written in the form
e^{i\pi}
where the hat symbol represents exponentiation with the exponent enclosed in the curly braces. It is important to note that in TEX curly braces
are used as scope delimiters and are only typeset by the TEX compiler
when directly ordered.

You might also like