ceviche 
Electromagnetic Simulation Tools + Automatic Differentiation. Code for paper Forward-Mode Differentiation of Maxwell's Equations.
What is ceviche?
ceviche provides two core electromagnetic simulation tools for solving Maxwell's equations:
-
finite-difference frequency-domain (FDFD)
-
finite-difference time-domain (FDTD)
Both are written in numpy / scipy and are compatible with the HIPS autograd package, supporting forward-mode and reverse-mode automatic differentiation.
This allows you to write code to solve your E&M problem, and then use automatic differentiation on your results.
As a result, you can do gradient-based optimization, sensitivity analysis, or plug your E&M solver into a machine learning model without having to go through the tedious process of deriving your derivatives by hand.
Examples
There is a comprehensive ceviche tutorial available at this link with several ipython notebook examples:
- Running FDFD simulations in ceviche.
- Performing inverse design of a mode converter.
- Adding fabrication constraints and device parameterizations.
- Inverse design of a wavelength-division multiplexer and advanced topics.
There are also a few examples in the examples/* directory.
Installation
There are many ways to install ceviche.
The easiest is by
pip install ceviche
But to install from a local copy, one can instead do
git clone https://github.com/twhughes/ceviche.git
pip install -e ceviche
pip install -r ceviche/requirements.txt
from the main directory.
Alternatively, just download it:
git clone https://github.com/twhughes/ceviche.git
and then import the package from within your python script
import sys
sys.path.append('path/to/ceviche')
Package Structure
Ceviche
The ceviche directory contains everything needed.
To get the FDFD and FDTD simulators, import directly from ceviche import fdtd, fdfd_ez, fdfd_hz
To get the differentiation, import from ceviche import jacobian.
constants.py contains some constants EPSILON_0, C_0, ETA_0, Q_E, which are needed throughout the package
utils.py contains a few useful functions for plotting, autogradding, and various other things.
optimizers.py contains optimizer functions for doing inverse design.
viz.py are functions that help with plotting fields and sructures.
modes.py contains a mode sorter (WIP) that can be used to create waveguide mode profiles for the simulation, for example.
Examples
There are many demos in the examples directory, which will give you a good sense of how to use the package.
Tests
Tests are located in tests. To run, cd into tests and
python -m unittest
to run all or
python specific_test.py
to run a specific one. Some of these tests involve visual inspection of the field plots rather than error checking on values.
To run all of the gradient checking functions, run
chmod +x test/test_all_gradients.sh
tests/test_all_gradients.sh
Credits
If you use this for your research or work, please cite
@article{hughes2019forward,
title={Forward-Mode Differentiation of Maxwell’s Equations},
author={Hughes, Tyler W and Williamson, Ian AD and Minkov, Momchil and Fan, Shanhui},
journal={ACS Photonics},
volume={6},
number={11},
pages={3010--3016},
year={2019},
publisher={ACS Publications}
}
Our logo was created by @nagilmer
Metadata
Release files for ceviche 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ceviche-0.1.3.tar.gz | 30.5 kB | Without provenance | Details for ceviche-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ceviche-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for ceviche-0.1.3-py3-none-any.whl |
Total release size: 63.1 kB
Release files / ceviche-0.1.3.tar.gz
| Download URL | ceviche-0.1.3.tar.gz |
|---|---|
| Size | 30.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7481ec6891944c7121d982c58d10ae5f1a71e057b7f890fb42a90b8383547b55
|
|
BLAKE2b-256 checksum How to use checksums |
22f6e804f69ff6401d4c37802f2f346dbc74d71e47af801ef02aa80b5fa1a7da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|
Release files / ceviche-0.1.3-py3-none-any.whl
| Download URL | ceviche-0.1.3-py3-none-any.whl |
|---|---|
| Size | 32.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d64e9e7f6bbe2fb3c6cc1057cc091173e3e8267777c8f73ed454d33e9557285
|
|
BLAKE2b-256 checksum How to use checksums |
c87b14fbe8ecfbff579511af47da8d29068bff1ee6d8b5e150621675f105dad3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.9
|
Security for ceviche 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.