Skip to main content

PyMieSim logo

Badge

Status

Python versions

Python

Documentation

Documentation Status

Scientific article

Scientific article

Continuous integration

Unittest Status

Test coverage

Unittest coverage

Google Colab

Google Colab

PyPI package

PyPI version

PyPI downloads

PyPI downloads

Anaconda package

Anaconda version

Anaconda downloads

Anaconda downloads

Latest Anaconda release

Latest release date

PyMieSim

PyMieSim is an open-source Python package for fast and flexible Mie scattering simulations. It supports spherical, cylindrical and core–shell particles and provides helper classes for custom sources and detectors. The project targets both quick single-scatterer studies and large parametric experiments.

Try the live webapp

Run Mie scattering simulations in your browser—no installation required.

Launch the PyMieSimX webapp in your browser

Launch the PyMieSimX webapp to configure optical setups, run parameter sweeps, explore individual particles, and download your results as CSV files. The hosted service brings PyMieSim to a graphical interface, making it easy to try simulations before installing the Python package. The interface is developed in PyMieSimX.

Features

  • Solvers for spheres, cylinders and core–shell geometries.

  • Built-in models for plane wave and Gaussian sources.

  • Multiple detector types including photodiodes and coherent modes.

  • Simple data analysis with pandas DataFrame outputs.

Installation

PyMieSim is available on PyPI and Anaconda. Install it with:

pip install PyMieSim
conda install PyMieSim  --channels MartinPdeS

This installs a pre-built wheel when one is available for your operating system, architecture, and Python version. Wheels are the recommended option for using PyMieSim because they include the compiled C++ and Fortran extensions.

Verify the installation with the same Python interpreter that you will use for your simulations:

python -c "import PyMieSim; print(PyMieSim.__version__)"

Named optical materials use PyOptik’s provenance-preserving RefractiveIndex.INFO catalog. Initialize its local snapshot once before using constructors such as SellmeierMaterial("BK7") or TabulatedMaterial("silver"):

python -m PyOptik setup

Building from source is intended for development or platforms without a matching wheel. It requires a C++20 compiler, Fortran, CMake, pybind11, and OpenMP; see troubleshooting if the compiled extension cannot be imported.

First simulation

Create a source, a scatterer, and a Simulation. Physical quantities use the built-in ureg unit registry, while refractive indices are dimensionless real or complex values.

from PyMieSim import (
    Gaussian,
    PolarizationState,
    Simulation,
    Sphere,
    ureg,
)

source = Gaussian(
    wavelength=633 * ureg.nanometer,
    polarization=PolarizationState(angle=0 * ureg.degree),
    optical_power=1e-3 * ureg.watt,
    numerical_aperture=0.2,
)

scatterer = Sphere(
    diameter=200 * ureg.nanometer,
    material=1.5 + 0.01j,
    medium=1.0,
)

simulation = Simulation(scatterer=scatterer, source=source)
qsca = simulation.run("Qsca")
print(qsca)

This prints a dimensionless scattering efficiency, approximately:

0.2080989068292113 dimensionless

Inspect the measures supported by the configured simulation with:

print(simulation.available_measures)

For explicit measure and unit metadata, request a typed result:

result = simulation.run("Qsca", as_result=True)
print(result.measure, result.quantity, result.units)

Units and material conventions

Always attach units to wavelengths, lengths, powers, and angles:

633 * ureg.nanometer
200 * ureg.nanometer
1e-3 * ureg.watt
0 * ureg.degree

Refractive indices are dimensionless. A complex index such as 1.5 + 0.01j represents an absorbing material under PyMieSim’s optical convention. Built-in and tabulated materials have supported wavelength ranges; use load_material and validate_wavelength when working with real material data.

Parameter sweeps

Use Experiment when you want to evaluate several wavelengths, particle sizes, or material parameters. Results retain named dimensions and coordinates, and can be converted to NumPy or pandas explicitly.

import numpy as np
from PyMieSim import (
    Experiment,
    GaussianSet,
    PolarizationSet,
    SphereSet,
    ureg,
)

source = GaussianSet(
    wavelength=np.linspace(500, 700, 5) * ureg.nanometer,
    polarization=PolarizationSet(angles=0 * ureg.degree),
    optical_power=1e-3 * ureg.watt,
    numerical_aperture=0.2,
)
scatterer = SphereSet(
    diameter=np.linspace(100, 500, 9) * ureg.nanometer,
    material=1.5,
    medium=1.0,
)

experiment = Experiment(scatterer_set=scatterer, source_set=source)
result = experiment.get("Qsca")
values = result.as_numpy()
dataframe = result.as_dataframe()

