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

Download URL lightwave2d-0.10.0-cp314-cp314-win_amd64.whl
Size 7.5 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
56713f895b14421b86202b146b233e7862935067bbce35857d58b8861fc43ad9
BLAKE2b-256 checksum
How to use checksums
d7f8b06832eb24fd64e7d40c835fa56037dfeea9e43352df383d7376f9697a5b
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.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.10.0-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
a42383445b5ab2bb19e8a3899cdec0cdebfaff22f96067c9a59da66814be418a
BLAKE2b-256 checksum
How to use checksums
917d4df2d7c52e426d1b6c8427bca3c71ee85845251a828f1d092a2df5592ec6
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.0-cp314-cp314-macosx_26_0_arm64.whl

Download URL lightwave2d-0.10.0-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
d246218b61eace146c643e80953eda248ddf7e6495b46b327f5b1dbbaad610fa
BLAKE2b-256 checksum
How to use checksums
4840fd349b4d55cf25881075dd02a2e76cbc85f5c633c4afb603a88e909d0c41
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.0-cp313-cp313-win_amd64.whl

Download URL lightwave2d-0.10.0-cp313-cp313-win_amd64.whl
Size 6.0 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3864fa0915a65127d827c69b54a047a73843174b8f74ff6f19f123990160ed11
BLAKE2b-256 checksum
How to use checksums
466101b721642efe626c379654d66b022128ced19858a5b58b0f2aa7cf9061da
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.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.10.0-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
a4aed6412abf64d19506415b66eb957e0d229c0332928b4b22374668a4d23156
BLAKE2b-256 checksum
How to use checksums
b9d05bf930d44ee0676945b9df9d042443bd618d14eb9d25a274869e273cfc28
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.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL lightwave2d-0.10.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
e8ca5d15273f47cb49197f889ab90713a006517b66facc60e4d5551a50d7b2e3
BLAKE2b-256 checksum
How to use checksums
ac2cca6c8f49321585307b9a7cf5099fb449e3b9ad2a704d46db3c974d6f45b6
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.0-cp312-cp312-win_amd64.whl

Download URL lightwave2d-0.10.0-cp312-cp312-win_amd64.whl
Size 4.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
bb5dfa0c6080992b7732a8a165c4744800f20a75cb3cf2aa98a729e4bf56fd32
BLAKE2b-256 checksum
How to use checksums
c229259f19bf3971e1897f00ebed4419026ac23d048e8adac1a8fe5845c7a5d5
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.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.10.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
1125ea7582e1d0690a13590f9125fd48502ba933b50d68088f853977eef10e28
BLAKE2b-256 checksum
How to use checksums
72509985dca82e26de8a156981276ec4f6b381428c7a5e2a9c84f89169acddad
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.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL lightwave2d-0.10.0-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
71c3c092a5858d515164559a5f77e9c387c0810d59e29d827886add7b7c77957
BLAKE2b-256 checksum
How to use checksums
2cb1d7f1a35d287b3f50ee375f215416bbe0b1fd5dc4fef0c7c6c4d0adcfcb90
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.0-cp311-cp311-win_amd64.whl

Download URL lightwave2d-0.10.0-cp311-cp311-win_amd64.whl
Size 3.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
d4083851eebf69481375f7602ef65aa312837a23ec4dce9b1f5631fc51303f5f
BLAKE2b-256 checksum
How to use checksums
9544d968c44282a68560d06b19c0f4ca01de0ed8d7667cb2140874aed500a36b
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.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL lightwave2d-0.10.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
bf1765c118b51e01660a5126357904525120b1084b976abceab309a8af71e5e7
BLAKE2b-256 checksum
How to use checksums
05bc8db4b0aa5c863cbca80cf8c2c31fbc70419d9c4cf6cb082cd3b87b4b2228
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.0-cp311-cp311-macosx_26_0_arm64.whl

Download URL lightwave2d-0.10.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
634b3ec4c330a6bc503f0734931d119d0e0dda5dc5a64b7d5f0c973acfc7a8bb
BLAKE2b-256 checksum
How to use checksums
e0b9364cd7407f35e2800d030ff8c85c1fead8ea177b0f7d915fa51fa316cb45
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