Skip to main content

Mie scattering of a plane wave by a sphere

Project description

PyPI GitHub Conda DOI

License Testing Docs Downloads

Try JupyterLite

Mie scattering calculations in pure Python

miepython provides a validated and efficient implementation of Mie scattering for spherical particles. It reproduces established reference results (including Wiscombe’s MIEV0) and is designed for scientific, educational, and computational research applications in optics.

The library implements the full Mie solution, including:

  • extinction, scattering, and absorption efficiencies

  • asymmetry parameter (scattering anisotropy)

  • angle-resolved scattering intensities

  • Mie expansion coefficients

  • complex amplitude functions and Mueller matrices

  • E-field and H-field calculations in the near-field around a sphere

The implementation is numerically stable for a wide range of size parameters and refractive indices, including lossy materials and high-index contrasts.

JupyterLite Implementation

The entire package can be used immediately in a browser — without installation — using the JupyterLite interface:

Try JupyterLite

This environment runs entirely client-side (Pyodide), and supports:

  • interactive notebooks

  • real-time plotting

  • full access to miepython functions

  • reproducible experiments (downloadable notebooks)

This makes it ideal for teaching, demonstrations, or quick exploratory calculations.

Installation

Install with pip:

pip install miepython

Or via conda:

conda install -c conda-forge miepython

Quick Start

A typical calculation is straightforward:

import miepython as mie

m = 1.5 - 0.1j     # refractive index
d = 100            # diameter (nm)
lambda0 = 314.15   # wavelength (nm)

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

Documentation and Examples

The full documentation is available on ReadTheDocs:

Docs

Representative results simple examples:

https://github.com/scottprahl/miepython/tree/main/miepython/examples

https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/01.svg https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/02.svg https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/03.svg https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/04.svg https://raw.githubusercontent.com/scottprahl/miepython/main/docs/images/05.svg

Performance and Acceleration

miepython supports optional Numba JIT compilation:

import os
os.environ["MIEPYTHON_USE_JIT"] = "1"  # must be set before import
import miepython

This can provide 10–50× speedups for large parameter sweeps or ensemble calculations.

Benchmark example (100,000 particles):

Version

Time

Speedup

Pure Python

4.00 s

JIT Enabled

0.15 s

27×

Citation

If you use laserbeamsize in academic, instructional, or applied technical work, please cite:

Prahl, S. (2026). miepython: Pure python calculation of Mie scattering (Version 3.1.0) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.7949263

BibTeX:

@software{prahl_miepython_2026,
  author  = {Scott Prahl},
  title   = {{miepython}: A Python library for Mie scattering calculations},
  url     = {https://github.com/scottprahl/miepython},
  doi     = {10.5281/zenodo.7949263},
  year    = {2026},
  version = {3.1.0},
  publisher = {Zenodo}
}

License

miepython is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

miepython-3.2.0.tar.gz (77.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

miepython-3.2.0-py3-none-any.whl (48.0 kB view details)

Uploaded Python 3

File details

Details for the file miepython-3.2.0.tar.gz.

File metadata

  • Download URL: miepython-3.2.0.tar.gz
  • Upload date:
  • Size: 77.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for miepython-3.2.0.tar.gz
Algorithm Hash digest
SHA256 88bd7c0ef00939650be4c8f7ed9bafb551f2ba3f34bfb790b3192873703cbb2c
MD5 6f5a7c12bfeff59127dbad12a412fc7d
BLAKE2b-256 9fdc5d84bed2c2c32c1cec5ba166db8706ab66c1530f431216185f016d564493

See more details on using hashes here.

Provenance

The following attestation bundles were made for miepython-3.2.0.tar.gz:

Publisher: pypi.yaml on scottprahl/miepython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file miepython-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: miepython-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for miepython-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 008011c6b7679a969f5203c55af43e855d666fca7bd42fdbc3a0ecc29203174c
MD5 fab38740d3a0cd8feb7fd9f6ac3e3bf2
BLAKE2b-256 a1ddb0f364af74b32a816fd47af4a3d93ceeb124d85e597a34eae5501ede28a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for miepython-3.2.0-py3-none-any.whl:

Publisher: pypi.yaml on scottprahl/miepython

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page