Meta | |||
Testing | |||
PyPI | |||
Anaconda |
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.
- 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.
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.
Below is a short example computing the scattering efficiency of a sphere.
import numpy as np
from PyMieSim.experiment.scatterer import Sphere
from PyMieSim.experiment.source import Gaussian
from PyMieSim.experiment import Setup
from PyMieSim.units import nanometer, degree, watt, AU, RIU
source = Gaussian(
wavelength=np.linspace(400, 1000, 500) * nanometer,
polarization=0 * degree,
optical_power=1e-3 * watt,
NA=0.2 * AU,
)
scatterer = Sphere(
diameter=[200] * nanometer,
property=[4] * RIU,
medium_property=1 * RIU,
source=source,
)
experiment = Setup(scatterer=scatterer, source=source)
df = experiment.get("Qsca")
df.plot_data(x="source:wavelength")
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 .
Run the unit tests with:
pip install PyMieSim[testing]
pytest
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},
}
For questions or contributions, contact [email protected].