Skip to main content
LightWave2D — Simulating light, clearly.

LightWave2D

Badge

Status

Python versions

Python

Documentation

Documentation Status

Continuous integration

Unittest Status

Test coverage

Unittest coverage

PyPI package

PyPI version

PyPI downloads

PyPI downloads

Anaconda package

Anaconda version

Anaconda downloads

Anaconda downloads

LightWave2D is a software designed for comprehensive 2D Finite-Difference Time-Domain (FDTD) simulations, featuring a user-friendly installation and operation process. The characterization of wave propagation, scattering, and diffraction within LightWave2D is determined by a set of specific components, as illustrated in the subsequent figure.

LightWave2D integrates various components, including waveguides, scatterers (squares, circles, ellipses, triangles, lenses), gratings, and resonators. Additional parameters governing the simulation are contingent upon the attributes of the components and the simulation setup.

Key Features

  • Intuitive API for configuring simulations.

  • Support for waveguides, scatterers, gratings, and resonators.

  • Built-in tools for rendering field animations.

  • Extensive gallery of examples in the documentation.


Documentation

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

Documentation Status


Installation

Install the published package with pip:

>>> pip install LightWave2D

Building Documentation Locally

To generate the HTML documentation on your machine, install the optional dependencies and run:

pip install .[documentation]
cd docs && make html
firefox build/html/index.html

Coding examples

LightWave2D was developed with the aim of being an intuitive and easy to use tool. All dimensional arguments can now be provided using pint quantities or strings with units. Below are two examples that illustrate this:

Spherical scatterer

 from LightWave2D.grid import Grid
 from LightWave2D.experiment import Experiment
 from MPSPlots import colormaps
 from TypedUnit import ureg

 grid = Grid(
     resolution=0.1 * ureg.micrometer,
     size_x=32 * ureg.micrometer,
     size_y=20 * ureg.micrometer,
     n_steps=300
 )

experiment = Experiment(grid=grid)

 scatterer = experiment.add_circle(
     position=('30%', '50%'),
     epsilon_r=2,
     radius=3 * ureg.micrometer
 )

 source = experiment.add_line_source(
     wavelength=1550 * ureg.nanometer,
     position_0=('10%', '100%'),
     position_1=('10%', '0%'),
     amplitude=10,
 )

experiment.add_pml(order=1, width="10%", sigma_max=5000 * ureg.siemens / ureg.meter)

experiment.run()

animation = experiment.render_propagation(
    skip_frame=5,
    colormap=colormaps.polytechnique.red_black_blue
)

animation.save('./spherical_scatterer.gif', writer='Pillow', fps=10)

some image

Ring resonator

from LightWave2D.grid import Grid
from LightWave2D.experiment import Experiment
from MPSPlots.colormaps import polytechnique
from TypedUnit import ureg

 grid = Grid(
     resolution=0.1 * ureg.micrometer,
     size_x=50 * ureg.micrometer,
     size_y=30 * ureg.micrometer,
     n_steps=800
 )

experiment = Experiment(grid=grid)


 scatterer = experiment.add_ring_resonator(
     position=('35%', '50%'),
     epsilon_r=1.5,
     inner_radius=4 * ureg.micrometer,
     width=2 * ureg.micrometer
 )

 source = experiment.add_point_source(
     wavelength=1550 * ureg.nanometer,
     position=('25%', '50%'),
     amplitude=100,
 )

experiment.add_pml(order=1, width="10%", sigma_max=5000 * ureg.siemens / ureg.meter)

experiment.run()

animation = experiment.render_propagation(skip_frame=5, colormap=polytechnique.red_black_blue)

animation.save('./resonator.gif', writer='Pillow', fps=10)

some image

Lens

from LightWave2D.grid import Grid
from LightWave2D.experiment import Experiment
from MPSPlots import colormaps
from TypedUnit import ureg

 grid = Grid(
     resolution=0.1 * ureg.micrometer,
     size_x=60 * ureg.micrometer,
     size_y=30 * ureg.micrometer,
     n_steps=1200
 )

experiment = Experiment(grid=grid)

 scatterer = experiment.add_lens(
     position=('35%', '50%'),
     epsilon_r=2,
     curvature=10 * ureg.micrometer,
     width=5 * ureg.micrometer
 )

 source = experiment.add_point_source(
     wavelength=1550 * ureg.nanometer,
     position=('10%', '50%'),
     amplitude=10,
 )


experiment.add_pml(order=1, width="10%", sigma_max=5000 * ureg.siemens / ureg.meter)

experiment.run()

experiment.plot_frame(
    frame_number=-1,
    enhance_contrast=5,
    colormap=colormaps.polytechnique.red_black_blue
)

