Skip to content

Mie scattering of light by perfect spheres

License

Notifications You must be signed in to change notification settings

andrej5elin/miepython

 
 

Repository files navigation

miepython

by Scott Prahl

pypi github conda doi

License Testing Docs Downloads code style: black


miepython is a pure Python module to calculate light scattering for non-absorbing, partially-absorbing, or perfectly-conducting spheres. Mie theory is used, following the procedure described by Wiscombe. This code has been validated against his results.

This code provides functions for calculating the extinction efficiency, scattering efficiency, backscattering, and scattering asymmetry. Moreover, a set of angles can be given to calculate the scattering for a sphere at each of those angles.

Full documentation at <https://miepython.readthedocs.io>

Version 3 changes (in progress)

This version contains major changes to the code base and has API breaking changes. If you don't need the new functionality for fields, then you can continue to use the last version with the old API: 2.5.5

Version 3.0 has many changes, but the major changes are:

  • a complete overhaul of API
  • added support to calculate Mie coefficients for fields inside sphere
  • added support for calculating electric and magnetic fields

Pay Attention!

When comparing different Mie scattering codes, make sure that you're aware of the conventions used by each code. miepython makes the following assumptions

  1. the imaginary part of the complex index of refraction for absorbing spheres is negative.
  2. the scattering phase function is normalized so it equals the single scattering albedo when integrated over 4π steradians. As of version 2.3, this can be changed.

Installation

Use pip:

pip install miepython

or conda:

conda install -c conda-forge miepython

An example

The following code:

import miepython as mie

m = 1.5 - 1j      # refractive index of sphere
d = 100           # nm diameter of sphere
lambda0 = 314.15  # nm wavelength in vacuum

qext, qsca, qback, g = mie.efficiencies(m, d, lambda0)

print("The extinction efficiency  is %.3f" % qext)
print("The scattering efficiency  is %.3f" % qsca)
print("The backscatter efficiency is %.3f" % qback)
print("The scattering anisotropy  is %.3f" % g)

should produce:

The extinction efficiency  is 2.336
The scattering efficiency  is 0.663
The backscatter efficiency is 0.573
The scattering anisotropy  is 0.192

There are a few short python scripts in the github repository.

Absorbing and non-absorbing spheres

Glass spheres with resonance spike

Water Droplets

Gold nanospheres

License

miepython is licensed under the terms of the MIT license.

About

Mie scattering of light by perfect spheres

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.8%
  • Makefile 1.2%