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 (using pip package manager)

conda install PyMieSim (using conda environment manager)

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

Flag_0


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

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 macOS 14.0+ ARM64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 macOS 14.0+ ARM64

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

Uploaded CPython 3.10 Windows x86-64

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

File metadata

  • Download URL: pymiesim-3.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 13.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pymiesim-3.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 256f0adfe0bce737e2ba87aae2a41cc964cf1ec4115b5faef29999ca80ccf8f2
MD5 cb63b36ca32ed2c84b55d65a6d19f8eb
BLAKE2b-256 2d1270b88d745f75314790731ea5cb457288a780a4bdb99564a9199949b814d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9f186377eaef60906d6b9ecee7bc3ad0e0affcc35abdc89cc43053a638af99d4
MD5 d137904cb27f3a7d1a6ee9d9beb0a473
BLAKE2b-256 40e5bc883bb461a1498ddae6b7953ac25a61cbc286d9b96266478ff55f00fe45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 465b18e20b7b78bdd47bcae92ca2f9bc43ff368dbc2abb0a09bb9d9bc81e70a9
MD5 137c93650b82f6fafe54eb1ff795569c
BLAKE2b-256 ebc311c96072f356cb9895cd4518ded5fc16f5712315a34508e39f606b7c8680

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6072c5b1e982b4affd7c5e5a6f81c074f381e8dcc18e912f547faab48a6b7dbc
MD5 a43e4f8e4810b1944e502e9ca7db9117
BLAKE2b-256 b52961f8c197d06468e805f9d1ecd084723120c2ecf3cbcf05d245bc75a96d1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c2dcdabff341864e2c17dee9d5e8ec1e55408629dff62687ffceb37e481cfbd
MD5 5e4f59a8e707633d155938cee3d939cd
BLAKE2b-256 2669413213efa04bbd782f90ae0b108ba70cb5d6784eb2c96da01523ed9edef8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ffbf4a3bea48661d55279f31b53c7fa38ed41995c86234270398f6ccdfc5dd31
MD5 40dd14a66f57c99e8f68f7c94f5851a5
BLAKE2b-256 11146cbf04e6eaeb388884a1751a204b7b8aed15a73c70f095c92d13d43adb72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3815d8db3b2c8c8ae47865931ec333a6758d291f2e624d1d516dee32e27502bd
MD5 be2e6bf98da59a40da2fa31af5a174bc
BLAKE2b-256 cf1fb60e7ca3d82cfb1feabaf5820884cedf40e01addd16a8ccbf55bf46d1f32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32d38f3d9276ae567e7b5173799ac7e37a436710932815769533bf331dad1b6d
MD5 2b8e996084b96569750f85b428c62e89
BLAKE2b-256 7fc68ad8d4e98cfe039464039e358b272ffc250bdbb7d8bf0240a07d76d12fbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymiesim-3.0.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 d9b147d6c7a117134359cb9faba66b3616e64e935e4b31dbf7a9e3b1164d2ecb
MD5 613b6c35c939f95a32c49fa0ac6cbb99
BLAKE2b-256 b3eeceac8f66e92102c055e3002b70647af203e4af8c46d249222af9b2734dd3

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