Skip to main content

A package for finite-difference time domain computation for light propagation

Project description

Meta

python

Documentation Status

Testing

Unittest Status

Unittest coverage

PyPi

PyPi

PyPi_download

Anaconda

Anaconda version

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

For common versions of Windows, Linux, and macOS, (on x86_64 architecture), the package can readily be installed using 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,
     point_0=('10%', '100%'),
     point_1=('10%', '0%'),
     amplitude=10,
 )

experiment.add_pml(order=1, width=70, sigma_max=5000)

experiment.run_fdtd()

animation = experiment.render_propagation(
    skip_frame=5,
    unit_size=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,
 )

pml = experiment.add_pml(order=1, width=70, sigma_max=5000)

experiment.run_fdtd()

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

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

some image

# Ring resonator

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_lense(
     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=50, sigma_max=5000)

experiment.run_fdtd()

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

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

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

some image

Plenty of other examples are available online, I invite you to check 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 .

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

If you're not sure about the file name format, learn more about wheel file names.

lightwave2d-0.6.0-cp313-cp313-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.13Windows x86-64

lightwave2d-0.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

lightwave2d-0.6.0-cp313-cp313-macosx_15_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

lightwave2d-0.6.0-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

lightwave2d-0.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

lightwave2d-0.6.0-cp312-cp312-macosx_15_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

lightwave2d-0.6.0-cp311-cp311-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.11Windows x86-64

lightwave2d-0.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (799.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

lightwave2d-0.6.0-cp311-cp311-macosx_15_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

Details for the file lightwave2d-0.6.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7688a4f31c6ad0df5aebee1bca320d1e420b4b0e22d1a36b93afe80e9106af29
MD5 98ed327a391d5fc63ad86209e23db977
BLAKE2b-256 15dbc4a82bc73cb81f86dc87fa35f15fd042bf523601c1086a404162786bf278

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 83925c01c76df11e6dcd5e7dd9614321b75f666fd1a32a5a516c75a875d46e40
MD5 977292662c020e26fee373309b1486aa
BLAKE2b-256 035b13db3bc55a090185b018a2beb33c62fedebee23c1aeb3a296f0d1589cf6a

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6d57bcb78c67232cd55155a91876f9584c27f2a50a4a881ab6e6ae8ffea7ea08
MD5 e2b2d009ac4f8d1d56f7a8999ed1754a
BLAKE2b-256 f15f0756ed945efe7a5bd845b89d20e6ddf8e93c35c27af5b10e0b51b3e859e3

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 25e7eca8e8692a1cd4bbdf18dc734a126febf30cbf996b6de823a6f61e89089b
MD5 aebe251525f06d450d2058bcd004e5ca
BLAKE2b-256 e2d54f4ffa555e2cf93a3f046958ecd11705c0ba250f4858d6e08e517f33abd7

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 6c4e7b58e28c141bd6609b2bcba5f8c9066550e547439db1a970b04c8a54e919
MD5 7669ec14d386b35e71caf26d175715fb
BLAKE2b-256 33aefad74b54ae323b0c093852f158aa82a4087ae14abf26a352c400a4895910

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9d8d84e8bce6e48b1b0bfad7c08f1e88e035242be1442c3d62548651eda4f861
MD5 1b69ad7178adb3cab292e6218bf88f64
BLAKE2b-256 174b4581afcebb7158345441b585d7cc23fa8faafe90ad60e0341b0cff014a44

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3af86c6875ffe3c64e2932926b458d224c58cb74f36bab0f42b37cfc5d08024d
MD5 57baa37f79703023960194e9c3cba778
BLAKE2b-256 aaf3896b9c3afa40353a6a2d99b145b3e5dce75ce3df4240a3927772e1cc6160

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 4ec815d5ff32f23a28080f0ed77f535a2f5176faf590f7b57a2d565b012277fc
MD5 0689f17872293623c9d62e020a30839e
BLAKE2b-256 161323f1e3d1830ee51b9234266d32dd7649d74b10686e6b6982eb27ac37a40d

See more details on using hashes here.

File details

Details for the file lightwave2d-0.6.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.6.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5c2c8a8d2eaca9163b58321b9d914546d807fa3e8beb9c1977ae71f9c4d8c3d0
MD5 32445b56e57e899370dd87cab2f64fc8
BLAKE2b-256 a892c6294f65b87d2668aa47fac5648d3feaf7f224a9165d3c5b4b9dccfd9dd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page