Skip to content
MartinPdeSPublic

About

Python framework for fast Lorenz Mie scattering simulations, including far field scattering, efficiencies, cross sections, and detector coupling for spheres and cylinders.

Topics

Resources

Contributing

Stars

40 stars

Watchers

5 watching

Forks

Repository files navigation

PyMieSim

PyMieSim logo

Badge Status
Python versions Supported Python versions
Documentation Documentation
Tests Tests Test coverage
PyPI PyPI version Monthly PyPI downloads
Conda Anaconda version Anaconda downloads Latest Anaconda release

A package for light scattering (Mie) computation.

Try online with PyMieSimX

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.

See the usage guide for further examples and implementation details. Open the project notebook in Colab.

Installation

Requires Python >=3.10.

$ python -m pip install PyMieSim

Install from the martinpdes Conda channel:

$ conda install -c martinpdes pymiesim

For an editable source installation:

$ git clone https://github.com/MartinPdeS/PyMieSim.git
$ cd PyMieSim
$ python -m pip install -e .

Sweep sphere diameter

"""
Sphere: Qsca vs diameter
========================

"""

import PyOptik
from PyMieSim import from_pyoptik
import numpy as np

from PyMieSim import (
    Measure,
    ureg,
    SphereSet,
    GaussianSet,
    PolarizationSet,
    MaterialSet,
    MediumSet,
    Experiment,
)


polarization_set = PolarizationSet(
    angles=[0.0] * ureg.degree,
)

source = GaussianSet(
    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)
https://raw.githubusercontent.com/MartinPdeS/PyMieSim/HEAD/docs/images/Qsca_diameter.png

Scattering efficiency as a function of sphere diameter.

Documentation

Use the PyMieSim documentation to work through examples and look up the inputs and return values of individual functions.

Citation

For the scattering model and its validation, cite the PyMieSim paper in Optics Continuum.

Contributing

Bug reports, worked examples, and documentation corrections are welcome. To set up a development checkout and run the tests, follow the contributing guide.

Contact

For questions, contact Martin Poinsinet de Sivry-Houle.

License

See the PyMieSim license for terms of use.

About

Python framework for fast Lorenz Mie scattering simulations, including far field scattering, efficiencies, cross sections, and detector coupling for spheres and cylinders.

Topics

Resources

Contributing

Stars

40 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages