ar4/deepwave

Wave propagation modules for PyTorch.

What it solves

Deepwave solves the problem of simulating wave propagation for applications like seismic imaging and inversion. It allows you to model how waves travel through a medium (e.g., the Earth's subsurface), generate synthetic data, or invert for properties like wave speed or scattering potential. This is essential for techniques such as full-waveform inversion (FWI), reverse-time migration (RTM), and least-squares RTM. It also lets you compute gradients for these inversions through PyTorch's automatic differentiation, so you can use your own objective functions and integrate the wave propagator into larger neural-network-style pipelines.

How it works

Deepwave provides wave propagation modules that are PyTorch autograd functions. You define a model (e.g., a velocity field), specify source and receiver locations, and call a propagator like deepwave.scalar(). The propagator runs a finite-difference simulation of the wave equation, producing receiver data and final wavefields. Because it is built with PyTorch's autograd, you can backpropagate through this simulation to get gradients with respect to any input (velocity, source wavelet, initial wavefield, etc.). Deepwave uses hand-derived adjoints in compiled kernels for computational efficiency and lower memory use. It supports several wave equations (acoustic, elastic, viscoacoustic, anisotropic VTI, pseudo-acoustic VTI) in 1D, 2D, and 3D, and on both CPU and GPU. It also supports second-order derivatives (Hessian-vector products), Born (linearised) modelling, and works seamlessly with PyTorch optimizers, torch.func transforms, and distributed data parallel over shots.

Who it's for

Deepwave is for researchers and engineers working on seismic imaging, full-waveform inversion, wave-equation-based inverse problems, and related fields like ultrasound/NDT and photoacoustic reconstruction. It assumes you are comfortable with PyTorch and basic wave propagation concepts (the README points to a glossary for terms like PML, CFL, Born, FWI). It requires Python 3.9+ and PyTorch 2.4+ and runs on both CPU and GPU. Prebuilt CPU wheels need an AVX2‑capable x86 CPU, but macOS Apple Silicon is supported.

Highlights

  • Supports 1D, 2D, 3D constant-density acoustic, variable density acoustic, elastic, viscoacoustic, and VTI (anisotropic) wave equations.
  • Runs on CPUs and appropriate GPUs.
  • Gradients with respect to model parameters, initial wavefields, and source amplitudes.
  • Built-in support for DAS strain-rate receivers and transducer-array helpers for ultrasound/NDT.
  • Segmented gradient checkpointing to bound memory for long simulations.
  • Time-dispersion correction to remove leapfrog error near the CFL limit.
  • Fits directly into PyTorch workflows: works with optimizers, DistributedDataParallel, torch.func, and any PyTorch loss function or network.
  • Supports second-order differentiation (Hessian-vector products) and Born (linearised) modelling.

Related

  • Project
  • Project
  • Project
  • Project