02 finite differences
TRANSCRIPT
-
7/30/2019 02 Finite Differences
1/27
Finite Differences
Finite Difference Approximations
Simple geophysical partial differential equations
Finite differences - definitions
Finite-difference approximations to pdes Exercises
Acoustic wave equation in 2D
Seismometer equations
Diffusion-reaction equation
Finite differences and Taylor Expansion
Stability -> The Courant Criterion
Numerical dispersion
1Computational Seismology
dx
xfdxxffx
)()(
-
7/30/2019 02 Finite Differences
2/27
Finite Differences
)(222
22
zyx
t
spcp
The acoustic
wave equation
- seismology- acoustics
- oceanography
- meteorology
Diffusion, advection,
Reaction
- geodynamics- oceanography
- meteorology
- geochemistry
- sedimentology
- geophysical fluid dynamics
P pressurec acoustic wave speed
s sources
pRCCCkCt v
C tracer concentrationk diffusivityv flow velocityR reactivityp sources
Partial Differential Equations in Geophysics
-
7/30/2019 02 Finite Differences
3/27
Finite Differences
Finite differences
Finite volumes
- time-dependent PDEs
- seismic wave propagation- geophysical fluid dynamics
- Maxwells equations
- Ground penetrating radar
-> robust, simple concept, easy to
parallelize, regular grids, explicit method
Finite elements- static andtime-dependent PDEs
- seismic wave propagation- geophysical fluid dynamics
- all problems
-> implicit approach, matrix inversion, well founded,
irregular grids, more complex algorithms,
engineering problems
- time-dependent PDEs
- seismic wave propagation- mainly fluid dynamics
-> robust, simple concept, irregular grids, explicit
method
Numerical methods: properties
-
7/30/2019 02 Finite Differences
4/27
Finite Differences
Particle-based
methods
Pseudospectral
methods
- lattice gas methods
- molecular dynamics- granular problems
- fluid flow
- earthquake simulations
-> very heterogeneous problems, nonlinear problems
Boundary element
methods
- problems with boundaries (rupture)
- based on analytical solutions- only discretization of planes
-> good for problems with special boundary conditions
(rupture, cracks, etc)
- orthogonal basis functions, special case of FD
- spectral accuracy of space derivatives- wave propagation, ground penetrating radar
->regular grids, explicit method, problems with
strongly heterogeneous media
Other numerical methods
-
7/30/2019 02 Finite Differences
5/27
Finite Differences
What is a finite difference?
Common definitions of the derivative of f(x):
dx
xfdxxff
dxx
)()(lim
0
dxdxxfxff
dxx )()(lim
0
dx
dxxfdxxff
dxx
2
)()(lim
0
These are all correct definitions in the limit dx->0.
But we want dx to remain FINITE
-
7/30/2019 02 Finite Differences
6/27
Finite Differences
What is a finite difference?
The equivalent approximat ions of the derivatives are:
dx
xfdxxffx
)()(
dx
dxxfxffx
)()(
dx
dxxfdxxffx
2
)()(
forward difference
backward difference
centered difference
-
7/30/2019 02 Finite Differences
7/27Finite Differences
Thebigquestion:
How good are the FD approximations?
This leads us to Taylor series....
-
7/30/2019 02 Finite Differences
8/27Finite Differences
Taylor Series
Taylor series are expansions of a function f(x) for somefinite distance dx to f(x+dx)
What happens, if we use this expression for
dx
xfdxxffx
)()(
?
...)(!4
)(!3
)(!2
)(dx)()( ''''4
'''3
''2
' xfdx
xfdx
xfdx
xfxfdxxf
-
7/30/2019 02 Finite Differences
9/27Finite Differences
Taylor Series
... that leads to :
The error of the first derivative using the forward
formulation is of order dx.
Is this the case for other formulations of the derivative?
Lets check!
)()(
...)(!3
)(!2
)(dx1)()(
'
'''3
''2
'
dxOxf
xfdx
xfdx
xfdxdx
xfdxxf
-
7/30/2019 02 Finite Differences
10/27Finite Differences
... with the centeredformulation we get:
The error of the first derivative using the centered
approximation is of order dx2
.
This is an important results: it DOES matter which formulation
we use. The centered scheme is more accurate!
Taylor Series
)()(
...)(!3
)(dx1)2/()2/(
2'
'''3
'
dxOxf
xfdx
xfdxdx
dxxfdxxf
-
7/30/2019 02 Finite Differences
11/27Finite Differences
xj 1 xj xj 1 xj 2 xj 3
f xj( )
dx h
desired x location
What is the (approximate) value of the function or its (first,
second ..) derivative at the desired location ?
How can we calculate the weights for the neighboring points?
x
f(x)
Alternative Derivation
-
7/30/2019 02 Finite Differences
12/27Finite Differences
Lets try Taylors Expansion
f x( )
dx
x
f(x)
dxxfxfdxxf )(')()( (1)
(2)
we are looking for something like
f x w f xi ji
index jj L
( ) ( )
( ),
( ) ( ) 1
Alternative Derivation
dxxfxfdxxf )(')()(
-
7/30/2019 02 Finite Differences
13/27Finite Differences
deriving the second-order scheme
af af af dx '
bf bf bf dx '
af bf a b f a b f dx( ) ( ) 'the solution to this equation for a and b leads to
a system of equations which can be cast in matrix form
dxba
ba
/1
0
0
1
ba
baInterpolation Derivative
2nd order weights
-
7/30/2019 02 Finite Differences
14/27Finite Differences
Taylor Operators
... in matrix form ...
0
1
11
11
b
a
Interpolation Derivative
... so that the solution for the weights is ...
dxb
a
/1
0
11
11
0
1
11
11 1
b
a
dxb
a
/1
0
11
11 1
-
7/30/2019 02 Finite Differences
15/27Finite Differences
... and the result ...
Interpolation Derivative
Can we generalise this idea to longer operators?
2/1
2/1
b
a
1
1
2
1
dxb
a
Let us start by extending the Taylor expansion beyond f(xdx):
Interpolation and difference weights
-
7/30/2019 02 Finite Differences
16/27Finite Differences
'''!3
)2(''!2
)2(')2()2(32
fdxfdxfdxfdxxf *a |
*b |
*c |
*d |
... again we are looking for the coefficients a,b,c,d with whichthe function values at x(2)dx have to be multiplied in order
to obtain the interpolated value or the first (or second) derivative!
... Let us add up all these equations like in the previous case ...
'''!3
)(''
!2
)(')()(
32
fdx
fdx
fdxfdxxf
'''!3)(''
!2)(')()(
32
fdxfdxfdxfdxxf
'''!3
)2(''
!2
)2(')2()2(
32
fdx
fdx
fdxfdxxf
Higher order operators
-
7/30/2019 02 Finite Differences
17/27Finite Differences
dfcfbfaf
)( dcbaf
)22(' dcbadxf
)222
2(''2 d
cbafdx
)6
8
6
1
6
1
6
8
('''3
dcbafdx
... we can now ask for the coefficients a,b,c,d, so that the
left-hand-side yields either f,f,f,f ...
Higher order operators
-
7/30/2019 02 Finite Differences
18/27Finite Differences
1 dcba
022 dcba
0222
2 dcb
a
06
8
6
1
6
1
6
8 dcba
... if you want the interpolated value ...
... you need to solve the matrix system ...
Linear system
-
7/30/2019 02 Finite Differences
19/27Finite Differences
High-order interpolation
0
0
0
1
6/86/16/16/8
22/12/12
2112
1111
d
c
b
a
... with the result after inverting the matrix on the lhs ...
6/1
3/2
3/2
6/1
d
c
b
a
... Interpolation ...
-
7/30/2019 02 Finite Differences
20/27Finite Differences
0
0
/1
0
6/86/16/16/8
22/12/12
2112
1111
dx
d
c
b
a
... with the result ...
6/1
3/4
3/4
6/1
2
1
dx
d
c
b
a
... first derivative ...
First derivative
-
7/30/2019 02 Finite Differences
21/27Finite Differences
Our first FD algorithm (ac1d.m) !
)( 222
22
zyx
t spcp
P pressurec acoustic wave speeds sources
Problem: Solve the 1D acoustic wave equation using the finiteDifference method.
Solution:
2
2
22
)()(2
)()(2)()(
sdtdttptp
dxxpxpdxxpdx
dtcdttp
-
7/30/2019 02 Finite Differences
22/27Finite Differences
Problems: Stability
2
2
22
)()(2
)()(2)()(
sdtdttptp
dxxpxpdxxpdx
dtcdttp
1 dx
dtc
Stability: Careful analysis using harmonic functions shows thata stable numerical calculation is subject to special conditions(conditional stability). This holds for many numerical problems.(Derivation on the board).
-
7/30/2019 02 Finite Differences
23/27Finite Differences
Problems: Dispersion
2
2
22
)()(2
)()(2)()(
sdtdttptp
dxxpxpdxxpdx
dtcdttp
Dispersion: The numerical
approximation hasartificial dispersion,in other words, the wavespeed becomes frequencydependent (Derivation inthe board).
You have to find afrequency bandwidthwhere this effect is small.The solution is to use asufficient number of gridpoints per wavelength.
True velocity
-
7/30/2019 02 Finite Differences
24/27Finite Differences
Our first FD code!
2
2
22
)()(2
)()(2)()(
sdtdttptp
dxxpxpdxxpdx
dtcdttp
% Time stepping
for i=1:nt,
% FD
disp(sprintf(' Time step : %i',i));
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
-
7/30/2019 02 Finite Differences
25/27Finite Differences
Snapshot Example
0 1000 2000 3000 4000 5000 6000
0
500
1000
1500
2000
2500
3000
Distance (km)
Time(s)
Velocity 5 km/s
-
7/30/2019 02 Finite Differences
26/27
Finite Differences
Seismogram Dispersion
-
7/30/2019 02 Finite Differences
27/27
Finite Differences - Summary
Conceptually the most simple of the numerical methods and
can be learned quite quickly
Depending on the physical problem FD methods are
conditionally stable (relation between time and space
increment) FD methods have difficulties concerning the accurate
implementation ofboundary conditions (e.g. free surfaces,
absorbing boundaries)
FD methods are usually explicit and therefore very easy to
implement and efficient on parallel computers FD methods work best on regular, rectangular grids