From the Lab to Research
Learning objectives
- Count what a research-size wave-equation run costs, in multiply-adds and in memory, from its cells, time steps, stencil and shots
- Say why doubling the frequency multiplies a 2D cost by about 8 and a 3D cost by about 16 once the wavelength sets the grid
- Name what the book's engine leaves out (density, a point source, a better absorbing edge, shear waves, a third dimension) and where each limit is set out
- Point to research codes, benchmark models and data sets beyond the book, each with its source
The Lab's Run
Every wave-equation run in this book is small on purpose. The standard earth is 800 m by 600 m of 5 m cells, 160 by 120 of them, and half a second of data takes 472 time steps of 1.06 ms. The fourth-order acoustic engine reads 9 points in every cell at every step, so one shot costs 81.6 million multiply-adds (the count of Figure 0.2) and holds 384 kB of values. A research run is the same equations on a bigger earth, and this section counts what that costs. The figure opens at the Lab's own run. Change what a research run changes (the size of the earth, the cell, the wave equation, the dimensions, the frequency, the record, the number of shots) and it counts again. It counts and does not time: a time appears only at a speed you assume.
Cost Is a Product
A wave equation updates every cell of its grid at every time step, reading stencil points in each, and every shot is a run of its own:
Plate (c) splits a run's cost, against the Lab's, into five factors that multiply to it exactly: a bigger earth, finer cells, more time steps, more points read in each cell, and more shots. Make the earth 8 km wide and 3 km deep and change nothing else: it holds 960,000 cells, 50 times the Lab's, and still needs 472 steps, so the cost is 50 times the Lab's, 4.08 billion multiply-adds. Add a third dimension to the Lab's own earth, as wide across the line as along it, and the cells become 3.07 million, the steps 578 (the stability limit is 0.500 for a three-dimensional grid and 0.612 for a two-dimensional one) and the points 13: the cost is 283 times the Lab's. Make the equation elastic, in two dimensions, and the points become 32: 290 million multiply-adds, 3.6 times the acoustic cost, the figure of Section 6.6.
Frequency Enters Twice
The cell cannot be larger than the wavelength allows. Alford, Kelly and Boore (1974) ask for five points per wavelength at fourth order, counted at the Ricker's upper half-power frequency, 1.4415 times its peak (Section 4.4), and the slowest wave sets the wavelength. At the Lab's 5 m cell the model's own cell sets the grid up to 65 Hz for the acoustic engine, whose slowest wave is the gas sand's P wave at 2.34 km/s, and up to 34 Hz for an elastic one, whose slowest wave is the shale's S wave at 1.24 km/s. Above those the wavelength sets the cell, and the cell falls as one over the frequency. The cells then rise as in two dimensions and in three, and the steps as , because the stability limit ties the step to the cell (Lines, Slawinski and Bording, 1998). So the cost rises as in two dimensions and in three.
Try it on a model cell of 20 m, which is too coarse for 30 Hz: the grid already uses the wavelength's 10.8 m. Doubling the frequency to 60 Hz takes the cell to 5.4 m, four times the cells and twice the steps, and the cost rises 7.9 times in two dimensions and 15.9 times in three, where the powers give 8 and 16 (cell counts are whole numbers). Five points per wavelength is a rule for the grid and not a guarantee: Section 4.4 shows the misfit growing with the distance travelled, so a long path through a big model asks for more.
Memory, and Why Shots Are Different
Memory is the number of values kept in each cell times four bytes. The book's acoustic engine keeps five arrays: three time levels of the wavefield, the leapfrog coefficient and the sponge field. An elastic velocity-stress scheme (Virieux, 1986) keeps a value for each velocity component, each stress component, and the density and two Lamé parameters: 8 in two dimensions and 12 in three. The elastic, three-dimensional run of the figure's third exercise, 10 km by 4 km at 5 m cells for 4 s, has 3.2 billion cells and 4,624 steps. It costs 1.07 quadrillion multiply-adds, 13 million times the Lab's run, and its values alone fill 154 GB before a snapshot or a receiver is kept. At an assumed billion multiply-adds a second that is 12 days for one shot. These are counts under the book's own accounting, a floor, and not a run the book makes.
Shots multiply the time and not the memory. A survey of 240 shots of the Lab's run costs 19.6 billion multiply-adds and still holds 384 kB, and because the shots are independent they can run side by side. The Marmousi data set has 240 shots (Stanford Exploration Project data library).
What the Book's Engine Leaves Out
Cost is not the only gap between the Lab and a research code. The engine of Part 4 is plain about what it is, and each limit is set out in the book:
- No density. It solves , so an interface reflects by the velocity contrast alone: −0.089 at the top of the gas sand, where the impedance contrast is −0.138 (Sections 5.6 and 6.6).
- A line source. A source on a two-dimensional grid is a line source, and its amplitude falls as one over the square root of the distance, where a point source in three dimensions falls as one over the distance (Section 4.6). Forbriger, Groos and Schäfer (2014) give a procedure that turns field recordings into equivalent line-source seismograms, so that two-dimensional full-waveform inversion can use shallow-seismic data.
- Only a sponge at the edges. The boundary is the Cerjan sponge, with no one-way absorber and no perfectly matched layer (Section 4.5). Bérenger (1994) published a perfectly matched layer for the absorption of electromagnetic waves, and Komatitsch and Martin (2007) published an unsplit convolutional perfectly matched layer improved at grazing incidence for the seismic wave equation.
- Acoustic propagation only. No shear wave and no converted wave travels through an earth of the book's. Angle-dependent amplitudes come from the exact Zoeppritz coefficients on a convolution (Sections 6.3 and 6.5), and the azimuthal amplitudes of fractured rock from the exact plane-wave coefficient of one anisotropic interface (Section 8.5). A velocity-stress scheme propagates the elastic waves themselves (Virieux, 1986); Levander (1988) made it fourth order in space, and his abstract says the dispersion analysis points to "5 gridpoints/wavelength", the number the book's fourth-order rule uses.
- Two dimensions. The engine has no third dimension; the three-dimensional counts above are the book's accounting and not runs.
Beyond the Book: Codes and Data
A model made in the Lab leaves the page as a file: Section 9.5 writes it as NumPy, CSV or SEG-Y revision 1, and Section 12.3 writes the book's convolution, its wave engine, its SEG-Y writer and Hudson's crack weaknesses as Python programs. Two research codes are worth knowing, each described here by its authors' own words.
Devito (Louboutin et al., 2019) is a domain-specific language embedded in Python. The equations of a finite-difference solver are written in a syntax close to the mathematics, and, in the paper's words, "The Devito compiler reads this code and applies a wide range of analysis to generate highly optimized and parallel code." The wave equation its paper works through is the acoustic one, the equation of Section 4.1 (the paper writes it with the squared slowness and a source term). Madagascar (Fomel et al., 2013) is open-source software "designed for analysis of large-scale multidimensional data" that, in its authors' words, "provides a framework for reproducible research" and contains "a collection of (a) computational modules, (b) data-processing scripts, and (c) research papers".
For something to test a code against, Section 9.4 covers Marmousi, Marmousi2 and the SEG and EAGE models. OpenFWI (Deng et al., 2022) is a collection of 12 data sets for full-waveform inversion, one of them for 3D, released with benchmarks of four deep-learning methods. Section 10.1 builds a far smaller data set, for fault detection.
The Rule, Counted
This is the fit-for-purpose rule one last time, now measured in compute. Each factor of the product is a decision: a cell no finer than the wavelength needs, a record no longer than the arrivals you want, an earth no wider than the question asks for, and a two-dimensional or acoustic run wherever the question allows it (Figure 0.2). When the question does need more, the same equations are waiting in the codes above, and the Lab's numbers are the ones to check them against. The last section closes the book.
References
- Alford, R. M., Kelly, K. R., & Boore, D. M. (1974). Accuracy of finite-difference modeling of the acoustic wave equation. Geophysics, 39(6), 834–842.
- Bérenger, J.-P. (1994). A perfectly matched layer for the absorption of electromagnetic waves. Journal of Computational Physics, 114, 185–200.
- Deng, C., Feng, S., Wang, H., Zhang, X., Jin, P., Feng, Y., Zeng, Q., Chen, Y., & Lin, Y. (2022). OpenFWI: Large-scale multi-structural benchmark datasets for full waveform inversion. Advances in Neural Information Processing Systems, 35 (Datasets and Benchmarks Track).
- Fomel, S., Sava, P., Vlad, I., Liu, Y., & Bashkardin, V. (2013). Madagascar: open-source software project for multidimensional data analysis and reproducible computational experiments. Journal of Open Research Software, 1(1), e8.
- Forbriger, T., Groos, L., & Schäfer, M. (2014). Line-source simulation for shallow-seismic data. Part 1: theoretical background. Geophysical Journal International, 198(3), 1387–1404.
- Komatitsch, D., & Martin, R. (2007). An unsplit convolutional perfectly matched layer improved at grazing incidence for the seismic wave equation. Geophysics, 72(5), SM155–SM167.
- Levander, A. R. (1988). Fourth-order finite-difference P-SV seismograms. Geophysics, 53, 1425–1436.
- Lines, L. R., Slawinski, R., & Bording, R. P. (1998). A recipe for stability analysis of finite-difference wave equation computations. CREWES Research Report, 10.
- Louboutin, M., Lange, M., Luporini, F., Kukreja, N., Witte, P. A., Herrmann, F. J., Velesko, P., & Gorman, G. J. (2019). Devito (v3.1.0): an embedded domain-specific language for finite differences and geophysical exploration. Geoscientific Model Development, 12(3), 1165–1187.
- Stanford Exploration Project. Marmousi synthetic dataset (C. B. Mora, 2002), SEP data library. https://sep.stanford.edu/data/media/public/docs/sepdatalib/marmousi.pdf
- Virieux, J. (1986). P-SV wave propagation in heterogeneous media: Velocity-stress finite-difference method. Geophysics, 51, 889–901.