API for miepython package
miepython.core Module
Mie scattering calculations for perfect spheres.
Extensive documentation is at <https://miepython.readthedocs.io>
miepython is a pure Python module to calculate light scattering of a plane wave by non-absorbing, partially-absorbing, or perfectly conducting spheres.
The extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry for a sphere with complex index of refraction m, diameter d, and wavelength lambda can be found by:
import miepython as mie
qext, qsca, qback, g = mie.efficiencies(m, d, lambda0)
The normalized scattering values for angles mu=cos(theta) are:
Ipar, Iper = mie.intensities(m, d, lambda0, mu)
If the size parameter is known, then use:
mie.efficiencies_mx(m, x)
Mie scattering amplitudes S1 and S2 (complex numbers):
mie.S1_S2(m, x, mu)
Normalized Mie scattering intensities for angles mu=cos(theta):
mie.i_per(m, x, mu)
mie.i_par(m, x, mu)
mie.i_unpolarized(m, x, mu)
Functions
|
Return the scattered intensities from a sphere. |
|
Return the scattered intensity in a plane parallel to the incident light. |
|
Return the scattered intensity in a plane normal to the incident light. |
|
Return the unpolarized scattered intensity at specified angles. |
|
Computes scattering and extinction efficiencies for a spherical particle using Mie theory. |
|
Calculate the efficiencies of a sphere. |
|
Calculate the scattering amplitude functions for spheres. |
|
Calculate the scattering (Mueller) matrix. |
|
Computes the Mie coefficients for a sphere. |
|
Compute arrays of Mie coefficients A and B for a sphere. |
|
Calculate Mie coefficients c_n and d_n for the internal field of a sphere. |
|
Compute the logarithmic derivative of ψ_n(z) using the best method. |
miepython.mie_nojit Module
Low-level Mie calculations that do not use numba.
Functions
|
Compute the logarithmic derivative of ψ_n(z) using the best method. |
|
Compute arrays of Mie coefficients A and B for a sphere. |
|
Calculate Mie coefficients c_n and d_n for the internal field of a sphere. |
|
Compute the Mie scattering functions π_n and τ_n for given cosine angles. |
|
Calculate the scattering amplitude functions for spheres. |
miepython.mie_jit Module
Low-level Mie calculations that use numba.
Functions
|
Compute the logarithmic derivative of ψ_n(z) using the best method. |
|
Compute arrays of Mie coefficients a_n and b_n for a sphere. |
|
Calculate Mie coefficients c_n and d_n for the internal field of a sphere. |
|
Compute the Mie scattering functions π_n and τ_n for given cosine angles. |
|
Calculate the scattering amplitude functions for spheres. |
miepython.rayleigh Module
Rayleigh approximation for scattering by small particles.
Functions
|
Calculate the efficiencies for a small sphere. |
|
Calculate the efficiencies of a sphere using Rayleigh's approximation. |
|
Calculate the scattering amplitude functions for small spheres. |
|
Return the parallel scattered intensity for small spheres. |
|
Return the perpendicular scattered intensity for small spheres. |
|
Return the unpolarized scattered intensity for small spheres. |
|
Return the scattered intensities from a sphere. |
|
Calculate the scattering (Mueller) matrix. |
miepython.bessel Module
Module for Bessel and Riccati-Bessel functions.
This module provides a collection of functions related to spherical Bessel functions, Hankel functions, Riccati-Bessel functions, and their derivatives. This supplements those provided by scipy.special
Functions provided:
Spherical Bessel functions:
spherical_h1: Spherical Hankel function of the first kind h_n^{(1)}(z).
spherical_h2: Spherical Hankel function of the second kind h_n^{(2)}(z).
Derivatives of Bessel functions:
d_spherical_jn: Derivative of the spherical Bessel function j_n’(z).
d_spherical_h1: Derivative of the spherical Hankel function of first kind h_n^{(1)}’(z).
d_spherical_h2: Derivative of the spherical Hankel function of second kind h_n^{(2)}’(z).
Riccati-Bessel functions:
riccati_bessel_jn: Riccati-Bessel function of the first kind ψ_n(z).
riccati_bessel_h1: Riccati-Bessel function of the second kind ξ_n(z).
riccati_bessel_h2: Riccati-Bessel function of the third kind ζ_n(z).
Derivatives of Riccati-Bessel functions:
d_riccati_bessel_jn: Derivative of the Riccati-Bessel function of the first kind ψ_n’(z).
d_riccati_bessel_h1: Derivative of the Riccati-Bessel function of the second kind ξ_n’(z).
d_riccati_bessel_h2: Derivative of the Riccati-Bessel function of the third kind ζ_n’(z).
Functions
|
Spherical Hankel function of the first kind. |
|
Spherical Hankel function of the second kind. |
|
Riccati-Bessel function of the first kind ψ_n(z). |
|
Riccati-Bessel function of the second kind ξ_n(z). |
|
Riccati-Bessel function of the third kind ζ_n(z). |
|
Derivative of the spherical Bessel function of the first kind. |
|
Derivative of the spherical Hankel function of the first kind h_n^{(1)}'(z). |
|
Derivative of the spherical Hankel function of the second kind h_n^{(2)}'(z). |
|
Derivative of the Riccati-Bessel function of the first kind ψ_n'(z). |
|
Derivative of the Riccati-Bessel function of the second kind ξ_n'(z). |
|
Derivative of the Riccati-Bessel function of the third kind ζ_n'(z). |
miepython.vsh Module
Vector Spherical Harmonics for Mie Scattering.
This module calculates the electric and magnetic vector spherical harmonics (VSH) required for Mie scattering computations. The functions in this module compute the VSH corresponding to the m=1 mode, which is commonly used in scattering problems.
Sign Conventions:
The sign conventions used in this module follow those presented on the “Vector Spherical Harmonics” webpage on Wikipedia as well as those described in the paper by Ladutenko (DOI: https://doi.org/10.1016/j.cpc.2017.01.017). In particular, the odd and even modes are consistent with these references.
The even and odd magnetic modes of Bohren & Huffman are reversed from those used here.
Bessel Function Selection:
The appropriate spherical Bessel function is chosen based on the spatial region where the field is evaluated:
For points inside the sphere (r < d_sphere/2), the regular spherical Bessel functions (
spherical_jn) are used.For points outside the sphere (r >= d_sphere/2), the spherical Hankel functions of the first kind (
spherical_h1) are employed to represent the radiating field.
Functions:
- M_odd(n, k, d_sphere, r, theta, phi)
Compute the nth odd magnetic vector spherical harmonic (m=1).
- M_even(n, k, d_sphere, r, theta, phi)
Compute the nth even magnetic vector spherical harmonic (m=1).
- N_odd(n, k, d_sphere, r, theta, phi)
Compute the nth odd electric vector spherical harmonic (m=1).
- N_even(n, k, d_sphere, r, theta, phi)
Compute the nth even electric vector spherical harmonic (m=1).
Additional Utility Functions:
- mie_pi(n, theta, deg=False)
Computes the angular variation (𝜋ₙ(𝜃)) for the electric multipole field, based on the associated Legendre polynomial.
- mie_tau(n, theta, deg=False)
Computes the angular variation (𝛕ₙ(𝜃)) for the magnetic multipole field, corresponding to the derivative of the associated Legendre polynomial.
Functions
|
Computes the angular variation of the electric field arising from the nth magnetic multipole 𝛕_n(𝜃). |
|
Computes the angular variation of the electric field arising from the nth electric multipole 𝜋_n(𝜃). |
|
Compute the nth even magnetic vector spherical harmonic (m=1). |
|
Compute the nth odd magnetic vector spherical harmonic (m=1). |
|
Compute the nth even electric vector spherical harmonic (m=1). |
|
Compute the nth odd electric vector spherical harmonic (m=1). |
|
Compute the nth even magnetic vector spherical harmonic (m=1). |
|
Generate the first n odd magnetic vector spherical harmonics (m=1). |
|
Compute the first n even electric vector spherical harmonics. |
|
Generate first n odd electric vector spherical harmonics (m=1). |
miepython.field Module
Electric and magnetic field calculations.
Only e_far has been verified to work.
Functions
|
Calculate the electric field in and around a sphere. |
|
Calculate a plane wave using vector spherical harmonics. |
|
Calculate the electric field in the far field. |
miepython.monte_carlo Module
Monte Carlo and Mie scattering.
Functions
|
Create a CDF for unpolarized scattering uniformly spaced in cos(theta). |
|
Create a CDF for unpolarized scattering for uniform CDF. |
|
Generate a new scattering angle using a cdf. |
miepython.util Module
Functions to format complex numbers or arrays of complex numbers.
Functions
|
Convert Cartesian coordinates (x, y, z) to spherical (r, theta, phi). |
|
Convert complex numbers to string for printing. |
|
Convert complex number to string for printing. |
|
Convert a tuple to string for printing. |
|
Convert complex numbers to phasor for printing. |
|
Convert complex scalar to phasors for printing. |
|
Convert spherical coordinates (r, theta, phi) to Cartesian (x, y, z). |
|
Convert spherical components (E_r, E_theta, E_phi) to Cartesian (Ex, Ey, Ez). |