Skip to main content

Parameterizations and the Gradient Contract

Overview

DevitoPhysics exposes the seismic model through a small set of parameterizations — the physical variable an optimizer descends in:

Name Optimizer vector Use case
'mZ' \(\log m\), at fixed impedance (or fixed reflectivity) Default for the acoustic physics: the ISIC slowness gradient, free of migration isochrones.
'm' \(m = v_p^{-2}\), at fixed density The plain mass-term slowness gradient.
'vp' \(v_p\) (km/s) Linear velocity inversion.
'vs' \(v_s\) (km/s) Elastic inversion.
'Z' the impedance \(Z = \rho c\) at fixed slowness; under vector_reflectivity, the reflectivity (vector Zx, Zy, or a scalar log impedance) With 'mZ' only: reflection FWI or velocity and impedance.
'b' buoyancy \(1/\rho\) at fixed slowness With 'm' only: velocity and density.
'r' McLeman et al.’s reflectivity, under vector_reflectivity With 'm': see reflection FWI.

The user picks one or more of these via the parameters tuple on DevitoPhysics; None takes the physics’ default:

physics = DevitoPhysics(parameters=('mZ', 'Z'), vector_reflectivity=True)

Each pair holds the other member fixed, so pairs do not mix: ('mZ', 'b') and ('m', 'Z') are refused. result.parameters from an optimizer holds the optimizer’s own variables, so its 'mZ' is \(\log m\); read the velocity from the returned model.

Input units

Internally every velocity field is held in km/s. When models are loaded from SEG-Y, HDF5 or Zarr the framework converts on the fly using the units entry of the config dict (or DataConfig.units):

# Bare string applies to every velocity parameter
config = {'model': {'vp': 'vp.segy'}, 'units': 'm/s'}

# Per-parameter dict for mixed inputs
config = {
    'model': {'vp': 'vp.h5', 'vs': 'vs.h5'},
    'units': {'vp': 'm/s', 'vs': 'ft/s'},
}

Supported strings: 'm/s', 'km/s', 'ft/s' (and their 'mps' / 'kmps' / 'fps' aliases). If units is omitted, the loader applies a safe value-based heuristic: velocities whose maximum exceeds 30 are assumed to be m/s and converted to km/s. The heuristic uses the maximum (not the minimum), so models with low-velocity layers — water columns, near-surface Vs around 100-300 m/s, air pockets — are still detected correctly.

Thomsen parameters (epsilon, delta) given as percentages and angles (theta, phi) given in degrees are also auto-converted; pass explicit values already in fraction / radian form to opt out.

The gradient contract

The framework’s contract with any solver is:

solver.perturbation(param=p).data holds (a constant multiple of) the gradient with respect to p, in the form the solver’s :attr:gradient_kind declares.

DevitoPhysics.adjoint reads solver.gradient_kind and converts to \(g_p = \partial J / \partial p\) matching the user’s chosen parameter before handing the gradient back to the optimizer.

gradient_kind declaration

Every solver class may declare a gradient_kind class attribute mapping parameter names to the flavor of gradient its kernel produces:

Kind Meaning
'linear' Kernel accumulates \(g_p\) directly (the default).
'log' Kernel accumulates \(g_{\log p}\). Framework applies the \(1/p\) chain rule.

A custom solver that produces \(g_m\) natively needs no declaration:

class MyAcousticSolver(AcousticIsotropic):
    def sensitivity(self, params=('m',)):
        dm = self.perturbation(param=params[0])
        # ... build a kernel that accumulates g_m into dm ...
        return imaging_eqs + self.extra

The default Horizon solver declares 'log' for m and Z because its ISIC kernel naturally produces \(g_{\log m}\) / \(g_{\log Z}\) (see the derivation). The framework then multiplies by \(v_p^2\) (= \(1/m\)) or \(b/v_p\) (= \(1/Z\)) numerically inside DevitoPhysics.adjoint, using the current model field values, so the adapter receives ordinary \(g_m\) / \(g_Z\).

The Horizon ISIC kernel

The kernel \(K_m = \sum_t [m \cdot u_{tt} \cdot v - \nabla u \cdot \nabla v]\) equals \(2 m \cdot g_m = 2 \cdot g_{\log m}\) in constant-density acoustic. The solver leaves this kernel as-is and declares gradient_kind = {'m': 'log', 'Z': 'log'}; the framework converts in _apply_gradient_chain_rule:

  • For m: \(1/m = v_p^2\) pulled from model.vp.data.
  • For Z: \(1/Z = b/v_p\) pulled from model.b.data / model.vp.data (constant-density models without a b field default to \(b = 1\)).

Custom solvers that prefer to apply the chain rule themselves can simply omit gradient_kind and bake \(1/p\) into their imaging condition; the framework will then treat the output as already linear.

See also

Back to top