Skip to main content

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

Project description

python Documentation Status 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.2.0.post0-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

lightwave2d-0.2.0.post0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (690.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lightwave2d-0.2.0.post0-cp312-cp312-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 Windows x86-64

lightwave2d-0.2.0.post0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lightwave2d-0.2.0.post0-cp311-cp311-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07230cfc85dbccec1d78cb170b0f0587d67230e6a3b5211ced8ab65a4a7afb52
MD5 b00ac714d91cc4b85ddf600cc484e572
BLAKE2b-256 0122b088a716d1b48e28085615e66eb65a652bb55c0d0223f5ee185b6008d0bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5917f868768232aed628137391a6d8c1ae4c3164f3d6a7dc716073466f95731
MD5 e16297dc53e67c01d03eae7dfc8212f2
BLAKE2b-256 6eab89b0448326959bb29e381db31296cbfb566e39996f373a214926b5023db0

See more details on using hashes here.

File details

Details for the file lightwave2d-0.2.0.post0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d0006896500825334f4bb0d847961aa82822ed2fe41911e373d50b5a42d92d1
MD5 2cf0090649c1ca69e079999f2af5642d
BLAKE2b-256 8137b789d45b99c6f3eea7b8c5288811f48a00d5142f3aac071a20acc733f68d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f9d47bb8f299932e7e4970713c1dbd51d72dd4502f9bf09d020cbca618c525a9
MD5 2dd962199ee3b60537dfef0323bbd331
BLAKE2b-256 03198e21074ed37cca5cf771092d192e2aa1a6f793fdf144450ca9a33b97bbed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4633a4c152e2accdf1174dba332e0d6de23927c33b0396120767b45457bfb05f
MD5 24a9b3a496df70d6bb1b00e65fd8f4e1
BLAKE2b-256 d3e2db926f547398a8e895de6afae008f9cf1eb1037a4d09833a491f0786609b

See more details on using hashes here.

File details

Details for the file lightwave2d-0.2.0.post0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lightwave2d-0.2.0.post0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89d677802b889c12d08e9f1dc86570fd59a19ed888df30e2eeb56150a2492831
MD5 95301e29a98420210f0dec855e24e946
BLAKE2b-256 e42172e88ec0d41975304aaed0dcd0802fbb18ddb6278d2fd67863f9597c26c5

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