fmmax


Namefmmax JSON
Version 0.8.0 PyPI version JSON
download
home_pageNone
SummaryFourier modal method with Jax
upload_time2024-03-29 19:37:07
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2023 Meta Research Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fmm rcwa jax optics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FMMAX: Fourier Modal Method with Jax

<a href="https://facebookresearch.github.io/fmmax/"><img src="https://img.shields.io/badge/Docs-blue.svg"/></a>
![Continuous integration](https://github.com/facebookresearch/fmmax/actions/workflows/build-ci.yml/badge.svg)
![PyPI version](https://img.shields.io/pypi/v/fmmax)

FMMAX is a an implementation of the Fourier modal method (FMM) in [JAX](https://github.com/google/jax). 

The FMM -- also known as rigorous coupled wave analysis (RCWA) -- is a semianalytical method that solves Maxwell's equations in periodic stratified media, where in-plane directions are treated with a truncated Fourier basis and the normal direction is handled by a scattering matrix approach [1999 Whittaker, 2012 Liu, 2020 Jin]. This allows certain classes of structures to be modeled with relatively low computational cost.

Our use of JAX enables GPU acceleration and automatic differentiation of FMM simulations. Besides these features, FMMAX is differentiated from other codes by its support for Brillouin zone integration, advanced vector FMM formulations which improve convergence, and anisotropic and magnetic materials.

## Brillouin zone integration
Brillouin zone integration [2022 Lopez-Fraguas] allows modeling of localized sources in periodic structures. Check out the `crystal` example to see how we model a Gaussian beam incident upon a photonic crystal slab, or an isolated dipole embedded within the slab. The Gaussian beam fields are shown below.

![Gaussian beam incident on photonic crystal](/img/crystal_beam.gif)

## Vector FMM formulations
Vector FMM formulations introduce local coordinate systems at each point in the unit cell, which are normal and tangent to all interfaces. This allows normal and tangent field components to be treated differently and improves convergence. FMMAX implements several vector formulations of the FMM, with automatic vector field generation based on functional minimization similar to [2012 Liu]. We implement the _Pol_, _Normal_, and _Jones_ methods of that reference, and introduce a new _Jones direct_ method which we have found to have superior convergence. These are supported also with anisotropic and magnetic materials. The `vector_fields` example computes vector fields by these methods for an example structure.

![Comparison of automatically-generated vector fields](/img/vector_fields.png)

## Anisotropic, magnetic materials
Our support of anisotropic, magnetic materials allows modeling of uniaxial perfectly matched layers. This is demonstrated in the `metal_dipole` example, which simulates in vaccuum located above a metal substrate. The resulting electric fields are whown below.

![Dipole suspended above metal substrate with PML](/img/metal_dipole.png)

## FMM Conventions
- The speed of light, vacuum permittivity, and vacuum permeability are all 1.
- Fields evolve in time as $\exp(-i \omega t)$.
- If $\mathbf{u}$ and $\mathbf{v}$ are the primitive lattice vectors, the unit cell is defined by the parallelogram with vertices at $\mathbf{0}$, $\mathbf{u}$, $\mathbf{u} + \mathbf{v}$, and $\mathbf{v}$.
- For quantities defined on a grid (such as the permittivity distribution of a patterned layer) the value at grid index (0, 0) corresponds to the value at physical location $\mathbf{0}$.
- The scattering matrix block $\mathbf{S}_{11}$ relates incident and transmitted forward-going fields, and other blocks have corresponding definitions. This differs from the convention e.g. in photonic integrated circuits.

## Batching
Batched calculations are supported, and should be used where possible to avoid looping. The batch axes are the leading axes, except for the wave amplitudes and electromagnetic fields, where a trailing batch axis is assumed. This allows e.g. computing the transmission through a structure for multiple polarizations via a matrix-matrix operation (`transmitted_amplitudes = S11 @ incident_amplitudes`), rather than a batched matrix-vector operation.

## Installation

FMMAX can be installed via pip:
```
pip install fmmax
```

For developers requiring a local installation, you will need to first clone this repository and then perform a local install from within the root directory using:
```
pip install -e ".[dev]"
```

The `[dev]` modifier specifies optional dependencies for developers which are listed in `pyproject.toml`.

Note: for this to work, it may be necessary to first update your pip installation using e.g. `python3 -m pip install --upgrade pip`.

## Citing FMMAX

If you use FMMAX, please consider citing [our paper](https://arxiv.org/abs/2308.08573),

```
@misc{schubert2023fourier,
      title={Fourier modal method for inverse design of metasurface-enhanced micro-LEDs}, 
      author={Martin F. Schubert and Alec M. Hammond},
      year={2023},
      eprint={2308.08573},
      archivePrefix={arXiv},
      primaryClass={physics.comp-ph}
}
```

## License
FMMAX is licensed under the [MIT license](https://github.com/facebookresearch/fmmax/blob/main/LICENSE).

## References
- [2012 Liu] V. Liu and S. Fan, [S4: A free electromagnetic solver for layered structures structures](https://www.sciencedirect.com/science/article/pii/S0010465512001658), _Comput. Phys. Commun._ **183**, 2233-2244 (2012).

- [1999 Whittaker] D. M. Whittaker and I. S. Culshaw, [Scattering-matrix treatment of patterned multilayer photonic structures](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.60.2610), _Phys. Rev. B_ **60**, 2610 (1999).

- [2020 Jin] W. Jin, W. Li, M. Orenstein, and S. Fan [Inverse design of lightweight broadband reflector for relativistic lightsail propulsion](https://pubs.acs.org/doi/10.1021/acsphotonics.0c00768), _ACS Photonics_ **7**, 9, 2350-2355 (2020).

- [2022 Lopez-Fraguas] E. Lopez-Fraguas, F. Binkowski, S. Burger, B. Garcia-Camara, R. Vergaz, C. Becker and P. Manley [Tripling the light extraction efficiency of a deep ultraviolet LED using a nanostructured p-contact](https://www.nature.com/articles/s41598-022-15499-7), _Scientific Reports_ **12**, 11480 (2022).
    

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fmmax",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Martin Schubert <mfschubert@gmail.com>, Alec Hammond <alec.m.hammond@gmail.com>",
    "keywords": "fmm, rcwa, jax, optics",
    "author": null,
    "author_email": "Martin Schubert <mfschubert@gmail.com>, Alec Hammond <alec.m.hammond@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ef/47/cd46584a9d5663eb2757f4dd0211b3aa32a14913e50793242cc9ef75569e/fmmax-0.8.0.tar.gz",
    "platform": null,
    "description": "# FMMAX: Fourier Modal Method with Jax\n\n<a href=\"https://facebookresearch.github.io/fmmax/\"><img src=\"https://img.shields.io/badge/Docs-blue.svg\"/></a>\n![Continuous integration](https://github.com/facebookresearch/fmmax/actions/workflows/build-ci.yml/badge.svg)\n![PyPI version](https://img.shields.io/pypi/v/fmmax)\n\nFMMAX is a an implementation of the Fourier modal method (FMM) in [JAX](https://github.com/google/jax). \n\nThe FMM -- also known as rigorous coupled wave analysis (RCWA) -- is a semianalytical method that solves Maxwell's equations in periodic stratified media, where in-plane directions are treated with a truncated Fourier basis and the normal direction is handled by a scattering matrix approach [1999 Whittaker, 2012 Liu, 2020 Jin]. This allows certain classes of structures to be modeled with relatively low computational cost.\n\nOur use of JAX enables GPU acceleration and automatic differentiation of FMM simulations. Besides these features, FMMAX is differentiated from other codes by its support for Brillouin zone integration, advanced vector FMM formulations which improve convergence, and anisotropic and magnetic materials.\n\n## Brillouin zone integration\nBrillouin zone integration [2022 Lopez-Fraguas] allows modeling of localized sources in periodic structures. Check out the `crystal` example to see how we model a Gaussian beam incident upon a photonic crystal slab, or an isolated dipole embedded within the slab. The Gaussian beam fields are shown below.\n\n![Gaussian beam incident on photonic crystal](/img/crystal_beam.gif)\n\n## Vector FMM formulations\nVector FMM formulations introduce local coordinate systems at each point in the unit cell, which are normal and tangent to all interfaces. This allows normal and tangent field components to be treated differently and improves convergence. FMMAX implements several vector formulations of the FMM, with automatic vector field generation based on functional minimization similar to [2012 Liu]. We implement the _Pol_, _Normal_, and _Jones_ methods of that reference, and introduce a new _Jones direct_ method which we have found to have superior convergence. These are supported also with anisotropic and magnetic materials. The `vector_fields` example computes vector fields by these methods for an example structure.\n\n![Comparison of automatically-generated vector fields](/img/vector_fields.png)\n\n## Anisotropic, magnetic materials\nOur support of anisotropic, magnetic materials allows modeling of uniaxial perfectly matched layers. This is demonstrated in the `metal_dipole` example, which simulates in vaccuum located above a metal substrate. The resulting electric fields are whown below.\n\n![Dipole suspended above metal substrate with PML](/img/metal_dipole.png)\n\n## FMM Conventions\n- The speed of light, vacuum permittivity, and vacuum permeability are all 1.\n- Fields evolve in time as $\\exp(-i \\omega t)$.\n- If $\\mathbf{u}$ and $\\mathbf{v}$ are the primitive lattice vectors, the unit cell is defined by the parallelogram with vertices at $\\mathbf{0}$, $\\mathbf{u}$, $\\mathbf{u} + \\mathbf{v}$, and $\\mathbf{v}$.\n- For quantities defined on a grid (such as the permittivity distribution of a patterned layer) the value at grid index (0, 0) corresponds to the value at physical location $\\mathbf{0}$.\n- The scattering matrix block $\\mathbf{S}_{11}$ relates incident and transmitted forward-going fields, and other blocks have corresponding definitions. This differs from the convention e.g. in photonic integrated circuits.\n\n## Batching\nBatched calculations are supported, and should be used where possible to avoid looping. The batch axes are the leading axes, except for the wave amplitudes and electromagnetic fields, where a trailing batch axis is assumed. This allows e.g. computing the transmission through a structure for multiple polarizations via a matrix-matrix operation (`transmitted_amplitudes = S11 @ incident_amplitudes`), rather than a batched matrix-vector operation.\n\n## Installation\n\nFMMAX can be installed via pip:\n```\npip install fmmax\n```\n\nFor developers requiring a local installation, you will need to first clone this repository and then perform a local install from within the root directory using:\n```\npip install -e \".[dev]\"\n```\n\nThe `[dev]` modifier specifies optional dependencies for developers which are listed in `pyproject.toml`.\n\nNote: for this to work, it may be necessary to first update your pip installation using e.g. `python3 -m pip install --upgrade pip`.\n\n## Citing FMMAX\n\nIf you use FMMAX, please consider citing [our paper](https://arxiv.org/abs/2308.08573),\n\n```\n@misc{schubert2023fourier,\n      title={Fourier modal method for inverse design of metasurface-enhanced micro-LEDs}, \n      author={Martin F. Schubert and Alec M. Hammond},\n      year={2023},\n      eprint={2308.08573},\n      archivePrefix={arXiv},\n      primaryClass={physics.comp-ph}\n}\n```\n\n## License\nFMMAX is licensed under the [MIT license](https://github.com/facebookresearch/fmmax/blob/main/LICENSE).\n\n## References\n- [2012 Liu] V. Liu and S. Fan, [S4: A free electromagnetic solver for layered structures structures](https://www.sciencedirect.com/science/article/pii/S0010465512001658), _Comput. Phys. Commun._ **183**, 2233-2244 (2012).\n\n- [1999 Whittaker] D. M. Whittaker and I. S. Culshaw, [Scattering-matrix treatment of patterned multilayer photonic structures](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.60.2610), _Phys. Rev. B_ **60**, 2610 (1999).\n\n- [2020 Jin] W. Jin, W. Li, M. Orenstein, and S. Fan [Inverse design of lightweight broadband reflector for relativistic lightsail propulsion](https://pubs.acs.org/doi/10.1021/acsphotonics.0c00768), _ACS Photonics_ **7**, 9, 2350-2355 (2020).\n\n- [2022 Lopez-Fraguas] E. Lopez-Fraguas, F. Binkowski, S. Burger, B. Garcia-Camara, R. Vergaz, C. Becker and P. Manley [Tripling the light extraction efficiency of a deep ultraviolet LED using a nanostructured p-contact](https://www.nature.com/articles/s41598-022-15499-7), _Scientific Reports_ **12**, 11480 (2022).\n    \n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Meta Research  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Fourier modal method with Jax",
    "version": "0.8.0",
    "project_urls": null,
    "split_keywords": [
        "fmm",
        " rcwa",
        " jax",
        " optics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25aa0f0c692a26a9b54081d5f179c41e8f1f2ab2586783513ee5f9c6e4ab6961",
                "md5": "8d1e1af9aeb005abcde03d578197ed06",
                "sha256": "c0179bf36204ccdc72c35fc93618a297ebcba63f6e34e977ee52f2369e0f7798"
            },
            "downloads": -1,
            "filename": "fmmax-0.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d1e1af9aeb005abcde03d578197ed06",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 52386,
            "upload_time": "2024-03-29T19:37:06",
            "upload_time_iso_8601": "2024-03-29T19:37:06.015621Z",
            "url": "https://files.pythonhosted.org/packages/25/aa/0f0c692a26a9b54081d5f179c41e8f1f2ab2586783513ee5f9c6e4ab6961/fmmax-0.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef47cd46584a9d5663eb2757f4dd0211b3aa32a14913e50793242cc9ef75569e",
                "md5": "918f77258e705edee3a5e99d0e0dc0d4",
                "sha256": "b8896f46a458b2f7596d37ce6f449c825c89b1553ab1deb87e0fedcd0e044f94"
            },
            "downloads": -1,
            "filename": "fmmax-0.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "918f77258e705edee3a5e99d0e0dc0d4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 49130,
            "upload_time": "2024-03-29T19:37:07",
            "upload_time_iso_8601": "2024-03-29T19:37:07.521990Z",
            "url": "https://files.pythonhosted.org/packages/ef/47/cd46584a9d5663eb2757f4dd0211b3aa32a14913e50793242cc9ef75569e/fmmax-0.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 19:37:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "fmmax"
}
        
Elapsed time: 0.57906s