yasfpy.coupling.backends#

Coupling backend implementations.

A coupling backend provides the action of the inter-particle coupling operator W (sometimes called the coupling matrix) used in the multiple-scattering linear system.

Backends differ in how they compute/apply that operator:

  • dense: precompute all pairwise lookup tables and apply the exact dense matvec

  • tiled dense: compute pairwise lookup tables for particle tiles on the fly

  • near/far: prototype approximation applying only near-field interactions

References

The VSWF-based translation/coupling approach is described in classic multiple scattering formulations [Waterman, 1971] and in CELES [Egel et al., 2017].

Classes#

CouplingBackend

Base class for coupling backends.

DenseCouplingBackend

Exact dense coupling backend.

TiledDenseCouplingBackend

Exact dense coupling without O(N^2) lookup tables.

NearFarCouplingBackend

Approximate near/far coupling backend (prototype).

Module Contents#

class yasfpy.coupling.backends.CouplingBackend#

Base class for coupling backends.

Variables:

requires_pairwise_lookups – Whether the backend requires precomputed pairwise lookup tables stored on a yasfpy.simulation.Simulation instance.

requires_pairwise_lookups: bool = False#
abstractmethod multiply(x, idx=None)#

Apply the coupling operator W.

Parameters:
  • x – Input vector/array.

  • idx – Optional wavelength/channel index.

Returns:

W @ x.

Return type:

numpy.ndarray

class yasfpy.coupling.backends.DenseCouplingBackend(simulation)#

Bases: CouplingBackend

Exact dense coupling backend.

This backend assumes that pairwise lookup tables have been precomputed and stored on the simulation object (plm, sph_h, e_j_dm_phi). The actual matvec is delegated to a yasfpy.coupling.ops.DenseCouplingOps instance, which may be CPU or CUDA.

Notes

The data flow is:

requires_pairwise_lookups: bool = True#
multiply(x, idx=None)#

Apply the dense coupling operator W.

Parameters:
  • x – Input vector or array.

  • idx – Optional wavelength/channel index.

Returns:

W @ x.

Return type:

numpy.ndarray

class yasfpy.coupling.backends.TiledDenseCouplingBackend(simulation)#

Bases: CouplingBackend

Exact dense coupling without O(N^2) lookup tables.

This backend computes the same interactions as DenseCouplingBackend, but constructs the yasfpy.functions.misc.mutual_lookup() quantities in particle tiles and immediately applies them to the matvec. This keeps memory usage bounded by tile size.

Notes

This backend is currently CPU-only.

requires_pairwise_lookups: bool = False#
multiply(x, idx=None)#

Apply tiled dense coupling.

Parameters:
  • x – Input vector/array.

  • idx – Optional wavelength/channel index.

Returns:

W @ x.

Return type:

numpy.ndarray

Raises:

NotImplementedError – If GPU execution is requested.

class yasfpy.coupling.backends.NearFarCouplingBackend(simulation)#

Bases: CouplingBackend

Approximate near/far coupling backend (prototype).

The current implementation applies near-field interactions exactly (via yasfpy.functions.misc.mutual_lookup()) for particle pairs within a configurable cutoff radius and ignores all remaining (far-field) interactions.

Compared to the initial prototype, this backend caches the near-field neighbor structure (per source tile) once, because particle geometry is fixed for the lifetime of a yasfpy.simulation.Simulation.

Notes

  • CPU only (GPU uses the dense GPU kernel today).

  • This is an approximation unless the radius includes all pairs.

requires_pairwise_lookups: bool = False#
multiply(x, idx=None)#

Apply the near-field-only coupling approximation.

Parameters:
  • x – Input vector/array of multipole coefficients.

  • idx – Optional wavelength/channel index.

Returns:

Approximate W @ x where only near-field pairs contribute.

Return type:

numpy.ndarray

Raises: