Skip to main content

Rigorous coupled wave analysis supporting automatic differentation with autograd

Project description

grcwa

https://img.shields.io/pypi/v/grcwa.svg Documentation Status

grcwa (autoGradable RCWA) is a python implementation of rigorous coupled wave analysis (RCWA) for arbitrarily shaped photonic crystal slabs, supporting automatic differentation with autograd

Citing

If you find grcwa useful for your research, please cite the following paper:

@article{Jin2020,
  title = {Inverse design of lightweight broadband reflector for relativistic lightsail propulsion},
  author ={Jin, Weiliang and Li, Wei and Orenstein, Meir and Fan, Shanhui},
  year = {2020},
  journal = {ACS Photonics},
  volume = {7},
  number = {9},
  pages = {2350--2355},
  year = {2020},
  publisher = {ACS Publications}
}

Features

imag/scheme.png

RCWA solves EM-scattering problems of stacked photonic crystal slabs. As illustrated in the above figure, the photonic structure can have N layers of different thicknesses and independent spatial dielectric profiles. All layers are periodic in the two lateral directions, and invariant along the vertical direction.

  • Each photonic crystal layer can have arbitrary dielectric profile on the 2D grids.

  • autograd is integrated into the package, allowing for automated and fast gradient evaluations for the sake of large-scale optimizations. Autogradable parameters include dielectric constant on every grid, frequency, angles, thickness of each layer, and periodicity (however the ratio of periodicity along the two lateral directions must be fixed).

Quick Start

  • Installation:

    $ pip install grcwa

    Or,

    $ git clone git://github.com/weiliangjinca/grcwa
    $ pip install .
  • Example 1: transmission and reflection (sum or by order) of a square lattice of a hole: ex1.py

  • Example 2: Transmission and reflection of two patterned layers: ex2.py, as illustrated in the figure below (only a unit cell is plotted)

    imag/ex.png
    • Periodicity in the lateral direction is Lx = Ly = 0.2, and frequency is 1.0.

    • The incident light has an angel pi/10.

      import grcwa
      import numpy as np
      grcwa.set_backend('autograd') # if autograd needed
      
       # lattice constants
       L1 = [0.2,0]
       L2 = [0,0.2]
       # Truncation order (actual number might be smaller)
       nG = 101
       # frequency
       freq = 1.
       # angle
       theta = np.pi/10
       phi = 0.
      
       # setup RCWA
       obj = grcwa.obj(nG,L1,L2,freq,theta,phi,verbose=1)
    • Geometry: the thicknesses of the four layers are 0.1,0.2,0.3, and 0.4. For patterned layers, we consider total grid points Nx * Ny = 100*100 within the unit cell.

    • Dielectric constant: 2.0 for the 0-th layer; 4.0 (1.0) for the 1st layer in the orange (void) region; 6.0 (1.0) for the 2nd layer in the bule (void) region; and 3.0 for the last layer.

      Np = 2 # number of patterned layers
      Nx = 100
      Ny = 100
      
      thick0 = 0.1
      pthick = [0.2,0.3]
      thickN = 0.4
      
      ep0 = 2.
      epN = 3.
      
      obj.Add_LayerUniform(thick0,ep0)
      for i in range(Np):
          obj.Add_LayerGrid(pthick[i],Nx,Ny)
      obj.Add_LayerUniform(thickN,epN)
      
      obj.Init_Setup()
    • Patterned layer: the 1-th layer a circular hole of radius 0.5 Lx, and the 2-nd layer has a square hole of 0.5 Lx

      radius = 0.5
      a = 0.5
      
      ep1 = 4.
      ep2 = 6.
      epbkg = 1.
      
      # coordinate
      x0 = np.linspace(0,1.,Nx)
      y0 = np.linspace(0,1.,Ny)
      x, y = np.meshgrid(x0,y0,indexing='ij')
      
      # layer 1
      epgrid1 = np.ones((Nx,Ny))*ep1
      ind = (x-.5)**2+(y-.5)**2<radius**2
      epgrid1[ind]=epbkg
      
      # layer 2
      epgrid2 = np.ones((Nx,Ny))*ep2
      ind = np.logical_and(np.abs(x-.5)<a/2 and np.abs(y-.5)<a/2))
      epgrid2[ind]=epbkg
      
      # combine epsilon of all layers
      epgrid = np.concatenate((epgrid1.flatten(),epgrid2.flatten()))
      obj.GridLayer_geteps(epgrid)
    • Incident light is s-polarized

      planewave={'p_amp':0,'s_amp':1,'p_phase':0,'s_phase':0}
      obj.MakeExcitationPlanewave(planewave['p_amp'],planewave['p_phase'],planewave['s_amp'],planewave['s_phase'],order = 0)
      
      # solve for R and T
      R,T= obj.RT_Solve(normalize=1)
  • Example 3: topology optimization of reflection of a single patterned layer, ex3.py

  • Example 4: transmission and reflection (sum or by order) of a hexagonal lattice of a hole: ex4.py

Note on conventions

  • The vacuum permittivity, permeability, and speed of light are 1.

  • The time harmonic convention is exp(-i omega t).

Acknowledgements

My implementation of RCWA received helpful discussions from Dr. Zin Lin. Many details of implementations were referred to a RCWA package implemented in c called S4. The idea of integrating Autograd into RCWA package rather than deriving adjoint-variable gradient by hand was inspired by a discussion with Dr. Ian Williamson and Dr. Momchil Minkov. The backend and many other styles follow their implementation in legume. Haiwen Wang and Cheng Guo provided useful feedback. Lastly, the template was credited to Cookiecutter and the audreyr/cookiecutter-pypackage.

History

0.1.2 (2020-11-01)

  • Add example for hexagonal lattice

0.1.1 (2020-05-18)

  • Fix license

0.1 (2020-05-12)

  • First release on PyPI.

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

grcwa-0.1.2.tar.gz (933.6 kB view details)

Uploaded Source

Built Distribution

grcwa-0.1.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file grcwa-0.1.2.tar.gz.

File metadata

  • Download URL: grcwa-0.1.2.tar.gz
  • Upload date:
  • Size: 933.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for grcwa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f4983743b94cad92560c0cf528a66ad632357d4df5fd536eb5bbf2cb69708664
MD5 c1b60d0ee51f4d5fb93ff26fbb85a05e
BLAKE2b-256 a94dd79d7dfcf73bb402890bc573ad482036d524f39d1868383da7c4a47c2a4b

See more details on using hashes here.

File details

Details for the file grcwa-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: grcwa-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for grcwa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65dbc0151d46a22985c1fe7f1070347e67562363fcb04371e9d158e3ba6140ee
MD5 ca7d668d826e8cd50cc818c6315d50ad
BLAKE2b-256 39efba5eae2e967f124ffbcd58b07943ac54b9840b70d602a9df78d895faf459

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