yasfpy.matrix_apply#

Matrix-apply helpers for simulations.

This module contains functionality extracted from yasfpy.simulation.Simulation related to applying the coupling operator W and the “master” operator

\[M = I - T W,\]

where T is the block-diagonal particle T-matrix (here: Mie coefficients for spheres) and W encodes inter-particle translation/coupling.

The operator form and VSWF translation-based coupling are commonly used in multiple-sphere scattering formulations; see, for example, [Egel et al., 2017, Waterman, 1971].

Functions#

coupling_matrix_multiply(sim, x[, idx])

Apply the coupling operator W.

master_matrix_multiply(sim, value, idx)

Apply the master operator M = I - T W.

Module Contents#

yasfpy.matrix_apply.coupling_matrix_multiply(sim, x, idx=None)#

Apply the coupling operator W.

Parameters:
  • sim – Simulation instance providing a configured coupling_backend.

  • x – Input vector (flattened VSWF coefficients). The expected shape matches the backend: usually (jmax,) for a single channel or (jmax, channels) for multi-wavelength runs.

  • idx – Optional wavelength/channel index. Some backends use it to select a single channel without allocating a full multi-channel output.

Returns:

The product W @ x.

Return type:

numpy.ndarray

Notes

If per-matvec timing is enabled (sim._matvec_detail_enabled), this function records the elapsed time under sim._matvec_detail['coupling'].

yasfpy.matrix_apply.master_matrix_multiply(sim, value, idx)#

Apply the master operator M = I - T W.

Parameters:
  • sim – Simulation instance providing mie_coefficients and coupling_backend.

  • value – Input vector of unknowns at a given wavelength.

  • idx – Wavelength/channel index selecting the corresponding diagonal T blocks.

Returns:

The product (I - T W) @ value.

Return type:

numpy.ndarray

Notes

The diagonal application of T is implemented by elementwise multiplication with the raveled Mie coefficient array. This corresponds to a block-diagonal T-matrix for independent spherical particles [Mishchenko, 2002, Bohren and Huffman, 1998].

If per-matvec timing is enabled (sim._matvec_detail_enabled), this function records the elapsed time under sim._matvec_detail['t_matrix'].