Beruflich Dokumente
Kultur Dokumente
+ + + =
+
Finite Differences
... with the centered formulation we get:
The error of the first derivative using the centered
approximation is of order dx
2
.
This is an important results: it DOES matter which formulation
we use. The centered scheme is more accurate!
Taylor Series
) ( ) (
... ) (
! 3
) ( dx
1 ) 2 / ( ) 2 / (
2 '
' ' '
3
'
dx O x f
x f
dx
x f
dx dx
dx x f dx x f
+ =
+ + =
+
Finite 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
Finite Differences
Lets try Taylors Expansion
f x ( )
dx
x
f(x)
dx x f x f dx x f ) ( ' ) ( ) ( + + (1)
(2)
we are looking for something like
f x w f x
i
j
i
index j
j L
( ) ( )
( )
,
( ) ( )
=1
Alternative Derivation
dx x f x f dx x f ) ( ' ) ( ) (
Finite Differences
deriving the second-order scheme
a f a f a f d x
+
+ '
b f b f b f d x
'
+ + +
+
a f b f a b f a b f d x ( ) ( ) '
the solution to this equation for a and b leads to
a system of equations which can be cast in matrix form
dx b a
b a
/ 1
0
=
= +
0
1
=
= +
b a
b a
Interpolation Derivative
2nd order weights
Finite Differences
Taylor Operators
... in matrix form ...
0
1
1 1
1 1
b
a
Interpolation Derivative
... so that the solution for the weights is ...
dx b
a
/ 1
0
1 1
1 1
0
1
1 1
1 1
1
b
a
dx b
a
/ 1
0
1 1
1 1
1
Finite Differences
... and the result ...
Interpolation Derivative
Can we generalise this idea to longer operators?
2 / 1
2 / 1
b
a
1
1
2
1
dx b
a
Let us start by extending the Taylor expansion beyond f(xdx):
Interpolation and difference weights
Finite Differences
' ' '
! 3
) 2 (
' '
! 2
) 2 (
' ) 2 ( ) 2 (
3 2
f
dx
f
dx
f dx f dx x f +
*a |
*b |
*c |
*d |
... 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 ...
' ' '
! 3
) (
' '
! 2
) (
' ) ( ) (
3 2
f
dx
f
dx
f dx f dx x f +
' ' '
! 3
) (
' '
! 2
) (
' ) ( ) (
3 2
f
dx
f
dx
f dx f dx x f + + + +
' ' '
! 3
) 2 (
' '
! 2
) 2 (
' ) 2 ( ) 2 (
3 2
f
dx
f
dx
f dx f dx x f + + + +
Higher order operators
Finite Differences
+ + +
+ + +
df cf bf af
+ + + + ) ( d c b a f
+ + + ) 2 2 ( ' d c b a dxf
+ + + + ) 2
2 2
2 ( ' '
2
d
c b
a f dx
)
6
8
6
1
6
1
6
8
( ' ' '
3
d c b a f dx + +
... 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
Finite Differences
1 = + + + d c b a
0 2 2 = + + d c b a
0 2
2 2
2 = + + + d
c b
a
0
6
8
6
1
6
1
6
8
= + + d c b a
... if you want the interpolated value ...
... you need to solve the matrix system ...
Linear system
Finite Differences
High-order interpolation
0
0
0
1
6 / 8 6 / 1 6 / 1 6 / 8
2 2 / 1 2 / 1 2
2 1 1 2
1 1 1 1
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 ...
Finite Differences
0
0
/ 1
0
6 / 8 6 / 1 6 / 1 6 / 8
2 2 / 1 2 / 1 2
2 1 1 2
1 1 1 1
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
Finite Differences
Our first FD algorithm (ac1d.m) !
) (
2 2 2
2 2
z
y x
t
s p c p
+ + =
+ =
P
pressure
c
acoustic wave speed
s sources
P pressure
c
acoustic wave speed
s sources
Problem:
Solve the 1D acoustic wave equation using the finite
Difference method.
Problem:
Solve the 1D acoustic wave equation using the finite
Difference method.
Solution:
Solution:
[ ]
2
2
2 2
) ( ) ( 2
) ( ) ( 2 ) ( ) (
sdt dt t p t p
dx x p x p dx x p
dx
dt c
dt t p
+ +
+ + = +
Finite Differences
Problems: Stability
[ ]
2
2
2 2
) ( ) ( 2
) ( ) ( 2 ) ( ) (
sdt dt t p t p
dx x p x p dx x p
dx
dt c
dt t p
+ +
+ + = +
1
dx
dt
c
Stability:
Careful analysis using harmonic functions shows that
a stable numerical calculation is subject to special conditions
(conditional stability). This holds for many numerical problems.
(Derivation on the board).
Stability:
Careful analysis using harmonic functions shows that
a stable numerical calculation is subject to special conditions
(conditional stability). This holds for many numerical problems.
(Derivation on the board).
Finite Differences
Problems: Dispersion
[ ]
2
2
2 2
) ( ) ( 2
) ( ) ( 2 ) ( ) (
sdt dt t p t p
dx x p x p dx x p
dx
dt c
dt t p
+ +
+ + = +
Dispersion:
The numerical
approximation has
artificial dispersion,
in other words, the wave
speed becomes frequency
dependent (Derivation in
the board).
You have to find a
frequency bandwidth
where this effect is small.
The solution is to use a
sufficient number of grid
points per wavelength.
Dispersion:
The numerical
approximation has
artificial dispersion,
in other words, the wave
speed becomes frequency
dependent (Derivation in
the board).
You have to find a
frequency bandwidth
where this effect is small.
The solution is to use a
sufficient number of grid
points per wavelength.
True velocity
Finite Differences
Our first FD code!
[ ]
2
2
2 2
) ( ) ( 2
) ( ) ( 2 ) ( ) (
sdt dt t p t p
dx x p x p dx x p
dx
dt c
dt t p
+ +
+ + = +
%Ti me st eppi ng
f or i =1: nt ,
%FD
di sp( spr i nt f ( ' Ti me st ep : %i ' , i ) ) ;
f or j =2: nx- 1
d2p( j ) =( p( j +1) - 2*p( j ) +p( j - 1) ) / dx^2; %space der i vat i ve
end
pnew=2*p- pol d+d2p*dt ^2; %t i me ext r apol at i on
pnew( nx/ 2) =pnew( nx/ 2) +sr c( i ) *dt ^2; %add sour ce t er m
pol d=p; %t i me l evel s
p=pnew;
p( 1) =0; %set boundar i es pr essur e f r ee
p( nx) =0;
%Di spl ay
pl ot ( x, p, ' b- ' )
t i t l e( ' FD ' )
dr awnow
end
Finite Differences
Snapshot Example
0 1000 2000 3000 4000 5000
0
500
1000
1500
2000
2500
3000
Distance (km)
T
i
m
e
(
s
)
Velocity 5 km/s
Finite Differences
Seismogram Dispersion
Finite Differences
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 of boundary 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