Inverse design of photonic, microwave and thermal devices with topology optimization and automatic differentiation
We optimize the shape and material layout of photonic, microwave and thermal devices to control waves and fields. Gradient-based topology optimization lets every element of the mesh become a design variable, and automatic differentiation makes the gradients cheap to obtain.
Open-Source Inverse Photonic Design

A silicon metagrating optimized with nannos. It sends 91% (TE) and 86% (TM) of the transmitted light into the (1, 0) diffraction order at 732 nm.
Mathematics 10, 3912 (2022)Advances in nanofabrication open new applications in nanophotonics, and engineering new functionalities requires rigorous and efficient numerical methods. In parallel, algorithmic differentiation (pushed by machine learning) makes large-scale device optimization possible with few changes to the underlying code. I wrote three open-source libraries for Maxwell’s equations, all with automatic differentiation: gyptis, a finite element code with a high-level interface for common photonics problems; nannos, a Fourier modal method for multilayer bi-periodic metasurfaces; and protis, a plane wave expansion method for band diagrams of two-dimensional photonic crystals. Each comes with typical inverse design examples.
Related article
- B. Vial, and Y. Hao, Open-Source Computational Photonics with Auto Differentiable Topology Optimization. Mathematics 10(20), (2022) DOI
Related code
- B. Vial, gyptis: Computational Photonics in Python with the finite element method (2020) gitlab
- B. Vial, nannos: Fourier Modal Method for multilayer metamaterials with auto diff (2021) gitlab
- B. Vial, protis: Plane wave expansion method for photonic crystals (2021) gitlab

Superscattering nanorods optimized with gyptis. The normalized scattering width peaks at the 600 nm target for both polarizations (blue: TE, red: TM). The insets show the silicon and silica layouts and their radiation patterns.
Mathematics 10, 3912 (2022)Bi-focal lens
Topology optimization gave the permittivity layout of a bi-focal lens that concentrates the electromagnetic field at different spatial positions depending on the wavelength. We 3D printed the device from two low-loss dielectrics, and field mapping at microwave frequencies confirmed the local field enhancement at two distinct locations for two separate frequencies.
Related article
- B. Vial, T. Whittaker, S. Zhang, W. G. Whittow, and Y. Hao, Optimization and experimental validation of a bi-focal lens in the microwave domain. AIP Advances 12(2):025103, (2022) DOI
Thermal cloak
The same machinery applies to diffusion, where wideband cloaks remain a challenge at high frequencies. We optimized a thermal cloak for an object of large thermal conductivity (copper), in a given frequency band and for a given diffusion direction. The cloak is near-perfect over a finite frequency band and still performs well in the time domain, including the transient regime and whatever the initial temperature. It also works fairly well for other highly conducting objects, but breaks down for poorly conducting ones.
Related article
- B. Vial, S. Guenneau, and Y. Hao, Topology Optimization of a Thermal Cloak in the Frequency Domain. AIP Advances 13(8):085111, (2023) DOI
Tunable metamaterials
Inverse design also shaped the microstructure of ferroelectric composites with enhanced tunability: see Homogenization and Effective Media.
Illusion device

The reference dielectric object (a) and the optimized coating that makes a metal cylinder look like it (b). Both parts were 3D printed in ABS (c).
Sci. Rep. 7, 3929 (2017)We designed, fabricated and experimentally verified an illusion device at microwave frequencies. Two-dimensional topology optimization finds the binary layout of a dielectric coating that, wrapped around a metallic cylinder, mimics the scattering of a predefined, arbitrarily shaped dielectric object. We 3D printed the coating and mapped the illusion effect with spatially resolved near-field measurements in a waveguide. The approach gives general guidelines for electromagnetic illusions and extends to shaping near and far fields with low-index isotropic materials.
Related article
- B. Vial, M. Torrico, and Y. Hao, Optimized microwave illusion device. Sci Rep 7(1):3929, (2017) DOI

Real part of the electric field at 10 GHz, simulated (top) and measured (bottom). From left to right: free space, bare metal cylinder, reference object, and the cylinder inside the illusion coating.
Sci. Rep. 7, 3929 (2017)Invisibility cloaking

The optimized ABS and air cloak (a) and the fields under line-source illumination, with the cloak (b, c) and without it (d).
Opt. Express 23, 23551 (2015)We designed an all-dielectric cloaking device at microwave frequencies. Gradient-based topology optimization finds the permittivity distribution that minimizes the diffracted field in free space. The binary layout (ABS plastic or air) reduces the scattering from an ABS cylinder excited by a line source. We compared cloaks optimized for one, two and three frequencies, and a modal analysis revealed the resonant mechanism behind the cloaking.
Related article
- B. Vial, and Y. Hao, Topology optimized all-dielectric cloak: Design, performances and modal picture of the invisibility effect. Opt. Express 23(18):23551, (2015) DOI