Rust API¶
The Python package is a thin layer over the Rust crate scatrs, which can also be used
directly. Its API reference is generated by rustdoc from the sources, with every example
compiled and run as a test:
Add it with cargo add scatrs. The same reference is on docs.rs.
The crate and the Python package¶
Rust |
Python |
Contents |
|---|---|---|
One sphere: coefficients, efficiencies, amplitudes, phase matrix, Greek coefficients and their derivatives. |
||
One layered sphere (a core and concentric shells): the same outputs, with derivatives with respect to every layer. |
||
One spheroid by the T-matrix method: orientation-averaged efficiencies, Greek coefficients and phase matrix, the T-matrix itself and its convergence, with derivatives. |
||
Averages of spheres, layered spheres and spheroids over size distributions, mixtures and batches (Python: grids), with error estimates and derivatives. |
||
Gauss–Legendre quadrature and Wigner d-functions. |
||
The |
||
The error type, and the exceptions that mirror it. |
The two APIs compute the same things with the same conventions, but differ in shape:
Vectorization. Python functions take arrays and loop over them in Rust. In Rust, a
Mieworkspace solves one sphere at a time, and the outputs are read from theMieSolution, into caller-owned buffers where they are arrays. For many spheres at the same angles, anAngularTableevaluates the angular functions once for all of them (the Python amplitude and phase-matrix functions use one).Precision and derivatives. The Rust kernels are generic over
Real, so they also run in double-double precision and withDualnumbers, for higher derivatives too. Python returnsf64values with first derivatives.Options. Keyword arguments in Python are builder methods in Rust, such as
MieOptions::with_n_maxandEnsembleOptions::with_rtol.
The rustdoc is the authoritative statement of each function’s accuracy contract and of its behaviour at the edges of its domain; the theory pages summarise it.