lecture_3_methods
lecture_3_methods
Specific methods:
• Finite differences
• Pseudospectral methods
• Finite volumes
Seismometers
Generally heterogeneous
medium
… we need numerical
explosion solutions! … we need grids! …
And big computers …
Partial Differential Equations in Geophysics
2t p c 2 p s The acoustic
wave equation
( 2x 2y 2z ) - seismology
- acoustics
PP pressure
pressure - oceanography
cc acoustic - meteorology
acousticwave
wavespeed
speed
ss sources
sources
f ( x dx) f ( x)
x f lim
dx 0 dx
f ( x) f ( x dx)
x f lim
dx 0 dx
f ( x dx) f ( x dx)
x f lim
dx 0 2dx
f ( x dx) f ( x)
x f forward difference
dx
f ( x) f ( x dx)
x f backward difference
dx
f ( x dx) f ( x dx)
x f centered difference
2dx
The big question:
This leads us to Taylor series....
Our first FD algorithm (ac1d.m) !
2t p c 2 p s PP pressure
pressure
cc acoustic
acousticwave
wavespeed
speed
( 2x 2y 2z ) ss sources
sources
Problem:
Problem:Solve
Solvethe
the1D
1Dacoustic
acousticwave
waveequation
equationusing
usingthe
thefinite
finite
Difference method.
Difference method.
Solution:
Solution:
c 2 dt 2
p (t dt ) 2
p ( x dx) 2 p ( x) p ( x dx)
dx
2 p (t ) p (t dt ) sdt 2
Problems: Stability
c 2 dt 2
p (t dt ) 2
p ( x dx) 2 p ( x) p ( x dx)
dx
2 p (t ) p (t dt ) sdt 2
Stability:
Stability:Careful
Carefulanalysis
analysisusing
usingharmonic
harmonicfunctions
functionsshows
showsthat
that
aastable
stablenumerical
numericalcalculation
calculationisissubject
subjectto
tospecial
specialconditions
conditions
(conditional
(conditionalstability).
stability).This
Thisholds
holdsfor
formany
manynumerical
numericalproblems.
problems.
dt
c 1
dx
Problems: Dispersion
c 2 dt 2
p (t dt ) 2
p ( x dx) 2 p ( x) p ( x dx)
dx
2 p (t ) p (t dt ) sdt 2
Dispersion:
Dispersion:The The
numerical
numerical
approximation
approximationhas has
artificial
artificialdispersion,
dispersion,
in
in other words,the
other words, thewave
wave
speed
speedbecomes
becomes
frequency
frequencydependent.
dependent.
You
Youhave
haveto tofind
findaa
True velocity
frequency
frequencybandwidth
bandwidth
where
where this effectisis
this effect
small.
small.
The
Thesolution
solutionisisto
touse
useaa
sufficient
sufficientnumber
numberof ofgrid
grid
points
pointsperperwavelength.
wavelength.
Our first FD code!
c 2 dt 2
p (t dt ) 2
p ( x dx) 2 p ( x) p ( x dx)
dx
2 p (t ) p (t dt ) sdt 2
% Time stepping
for i=1:nt,
% FD
for j=2:nx-1
d2p(j)=(p(j+1)-2*p(j)+p(j-1))/dx^2; % space derivative
end
pnew=2*p-pold+d2p*dt^2; % time extrapolation
pnew(nx/2)=pnew(nx/2)+src(i)*dt^2; % add source term
pold=p; % time levels
p=pnew;
p(1)=0; % set boundaries pressure free
p(nx)=0;
% Display
plot(x,p,'b-')
title(' FD ')
drawnow
end
Snapshot Example
Velocity 5 km/s
3000
2500
2000
Time (s)
1500
1000
500
0
0 1000 2000 3000 4000 5000 6000
Distance (km)
Seismogram Dispersion
Finite Differences - Summary
•• Conceptually
Conceptuallythethemost
mostsimple
simpleofofthe
thenumerical
numericalmethods
methodsandand
can
canbe
belearned
learnedquite
quitequickly
quickly
•• Depending
Dependingon onthe
thephysical
physicalproblem
problemFD FDmethods
methodsare are
conditionally
conditionally stable
stable(relation
(relationbetween
betweentime
timeand
andspace
space
increment)
increment)
•• FD
FDmethods
methodshave
havedifficulties
difficultiesconcerning
concerningthetheaccurate
accurate
implementation
implementationof ofboundary
boundaryconditions
conditions(e.g.
(e.g.free
freesurfaces,
surfaces,
absorbing
absorbingboundaries)
boundaries)
•• FD
FDmethods
methodsareareusually
usuallyexplicit
explicitand
andtherefore
thereforevery
veryeasy
easyto
to
implement
implementandandefficient
efficientononparallel
parallelcomputers
computers
•• FD
FDmethods
methodswork
workbest
bestononregular,
regular,rectangular
rectangulargrids
grids
The Fourier Method
- Fourier Derivatives
.. let us recall the definition of the derivative using Fourier integrals ...
x f ( x) x F (k )e dk
ikx
ikF (k )e ikx dk
... the latter approach became interesting with the introduction of the
Fast Fourier Transform (FFT). What’s so fast about it ?
The FFT originates from a paper by Cooley and Tukey (1965, Math.
Comp. vol 19 297-301) which revolutionised all fields where Fourier
transforms where essential to progress.
N1
u k uˆ j e 2ikj / N , k 0,1,..., N 1
j 0
1 1 1 1 1 uˆ0 u0
1
2 3 N 1 uˆ1 u1
1 2 4 6 2 N 2 uˆ 2 u 2
( N 1) 2
1
N1
uˆ N 1 u N 1
.. where ...
e 2i / N
Numerical Methods in Geophysics The Fourier Method
The Fast Fourier Transform
... the FAST bit is recognising that the full matrix - vector multiplication
can be written as a few sparse matrix - vector multiplications
(for details see for example Bracewell, the Fourier Transform and its
applications, MacGraw-Hill) with the effect that:
Number of multiplications
N2 2Nlog2N
Number of multiplications
1 2 1
t p
x x p
c 2
1 1
p (t dt ) 2 p (t ) p (t dt )
x x p
c dt
2 2
1
p (t dt ) c 2 dt 2 x x p 2 p (t ) p (t dt )
where the space derivatives will be calculated using the Fourier Method.
The highlighted term will be calculated as follows:
ˆ n ik P
Pjn FFT P ˆ n FFT 1 P n
x j
multiply by 1/
n n
1 1 ˆ 1 ˆ 1 1 n
x Pjn FFT x P ik x P FFT x x Pj
... then extrapolate ...
p (t dt )
1 1 1
c dt x x p y y p z z p
2
2
2 p (t ) p (t dt )
ˆ n ik P
Pjn FFT P ˆ n FFT 1 P n
x j
n n
1 1 ˆ 1 ˆ 1 1 n
x Pjn FFT x P ik x P FFT x x Pj
nx=max(size(f));
n2=(nop-1)/2;
df=[1:nx]*0;
for i=1:nop;
df=df+d(i).*cshift1d(f,-n2+(i-1));
end
function df=sder1d(f,dx)
% SDER1D(f,dx) spectral derivative of vector
nx=max(size(f));
% initialize k
kmax=pi/dx;
dk=kmax/(nx/2);
for i=1:nx/2, k(i)=(i)*dk; k(nx/2+i)=-kmax+(i)*dk; end
k=sqrt(-1)*k;
we obtain
2 n 2 i ( kjdx ndt )
p k e
x j
2 dt
k sin
cdt 2
Numerical Methods in Geophysics The Fourier Method
Fourier Method - Dispersion and Stability
2 dt 2 1 kcdt
k sin sin ( )
cdt 2 dt 2
k max cdt
1
2
cdt / dx 2 / 0.636
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
3 point - 2 order; T = 6.6 s, Error = 50.8352%
1
0.5
-0.5
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
5 point - 2 order; T = 7.8 s, Error = 3.9286%
1
0.5
-0.5
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
Fourier - 2 order; T = 35 s, Error = 2.72504%
1
0.5
-0.5
-1
0.8 0.9 1 1.1 1.2 1.3 1.4 1.5
Time (sec)
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
3 point - 2 order; T = 7.8 s, Error = 156.038%
1
0.5
-0.5
-1
0.8 0.9 1 1.1 1.2 1.3 1.4 1.5
Time (sec)
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
5 point - 2 order; T = 7.8 s, Error = 45.2487%
1
0.5
-0.5
0.5
0.5
0
-0.5 0
0 200 400 600 0 10 20 30
Fourier - 2 order; T = 34 s, Error = 18.0134%
1
0.5
-0.5
-1
0.8 0.9 1 1.1 1.2 1.3 1.4 1.5
Time (sec)
160
140
120
Simulation time
100
3 point 5.4s
80 5 point 7.8s
Fourier 33.0s
60
40
20
0
5 Hz 10 Hz 20 Hz
t2 p c 2 p
t2 p ( x) (t ) c 2 p
the formal solution to this equation is
1 (t x / c )
p ( x, t )
4c 2 x
(Full proof given in Aki and Richards, Quantitative Seismology, Freeman+Co, 1981, p. 65)
1 (t x / c )
p ( x, t )
4c 2 x
In words this means (in 1D and 3D but not in 2D, why?) , that in
homogeneous media the same source time function which is input at the
source location will be recorded at a distance r, but with amplitude
proportional to 1/r.
0.8
0.6
5 point operator
0.4
0.2
0
10 200 400 600 800 1000
0.8
0.6
Fourier Method
0.4
0.2
0
Impulse response (analytical)
0 200 400 600 800 1000
Impulse response (numerical
Time steps
8 8 8
7 7 7
Frequency increases
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0
500 1000 1500 500 1000 1500 500 1000 1500
... regular
grid ...
Domain D
The key idea in FE analysis is to approximate all
functions in terms of basis functions , so that
N
u u~ ci i
i 1
Finite elements – basic formulation
Ax b |*y
yAx yb y n
We first look at Poisson’s equation (e.g., wave
equation without time dependence)
u ( x) f ( x)
where u is a scalar field, f is a source term and in 1-D
2
2 2
x
Formulation – Poisson’s equation
uv fv
D D
1 1
uvdx fvdx
0 0
1 1
uvdx uv 0 vudx
1
0 0
uvdx fvdx
0 0
... with u being the unknown function. This is also true for our
approximate numerical system
1 1
~vdx fvdx
u
0
0
... where ...
N
u~ ci i
i 1
10
... otherwise we
are free to choose 9
any function ...
8
The simplest 7
choice are of 6
course linear
functions: 5
4
+ grid nodes
3
blue lines – basis 2
functions i
1
The discrete system
The ingredients: N
v k u~ ci i
i 1
1 1
~vdx fvdx
0
u 0
1 1
n
ci i k dx f k dx
0 i 1 0
n 1 1
c dx f dx
i 1
i i k k
0 0
bi Aik g k
T
A b g kik i
The solution
bi A T 1
ik gk
remember that while the bi’s are really the coefficients of the
basis functions these are the actual function values at node
points i as well because of our particular choice of basis
functions.
Basis functions and element
Linear Quadratic
Trangles
Quadrangles
The Acoustic Wave Equation 1-D
1 1 1
t j u j dx f j dx
2 2
u dx v
0 0 0
N
u u~ ci (t ) i ( x)
i 1
together we obtain
1
1
1
t i i j
ci i j dx f j
2 2
c dx v
i 0 i 0 0
which we can write as ...
Time extrapolation
1
1
1
t i i j
ci i j dx f j
2 2
c dx v
i 0 i 0 0
M A b
mass matrix stiffness matrix
M T c v 2 AT c g
... remember the coefficients c correspond to the
actual values of u at the grid points for the right choice
of basis functions ...
M T c v 2 AT c g
ck 1 2c ck 1 2 T
T
M 2 v A ck g
dt
... leading to the solution at time tk+1:
ck 1 ( M T ) 1 ( g v 2 AT ck ) dt 2 2ck ck 1
Mij Aij
M=zeros(nx); A=zeros(nx);