The experiment grid has five wavelength values and nine diameter values, so values.shape is (5, 9). See the parameter sweep guide for multiple measures and plotting.

Detector coupling

Add a detector when you need collected or coupled power rather than only a scatterer property:

from PyMieSim import (
    Gaussian,
    Photodiode,
    PolarizationState,
    Simulation,
    Sphere,
    ureg,
)

single_source = Gaussian(
    wavelength=633 * ureg.nanometer,
    polarization=PolarizationState(angle=0 * ureg.degree),
    optical_power=1e-3 * ureg.watt,
    numerical_aperture=0.2,
)
single_scatterer = Sphere(
    diameter=200 * ureg.nanometer,
    material=1.5 + 0.01j,
    medium=1.0,
)

detector = Photodiode(
    sampling=500,
    numerical_aperture=0.2,
    phi_offset=0 * ureg.degree,
    gamma_offset=0 * ureg.degree,
    medium=1.0,
)
simulation = Simulation(
    scatterer=single_scatterer,
    source=single_source,
    detector=detector,
)
coupling = simulation.run("coupling")
print(coupling)

coupling requires a detector. Other available detector types include CoherentMode and IntegratingSphere; see the detector coupling guide.

Common issues

  • If import PyMieSim fails, run python -m pip show PyMieSim and check that it uses the same Python executable as your script.

  • If a constructor reports a unit error, check that every dimensional input has units and convert it with .to(...) when necessary.

  • If coupling is unavailable, add a detector and inspect simulation.available_measures.

  • For slow or memory-heavy sweeps, print experiment.array_shape and experiment.total_iterations before requesting a result.

  • On servers or in CI, select a non-interactive Matplotlib backend such as Agg before importing plotting code.

See the online documentation for theory, performance guidance, runnable examples, and advanced near-field and far-field workflows.

Scattering efficiency of a 200 nm sphere with refractive index 4.0.

Code structure

Here is the architecture for a standard workflow using PyMieSim:

Code structure of a standard workflow using PyMieSim.

Developer setup

Clone the repository, select the Python interpreter you want to use, install the development and testing dependencies, and build an editable installation:

git clone https://github.com/MartinPdeS/PyMieSim.git
cd PyMieSim
python -m pip install ".[testing,documentation,dev]"
python -m PyOptik setup --no-progress
make PYTHON=python editable

make editable builds the native extensions in the local build directory and installs them into the same environment. Always run tests with that same interpreter:

python -c "import PyMieSim; print(PyMieSim.__version__)"
python -m pytest --config-file=pytest.ini

If the import reports missing native extensions, the build was not completed for this interpreter. Re-run make editable after checking that CMake, Fortran, pybind11, and OpenMP are installed. Do not mix build artifacts from different Python versions or architectures.

Building from source manually

The equivalent lower-level workflow is:

python -m pip install --no-build-isolation -Cbuild-dir=build -e .

The editable workflow is preferred because it keeps the Python sources and compiled extensions aligned. A released wheel does not require a compiler or the native build toolchain.

Testing

After the developer setup, run the unit tests with:

python -m pytest --config-file=pytest.ini

Citing PyMieSim

If you use PyMieSim in academic work, please cite:

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

Contact

For questions or contributions, contact martin.poinsinet.de.sivry@gmail.com.

Metadata

Release files for PyMieSim 6.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for PyMieSim 6.1.1
File Actions
pymiesim-6.1.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for pymiesim-6.1.1-cp314-cp314-win_amd64.whl
pymiesim-6.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for pymiesim-6.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pymiesim-6.1.1-cp314-cp314-macosx_26_0_arm64.whl CPython 3.14 CPython 3.14 macOS 26.0+ ARM64 Details for pymiesim-6.1.1-cp314-cp314-macosx_26_0_arm64.whl
pymiesim-6.1.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for pymiesim-6.1.1-cp313-cp313-win_amd64.whl
pymiesim-6.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for pymiesim-6.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pymiesim-6.1.1-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details for pymiesim-6.1.1-cp313-cp313-macosx_26_0_arm64.whl
pymiesim-6.1.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for pymiesim-6.1.1-cp312-cp312-win_amd64.whl
pymiesim-6.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for pymiesim-6.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pymiesim-6.1.1-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for pymiesim-6.1.1-cp312-cp312-macosx_26_0_arm64.whl
pymiesim-6.1.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for pymiesim-6.1.1-cp311-cp311-win_amd64.whl
pymiesim-6.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for pymiesim-6.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
pymiesim-6.1.1-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details for pymiesim-6.1.1-cp311-cp311-macosx_26_0_arm64.whl

Total release size: 98.3 MB

Release files / pymiesim-6.1.1-cp314-cp314-win_amd64.whl

