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#
Base class for coupling backends. |
|
Exact dense coupling backend. |
|
Exact dense coupling without O(N^2) lookup tables. |
|
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.Simulationinstance.
- 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:
- class yasfpy.coupling.backends.DenseCouplingBackend(simulation)#
Bases:
CouplingBackendExact 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 ayasfpy.coupling.ops.DenseCouplingOpsinstance, which may be CPU or CUDA.Notes
The data flow is:
lookups computed by
yasfpy.lookups.compute_lookups()backend selected by
yasfpy.simulation.Simulationmatvec executed by
yasfpy.coupling.factory.get_dense_coupling_ops()
- 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:
- class yasfpy.coupling.backends.TiledDenseCouplingBackend(simulation)#
Bases:
CouplingBackendExact dense coupling without O(N^2) lookup tables.
This backend computes the same interactions as
DenseCouplingBackend, but constructs theyasfpy.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.
- multiply(x, idx=None)#
Apply tiled dense coupling.
- Parameters:
x – Input vector/array.
idx – Optional wavelength/channel index.
- Returns:
W @ x.- Return type:
- Raises:
NotImplementedError – If GPU execution is requested.
- class yasfpy.coupling.backends.NearFarCouplingBackend(simulation)#
Bases:
CouplingBackendApproximate 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.
- 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 @ xwhere only near-field pairs contribute.- Return type:
- Raises:
ValueError – If
numerics.coupling_near_field_radiusis not set.NotImplementedError – If GPU execution is requested.