Sie sind auf Seite 1von 7

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi

ving 10 - Matlab

Numerical solution of the wave equation


Introduction
Marine seismic oil/gas exploration is carried out by generating soundwaves that
propagate through the earth. The waves are re ected from interfaces between di erent
geological layers. Receivers are recording the re ected waves, converting the acoustic
energy into electronic energy, and then storing the data on tape. By di erent seismic
processing techniques an image of the subsurface can be made from the acquired data.
In this exercise we will be simulating propagation of sound in simple media using the
nite di erence method. The nite di erence method is to be implemented in Matlab,
and also the plots should be made in Matlab.
To avoid running out of computer memory we will restrict ourselves to two spatial
dimensions represented by the x-axis and the z-axis. The equation de ning the wave
propagation of the pressure eld P (x z t) is a partial di erential equation given by

@ 2 P (x z t) + @ 2 P (x z t) = 1 @ 2 P (x z t) + S (x z t)
(1)
@x2
@z2
c2(x z) @t2
where c(x z) is the wave-velocity and S (x z t) is a source term
We shall replace the di erential equation (1) with a nite di erence equation being an
approximation to equation (1). The nite di erence equation can be rearranged, enabling
us to nd the pressure at the next time step as a function of the pressure at present and
previous timesteps.

Derivation of the nite di erence formula


As a starting point for deriving the nite di erence equation we consider the de nition of
the derivative of P (x z t) with respect to x.

@P (x z t) = lim P (x + x z t) ; P (x z t)
x!0
@x
x
Allowing x to be nite rather than in nitesimal yields the approximation:
@P (x z t) P (x + x z t) ; P (x z t)
@x
x
The second derivative is obtained by repeating the above procedure.
Norges teknisk-naturvitenskapelige universitet
Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

@ 2 P (x z t) = @ @P (x z t)
@x2
@x @x

@P (x+ x z t)
@x

; @P (@xx z t)

(P (x + 2 x z t) ; P (x + x z t)) ; (P (x + x z t) ; P (x z t))
x2
we may perform a backward shift x resulting in:
@ 2 P (x z t) P (x + x z t) ; 2P (x z t) + P (x ; x z t)
@x2
x2
We introduce a more compact notation.
P (x z t) ) Plnm = P (l x m z n t)
c(x z) ) cl m = c(l x m z)
S (x z t) ) Slnm = S (l x m z n t)

(2)
(3)
(4)
(5)

On nite di erence form equation (1) appears this way:


Plnm+1 ; 2Plnm + Plnm;1 n
Pln+1 m ; 2Plnm + Pln;1 m Plnm+1 ; 2Plnm + Plnm;1
1
+
= c2
+ Sl m
x2
z2
t2
lm
(6)
For simplicity we use the same step-length in the x- and z-direction z = x. Hence
equation (6) may be rewritten:
c2l m t2 ; n
n
n
n
n
n
n;1
2
2 n
n
+1
Pl m =
x2 Pl+1 m + Pl m+1 ; 4Pl m + Pl;1 m + Pl m;1 + 2Pl m ; Pl m ; cl m t Sl m
(7)

Part 1:

Make a Matlab program that gives the pressure eld as a function of x and z at time
0.2 s, n=200 and plot the result. Use equation (7)
Let x = y = 4m and let t = 0:001s. m and l should cover a 200x200 grid-area.
Assume a constant wave
velocity of c0 = 1500 m/s (The velocity of sound in water).
2 t2
c
(It is important that m x2 < 21 Otherwise the error will increase for each timestep
causing instability.)
n
n
n
Boundary conditions are P0nm = P200
m = Pl 0 = Pl 200 = 0, while the initial conditions are
given by
Pl0m = 0
(8)
Pl1m = 0
(9)
a)

Norges teknisk-naturvitenskapelige universitet


Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

n+1

n1

Figure 1: Finite di erence grid. The pressure at the star is calculated from the values of
the pressure at the dots
To generate the waves we use a source Slnm de ned by
n
S100
100 = f (n)
Slnm = 0 else

(10)
(11)

f (n) may be down-loaded from http://www.ipt.ntnu.no/~bufag/kilde. Save kilde


