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

Total release size: 34.7 MB

Release files / lightwave2d-0.10.1-cp314-cp314-win_amd64.whl

Download URL lightwave2d-0.10.1-cp314-cp314-win_amd64.whl
Size 7.5 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
6f9e5ab3aba858448f1706098798d56451ef35eacc7a918043c4dc6df75a5102
BLAKE2b-256 checksum
How to use checksums
e4b36a9aac1ebb23a26e4ff3d4cd8a29c57fe1d307dcbba6ac5cfc19c9accd6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / lightwave2d-0.10.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.10.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.1 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
63e250651751a806c47aa8611750210dfa5a4d08d4148aa0fc4efd8e28978ed6
BLAKE2b-256 checksum
How to use checksums
dbee49d746f0a7a4579988c64c4050ce267eaea1609988ac6ee394c0d95edfec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / lightwave2d-0.10.1-cp314-cp314-macosx_26_0_arm64.whl

Download URL lightwave2d-0.10.1-cp314-cp314-macosx_26_0_arm64.whl
Size 1.5 MB
Tags CPython 3.14 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
b18fdb5f39a9e59e94944d0a5016c3d0b5dfd09e29bd674e0faafd91e974399f
BLAKE2b-256 checksum
How to use checksums
e328c6b79caa83a5cc26ef52266cd2abbd70286cc6e163d492e401f0d6b230a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-cp313-cp313-win_amd64.whl
Size 6.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
f63a5940f81ad06b427d138ccee5fa5c0cf90475e75767957ee9a98f578b3d0c
BLAKE2b-256 checksum
How to use checksums
bced6426a60171dcc4356c1564ba1cfccfa6d4b3c1eb5488cd0ec1250b924e22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7b25d632f7249695caf52eb110eff214366ae83073e7f068a80da9017311dab2
BLAKE2b-256 checksum
How to use checksums
1222cf6da24a244f7b6430cc3a2c1afeb70c3b0ac09c8df58c91030dd063097a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-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
51b142092e86cc9528fb77dc4f8fa37d1c5bbe352d729346c18eaaf248ea3934
BLAKE2b-256 checksum
How to use checksums
3072b733dee677c69d593eb9b3b23197f73520f0944687c2b23229a52be7f7a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-cp312-cp312-win_amd64.whl
Size 4.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
edd9a2077e53df123cb42a92eaffd383755f958e2bc313e193bdd9f3a382dc22
BLAKE2b-256 checksum
How to use checksums
2c9545ae8c2d855e67bfc29e9f90c0a20a034adda91e3ce7bae217faf29b538c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-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
0642a4cf5452c38aa1122fc49a531293cf198f227924e800beb51c240d3e8d43
BLAKE2b-256 checksum
How to use checksums
5fa69fd40201134727b88d2d11a3eba174b6a8f48bbe953d93697037867e7045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-cp312-cp312-macosx_26_0_arm64.whl
Size 1.3 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
fad9cbcc06c7f21ba1d200dba3d06ac7bb95dd5e316ffd438c24b93cdb26589b
BLAKE2b-256 checksum
How to use checksums
bc91cc0bdb540e98959aaddd99dd0fa178a58c00f8a7fe58eddf5d55eccfd472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-cp311-cp311-win_amd64.whl
Size 3.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
1899c43c528e9bbd222ae2e4caa1c5532c2cb8757cd3a0d540e57caabff24277
BLAKE2b-256 checksum
How to use checksums
a7e281729408ea56ab63740dd268c6ca4350ce23590db496ec6ba1311c49ef4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-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
8b59d19116038352cbe9319a5f1a526e777f9f8e86112f0f2bfb663455e381c1
BLAKE2b-256 checksum
How to use checksums
b7d6525fd1e95289e86e2ed06757d65053552c6c1b27703f7c542f4f20cabbd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL lightwave2d-0.10.1-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
53c4da39758e0cd6120be5463ac2cf32a263ea37679703efcb9e420e6a47e43b
BLAKE2b-256 checksum
How to use checksums
8831efcb416daccf9feb7bee86187fdea8ef5ae23ed75bf6d30e612bb49d5ec2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
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