Package: rcwa
What this package can doCalculate reflectance, transmittance, and scattering parameters from stacks of planar thin filmsSimulate diffraction efficiencies, scattering matrices from 1D diffraction gratingsSimulate diffraction efficiencies, scattering matrices from 2D photonic crystalsGetting StartedInstallationThe recommended way to install this software is withpip:pip install rcwaAnd that's it!Hello World ProgramTo see a simple example, run:python -m rcwa.examples.bragg_mirrorThis should run an example with a 10-layer bragg mirror (also known as adielectric mirror), which can have very high reflectance near its design wavelength, and output the reflectance as a function of wavelength, as seen below:FeaturesImplements 1D Transfer Matrix Method for homogenous layersImplements full rectangular 2D RCWA for periodic layersHuge material database for n/k values in optical range built-in based onrefractiveindex.info, including metals, plastics, glass, and ceramicsEasy to use class-based syntaxIntegrated parameter sweeps of any simulation parameter: geometry, materials, wavelength, angle of incidence, etc.Compute reflection and transmission spectra at arbitrary incidence and polarizationCompute spectroscopic ellipsometry curvesCompute reflected power, transmitted power, and S-parametersLarge, fast-to-run test suiteExtremely fast narrowband, rigorously correct simulations well suited for resonant devicesBuilt-in convergence testingExample UsesCompute reflected and transmitted power from a thin film stackDetermine resonant frequency of a VCSELDetermine reflectance of a bragg mirror, on or off-axisFind diffraction efficiencies for a 1D or 2D diffraction gratingCompute reflected power from a metallic mirrorExamplesAll examples are in theexamples/directory in your locally installedrcwapackage, or inrcwa/examples/on this repository.Reflection off Dispersive MaterialsThe below example demonstrates the reflection spectra you get reflecting off a bare surface of silicon, using the built-in materials database.from rcwa import Material, Layer, LayerStack, Source, Solver, Plotter

import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
startWavelength = 0.25
stopWavelength = 0.8
stepWavelength = 0.001

# Setup the source
source = Source(wavelength=startWavelength)

# Setup the materials and geometry
si = Material(name='Si')

# Setup the interface
reflectionLayer = Layer(n=1) # Free space
transmissionLayer = Layer(material=si)
stack = LayerStack(incident_layer=reflectionLayer, transmission_layer=transmissionLayer)

# Setup the solver
TMMSolver = Solver(stack, source, (1, 1))

# Setup and run the sweep
wavelengths = np.arange(startWavelength, stopWavelength + stepWavelength,
        stepWavelength)
results = TMMSolver.solve(wavelength=wavelengths)
results.plot(x='wavelength', y='RTot', show=True)Source Wavelength / Angle Sweepsimport numpy as np
from rcwa import Material, Layer, LayerStack, Source, Solver, Plotter

# Setup the source
startWavelength = 0.25
stopWavelength = 0.8
stepWavelength = 0.02
wavelengths = np.arange(startWavelength, stopWavelength + stepWavelength,
        stepWavelength)
thetas = np.linspace(0, np.pi/4,10)

source = Source(wavelength=startWavelength)

thin_film = Layer(thickness=0.1, n=2)
substrate = Layer(n=4)
stack = LayerStack(thick_film, transmission_layer=substrate)

solver = Solver(stack, source)

results = solver.solve(wavelength=wavelengths, theta=thetas)
results.plot(x='wavelength', y='RTot', show=True)Geometry SweepsHere, we set up a simulation with a rectangular grating on a substrate with a relative permittivity of 9, and a wavelength of 0.5 units (microns, meters, whatever you like!). This can be found in thegrating_sweep.pyexample. In this example we are sweeping the thickness, but we could have swept the period or refractive index or permittivity.from rcwa import Source, Layer, LayerStack, Crystal, Solver, RectangularGrating
import numpy as np
from matplotlib import pyplot as plt

reflection_layer = Layer(er=1.0, ur=1.0)
transmission_layer = Layer(er=9.0, ur=1.0)

wavelength = 0.5
source = Source(wavelength=wavelength)

N_harmonics = 11

grating_layer = RectangularGrating(period=2, thickness=0.5, n=4, n_void=1, nx=500)
layer_stack = LayerStack(grating_layer, incident_layer=reflection_layer, transmission_layer=transmission_layer)

solver_1d = Solver(layer_stack, source, N_harmonics)
results = solver_1d.solve((grating_layer, {'thickness': np.linspace(0.3, 0.5, 100)}))

results.plot(x='thickness', y='RTot', show=True)DocumentationThis  project is documented onGithub Pages. For additional information, including downloading examples, you can view this project ongithub.Author: Jordan Edmunds, UC Irvine Alumnus, UC Berkeley Ph.D. StudentDate Started: 2020/01/05Frequently Asked QuestionsQ: How do I tell the solver to use the Transfer Matrix Method or Rigorous Coupled Wave Analysis?
A: Don't worry, it will figure it out for you.LicenseThis project is distributed under theMIT license.DependenciesDependencies are comprehensively covered by the setup.py file, and the most
recent set of dependencies can be found there. Currently, this requires numpy,
scipy, pandas, matplotlib, and pyyaml. The documentation is built using Sphinx
and hosted on readthedocs.io.Acknowledgements / ReferencesThis work is based primarily on a set of lectures and associated course
material by ProfessorRaymond Rumpfat
the University of Texas, El Paso.[1] Rakić, Aleksandar D., Aleksandra B. Djurišić, Jovan M. Elazar, and Marian L. Majewski. "Optical properties of metallic films for vertical-cavity optoelectronic devices." Applied optics 37, no. 22 (1998): 5271-5283.