| Badge | Status |
|---|---|
| Python versions | |
| Documentation | |
| Tests | |
| PyPI | |
| Conda |
A package for light scattering (Mie) computation.
Calculate scattering by spheres, coated spheres, and cylinders. Specify the incident field, particle geometry, and optical material, then sweep one input to see how scattering efficiency or detector coupling changes.
For a homogeneous sphere illuminated by an unclipped Gaussian beam, use
Gaussian(waist=..., optical_power=...) to compute complex far fields and
detector power with generalized Lorenz–Mie theory (GLMT). Use
particle_position to specify the sphere center relative to the beam waist.
GaussianPlaneWave(numerical_aperture=..., optical_power=...) uses the
Gaussian peak irradiance with a plane-wave scattering pattern.
See the GLMT equations and examples.
See the usage guide for further examples and implementation details. Open the project notebook in Colab.
Requires Python >=3.10.
$ python -m pip install PyMieSimInstall from the martinpdes Conda channel:
$ conda install -c martinpdes pymiesimFor an editable source installation:
$ git clone https://github.com/MartinPdeS/PyMieSim.git
$ cd PyMieSim
$ python -m pip install -e ."""
Sphere: Qsca vs diameter
========================
"""
import PyOptik
from PyMieSim import from_pyoptik
import numpy as np
from PyMieSim import (
Measure,
ureg,
SphereSet,
GaussianPlaneWaveSet,
PolarizationSet,
MaterialSet,
MediumSet,
Experiment,
)
polarization_set = PolarizationSet(
angles=[0.0] * ureg.degree,
)
source = GaussianPlaneWaveSet(
wavelength=[405] * ureg.nanometer,
polarization=polarization_set,
optical_power=[1e-3] * ureg.watt,
numerical_aperture=[0.2],
)
bk7 = from_pyoptik(PyOptik.load_material(name="specs/SCHOTT-optical/P-BK7"))
scatterer = SphereSet(
diameter=np.linspace(10, 1000, 150) * ureg.nanometer,
material=MaterialSet(materials=[bk7]),
medium=MediumSet(refractive_indices=[1.33, 1.34, 1.5]),
)
experiment = Experiment(scatterer_set=scatterer, source_set=source)
result = experiment.run(Measure.QSCA)
print("Result dimensions and shape:", result.dims, result.shape)
print("Measure units:", result.units)
result.plot(x="scatterer:diameter", show=True)Use the PyMieSim documentation to work through examples and look up the inputs and return values of individual functions.
For the scattering model and its validation, cite the PyMieSim paper in Optics Continuum.
Bug reports, worked examples, and documentation corrections are welcome. To set up a development checkout and run the tests, follow the contributing guide.
For questions, contact Martin Poinsinet de Sivry-Houle.
See the PyMieSim license for terms of use.

