codecov travis python zenodo colab docs

PyMieSim

PyMieSim is a very easy to install/use tool for extensive Mie scattering analysis. The scattering event is defined by a few properties as shown in the following picture:

Scattering event

PyMieSim combines (for now) three different solver for three different scatterer type: sphere, infinite cylinders and core/shell sphere. The other parameter of the scattering event are defined per the light source and the detector (if needed). The attribute of each those “objects” is shown in the following figure.

Structure of the library

The package also lets you construct an Experiment using SphereSet/CoreShellSet/CylinderSet, SourceSet and DetectorSet. Those class define the type of scatterers, light sources and detectors you want to study.


Documentation

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

docs


Google Colab

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

colab


Installation

For common version of Windows, Linux and MacOS The package can readily be installed using pip;

If, however, this fail you can build the package from scratch following the steps on the Building the package section.

Note: Wheel support now extended to manylinux2014.


Running Unittest

To run the Unittests, one need the coverage library.

>>> python3 -m unittest tests/Unittest.py

Coding examples

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 documentation.


Citing this work?

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

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


Building the package

The computing core of PyMieSim is written in C++ and Fortran. Thus, to build the extensions one need the following requirements:

  • C++ compiler

  • Fortran compiler

  • Python (version >= 3.7)

  • Git

On a windows machine I would recommend using MSYS with the MinGW64 toolchain. The toolchain can be installed from the MSYS terminal with: “pacman -S mingw-w64-x86_64-toolchain”

The first step to build the package one has to clone the repository and update the submodules;

Next step is to configure the CMake;

Warning: It looks like one has to change a particular PyBind11 file to build the package on windows.

Line 24 of extern/pybind11/include/pybind11/detail/common.h shows visibility(‘’default’’).”

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

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 .

Email:martin.poinsinet-de-sivry@polymtl.ca .

PyMieSim’s documentation

_images/Logo.png

Indices and tables