Download URL pymiesim-6.1.1-cp314-cp314-win_amd64.whl
Size 14.2 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1de33da41e5be2bf8c56fc6d8663d3393c593cd26256e38caef3f1823a3f3e7a
BLAKE2b-256 checksum
How to use checksums
58aec6c9c957168cfb9e73bcb6e19b76e8c1782ea14f401a1e640bf4011e0380
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pymiesim-6.1.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a8cdd9f2c105cd4e950d1f3f55f3a3f44f8ca902e850a9eff27299e23ebc7965
BLAKE2b-256 checksum
How to use checksums
b0b29501d299cbebc37aa4276b67ad365d9568eee164830084f15c79ff08b263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp314-cp314-macosx_26_0_arm64.whl

Download URL pymiesim-6.1.1-cp314-cp314-macosx_26_0_arm64.whl
Size 4.8 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
1530a60ff5b468ccf10ecffae62bfbae8ab5a8e9aa4bf74beb5b4b0fba317785
BLAKE2b-256 checksum
How to use checksums
d38559a21dd93b63fd79ba6f0aad48b33ef4bd6f8c7bcb57cb5ff3082ad8828c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp313-cp313-win_amd64.whl

Download URL pymiesim-6.1.1-cp313-cp313-win_amd64.whl
Size 13.7 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
aa4938fba6e0211f153efc012740886023b628f1765e28b92354b59d6d3dfaa9
BLAKE2b-256 checksum
How to use checksums
bb7891930544c33f2b24dc53569b780bb29402ad51886cc53a7356a9eda4c066
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pymiesim-6.1.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
8323700cd1466616db5507771bea56b727edf7baf3cd20a15037fedbb3c0847c
BLAKE2b-256 checksum
How to use checksums
fce7046337a1b6bec16060f59ff348e5d29d4ba1b2d584a4e66bbd604024781a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp313-cp313-macosx_26_0_arm64.whl

Download URL pymiesim-6.1.1-cp313-cp313-macosx_26_0_arm64.whl
Size 4.8 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
8274138a719ad7607f585b4b891191305adec9e145d0beef7cd5aac48e6fea3b
BLAKE2b-256 checksum
How to use checksums
f422775dc559fff52e9fcbe075eca45d5ce3e37bf6d99bc70f80675e663bde8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp312-cp312-win_amd64.whl

Download URL pymiesim-6.1.1-cp312-cp312-win_amd64.whl
Size 13.7 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
2d4199d6604b184f00c663eaf2022591c3e153b786bd6bb305f3c4f2c003b101
BLAKE2b-256 checksum
How to use checksums
25d0ff5e848edbace2c24ff22d7bd4b1067ad234122a620697e27fd5ca04b268
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pymiesim-6.1.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0d72e72047026569ecac0a1b0d60282b42e224679ef93a4eef026cc95599f2aa
BLAKE2b-256 checksum
How to use checksums
a1418d5973bcf01df2ead01da2f5da551b3434c420ac3d622b7ef8bd1d54be88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp312-cp312-macosx_26_0_arm64.whl

Download URL pymiesim-6.1.1-cp312-cp312-macosx_26_0_arm64.whl
Size 4.8 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
9cfc11bebde03a81220bae994858efb07755f291446093691d3dab4419ac399f
BLAKE2b-256 checksum
How to use checksums
2bcb07e74463225a62c997b00f59f05f95803017446e572bc3c5e4d1f80beb11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp311-cp311-win_amd64.whl

Download URL pymiesim-6.1.1-cp311-cp311-win_amd64.whl
Size 13.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
354aa296af8061cb25d75c285f2b7f619e03f9d205c3abd0d0f0dbfe0270229b
BLAKE2b-256 checksum
How to use checksums
767e1fa5c0f4ef4e389003c50d35311da4a268100881f294b7f9fc7a65f22c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pymiesim-6.1.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 6.0 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
95c99432b3c951aca0b5699f8d3a68f59a85b0668ecd501f7d9a9b0bd6092066
BLAKE2b-256 checksum
How to use checksums
cdc1f9402c135c9e3dad33eb9e296e7ba2b2672db166746caf373f2d8dbffcab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Release files / pymiesim-6.1.1-cp311-cp311-macosx_26_0_arm64.whl

Download URL pymiesim-6.1.1-cp311-cp311-macosx_26_0_arm64.whl
Size 4.8 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
285b0899f7bfa77e99d053f4c5fe1511edb00b5f33c0136b3a4037fa706d22c7
BLAKE2b-256 checksum
How to use checksums
6896fdb2c998d5548d4f6287bad2f558dd81f2398c85681e9dc99fa1fbdc3a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

Security for PyMieSim 6.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.1.1 This release

12 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page