BHMIE is the Bohren-Huffman reference implementation of Mie scattering. The tool's version is a line-by-line port in TypeScript, careful about the recurrence directions that make the series numerically stable.
Truncation
The series over n is truncated at
nmax = ⌊x + 4 x1/3 + 2⌋
This is Wiscombe's empirical formula; it grows roughly linearly with x and gives six-digit accuracy on Qext for x up to several hundred.
Two recurrences
- Downward for Dn(mx) = ψ′n/ψn. The upward form amplifies round-off exponentially; starting from zero at a high index and recursing down is numerically stable.
- Upward for ψn(x) and χn(x) separately — these Riccati-Bessel functions are fine upward.
What comes out
Scattering (Qsca), absorption (Qabs), extinction (Qext = Qsca + Qabs), backscatter, and the asymmetry parameter g = ⟨cos θ⟩. All dimensionless efficiencies; multiply by πr² to get cross-sections.