yasfpy.matrix_apply =================== .. py:module:: yasfpy.matrix_apply .. autoapi-nested-parse:: 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 .. math:: 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, :cite:`Waterman-1971-ID50,Egel-2017-ID1`. Functions --------- .. autoapisummary:: yasfpy.matrix_apply.coupling_matrix_multiply yasfpy.matrix_apply.master_matrix_multiply Module Contents --------------- .. py:function:: coupling_matrix_multiply(sim, x, idx = None) Apply the coupling operator ``W``. :param sim: Simulation instance providing a configured ``coupling_backend``. :param 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. :param 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``. :rtype: numpy.ndarray .. rubric:: Notes If per-matvec timing is enabled (``sim._matvec_detail_enabled``), this function records the elapsed time under ``sim._matvec_detail['coupling']``. .. py:function:: master_matrix_multiply(sim, value, idx) Apply the master operator ``M = I - T W``. :param sim: Simulation instance providing ``mie_coefficients`` and ``coupling_backend``. :param value: Input vector of unknowns at a given wavelength. :param idx: Wavelength/channel index selecting the corresponding diagonal ``T`` blocks. :returns: The product ``(I - T W) @ value``. :rtype: numpy.ndarray .. rubric:: 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 :cite:`Bohren-1998-ID178,Mishchenko-2002-ID6`. If per-matvec timing is enabled (``sim._matvec_detail_enabled``), this function records the elapsed time under ``sim._matvec_detail['t_matrix']``.