Discretizing: FD Stencils
Learning objectives
- Derive the second-order stencil from Taylor's series and name the term it leaves out, the truncation error
- Solve the fourth-order weights from the same conditions and read their leading error
- Read a stencil's error on a pulse and on a plane wave against the points on a wavelength
- Apply Alford, Kelly and Boore's ten and five points per wavelength to a grid, and count what each stencil costs
From a Derivative to a Sum
The wave equation of Section 4.1 asks, at every point and every moment, for the curvature of the field, its second space derivative . A computer does not hold the function . It holds at grid points a distance apart, the 5 m cell of the book's standard grid, and the curvature has to be built from those samples. Expand the two neighbours in Taylor's series about the point and add them: the odd powers of cancel, and what remains is
Divide by and the weights over give the curvature, wrong by . That leftover is the truncation error, and the stencil is called second-order accurate because it falls as . A test you can do by hand: the function has zero curvature at , and its samples at are , so with the stencil returns 2, which is , the leftover exactly.
A Wider Stencil, a Higher Order
Reach further and more terms cancel. Take the sample and two neighbours on each side, with weights , the same on both sides of the centre. Ask that the sum return and that the term vanish as well, and the weights must satisfy , and . They give over , and the first term that survives is : the fourth-order stencil. Fornberg (1988) gives a recursion for the weights of any order on any grid and tables the equally spaced cases; the figure below solves the conditions rather than typing the weights, and the engine of this part applies these five. On the same test, at with , the fourth-order stencil returns 0, exact, because its first leftover involves the sixth derivative, which does not have.
The Error in Points per Wavelength
What matters for a wave is not alone but the number of points on a wavelength, . On a plane wave sampled times a wavelength, each stencil returns the exact curvature times a factor that depends on alone, and for large the error is Taylor's first term: at second order and at fourth, with . Plate (c) draws both. At ten points on a wavelength the second-order stencil's curvature is 3.2 percent short (Taylor's first term alone gives 3.3), and at five points the fourth-order stencil's is 2.4 percent short (the first term gives 2.8). Give the fourth-order stencil ten points and it falls to 0.17 percent.
Ten and five are Alford, Kelly and Boore's counts. Comparing finite-difference seismograms for a wedge in a two-dimensional medium with exact ones, they found that “ten or more grid points per wavelength at the frequency of the upper half-power point should be adequate” with the second-order scheme, while the fourth-order scheme “seems to produce accurate results at five grid points per wavelength” (Alford, Kelly and Boore, 1974).
The frequency is the upper half-power frequency of the source, where the Ricker's power has fallen to half (Ricker, 1953): 1.44 times the peak, 43.2 Hz for the standard 30 Hz pulse. In the slowest rock of the standard earth, the gas sand at 2.34 km/s, that is a wavelength of 54 m, so the rule allows a cell of 5.4 m at second order and 10.8 m at fourth. The book's 5 m cell puts 10.8 points on it: just inside the second-order rule, and a little over twice the fourth-order count. Raise the pulse to 45 Hz and the same cell puts 7.2 points on its wavelength, short of ten and above five: the second-order stencil misses the pulse's curvature by 7.3 percent of its peak, the fourth by 1.1.
The two rules ask for about the same accuracy. On the pulse, a snapshot of the 30 Hz Ricker laid along a line, the second-order stencil at Alford's 5.4 m misses the peak curvature by 3.9 percent and the fourth-order stencil at 10.8 m by 4.1. The fourth-order stencil reaches the second-order stencil's ten-point accuracy on a plane wave at 4.6 points, so Alford's five is not a round number but the same accuracy at about half the points. The percentages are the stencil's own: the counts of Alford, Kelly and Boore are for the whole scheme, and what the time step adds to the stencil's error is the subject of Section 4.4.
What Meeting the Count Costs
The fourth-order stencil is wider. In 2D its Laplacian reads 9 samples where the second order reads 5, and in 3D 13 where the second reads 7, the 9 and 13 that the cost model of Figure 0.2 counts for the acoustic engine. But Alford's rule lets it use a cell twice as wide, and a coarser grid is cheaper in cells and in steps. On the standard 800 by 600 m earth at 30 Hz, for 0.5 s, the second-order stencil at 5.4 m needs 148 by 111 cells and 378 steps at the stability limit: 31.0 million multiply-adds. The fourth-order stencil at 10.8 m needs 74 by 56 cells and 218 steps, although its limit on the step is lower, 0.61 of a cell against 0.71 (Section 4.3): 8.1 million, 3.8 times fewer. The counts are floors, without absorbing borders. They grow with the cube of the frequency in 2D, the cells as its square and the steps as its first power, so at 45 Hz the fourth-order count is 3.4 times that at 30.
What the Stencil Leaves Out
This figure holds one thing, the space derivative, on a function whose second derivative is known exactly. It has no time step, no variable velocity and no boundary. A wave run adds the error of the time step to the stencil's (Section 4.4), and the stencil's error, small in one cell, accumulates over the distance a wave travels. Both belong to the sections that follow; this one gives the stencil, its weights, its error and the grid it needs.
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.
- Fornberg, B. (1988). Generation of finite difference formulas on arbitrarily spaced grids. Mathematics of Computation, 51(184), 699–706.
- Ricker, N. (1953). The form and laws of propagation of seismic wavelets. Geophysics, 18, 10–40.