Finite Difference Modeling of Acoustic Waves in Matlab: January 1999
Finite Difference Modeling of Acoustic Waves in Matlab: January 1999
net/publication/237476404
CITATIONS READS
9 1,931
2 authors:
6 PUBLICATIONS 67 CITATIONS
Independent Researcher
314 PUBLICATIONS 2,169 CITATIONS
SEE PROFILE
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Gary Margrave on 05 September 2016.
ABSTRACT
A Matlab toolkit, called the AFD package, has been written to model waves using
acoustic finite differences. It uses central finite difference schemes to approximate
derivatives to the scalar wave equation. Both a second order or 5 point
approximation, and a fourth order or 9 point approximation, to the Laplacian are
included. The fourth order approximation is slower, but is more accurate, and results
in a broader temporal bandwidth. The AFD package is also equipped with absorbing
boundary conditions to suppress reflections from the edges of the grid. The toolkit is
able to create velocity models, shot records, exploding reflector models, as well as
snapshots and movies of the wavefield propagating in depth.
THEORY
The basis of the forward modeling algorithm is second order central difference
approximations to the scalar wave equation. Recalling the scalar wave equation:
∂ 2φ ( x, z, t )
= v 2 ( x, z ) ∇ 2φ ( x, z, t )
∂t 2 (1)
where the Laplacian, ∇ 2 , is given by:
∂ 2φ ∂ 2φ
∇ 2φ =
+
∂x 2 ∂z 2 (2)
The Laplacian operator can be approximated with central difference operators.
The two approximations used within the AFD software are a second and a fourth
order approximation. The approximations use five and nine points of the grid
respectively. The second order approximation to the Laplacian operator is:
φ nj +1 − 2φ nj + φ nj −1 φ nj +1 − 2φ nj + φ nj −1
∇φ ≈
2 n
+ (3)
∆x 2 ∆z 2
j
(n-1, j -1)
(n, j )
(n+1, j+1)
1 −1 n + 2 16 n +1 30 n 16 n −1 1 n − 2
∇ 2 φ nj ≈ φj + φj − φj + φj − φj +
∆x 2 12 12 12 12 12
1 −1 n
φ j + 2 + φ nj +1 − φ nj + φ nj −1 − φ nj − 2
16 30 16 1
2
( 4)
∆z 12 12 12 12 12
In order to reduce the computing time, the AFD toolkit requires the grid spacing to
be equal in the horizontal and vertical directions: ∆x = ∆z. As one would expect, the
fourth order approximation is more accurate, but is slower. Its main advantage,
though, is an increased bandwidth. Finally, each finite difference scheme has a
stability condition (Lines, Slawinsky, and Bording, 1998). The stability conditions
for the second order and fourth order approximations are respectively:
v max ∆t 1
≤ (5)
∆x 2
v max ∆t 3
≤ (6 )
∆x 8
where the velocity, spatial sampling rate, and grid spacing are in consistent units.
∂ 2 φ( t ) φ( t + ∆t ) − 2φ( t ) + φ( t − ∆t )
≈ (7)
∂t 2 ∆t 2
By substituting equation (7) and a Laplacian approximation into the scalar wave
equation, one can solve for the wavefield at time = t + ∆t.
(
φ nj ( t + ∆t ) ≈ ∆t 2 ( v j
n2
)∇ 2
+ 2) φ nj ( t ) − φ nj ( t − ∆t ) (8)
Equation 8 shows that the wavefield at time t + ∆t can be created by knowing the
wavefield at time t and t - ∆t. This process is called time-stepping and each wavefield
is called a snapshot. Note that the Laplacian is applies to the wavefield at time t
while the wavefield at t - ∆t is simply subtracted. To use equation 8 in a wavefield
time-stepping scheme requires the prescription of two initial snapshots at time 0 and
∆t. Usually, we simply prescribe these as identical fields of a simple source. It can
be shown that this creates a source with equal amounts of upgoing and downgoing
waves.
2. Re place φ nj ( t − ∆t ) with φ nj ( t )
3. Re place φ nj ( t ) with φ nj ( t + ∆t )
4. Increment t to t + ∆t
Absorbing boundary conditions are included in order to reduce reflections from the
grid edges. The absorbing boundary conditions are constructed from paraxial
approximations of the wave equation (Clayton and Enquist, 1977). It is important to
note that the corners of the absorbing boundaries are calculated with a less robust
approximation, and are therefore less accurate. As well, the boundary conditions are
applied as one ‘layer’ of the outside row and column of the grid for the second order
finite difference scheme. However, because the fourth order scheme computes the
derivative from the surrounding two rows and columns on either side, it is necessary
to apply the absorbing boundary conditions to two ‘layers’ of outside rows and
columns. Therefore, the absorbing boundary conditions are less accurate for the
fourth order approximation.
The absorbing boundary conditions for the corners are optimal for a wavefield
travelling along a 45 degree diagonal into the corner. This limitation causes artifacts
from the corner boundary if a wave travels directly into a corner at 0 or 90 degrees.
This has been compensated for in some of the programming, but should be kept in
mind. Finally, the absorbing boundary conditions will produce artifacts if a line or
point source is positioned too close to the boundary. Because of this, most of the
programs in the AFD toolkit do not have an absorbing boundary on the top of the
model, so sources may be positioned at the surface. For all the above reasons, it is
best to keep interesting features towards the middle of the matrices, so that no desired
effects will be missed or cause artifacts.
MATLAB PROGRAMS
The AFD software package includes eight different functions to make it as
versatile as possible. These functions all have a number of common variables required
as input. The common input variables are:
• xmax – the maximum horizontal extent of the grid (in consistent units)
• delx – the grid spacing for the horizontal and vertical directions (in consistent
units)
The eight functions of the AFD toolkit are described below. The input variables
are in the vector on the right hand side, and the output variables are in the vector on
the left hand side.
1. afd_snap
[snapshotn,z,x]=afd_snap(xmax,zmax,delx,delt,velocity,field1,field2,laplacian,
boundary);
This function is the basis for all of the other functions. It time-steps the wavefield
one step, and returns its snapshot. This is of minimal use when not embedded in
other functions.
2. afd_snapn
[snapshotn,z,x]=afd_snapn(xmax,zmax,delx,delt,velocity,field1,field2,toutput,
laplacian,boundary);
The ‘afd_snapn’ function will time-step the wavefield from time zeros to the
desired ouput time. The snapshot of the wavefield at the output time will then be
returned. This function can be used for teaching, demonstrations, and
troubleshooting.
3. afd_moviesnapn
[M]=afd_moviesnapn(xmax,zmax,delx,delt,velocity,field1,field2,toutput,
maxframes, laplacian,boundary);
maxframes – the maximum number of frames in the movie (it is suggested that there
should be no more than 40)
4. afd_seismo
[seis,filtseis,t,x,z]=afd_seismo(xmax,zmax,delx,delt,tmax,velocity,field1,field2,
nrec, xrec,zrec,filt,laplacian);
filt – a four component vector specifying the gaussian filter to filter the data with
filt = [fmin wmin fmax wmax] where
fmin - is the 3 dB down point of the filter on the low end
wmin – is the gaussian width of the filter on the low end
fmax – is the 3 dB down point of the filter on the high end
wmax – is the gaussian width of the filter on the high end
This function will return a shot record. The number of receivers, their x-
coordinates, and their z-coordinates are input in consistent units as ‘nrec’, ‘xrec’, and
‘zrec’ respectively. There is no limit to the number or position of the receivers, so
this function can be used to create VSPs as well. The boundary variable defaults to
absorbing boundaries on both sides and the bottom, so sources may be placed on the
surface (top boundary).
The source array is specified within field1 and field2. These input variables are
matrices of zeros the same size as the input velocity matrix. The position and
strength of sources are indicated by non-zeros values within the matrices. As
mentioned within the theory section, the two fields are usually set to be equal in order
to create a source with equal amounts of upgoing and downgoing waves. See
afd_source for more information on how to create these matrices.
Each time the wavefield is stepped forward by one time increment (using
afd_snap), the function grabs the seismic response at each receiver location. Thus,
only the seismic shot record can be filtered, as the wavefield is in units of depth, not
time. Once the shot record has been created, filtering takes place using the gaussian
function specified in ‘filt’. The program returns the unfiltered (‘seis’) and filtered
data (‘filtseis’). There will be one trace per receiver in the output shot records.
5. afd_exreflector
[seismogram,seis,t,x]=afd_exreflector(xmax,zmax,delx,delt,tmax,velocity,nrec, xrec,
zrec,wavelet,tw,nzero,laplacian,clipn);
nzero – the sample number of the wavelet that occurs at zero time value
- this allows the user to create a casual or non-casual wavelet as desired
clipn – the number of bins with which to clip the reflectivity matrix to prevent
instability in the corners
6. afd_reflect
[velocity,field1]=afd_reflect(xmax,zmax,delx,velocity,clipn);
velocity – the velocity matrix divided by 2 to compensate for 1 way travel time
field1 – the reflectivity matrix of the velocity, which will be used as the initial
wavefield in the exploding reflector model
The function ‘afd_reflect’ is meant for exploding reflector models. It will divide
the velocity matrix by 2 to create velocities appropriate for one way travel time, and
will calculate the reflectivity of the velocity model. This function is already
embedded in afd_exreflector, but is necessary to create the initial wavefield (‘field1’)
to be able to use other functions within this package. In order to prescribe equal
amounts of upgoing and downgoing waves, field1 and field2 are set to be identical.
This allows the use of ‘afd_snapn’, and ‘afd_moviesnapn’.
7. afd_source
[wavefield,z,x]=afd_source(xmax,zmax,delx,nsource,xsource,zsource,sz,default,
smatrix);
sz – the vector of horizontal span of the sources is consistent units (a span of less
than the grid spacing is considered a point source)
- if a custom source matrix is entered, the size of this matrix is entered bin
numbers
- a custom source matrix must be a square matrix where the size in bins is odd,
so that the matrix may be centered
This function is to assist in the creation of the initial wavefields field1 and field 2.
Within these fields, a source will be represented by a ‘1’, and all other positions will
be zeros. There are two options when using this program: one may enter a custom
source matrix, or have one built within the program. If you choose not to enter a
source matrix, the positions and horizontal extent of the sources are specified with
‘xsource’, ‘zsource , and ‘sz’. All variables are entered in consistent units. Finally,
‘default’ is set to ‘1’, and ‘smatrix’ to ‘0’. The function will center the sources at the
‘xsource’ and ‘zsource’ locations.
If one wants to enter a custom source, first build the source within a square
matrix where the size is an odd number of bins. The matrix will be centered on the
position ‘xsource’ and ‘zsource’, ensuring that the source matrix is always contained
within the grid. If the ‘zsource’ value of set to ‘0’ (the surface), the program will
adjust the centering algorithm so that the source matrix does not protrude above the
surface. The positioning variables are entered in consistent units, but the size of the
source matrix, ‘sz’ is entered in bins. Finally, ‘default’ is set to ‘0’, and ‘smatrix’ is
equal to the source matrix. In this way, the source matrix can be as complicated as
desired.
At this time, because the AFD software package is limited to shot records, it is
assumed that only one source or source matrix will be needed. However, the program
is equipped to deal with more than one source or source matrix. The variables
‘xsource’, ‘zsource’, ‘sz’, and ‘smatrix’ will then become vectors.
8. afd_vmodel
[velfinal]=afd_vmodel(xmax,zmax,delx,velocity,vpoly,xpoly,ypoly,conversion);
velfinal – the initial velocity matrix with the polygon of velocity ‘vpoly’
superimposed upon it
A. B.
Fig. 2. (a) The Marmousi velocity model and (b) the thrust belt velocity model.
Four different variations of the velocity models were used in generating models.
The first parameter set is used to illustrate the afd_snapn and the afd_seismo
functions. The velocity model with the source position, and its models are shown are
illustrated in Figure 3.
A. B.
C. D.
Fig. 3. The velocity model and forward models for parameter set 1: (a) The velocity
model where the source is represented by the white block (b) A snapshot of the
wavefield at 0.5 seconds (c) A snapshot of the wavefield at 1 second (d) The shot
record of the velocity model.
A. B.
Fig. 4. (a) The shot and borehole position for the Marmousi VSP. (b) The shot record for
the VSP.
A. B.
Fig. 5. (a) The shot and borehole position for the thrust belt VSP. (b) The shot record for
the VSP.
As one can see, it is almost impossible to distinguish events on the Marmousi VSP
because of the complexity of the velocity model. The thrust belt model is simpler,
and gives a clearer record of individual events.
The last part of this section deals with the exploding reflector model. The three
different parameter sets of the Marmousi velocity model are used to determine the
effect that temporal and spatial sampling have on bandwidth. Parameter sets 2 and 3
indicate that the grid spacing has been changed from the original model. This was
done using the ‘interp2’ function, and changed only the number of bins, not the
horizontal or vertical extent of the velocity model.
The most important variable in the exploding reflector model is the ‘clipn’ variable,
or the number of bins from the edges of the reflectivity model that have been clipped
to prevent artifacts. Artifacts are produced because the absorbing boundary
conditions are optimal for wavefields travelling at a diagonal of 45 degrees into the
corners. When the wavefields are closer to 0 or 90 degrees, the corners become
unstable. To prevent this, the ‘clipn’ variable must be set for a number of bins that
will span at least 100 meters.
Fig. 6. An exploding reflector model for parameter set 2 with a ‘clipn’ spanning only 30
meters.
Due to time constraints, the optimum value for the ‘clipn’ variable has not been
found, and evidence of artifacts will be seen in the following examples!
All of the models included within this paper have been computed with the fourth
order, or nine point approximation to the Laplacian. A comparison of the second
order and fourth order approximations is shown in Figure 7 and 8.
A. B.
Fig. 7. (a) The exploding reflector model for parameter set 1 with a fourth order
approximation to the Laplacian operator. (b) The exploding reflector model for
parameter set1 with a second order approximation to the Laplacian operator.
Fig. 8. A comparison of the dB spectrum of the second and fourth order approximations
to the Laplacian operator. One can see that the fourth order approximation (solid line)
has an increased bandwidth.
The fourth order Laplacian approximation does increase the bandwidth, but not
significantly. Next we will compare the effect temporal and spatial sampling rates
have on bandwidth using the exploding reflector model. Figure 9 demonstrates the
effect temporal sampling rate has on bandwidth by comparing two different sampling
rates for parameter set 1. It becomes apparent that though increasing the time
sampling rate does increase bandwidth, it also does not have a dramatic effect.
A.
B. C.
Fig. 9. (a) The exploding reflector model for parameter set 1, a fourth order
approximation to the Laplacian operator, at a1 ms sampling rate. (b) The dB spectrum
for parameter set 1 at a 2 ms sampling rate. (c) The dB spectrum for parameter set 1 at
a 1 ms sampling rate.
The next figures demonstrate the effect that spatial sampling rate has on
bandwidth. The first models illustrate the effect of parameter set 2 with the grid
spacing halved, and a time sampling rate of 1 millisecond. The second model
illustrates the effect of parameter set 3 which has a grid spacing of 1/3 the original, and
a time sampling rate of 0.5 milliseconds. The effects are dramatic, and it becomes
apparent that spatial sampling rate has a definite influence on bandwidth.
A. B.
C. D.
Fig. 10. (a) The exploding reflector model for parameter set 2. (b) The dB spectrum for
parameter set 2. (c) The exploding reflector model for parameter set 3. (d) The dB
spectrum for parameter set 3.
Figure 10 illustrates the problem of artifacts within the lower right hand corner.
The polarity of these artifacts seems to be determined by the polarity of the offending
wavefront. Figure 10 (a) has a ‘clipn’ span of 120 meters, and (c) has a ‘clipn’ span
of 140 meters. Obviously these are not large enough. It is of interest, however, to
note that parameter set 1 has a ‘clipn’ span of 60 meters, and this seems sufficient. It
may be that the presence of artifacts is dependent upon not only the distance of the
wavefield from the boundary, but that time and spatial sampling have an effect as
well.
It is apparent that increased spatial and temporal sampling rate, as well as a more
robust approximation to the Laplacian operator , increases bandwidth. This must be
balanced with time constraints. Table 2 summarizes the run times for the different
exploding reflector models.
Table 2: The summary of the different parameter sets. With the exception of
parameter set 1(a) all use the fourth order approximation to the Laplacian operator.
Parameter Set Velocity Bin Spacing Temporal Run Time
Model (m) Sampling Rate
(s)
**2ndorder
Laplacian
approximation
The absorbing boundary conditions work well for limited conditions. When a line
source is parallel and close to a boundary, or a wave travels at 0 or 90 degrees into a
corner, the boundary generates artifacts. These problems are especially prevalent in
an exploding reflector model. In an effort to circumvent these problems, the ‘clipn’
variable has been introduced. This variable clips the edges of the reflectivity model a
specified number of bins. However, the optimum value of the ‘clipn’ variable has not
been found. It is possible that this variable is dependent upon temporal and sampling
rates.
Overall, the AFD software package has shown to be a useful and flexible tool. Our
future plans include: research on the absorbing boundary condition problems,
variations on functions to allow users to create topography in their models, and
further testing to determine the full capabilities of modeling using acoustic finite
difference.
AKNOWLEDGEMENTS
We would like to thank the CREWES sponsors for their continued support and
feedback.
REFERENCES
Clayton, R. and Enquist, B., 1977, Absorbing boundary conditions for acoustic and elastic wave
equations: Bull. Seis. Soc. Am., 67, 1529-1540.
Dablain, M. A., 1985, The application of high-order differencing to the scalar wave equation:
Geophysics, 51, 54-66.
Lines, L. R., Slawinski, R., and Bording, R. P., 1998, A recipe for stability analysis of finite-
difference wave equation computations: 1998 Annual Research Report of the CREWES
Project.
Versteeg, R. and Grau, G., Editors.,1991, The Marmousi Experience: Proc. Of 1990 EAEG Workshop
on practical aspects of seismic data inversion.