Skip to main content

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

Project description

python Documentation Status Unittest coverage PyPi PyPi_download

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.


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

Coding examples

LightWave2D was developed with the aim of being an intuitive and easy to use tool. Below are two examples that illustrate this:

# Spherical scatterer

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

grid = Grid(
    resolution=0.1e-6,
    size_x=32e-6,
    size_y=20e-6,
    n_steps=300
)

experiment = Experiment(grid=grid)

scatterer = experiment.add_circle(
    position=('30%', '50%'),
    epsilon_r=2,
    radius=3e-6
)

source = experiment.add_line_source(
    wavelength=1550e-9,
    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

grid = Grid(
    resolution=0.1e-6,
    size_x=50e-6,
    size_y=30e-6,
    n_steps=800
)

experiment = Experiment(grid=grid)


scatterer = experiment.add_ring_resonator(
    position=('35%', '50%'),
    epsilon_r=1.5,
    inner_radius=4e-6,
    width=2e-6
)

source = experiment.add_point_source(
    wavelength=1550e-9,
    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

grid = Grid(
    resolution=0.1e-6,
    size_x=60e-6,
    size_y=30e-6,
    n_steps=1200
)

experiment = Experiment(grid=grid)

scatterer = experiment.add_lense(
    position=('35%', '50%'),
    epsilon_r=2,
    curvature=10e-6,
    width=5e-6
)

source = experiment.add_point_source(
    wavelength=1550e-9,
    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 localy (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

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

lightwave2d-0.3.0.post0-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

lightwave2d-0.3.0.post0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (711.6 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lightwave2d-0.3.0.post0-cp312-cp312-macosx_14_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

lightwave2d-0.3.0.post0-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

lightwave2d-0.3.0.post0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (503.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lightwave2d-0.3.0.post0-cp311-cp311-macosx_14_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

File details

Details for the file lightwave2d-0.3.0.post0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 53e0d99f6237072e8805d71d046ccbc06e2c2bf20eba85770b2a6bcdf31981f9
MD5 a40a9ace628a71ff3f8cc07caf5d1258
BLAKE2b-256 378b1d829984dcdfc5e8e3d06d060a772cbd2d6805688a2c4b1f81374e66e852

See more details on using hashes here.

File details

Details for the file lightwave2d-0.3.0.post0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27b5eb6377af4633a47d50ee16860246776bcb2abb7e68ca3ba85215a719b73d
MD5 44ba26c9019232bb9d394fcd29e072c0
BLAKE2b-256 7dcf8885730eef888d55e3a4ee97c3624eb9c65334c6b4f4d8a0c23f440fc513

See more details on using hashes here.

File details

Details for the file lightwave2d-0.3.0.post0-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a4429f575d30d3e9ddb6a501c1e5adf7d1bc1a28109503e1b001bb7f6a2e8dda
MD5 42e9e5d26d204f48ff878d790f909189
BLAKE2b-256 474f5452e0b2a378a55c24f4e8dd837842ba936e116084739cc25378c3f85615

See more details on using hashes here.

File details

Details for the file lightwave2d-0.3.0.post0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 28643f169d3387a70eff8c4ba30b1231b42f30685dc4f7c10cf4ffe1973ca911
MD5 316b2babf925a16d235a0e67d467d7ec
BLAKE2b-256 446a5b8110fa318aab6773679b42fa7ea23311274cbe29849aa3505217840399

See more details on using hashes here.

File details

Details for the file lightwave2d-0.3.0.post0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a87d3a42042fc0e89c4703ab395e87a8535d2ddc0b888d2866d5bc48ce7afa54
MD5 3737d7ac8fd0c12db87965e1069381b3
BLAKE2b-256 835ba545739ae4a4d0c5059181e0f4f233888de4be9c8a4971f20674b21ffbea

See more details on using hashes here.

File details

Details for the file lightwave2d-0.3.0.post0-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.3.0.post0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 b772ddd26bc02d865ab74c52c92275e7c31c2f80bfcbf4aa9683f73a0cbdc8d9
MD5 9b5b8db0777d0ad0cf462756a9363f10
BLAKE2b-256 54420c2bdfe1b3ff1e5f5d4f82285c9f7a3568422acb6de46143600fa9101eac

See more details on using hashes here.

Supported by

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