on your computer and load into Matlab with the command load kilde. Matlab
functions suitable for two-dimensional plots include mesh, contour and contourf. If
you have named the pressure P, you could use the command contour(P).
You may try to nd the pressure at other timesteps, but storing all timesteps in memory
will at some point cause memory shortage.
b) Register the pressure at all timesteps and all x-coordinates, but x the z-coordinate at
m=100. Make a plot of this as well. This simulates seismic acquisition along the line
m=100.

Part 2:

Repeat part 1a) and b), but insert a re ector along m=120 by letting the velocity be
2000 m/s above m=120.

Matlab commands
The pc-version of Matlab is started by clicking the matlab-icon or writing matlab in the
run window. The Unix version is started from the dtterm window or xterm window with
Norges teknisk-naturvitenskapelige universitet
Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

the command matlab. Writing quit at the Matlab prompt will terminate the session.
Documentation for all matlab commands is obtained writing help command The current
working directory can be found with the command pwd. You may change directory to e.g.
c:\yourdirectory (assuming pc-matlab) using the command
cd c:\yourdirectory

load kilde into Matlab by the command

load c:\yourdirectory\kilde

You can plot kilde using the command


plot(kilde)
plot(kilde(1:5))
plot(kilde(1:4:49))
plot(kilde(50:-1:1))

plots the rst 5 timesamples


plots every fourth sample up to 49
reverses kilde
Reversing kilde can also be achieved by writing plot(fliplr(kilde)). The values along
the x-axis correspond to the component-numbers of kilde if only kilde is included in the
plot command. To adjust the x-axis, we rst create a variable
x=(1:length(kilde))/1000

x has the same number of components as kilde (which is important). This number is
found with the length command. The component-values are
1/1000,2/1000,3/1000,4/1000.... The semicolon prevents these values from being
displayed on the screen We specify the x-coordinate by issuing two input vectors for the
plot command: x and kilde. Two more vectors will be interpreted as a new
x-coordinate/y-coordinate pair yielding two curves
plot(x,kilde)
plot(x,kilde,x,kilde+1)

Two curves
Vectors can be created 'manually' by writing the component values between brackets
0 1 0 3 4 3]

This way you can manipulate kilde plot(


speci ed using the command axis

kilde(1:5) 0 0 kilde(6:10)])

The axis is

axis( xmin xmax ymin ymax])

A matrix can be constructed like this

matrise= 0:4 2:6 3:7 4:8]

The rows of the matrix are separated by semicolons. This can be plotted using for
instance
mesh(matrise) or
contour(matrise)

Loops are constructed similarly to other programming languages. It can be done like this
for k=1:20, energi(k)=kilde(k)*kilde(k) end

Matlab o ers an alternative to the above structure:


k=1:20

energi(k)=kilde(k).*kilde(k)

Placing a period before the multiplication sign ensures that multiplication is carried out
component by component. The last alternative is much faster than the for-end alternative
Conditional statements are implemented this way
if (x==0), y=0 end

Norges teknisk-naturvitenskapelige universitet


Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

x is tested for equality with zero (note two equal signs). If this is true, y is assigned the
value zero. In the next example x has to be di erent from zero and z has to be less than
8 for the operation y=0 to be carried out
'&'

if ~(x==0) & z<8 , y=0 end


'|'

corresponds to 'and', while

corresponds to 'or'.

Norges teknisk-naturvitenskapelige universitet


Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

500

450

400

350

300

250

200

150

100

50

50

100

150

200

250

300

350

400

450

500

Figure 2: Wave propagation as in part 1, plotted using the command sequence:


clf for f=1:4:500, plot(P(f,:,1)*600+f) hold on end
0

50

100

150

Tid

200

250

300

350

400

450

500

50

100

150

200

250

300

350

400

450

500

Figure 3: Arrival times for di erent x values, z=250

Norges teknisk-naturvitenskapelige universitet


Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

TPG4155 Anvendt datateknikk i geofag og petroleumsteknologi


ving 10 - Matlab

500

450

400

350

300

250

200

150

100

50

50

100

150

200

250

300

350

400

450

500

Figure 4: Wave propagation with a re ector at z=300


0

50

100

150

Tid

200

250

300

350

400

450

500

50

100

150

200

250

300

350

400

450

500

Figure 5: Arrival times for di erent x values, z=250, direct wave and re ection.

Norges teknisk-naturvitenskapelige universitet


Institutt for petroleumsteknologi og anvendt geofysikk

Stipendiat Tommy Toverud

Das könnte Ihnen auch gefallen