Date: Sep 04, 2025, Version: 3.8.3
PyMieSim#
PyMieSim is an open-source Python package for fast and flexible Mie scattering simulations. It supports spherical, cylindrical and core–shell particles and provides helper classes for custom sources and detectors. The project targets both quick single-scatterer studies and large parametric experiments.
Features#
Solvers for spheres, cylinders and core–shell geometries.
Built-in models for plane wave and Gaussian sources.
Multiple detector types including photodiodes and coherent modes.
Simple data analysis with pandas DataFrame outputs.
Installation#
PyMieSim is available on PyPI and Anaconda. Install it with:
pip install PyMieSim
conda install PyMieSim
See the online documentation for detailed usage and additional examples.
Quick example#
Below is a short example computing the scattering efficiency of a sphere.
import numpy as np
from TypedUnit import ureg
from PyMieSim.experiment.scatterer import Sphere
from PyMieSim.experiment.source import Gaussian
from PyMieSim.experiment import Setup
source = Gaussian(
wavelength=np.linspace(400, 1000, 500) * ureg.nanometer,
polarization=0 * ureg.degree,
optical_power=1e-3 * ureg.watt,
NA=0.2 * ureg.AU,
)
scatterer = Sphere(
diameter=[200] * ureg.nanometer,
property=[4] * ureg.RIU,
medium_property=1 * ureg.RIU,
source=source,
)
experiment = Setup(scatterer=scatterer, source=source)
df = experiment.get("Qsca")
df.plot_data(x="source:wavelength")
Building from source#
For development or manual compilation, clone the repository and run:
git submodule update --init
mkdir build && cd build
cmake ../ -G"Unix Makefiles"
sudo make install
cd ..
python -m pip install .
Testing#
Run the unit tests with:
pip install PyMieSim[testing]
pytest
Citing PyMieSim#
If you use PyMieSim in academic work, please cite:
@article{PoinsinetdeSivry-Houle:23,
author = {Martin Poinsinet de Sivry-Houle and Nicolas Godbout and Caroline Boudoux},
journal = {Opt. Continuum},
title = {PyMieSim: an open-source library for fast and flexible far-field Mie scattering simulations},
volume = {2},
number = {3},
pages = {520--534},
year = {2023},
doi = {10.1364/OPTCON.473102},
}
Contact#
For questions or contributions, contact martin.poinsinet.de.sivry@gmail.com.