# Scalar wave equation¶

## Derivation¶

To derive the constant density acoustic wave equation (which is a scalar wave equation), we use Newton’s second law (\(F=ma\)) and conservation of mass. Applied to a constant density medium, these yield, to first order,

and

where \(P\) is pressure, \(\mathbf{f}\) is an external force per unit area (in 2D, or per unit volume in 3D), \(\mathbf{u}\) is particle displacement, \(\rho\) is total density, and \(\rho_0\) is the constant background density. Applying the divergence operator to (1) and the time derivative to (2), we can combine these two equations to yield

Pressure and density are proportional, and we will call the constant of proportionality \(c^2\),

Substituting this into (3) and rearranging yields the scalar wave equation

The dimensions of each term in 2D are \([ML^{-2}T^{-2}]\).

## Implementation¶

The scalar wave equation implemented in Deepwave is

where \(u\) is a scalar field that obeys the wave equation, such as pressure, \(c\) is the wave speed, and \(f\) is a scalar source term. Sources are added to grid cell centres. If \(u\) is pressure (as in (5)) then an explosive point source centred on a grid cell corresponds to a single scalar source in (6).

Deepwave uses central finite differences in time (with second-order accuracy) and space (with a user-specified order of accuracy) to approximately solve this equation on a given time and space domain.

To prevent unwanted reflections from the spatial boundaries of this domain, Deepwave uses a Perfectly Matched Layer (PML). For the scalar wave equation, Deepwave uses the method of Pasalic and McGarry. In this approach, spatial derivatives are replaced by

where \(\psi\) is an operator defined at time step \(t\) as

and \(a\) and \(b\) are values that are determined for each grid cell depending on its location.

Applying this to (6), and, for simplicity, just using one spatial dimension,

where we define new auxiliary variables

and

Using finite differences in time, with time step interval \(h_t\), the update equation for \(u\) is thus

Using (8) in (10) and (11), we can calculate \(p\) and \(z\) using

and

We see that \(z^t\) depends on the spatial derivative of \(p^t\). This is problematic to calculate, especially on a GPU (where it is preferable for each element’s calculation to be independent from those of its neighbours). We therefore substitute (13) into (14) to get

Applying the same change to (12), we get

With some rearrangement, we can express each timestep in matrix form,

Time sample \(t\) of the output receiver data \(r\) is produced by recording \(u^t\) at the specified receiver locations \(\delta_r\). This means that the receiver data covers the same time range as the source data. Since the wavefield \(u\) isn’t affected by time sample \(t\) of the source until time step \(t+1\) (see (12), where \(f^t\) is added to \(u^{t+1}\)), the first time sample of the receiver data will not be affected by the source, and the last time sample of the source does not affect the receiver data.

The propagator returns \(u^{T}\), \(u^{T-1}\), \(p_y^{T-1}\), \(p_x^{T-1}\), \(z_y^{T-1}\), \(z_x^{T-1}\), and \(r\), where \(T\) is the number of time steps.