Package: angler
anglerangler(named for 'adjointnonlineargradients') is a package for simulating and optimizing optical structures.It provides a finite-difference frequency-domain (FDFD) solver for simulating for linear and nonlinear devices in the frequency domain.It also provides an easy to use package for adjoint-based inverse design and optimization of linear and nonlinear devices.  For example, you can inverse design optical switches to transport power to different ports for different input powers:angleris released as part of a paperAdjoint method and inverse design for nonlinear optical devices, which can be viewedhere.InstallationOne can install the most stable version ofanglerand all of its dependencies (apart from MKL) usingpip install anglerAlternatively, to use the most current versiongit clone https://github.com/fancompute/angler.git
pip install -e anglerAnd then this directory can be added to path to import angler, i.e.import sys
sys.path.append('path/to/angler')Make angler fasterThe most computationally expensive operation inangleris the sparse linear system solve.  This is done withscipy.sparse.linalg.spsolve()by default.  If MKL is installed,anglerinstead uses this with a python wrapperpyMKL, which makes things significantly faster, depending on the problem.  The best way to install MKL, if using anaconda, isconda install MKL(pyMKL does not work when MKL is pip installed.)Examples / QuickstartThere are several jupyter notebook examples in theNotebooks/directory.For a good introduction, try:Notebooks/Splitter.ipynbFor more specific applications:Electromagnetic simulationsFor modeling linear devices with our FDFD solver (no optimization), seeNotebooks/Linear_system.ipynbFor modeling nonlinear devices with FDFD (no optimization), seeNotebooks/Nonlinear_system.ipynbInverse design & optimizationFor examples of optimizing linear devices, seeNotebooks/Splitter.ipynb
Notebooks/Accelerator.ipynbFor examples of optimizing nonlinear devices, seeNotebooks/2_port.ipynb
Notebooks/3_port.ipynb
Notebooks/T_port.ipynbPackage Structureanglerprovides two main classes,SimulationandOptimization, which perform most of the functionality.Generally,Simulationobjects are used to perform FDFD simulations, andOptimizationclasses run inverse design and optimization algorithms overSimulations.  To learn more about howanglerworks and how to use it, please take a look atangler/README.mdfor a more detailed explanation.TestsTo run all tests:python -m unittest discover testsOr to run individually:python tests/individual_test.pyContributingangleris under development and we welcome suggestions, pull-requests, feature-requests, etc.If you contribute a new feature, please also write a few tests and document your changes inangler/README.mdor the wiki.Authorsanglerwas written by Tyler Hughes, Momchil Minkov, and Ian Williamson.CitingIf you useangler, please cite us using@misc{hughes2018adjoint,
Author = {Tyler W. Hughes and Momchil Minkov and Ian A. D. Williamson and Shanhui Fan},
Title = {Adjoint method and inverse design for nonlinear nanophotonic devices},
Year = {2018},
Eprint = {arXiv:1811.01255},
}LicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details. Copyright 2018 Tyler Hughes.Acknowledgmentsour logo was made byNadine GilmerRIP Ian's contributions before the code mergeWe made use of a lot of code snippets (and advice) fromJerry Shi