codecov travis python zenodo colab docs


PyMieSim is a very easy to install/use tool for extensive Mie scattering analysis. It allows to study the light scattering on different kind of object (scatterer), at the moment I only implemented spherical scatterers. Using this package, one can easily set a Source a Scatterer and a Detector within a very wide range of parameters such as:

  1. Source structure (e.g. plane wave or Gaussian focused)

  2. Source wavelength

  3. Source Polarization

  4. Scatterer diameter

  5. Scatterer refractive index

  6. Medium refractive index

  7. Detector type (photodiode or LPMode)

  8. Detector numerical aperture

  9. Detector angle offfset in polariation parallel axis (\(\phi\))

  10. Detector angle offfset in polariation perpendicular axis (\(\theta\))

  11. Detector coupling mode (Mean coupling or centered coupling)

The package also let you to construct an Experiment using ScattererSet, SourceSet and DetectorSet. Those class define the type of scatterers, light source and detector type you want to study.


All the latest available documentation is available here or you can click the following badge:


Google Colab

It’s 2021, you don’t need to run all codes on you computer anymore. Google Colab is a platform which allows to write/use python script remotely. You can open the PyMieSim.ipynb in the file (or click on the “Open in Colab” badge) to access it or click on the following badge:



Wheel support now extended to manylinux2014

It’s pretty simple:

pip install PyMieSim

Running Unittest

To run the Unit-tests one need the coverage library.

python -m unittest tests/


Here is an example on how to use the library.

from PyMieSim.Source import PlaneWave
from PyMieSim.Detector import LPmode
from PyMieSim.Scatterer import Sphere

Source = PlaneWave(Wavelength   = 450e-9,
                   Polarization = 0,
                   E0           = 1)

Detector = LPmode(Mode         = (0, 1),
                  Rotation     = 0.,
                  Sampling     = 201,
                  NA           = 0.2,
                  GammaOffset  = 0,
                  PhiOffset    = 0,
                  CouplingMode = 'Centered')

Scat = Sphere(Diameter    = 300e-9,
              Source      = Source,
              Index       = 1.4)

Coupling = Detector.Coupling(Scatterer = Scat)

print(Coupling) # output: 1.66e+02 nWatt

For more examples I invite you to check the examples section of the documentations.

Coding examples

A large set of examples is avaialble in the test/Examples folder. You can also see them in the examples section of the documentation

To-Do List

  • Adding dumb-proof assertions

  • Adding docstring

  • Adding Stokes parameter representations [DONE]

  • Multiprocess Experiment class

  • Adding more unittests

  • Adding monotonic metric to optimizer class [DONE]

  • Comments on c++ codes

  • Multiclass c++ codes

  • verify if changes of NA for <LPmode> class can be simplified [DONE]

  • adding travis and codecov [DONE]

  • adding material Sellmeier boundary

Citing this work?

I spend half a year to develop this tool for you to use so if it helped you in your research I would greatly appreciate you to cite my work. Many thanks zenodo

(Is this the new “like, comment and share” ?)

Developper mode

In order to compile the project without using pip a few depedencies are to be installed. Those are the C++ boost library and a C++/Fortran wrapper for bessel function with complex argument (nowhere to be found as C++ lib)

I have worked out a Dockerfile (see the PyMieSim Git) to install all the necessaries library.

I you prefer to directly install in your computer the files you can do the following

Boost library

Linux (Debian)

sudo apt-get install libboost-all-dev


brew install boost


Boost installation guide

Fortran wrapper

You have to compile and install the code yourself. Follow the instruction as showed here .

Contact Information

As of 2021 the project is still under development if you want to collaborate it would be a pleasure. I encourage you to contact me.

PyMieSim was written by Martin Poinsinet de Sivry-Houle . .