Skip to main content

A package for light scattering computation.

Project description

PyOptik logo

Meta

Python

Documentation Status

Scientific article

Testing

Unittest Status

Unittest coverage

Google Colab

PyPi

PyPi version

PyPI - Downloads

Anaconda

Anaconda version

Anaconda downloads

Latest release date

PyMieSim

PyMieSim is a Python library designed to provide a robust and flexible framework for performing Mie scattering simulations. The software is easy to install and operate, making it accessible to both new users and experienced researchers. PyMieSim enables users to explore the scattering properties of particles under various configurations, and is tailored for investigating single scattering events, as well as conducting large-scale parametric experiments.

At its core, PyMieSim includes three solvers optimized for different types of scatterers:

  • Spherical particles

  • Infinite cylindrical particles

  • Core-shell spherical particles

The software also allows the user to customize the light source and detector attributes, depending on the specific simulation needs. The package is modular and provides an intuitive interface for users to model complex scattering scenarios with minimal effort.

Structure of the library

Main Submodules

PyMieSim is organized into two primary submodules:

  1. single: Focused on analyzing individual scattering events, such as: - Far-field distributions - Scattering phase functions - Stokes parameters

  2. experiment: Designed for exploring how scattering parameters, such as Qsca, Qext, g, and coupling (power), behave over large datasets, incorporating variations in sources, scatterers, and detectors.

Both submodules work seamlessly together, making PyMieSim adaptable for a wide range of scattering simulations.


Getting Started

To use PyMieSim in Python, simply install the package and begin incorporating it into your scripts.

Installation

PyMieSim supports Windows, Linux, macOS (including Apple M1/M2 chips), and ARM architectures. To install the package, use pip:

pip install PyMieSim

For more details, visit the documentation for a comprehensive guide on how to use the package.


Example Code

Here is an example of how to use PyMieSim for a simple Mie scattering simulation. This example demonstrates how to configure a light source, scatterer, and detector, and retrieve the scattering data:

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)

dataframe = experiment.get('Qsca')

dataframe.plot_data(x="source:wavelength")

It produces the following figure which is equivalent to the one found on wikipedia.

Example wikipedia

This is just one example of PyMieSim in action. You can find more examples in the examples section of the documentation.


Examples

Here are a few more examples showcasing the capabilities of PyMieSim:

Example 1: Plasmonic Resonances for CoreShell Particles

Plasmonic resonances

Example 2: Scattering Efficiency vs Diameter for Spherical Particles

Qsca vs diameter


Manual Building

If you prefer or need to build the project manually (e.g., for Apple silicon devices), ensure you have a C++ compiler (such as gcc) and Fortran installed, as well as Python 3.7+.

Build Instructions

Linux/MacOS

git clone https://github.com/MartinPdeS/PyMieSim.git
cd PyMieSim
git submodule init && git submodule update
mkdir build
cd build
cmake ../ -G"Unix Makefiles"
sudo make install
cd ..
python -m pip install .

For Windows, use MinGW Makefiles instead of Unix Makefiles when invoking CMake.


Testing

You can test the local version of PyMieSim by running the following commands:

git clone https://github.com/MartinPdeS/PyMieSim.git
cd PyMieSim
pip install PyMieSim[testing]
pytest

This will run the suite of unit tests and provide coverage details.


Google Colab

In 2024, running code on your local machine is optional! You can leverage the power of Google Colab to run PyMieSim remotely. Use the provided Colab notebook for an interactive experience.

Google Colab


Citing PyMieSim

If PyMieSim contributes to your research, we kindly ask that you cite the following paper:

@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},
}

You can access the full article here


Experimental Graphical User Interface (GUI)

Since version 1.7.0, PyMieSim offers an experimental GUI for users who prefer a graphical approach to simulations. While still under development, the GUI can be installed and accessed as follows:

pip install PyMieSim
python -m  PyMieSim

The GUI is not yet as robust as the core Python API, but it provides a simplified interface for generating simulations.

Structure of the library


Contact Information

PyMieSim is actively developed and maintained by Martin Poinsinet de Sivry-Houle. If you’re interested in contributing or have questions, feel free to reach out.

Email: martin.poinsinet.de.sivry@gmail.ca


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pymiesim-3.0.0.4-cp312-cp312-win_amd64.whl (13.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

pymiesim-3.0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pymiesim-3.0.0.4-cp312-cp312-macosx_14_0_arm64.whl (6.3 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

pymiesim-3.0.0.4-cp311-cp311-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.11 Windows x86-64

pymiesim-3.0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pymiesim-3.0.0.4-cp311-cp311-macosx_14_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

pymiesim-3.0.0.4-cp310-cp310-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.10 Windows x86-64

pymiesim-3.0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pymiesim-3.0.0.4-cp310-cp310-macosx_14_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

File details

Details for the file pymiesim-3.0.0.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f987e7e7faecfb2265b0013261caabb1e941a3ba3403c8f567739b729fe77691
MD5 92595dd25bee20896215ef0db7f48d01
BLAKE2b-256 e365bf3d256efe300edf86a3d800c571201be32d588c7e3bcf6704caf1d5f9cb

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2229e8a774766f66634831911ca365fdc5de72d38c3b26b0ef631b0066960aae
MD5 13b2ebb5cdb701cab34e05d5491c4de6
BLAKE2b-256 aaa37620cc60addc7fea5d45c084a57ccffba5dae7f7fa6606905a705f44c99e

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 16468a7da9b7134befcee14a8798dc06055367635ae3d6ee84f43c2e2311abad
MD5 653aa366f0719138f0a896a498ba71c8
BLAKE2b-256 4759ac7ad1b7487e41ee32f8c47dc8403b56d4b0bade4017be712bc8181e4904

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 40fe691c117d4c15407d9757dba100eb138c73626d86f1440444b579781d6698
MD5 a24de386be193576e03eb0712bc66058
BLAKE2b-256 23f13da1a4cb0ada7be1676075aa772e573b65225bc4600c3e5348f7d870de4c

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b0931a66ed5aa44ff3fb5c4ad006ee3eb708a7defff443d38be376a44cff53e5
MD5 f93be6c897b2dd554e7930a950f8f1d2
BLAKE2b-256 1a45ac301da994d32246baaf5b9734e08d78297fda51cc10951501e9e99c24ed

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 2992c0d84291d85b5db1527a0447e633215fda2e7b60b1fde09a2cabc64bd696
MD5 8755cd9542989c6fa8b3a0dc9673384a
BLAKE2b-256 19847f0ec1e4d106bf26dddc692ca0a47856bfe1be82d07da973d920d232084b

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2634a8c989d3749f55ff287bff8a35d1498e65a3a99ba43e205b48d621dc65d0
MD5 c395d28f233673cde0274cf208677715
BLAKE2b-256 e9216b40a0b82c254a8e574c2770f5befab21ba5bb1fbccf191f9d4780ea367e

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87cafee3e71f1353fdd44235c48e22aa9320ed040e2ff27a7a677539e0235e9c
MD5 79edacb228c703797b13fd3f9a1439ae
BLAKE2b-256 bbb583defcf4617ddd1f2d4058d394a68ba41b8b2b6ae15b5c4f08847c57c774

See more details on using hashes here.

File details

Details for the file pymiesim-3.0.0.4-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pymiesim-3.0.0.4-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3caadaf5174100f7c7a5a4177b3bc5dd8886dbf6a8c7f22a65ab108bfd8d7b3f
MD5 64b42ff81db6b63228589dae6e543a0c
BLAKE2b-256 b7e6e6557eb9efc27c0068016ecb58a1d56152c1df3925ef354227434f2da183

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page