yasfpy.mie_coefficients ======================= .. py:module:: yasfpy.mie_coefficients .. autoapi-nested-parse:: Mie coefficient generation utilities. This module contains the implementation that used to live in `yasfpy.simulation.Simulation.compute_mie_coefficients`, extracted to keep `simulation.py` smaller. The coefficients computed here are the diagonal entries of each particle's T-matrix in a vector-spherical-wave-function (VSWF) basis for homogeneous spheres (classical Mie scattering): - ``tau = 1`` corresponds to one polarization family (often "TE"/"magnetic") - ``tau = 2`` corresponds to the other polarization family (often "TM"/"electric") The formulas follow standard Mie theory; see, e.g., :cite:`Bohren-1998-ID178` or :cite:`Mishchenko-2002-ID6`. Functions --------- .. autoapisummary:: yasfpy.mie_coefficients.compute_mie_coefficients Module Contents --------------- .. py:function:: compute_mie_coefficients(sim) Compute diagonal Mie coefficients for unique (radius, material) pairs. :param sim: Simulation instance providing medium wavenumbers and particle material refractive indices. The results are stored on ``sim``. :rtype: None .. rubric:: Notes This routine computes the diagonal spherical-particle T-matrix entries (Mie coefficients) for each unique (radius, material) pair found in ``sim.parameters.particles``. The legacy implementation in YASF called ``t_entry()`` for every ``(pair, tau, l)`` and then repeated the scalar coefficient for all ``m = -l..l``. In typical geometries with many distinct radii, that created substantial overhead from repeated special-function evaluations. This implementation reduces overhead by vectorizing the special-function evaluation: - evaluates spherical Bessel/Hankel functions for all ``l = 1..lmax`` on an outer ``(l, channel)`` grid - fills the ``(tau, l, m)`` blocks by slicing (no inner ``m`` loop) The math is unchanged; only the computational structure differs. The additional array ``sim.scatter_to_internal`` stores the ratio between internal-field and scattered-field coefficients used elsewhere in the solver. .. rubric:: References Standard Mie scattering theory for homogeneous spheres: :cite:`Bohren-1998-ID178,Mishchenko-2002-ID6`.