Skip to main content

Differentiable plane-wave and guided-mode expansion for photonic crystals

Project description

legume

legume (le GUided Mode Expansion) is a python implementation of the GME method for photonic crystal slabs, including support for multi-layer structures. Plane-wave expansion for purely 2D structures is also included.

Install

Eventually this should be pip installable from PyPi, but for now hopefully this will work for you:

git clone https://github.com/fancompute/legume.git
pip install -e legume
pip install -r legume/requirements.txt

Alternatively just git clone it, make sure you have all the requirements installed, and add the path to the folder in your python path: export PYTHONPATH=$PYTHONPATH:/path/to/the/location/of/legume.

Autograd

One exciting feature is the autograd backend that can be used to automatically compute the gradient of the eigenmodes and eigenfrequencies with respect to any input parameters! When running GME, you can specify 'gradients' = 'exact' (default), or 'gradients' = 'approx' (faster). The latter discards the gradient due to the guided mode basis itself and only keeps the gradients from the diagonalization. Here are some rules of thumb on what to use:

  • If you're optimizing hole positions (i.e. parameters that don't change the average permittivity), you're in luck! In this case, the approx gradients should actually be exact!
  • If you're optimizing dispersion (real part of eigenfrequencies) w.r.t. parameters that do not include the layer thicknesses, you could still try using approx gradients, as they might be within just a few percent of the exact ones.
  • If you're optimizing loss rates (imaginary part of eigenfrequencies) and/or if your parameters include the layer thicknesses, then the approx gradients could be significantly off, exact is recommended.

Guided-mode computation options

GuidedModeExp.run() takes a number of optional arguments. Below is a list of the most important ones, with a short explanation.

  • gmode_compute: {'exact'}, 'interp' Define whether the guided modes are computed in the beginning and then interpolated, or whether they are computed exactly at every k-step.
  • gmode_inds: {[0]}, list/numpy array List of indexes of the guided bands to be included in the expansion. These alternate between TE and TM defined with respect to the propagation direction.
  • numeig: {10}, int Number of eigen-frequencies to be stored.
  • eig_sigma: {0.}, float Target frequency, the closest numeig eigen-frequencies are stored.
  • compute_im: {True}, bool Specifies if the imaginary parts of the frequencies should also be computed.
  • gradients: {'exact'}, 'approx' Specifies whether to compute exact gradients, or approximate (faster)
  • eps_eff: {'average'}, 'background' Using the 'average' or the 'background' permittivity of the layers in the guided mode computation.
  • verbose: {True}, bool Print information at intermmediate steps.

Convergence

If you think the GME run might not be fully converged, I suggest changing the parameters in the following order:

  • First, make sure you have a high enough gmax, which is defined upon initialization of GuidedModeExp.
  • Then, include higher-order modes by increasing the number of indexes included in options['gmode_inds'].
    • Note that after including more modes in gmode_inds, you should test again the convergence w.r.t. gmax.

Note that GME is, in the end, only an approximate method, so even if it is converged with respect to the above parameters but produces strange results, it might be that it's not that well-suited for the structure you are simulating.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

legume-gme-0.0.2.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

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

legume_gme-0.0.2-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file legume-gme-0.0.2.tar.gz.

File metadata

  • Download URL: legume-gme-0.0.2.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

File hashes

Hashes for legume-gme-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5b696e5397cbeaf7ee5d9aebdbe99fccdc54b1cc294cba42cf6b4a947e279ca9
MD5 9e9fa2fbf7523a24214502890cd875e1
BLAKE2b-256 27fabaa3d565760c5dccf806d1baa8915ab48b8f8d900f642bc7dec9208e7d69

See more details on using hashes here.

File details

Details for the file legume_gme-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: legume_gme-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 46.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.5

File hashes

Hashes for legume_gme-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9e3a79b6010dc4d8ede67582c01d1648b3df99af5119300689c45c3867d54e9
MD5 b0659b5dd68969e980e33df5434bc5cc
BLAKE2b-256 a4a1560540d354ecd41a906db520c8e5b083018d390f0623d2bc98c72e8b68a5

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