holopy.scattering.theory.mie_f package

Fortran extension module for calculating cluster holograms using tmatrix scattering theory.

Submodules

Compute special functions needed for the computation of scattering coefficients in the Lorenz-Mie scattering solution and related problems such as layered spheres.

These functions are not to be used for calculations at each field point. Rather, they should be used once for the calculation of scattering coefficients, which then get passed to faster Fortran code for field calculations.

Papers referenced herein:

D. W. Mackowski, R. A. Altenkirch, and M. P. Menguc, “Internal absorption cross sections in a stratified sphere,” Applied Optics 29, 1551-1559, (1990).

Yang, “Improved recursive algorithm for light scattering by a multilayered sphere,” Applied Optics 42, 1710-1720, (1993).

Qratio(z1, z2, nstop, dns1=None, dns2=None, eps1=0.001, eps2=1e-16)

Calculate ratio of Riccati-Bessel functions defined in [Yang2003] eq. 23 by up recursion.

Notes

Logarithmic derivatives calculated automatically if not specified. Lentz continued fraction algorithm used to start downward recursion for logarithmic derivatives.

R_psi(z1, z2, nmax, eps1=0.001, eps2=1e-16)

Calculate ratio of Riccati-Bessel function psi: psi(z1)/psi(z2).

Notes

See [Mackowski1990] eqns. 65-66. Uses Lentz continued fraction algorithm for logarithmic derivatives.

log_der_1(z, nmx, nstop)

Computes logarithmic derivative of Riccati-Bessel function psi_n(z) by downward recursion as in BHMIE.

Parameters:
  • z (complex argument) –
  • nmx (order from which downward recursion begins.) –
  • nstop (integer, maximum order) –

Notes

psi_n(z) is related to the spherical Bessel function j_n(z). Consider implementing Lentz’s continued fraction method.

log_der_13(z, nstop, eps1=0.001, eps2=1e-16)

Calculate logarithmic derivatives of Riccati-Bessel functions psi and xi for complex arguments. Riccati-Bessel conventions follow Bohren & Huffman.

See Mackowski et al., Applied Optics 29, 1555 (1990).

Parameters:
  • z (complex number) –
  • nstop (maximum order of computation) –
  • eps1 (underflow criterion for Lentz continued fraction for Dn1) –
  • eps2 (convergence criterion for Lentz continued fraction for Dn1) –
riccati_psi_xi(x, nstop)

Calculate Riccati-Bessel functions psi and xi for real argument.

Parameters:
  • x (float) – Argument
  • nstop (int) – Maximum order to calculate to
Returns:

psi and xi

Return type:

ndarray(2, nstop)

Notes

Uses upwards recursion.

MieScatLib.py

Library of code to do Mie scattering calculations.

asymmetry_parameter(al, bl)

Calculate asymmetry parameter of scattered field.

Parameters:bn (an,) – coefficient arrays from Mie solution
Returns:
Return type:float

Notes

See discussion on Bohren & Huffman p. 120. The output of this function omits the prefactor of 4/(x^2 Q_sca).

cross_sections(al, bl)

Calculates scattering and extinction cross sections given arrays of Mie scattering coefficients an and bn.

Parameters:bn (an,) – coefficient arrays from Mie solution
Returns:Scattering, extinction, and radar backscattering cross sections
Return type:ndarray(3)

Notes

See Bohren & Huffman eqns. 4.61 and 4.62. The output omits a scaling prefactor of 2 * pi / k^2.

internal_coeffs(m, x, n_max, eps1=0.001, eps2=1e-16)

Calculate internal Mie coefficients c_n and d_n given relative index, size parameter, and maximum order of expansion.

Parameters:docstring for scatcoeffs (See) –
Returns:Internal coefficients c_n and d_n
Return type:ndarray(2,n) complex

Notes

Follow Bohren & Huffman’s convention. Note that van de Hulst and Kerker have different conventions (labeling of c_n and d_n and factors of m) for their internal coefficients.

nstop(x)

Calculate maximum expansion order of Lorenz-Mie solution.

Parameters:x (float) – Particle size parameter
Returns:nstop
Return type:int

Notes

Criterion taken from [Wiscombe1980].

scatcoeffs(m, x, nstop, eps1=0.001, eps2=1e-16)

Calculate expansion coefficients for scattered field in Lorenz-Mie solution.

Parameters:
  • m (complex) – Sphere relative refractive index (n_sphere / n_medium)
  • x (float) – Sphere size parameter (k_med * a)
  • nstop (int) – Maximum order of scattered field expansion
  • eps1 (float, optional) – In Lentz continued fraction algorithm for logarithmic derivative D_n(z), value of continued fraction numerator or denominator triggering ill-conditioning workaround.
  • eps2 (float, optional) – Convergence criterion for Lentz continued fraction algorithm
Returns:

Scattering coefficients a_n and b_n

Return type:

array(2, nstop), complex

Notes

Uses formula for scattering coefficients based on logarithmic derivative D_n(z) of spherical Bessel function psi_n(z). See [Bohren1983] eq. 4.88.

Following BHMIE, calculates D_n for complex argument using downward recursion, and Riccati-Bessel functions psi and xi for real argument using upward recursion.

Initializes downward recursion for D_n using Lentz continued fraction algorithm [Lentz1976].

multilayer_sphere_lib.py

Author: Jerome Fung (fung@physics.harvard.edu)

Functions to calculate the scattering from a spherically symmetric particle with an arbitrary number of layers with different refractive indices.

Key reference for multilayer algorithm: Yang, “Improved recursive algorithm for light scattering by a multilayered sphere,” Applied Optics 42, 1710-1720, (1993).

scatcoeffs_multi(marray, xarray, eps1=0.001, eps2=1e-16)

Calculate scattered field expansion coefficients (in the Mie formalism) for a particle with an arbitrary number of spherically symmetric layers.

Parameters:
  • marray (array_like, complex128) – array of layer indices, innermost first
  • xarray (array_like, real) – array of layer size parameters (k * outer radius), innermost first
  • eps1 (float, optional) – underflow criterion for Lentz continued fraction for Dn1
  • eps2 (float, optional) – convergence criterion for Lentz continued fraction for Dn1
Returns:

scat_coeffs – Scattering coefficients

Return type:

ndarray (complex)

Extensions for T-Matrix scattering calculations (in fortran77 and fortran90); numpy.distutils should automatically use f2py to compile these, and f2py should detect your fortran compiler.

The code works with gcc, but has not been tested with other compilers. Note that f2py by default compiles with optimization flags.

Ignore compiler warnings of unused variables, unused dummy arguments, and variables being used uninitialized from compiling scsmfo_min. The former is relics of how scsmfo was written which I am not touching. The latter is likely due to some GOTO statements that could cause a variable to be referenced before it’s initialized. Under normal usage I wouldn’t worry about it.

configuration(parent_package='', top_path=None)