Escolar Documentos
Profissional Documentos
Cultura Documentos
f ( x dx) f ( x)
x f
dx
2t p c 2 p s The acoustic
wave equation
( 2x 2y 2z ) - seismology
- acoustics
P pressure - oceanography
c acoustic wave speed - meteorology
s sources
Finite Differences
Numerical methods: properties
Finite Differences
Other numerical methods
Finite Differences
What is a finite difference?
f ( x dx) f ( x)
x f lim
dx0 dx
f ( x) f ( x dx)
x f lim
dx0 dx
f ( x dx) f ( x dx)
x f lim
dx0 2dx
Finite Differences
What is a finite difference?
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
Finite Differences
The big question:
How good are the FD approximations?
Finite Differences
Taylor Series
2 3 4
dx dx dx
f ( x dx) f ( x) dxf ' ( x) f '' ( x) f ''' ( x) f '''' ( x) ...
2! 3! 4!
f ( x dx) f ( x)
x f ?
dx
Finite Differences
Taylor Series
f ( x dx) f ( x) 1 dx 2
dx 3
dxf ( x) '
f ( x)
''
f ( x) ...
'''
dx dx 2! 3!
f ' ( x) O(dx)
Finite Differences
Taylor Series
f ( x dx / 2) f ( x dx / 2) 1 dx 3
dxf ( x) '
f ( x) ...
'''
dx dx 3!
f ' ( x) O(dx 2 )
Finite Differences
Alternative Derivation
f(x)
f ( xj )
x
dx h
xj 1 xj xj 1 xj 2 xj 3
desired x location
What is the (approximate) value of the function or its (first,
second ..) derivative at the desired location ?
Finite Differences
Alternative Derivation
x
f ( x)
dx
f ( x dx) f ( x) f ' ( x)dx (1)
f ( x dx) f ( x) f ' ( x)dx (2)
f (i )
( x ) w (j i ) f ( xindex ( j ) )
j 1, L
Finite Differences
2nd order weights
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
Interpolation Derivative
a b 1 ab 0
a b 0 a b 1 / dx
Finite Differences
Taylor Operators
Interpolation Derivative
1 1 a 1 1 1 a 0
1 1 b 0 1 1 b 1 / dx
1 1
a 1 1 1 a 1 1 0
b 1 1 0 b 1 1 1 / dx
Finite Differences
Interpolation and difference weights
Interpolation Derivative
a 1 / 2 a 1 1
b 1 / 2 b 2dx 1
Finite Differences
Higher order operators
(2dx) 2 (2dx)3
*a | f ( x 2dx) f (2dx) f ' f ' ' f '''
2! 3!
(dx) 2 (dx)3
*b | f ( x dx) f (dx) f ' f ' ' f '''
2! 3!
(dx) 2 (dx)3
*c | f ( x dx) f (dx) f ' f ' ' f '''
2! 3!
(2dx) 2 (2dx)3
*d | f ( x 2dx) f (2dx) f ' f ' ' f '''
2! 3!
... again we are looking for the coefficients a,b,c,d with which
the 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 ...
Finite Differences
Higher order operators
af bf cf df
f (a b c d )
6 6 6 6
... we can now ask for the coefficients a,b,c,d, so that the
left-hand-side yields either f,f’,f’’,f’’’ ...
Finite Differences
Linear system
a b c d 1
2a b c 2d 0
b c
2a 2d 0
2 2
8 1 1 8
a b c d 0
6 6 6 6
Finite Differences
High-order interpolation
1 1 1 1 a 1
2 1 1 2 b 0
2
1/ 2 1/ 2 2 c 0
8 / 6 1 / 6 1 / 6 8 / 6 d 0
... with the result after inverting the matrix on the lhs ...
a 1/ 6
b 2/3
c 2/3
d 1/ 6
Finite Differences
First derivative
1 1 1 1 a 0
2 1 1 2 b 1 / dx
2
1/ 2 1/ 2 2 c 0
8 / 6 1 / 6 1 / 6 8 / 6 d 0
... with the result ...
a 1/ 6
b 1 4 / 3
c 2dx 4 / 3
d 1/ 6
Finite Differences
Our first FD algorithm (ac1d.m) !
2t p c 2 p s P pressure
c acoustic wave speed
( 2x 2y 2z ) s sources
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
Finite Differences
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
dt
c 1
dx
Finite Differences
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
Finite Differences
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
Finite Differences
Snapshot Example
Velocity 5 km/s
3000
2500
2000
Time (s)
1500
1000
500
0
0 1000 2000 3000 4000 5000 6000
Distance (km)
Finite Differences
Seismogram Dispersion
Finite Differences
Finite Differences - Summary
Finite Differences