Skip to content

Operators

This section documents the three spatial-derivative operator classes in sweep.operators. For the conceptual / how-to guide and decision tree see Operators.

from sweep.operators import (
    LaplaceGradientOps,      # Laplacian + gradient bundle
    StaggeredDerivative,     # 1st-order staggered FD
    RSGDerivative,           # rotated staggered grid (2-D)
)

You usually do not instantiate these directly:

  • LaplaceGradientOps is mixed into SecondOrderEquation — accessed as self.laplacian_2d(...), self.separable_d2_2d(...), self.gradient(...).
  • StaggeredDerivative is built by FirstOrderEquation.__init__ and stored on self.pd.
  • RSGDerivative is constructed explicitly by ElasticTTI / ElasticTTISG as self.rsg.

LaplaceGradientOps

sweep.operators.LaplaceGradientOps

LaplaceGradientOps(backend: str = 'torch')

Backend-dispatched second-derivative and gradient operator bundle.

On construction this class imports five backend-specific functions from either :mod:sweep.operators.torch or :mod:sweep.operators.jax and binds them as instance attributes:

  • :func:separable_d2_2d / :func:separable_d2_3d — return per-axis second derivatives (d2z, d2x[, d2y]) for anisotropic equations.
  • :func:laplacian_2d / :func:laplacian_3d — return the scalar isotropic Laplacian ∇²u (= sum of the per-axis components).
  • :func:gradient — first-order partial derivative along one axis.

Mixed into :class:sweep.equations.base.SecondOrderEquation so every 2-D / 3-D second-order acoustic equation can call self.laplacian_2d(...) or self.separable_d2_2d(...) etc. without an explicit operator object.

Bind second-derivative + gradient operators for the chosen backend.

Parameters:

  • backend (str, default: 'torch' ) –

    'torch' (default) or 'jax'. The corresponding sweep.operators.<backend> module is imported lazily so installations that lack one backend stay importable.

StaggeredDerivative

sweep.operators.StaggeredDerivative

StaggeredDerivative(spatial_order: int = 4, device='cpu', backend='torch', ndim=2)

RSGDerivative

sweep.operators.RSGDerivative

RSGDerivative(
    spatial_order: int = 4, device: str = "cpu", backend: str = "torch", ndim: int = 2
)

2D rotated staggered-grid fused derivative operator.