animation = experiment.render_propagation(
    skip_frame=5,
    colormap=colormaps.polytechnique.red_black_blue
)

animation.save('./lens.gif', writer='Pillow', fps=10)

some image

Plenty of other examples are available online; see the examples section of the documentation.

Testing

To test locally (with cloning the GitHub repository) you’ll need to install the dependencies and run the coverage command as

>>> git clone https://github.com/MartinPdeS/LightWave2D.git
>>> cd LightWave2D
>>> pip install -r requirements/requirements.txt
>>> coverage run --source=LightWave2D --module pytest --verbose tests
>>> coverage report --show-missing

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


Contact Information

As of 2024 the project is still under development if you want to collaborate it would be a pleasure. I encourage you to contact me.

LightWave2D was written by Martin Poinsinet de Sivry-Houle .

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

Metadata

Release files for LightWave2D 0.8.0

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 LightWave2D 0.8.0
File
lightwave2d-0.8.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
lightwave2d-0.8.0-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
lightwave2d-0.8.0-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details
lightwave2d-0.8.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
lightwave2d-0.8.0-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
lightwave2d-0.8.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details
lightwave2d-0.8.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
lightwave2d-0.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
lightwave2d-0.8.0-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details

Total release size: 23.8 MB

Release files / lightwave2d-0.8.0-cp313-cp313-win_amd64.whl

Download URL lightwave2d-0.8.0-cp313-cp313-win_amd64.whl
Size 6.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f6c85ab5c1ab2bc59c66f23c4999f730fa4060fe7cbf8274796755af59595e45
BLAKE2b-256 checksum
How to use checksums
0bc0867473011a9b894633dfdd6e464680d28dc4b258df128800b6a44f212bb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.8.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.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
fb968b02e6df361a94dc0de3d3f461f5fcf8849c579c3deec2d56ade9848a10f
BLAKE2b-256 checksum
How to use checksums
e874236f7f52636b89f674bc86ffab2eef108c0a8ffdf034881626e1a1724abb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL lightwave2d-0.8.0-cp313-cp313-macosx_26_0_arm64.whl
Size 1.4 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
87fe49d7b44fbc727c8a50921fa77b296873f811b3dcc35271364537afd0b0af
BLAKE2b-256 checksum
How to use checksums
b3bf4542d7b424f8c1c93f3b931d2c72c6f0978297095f754344b22c5d4a28a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp312-cp312-win_amd64.whl

Download URL lightwave2d-0.8.0-cp312-cp312-win_amd64.whl
Size 4.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f1d7d76e61b9a4be58da2657f662ed3663a3f2a22b8216694fa505130500033f
BLAKE2b-256 checksum
How to use checksums
ec52c89c432871dfe69c4941b368bd4c88765331a7fc3b22307e936446c5803a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.8.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
0008c83334191ed71de92b5f510d06c7e3c76c6bc66e02c68419977fce614baf
BLAKE2b-256 checksum
How to use checksums
8cb2a23da6a0dbc291e4327bf1049627d7d439dc2a531b29d843d67fcc62cd9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL lightwave2d-0.8.0-cp312-cp312-macosx_26_0_arm64.whl
Size 1.4 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
c5dc4d5cd76aa5952e93176fcd9d52754a11a7c1b6751f8fcd193f35d939c0e3
BLAKE2b-256 checksum
How to use checksums
65898361c5f9d296e85100a37de38f933e197ad0599ca77a21af3a0c96728ea2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp311-cp311-win_amd64.whl

Download URL lightwave2d-0.8.0-cp311-cp311-win_amd64.whl
Size 3.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
a92eb526fbbeec26ea1435c3043e8f4916fbe58b02758efe2cfa4d33b69ea249
BLAKE2b-256 checksum
How to use checksums
b8eebc8d5e5c04844ca669019a1c706e9193a02a1ca2a161544073235ee2ce4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.8.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
aea8853df8492fbfeeac1a71df5f2ba4bc50a874cd4b7d8ca609b9e1715aaaa6
BLAKE2b-256 checksum
How to use checksums
b9a40cc2ebecc524d863656fce3c926f3597f22d7671830519df89bc5498c4e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / lightwave2d-0.8.0-cp311-cp311-macosx_26_0_arm64.whl

Download URL lightwave2d-0.8.0-cp311-cp311-macosx_26_0_arm64.whl
Size 1.2 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
53f14bf735a65fad3265869ad7fca9c782c65fbf6866bb1e7d4fce82bef16e8c
BLAKE2b-256 checksum
How to use checksums
98facb4813c13d3204b42f89fac9cef16493a6f88339dc6e3cbd80ea44ff3949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25
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