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 version

Anaconda

Anaconda version

Anaconda downloads

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-2.6.3-cp312-cp312-win_amd64.whl (13.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

pymiesim-2.6.3-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-2.6.3-cp312-cp312-macosx_14_0_arm64.whl (6.3 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

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

Uploaded CPython 3.11 Windows x86-64

pymiesim-2.6.3-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-2.6.3-cp311-cp311-macosx_14_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

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

Uploaded CPython 3.10 Windows x86-64

pymiesim-2.6.3-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-2.6.3-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-2.6.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 122ba5dcde54657dcdc15491205ee732e6dead37251839b7a20ea906a0e65606
MD5 d68471684912cc1f922435bca59b1416
BLAKE2b-256 2df84114fc0483a7028c9317a3993b7a75f2973964df9ded13d2ad323660c732

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e1acedc32e3dabc17d9637b40b0a971939d5e3f9a853fcda91473c3c3471638
MD5 85a8dae8855efe42c90443020e0e6390
BLAKE2b-256 c37c072012c0f663c396baed58e04337ba8435693081bc11cea05a34c4b41652

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9e5a37ff7958d009a4a33f28649c05919ca894b01035419950d97cd77b5a2219
MD5 63e70623732e02fa84255d603cbe551f
BLAKE2b-256 fdfe3dc99a1f51a353744a72f70bfdcede592d065b6878f82becaf5bae378fd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a5abc242d509203eff4ea80d13011a29bd240ba2eea719a9ae7d195a94c8e588
MD5 b5e391e454555824b323a091fcb4d710
BLAKE2b-256 223c90f286fe657cfc3293cafb74667b2bfd70d20cb71f87fc6510b5360df6c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e571158a4b1db398ccd7aa4de7d285abf6920e6423e987063006c328a201a5d
MD5 a1b4aef05f247248ffea29a8c2b783f5
BLAKE2b-256 20ff55725440266b97ad820187976c30f8d2dfe7e3b11731c140537fa42cf840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 06c2ae67fb4c5199ec53d2066446b6011f0674f82f7efa25a27bf678493ab9c0
MD5 9999ada6b9354a661257b795b43ae597
BLAKE2b-256 a75ca6438fffe503bb51e13c4df6fb70dc1c12b6091b2119a3de2457836e6bce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9e4b1e956b8b7ea31f171d0e22ecfe4d6b7c932f65a18dda7fc91236a294dd7d
MD5 72077dbd484dcd7a2f63c39eec0bb3ff
BLAKE2b-256 08862748fa8de9a70c2d286bd22cf5b583302de2665b2f3f120f4c29df3c1f9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dcfa1059081ba8ff4cd047563207a08a56e5095d15321e3feb468829d619e5f2
MD5 20db52c7474c641338d889e557ac196e
BLAKE2b-256 7fbc9e9fe7aa100cbab64773905b1db1fd7dcb623cfbd3d9d057d90ef8d5f7c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-2.6.3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6112dec2825e1e7ea24c53d1b3bdb5140a08378a4184cdc58ea1f20927ec2105
MD5 e87c4ac9caf295cebd123b198c000ef2
BLAKE2b-256 197c2e9aaea983a89f4a1bb5929876a1640fb45d495d7c36ad9f1b602ea5327a

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