Technical Notes

Topology Optimization and the Adjoint Method

Topology optimization, gradient-based optimizers and the adjoint method are the three parts of photonic inverse design. What each does and how they fit together.

Language: English · 日本語

English

Topology optimization is a design method that lets an optimizer decide, pixel by pixel, where material should be placed in a device so as to maximize a performance goal. In photonics it is combined with two other ingredients: a gradient-based optimizer, which updates the design step by step, and the adjoint method, which computes the gradient with respect to every pixel from just two electromagnetic simulations. Together they form the core of photonic inverse design (term note 1).

Overview

What problem these methods solve

Conventional photonic design starts from a known shape (a bend radius, a coupler length, a grating period) and tunes a few parameters by physical insight and sweeps. Inverse design reverses the direction: the designer states what the device must do, for example “transmit as much light as possible around a 90° corner within 2.5 µm”, and an algorithm searches for a structure that does it. The result can be a compact, non-intuitive shape that no parameter sweep would have found.1 2

Three terms are often used interchangeably, but they describe different parts of the method (Fig. 1):

  • Topology optimization is a problem formulation: the design is described by a density in every pixel of a design region, so the optimizer can create, merge or remove features freely.
  • Gradient-based optimization is the update algorithm: steepest ascent, Adam, L-BFGS or MMA use the gradient of the objective to choose the next design.
  • The adjoint method is the way the gradient is computed: one forward and one adjoint simulation give the derivative with respect to every design variable at once.

Each can be used without the others. A design with two parameters can be optimized with adjoint gradients and Adam (an example is shown below); topology optimization can, in principle, be done without gradients, but only for very few pixels. In practice, large-scale photonic topology optimization is possible only because adjoint gradients make every iteration cost two simulations, whatever the number of pixels.

Flow diagram of the optimization loop. Design variables go through filter and projection to a permittivity, then a forward simulation gives the objective, an adjoint simulation gives its derivative with respect to permittivity, the chain rule gives the derivative with respect to the design variables, and a gradient-based update returns to the design variables. Labels group the boxes into problem formulation, gradient computation and update algorithm.
Figure 1. One iteration of adjoint-based topology optimization. The problem formulation (indigo) maps design variables to a permittivity; the adjoint method (teal) gives the gradient from a forward and an adjoint simulation; a gradient-based optimizer (olive) updates the design. The three parts are independent and can be combined differently.

Theory

The optimization problem

Every optimization starts with three choices: what to maximize (the objective function (term note 2)), what may change, and what must be respected. Written formally:

max⁡p  F(E(p))subject toA(p) E=b,0≤pi≤1.\max_{\mathbf{p}}\; F\big(\mathbf{E}(\mathbf{p})\big) \quad \text{subject to} \quad \mathbf{A}(\mathbf{p})\,\mathbf{E} = \mathbf{b}, \quad 0 \le p_i \le 1 .

The constraint is not optional: the field E\mathbf{E} is not free but must solve Maxwell’s equations for the current structure. That is what makes each evaluation of FF a full electromagnetic simulation, and what makes the gradient expensive unless it is computed cleverly.

Photonic design problems are almost always non-convex: they have many local optima (term note 3). A gradient method finds a good design near its starting point, not the best possible design. The starting point and the optimization schedule therefore matter.

Parameter optimization versus topology optimization

The two formulations differ in what p\mathbf{p} describes.

  • In parameter (shape) optimization, p\mathbf{p} is a handful of dimensions: a tooth width, an etch depth, a radius. The topology (how many pieces, how many holes) is fixed by the designer.
  • In topology optimization, the design region is divided into NN pixels, and each pixel has a density ρi\rho_i between 0 (cladding) and 1 (core).3 The permittivity follows from the density by a material interpolation:
εr(ρˉi)=εclad+ρˉi (εcore−εclad),\varepsilon_r(\bar\rho_i) = \varepsilon_\text{clad} + \bar\rho_i\,\big(\varepsilon_\text{core} - \varepsilon_\text{clad}\big),

Because every pixel can change, features can appear, merge and disappear during the optimization. Intermediate densities (“grey” pixels) are allowed during the search to make the problem continuous and differentiable, but they are not fabricable, so the final design must be pushed to 0 or 1.

Gradient-based updates

Given the gradient ∇F=(∂F/∂p1,…,∂F/∂pN)\nabla F = (\partial F/\partial p_1, \dots, \partial F/\partial p_N), the simplest update moves uphill:

p(k+1)=p(k)+α ∇F(p(k)).\mathbf{p}^{(k+1)} = \mathbf{p}^{(k)} + \alpha\,\nabla F\big(\mathbf{p}^{(k)}\big).

Practical optimizers refine this. Adam (term note 4) keeps running averages of the gradient and its square, which adapts the step for each variable and damps noise.4 L-BFGS builds an approximation of the curvature from past gradients.5 The method of moving asymptotes (MMA) (term note 5) solves a sequence of simple convex approximations and handles bounds and constraints well; it is the classic choice for topology optimization.6 All of them need the gradient, and the gradient is the expensive part.

The adjoint method: the whole gradient from two simulations

The obvious way to obtain the gradient is finite differences: change each pip_i slightly and simulate again. That needs N+1N+1 simulations per iteration, about 10410^4 for a 101×101101\times101-pixel design. The adjoint method (term note 6) gives the same gradient from two.7 8

Start from the discretized Maxwell equations A(p) E=b\mathbf{A}(\mathbf{p})\,\mathbf{E} = \mathbf{b} and differentiate with respect to one design variable. The source does not depend on the design, so differentiating gives:

∂A∂pi E+A ∂E∂pi=0,∂E∂pi=−A−1 ∂A∂pi E.\begin{aligned} \frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E} + \mathbf{A}\,\frac{\partial \mathbf{E}}{\partial p_i} &= 0,\\ \frac{\partial \mathbf{E}}{\partial p_i} &= -\mathbf{A}^{-1}\,\frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E}. \end{aligned}

For a real objective of the complex field, the chain rule gives dF/dpi=2 Re[(∂F/∂E) ∂E/∂pi]dF/dp_i = 2\,\mathrm{Re}\big[(\partial F/\partial\mathbf{E})\,\partial\mathbf{E}/\partial p_i\big]. Inserting the expression above and grouping the factors differently gives the adjoint formula:

dFdpi=−2 Re ⁣[λT ∂A∂pi E],ATλ=(∂F∂E)T.\begin{aligned} \frac{dF}{dp_i} &= -2\,\mathrm{Re}\!\left[\boldsymbol{\lambda}^{T}\,\frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E}\right],\\ \mathbf{A}^{T}\boldsymbol{\lambda} &= \left(\frac{\partial F}{\partial \mathbf{E}}\right)^{T}. \end{aligned}

The key point is that λ\boldsymbol{\lambda} does not depend on ii. One forward simulation gives E\mathbf{E}, one adjoint simulation gives λ\boldsymbol{\lambda}, and then every component of the gradient is a cheap local product. For reciprocal materials AT=A\mathbf{A}^T = \mathbf{A}, so the adjoint simulation is an ordinary simulation with a source placed at the output monitor. Because ∂A/∂ε\partial\mathbf{A}/\partial\varepsilon is local, the sensitivity to the permittivity at a point is proportional to Re[E(r)⋅λ(r)]\mathrm{Re}[\mathbf{E}(\mathbf{r})\cdot\boldsymbol{\lambda}(\mathbf{r})], the overlap of the forward and adjoint fields there. Meep’s adjoint solver does exactly this: a forward and an adjoint time-domain run, with the gradient assembled from their Fourier-transformed fields.9

Filters, projection and fabricable designs

Raw pixel densities left to themselves produce checkerboards and features far smaller than can be fabricated. Two operations are applied before every simulation (Fig. 2).

First, a density filter (term note 7) blurs the raw densities over a radius rr:

ρ~i=∑jwij ρj∑jwij,wij=max⁡(0,  r−∣xi−xj∣)\begin{aligned} \tilde\rho_i &= \frac{\sum_j w_{ij}\,\rho_j}{\sum_j w_{ij}},\\ w_{ij} &= \max\big(0,\; r - |\mathbf{x}_i - \mathbf{x}_j|\big) \end{aligned}

Second, a projection (term note 8) pushes the smooth filtered field back toward 0 or 1 with a smoothed threshold:11

ρˉi=tanh⁡(βη)+tanh⁡(β(ρ~i−η))tanh⁡(βη)+tanh⁡(β(1−η)).\bar\rho_i = \frac{\tanh(\beta\eta) + \tanh\big(\beta(\tilde\rho_i - \eta)\big)}{\tanh(\beta\eta) + \tanh\big(\beta(1-\eta)\big)} .

β\beta is increased in stages during the optimization (β\beta-continuation): a small β\beta keeps the problem smooth while the topology forms, and a large β\beta makes the design nearly binary at the end. The filter radius and the threshold together set a minimum length scale (term note 9): features and gaps narrower than a size related to rr are suppressed, which is how fabrication limits enter the optimization.11 12

The threshold also offers a simple model of fabrication error. Raising η\eta above 0.5 shrinks every feature slightly (an eroded design, like over-etching); lowering it grows every feature (dilated). Robust optimization (term note 10) maximizes the average (or the worst case) of the objective over the eroded, nominal and dilated designs built from the same variables, so the result tolerates a known bias by construction.11

Two panels of density versus position for a 1D toy example. Left: a noisy raw density between 0 and 1 and a smooth filtered version. Right: the filtered density after tanh projection with beta 4, which is still partly grey, with beta 32, which is nearly a square wave of 0 and 1, and with beta 32 and threshold 0.556, which gives slightly narrower features.
Figure 2. Filter and projection on a 1D toy density (closed-form illustration, not a simulation). Left: the conic filter removes pixel-scale noise. Right: the tanh projection with β = 4 still leaves grey values; β = 32 is nearly binary; raising the threshold to η = 0.556 shrinks every feature slightly (an eroded design).

Design guide: what changes what

The same handful of settings decides the outcome of almost every inverse-design run. The list below gives their effect and the reason.

Simulation

What is shown here

The examples re-use saved results from my photonics simulation toolkit, computed with Meep’s adjoint solver in 2D (effective-index silicon strip, ncore=2.7n_\text{core}=2.7, nclad=1.44n_\text{clad}=1.44, 500 nm wide waveguides, TE polarization). No new optimizations were run for this article. The FDTD, FEM and RCWA article explains the FDTD method used for every simulation.

Example 1: topology optimization of a compact bend

The task is a 90° waveguide bend inside a 2.5 µm × 2.5 µm design region, about 1.85 wavelengths across. The region has 101×101=10 201101 \times 101 = 10\,201 pixels, the conic filter radius is 0.2 µm, and the objective is the transmission ∣S21∣2|S_{21}|^2 at 1.35 µm. The optimizer is MMA from NLopt, run for 80 iterations in four stages of 20 with β=4,8,16,32\beta = 4, 8, 16, 32. Training used a resolution of 30 pixels/µm; the final binarized design was re-measured independently at 40 pixels/µm. The starting density was a corner-biased random field; a uniform grey start was tried and stalled.

Fig. 3 shows the objective rising from 0.026 to 0.883 over the 80 iterations, with visible steps at each β\beta change, and the final designs. Each iteration cost one forward and one adjoint FDTD run, so the 10 201-component gradient was computed 80 times for the price of 160 simulations. Finite differences would have needed about 800 000.

Left: objective versus iteration from 1 to 80 for the single-objective and robust optimizations; both rise from about 0.03 to about 0.6 by iteration 20 and to about 0.88 by iteration 80, with dotted lines at the beta changes 4, 8, 16 and 32. Middle and right: the final binarized designs as green and white pixel maps of the 2.5 micrometre design region, a curved main path with a few small islands near the edges; the robust design has fewer small islands.
Figure 3. Adjoint topology optimization of a 90° bend (2.5 µm design region, 101 × 101 pixels). Left: objective |S₂₁|² at 1.35 µm in the training runs, for the single-objective and the robust (3-way averaged) optimization, with the β stages marked. Middle and right: final binarized designs (green: core). From data/sparams/bend_topopt_robust/final (notebooks 04 and 04b).

Is the result worth it? Fig. 4 (left) compares the optimized bend with a conventional Euler bend fitted into the same footprint, both measured at 40 pixels/µm. At 2.5 µm the optimized design transmits 0.816 against 0.625 for the Euler bend. The advantage shrinks as the footprint grows: at 4.05 µm the two are within 0.3 %, and at 4.5 µm the Euler bend is slightly better (0.968 against 0.964). Topology optimization pays off when the space is too small for a smooth shape, not when a smooth shape already works.

Example 2: making the bend tolerant to fabrication

The single-objective design was then tested under a ±10 nm boundary bias, modelled by projecting the same variables with thresholds ηe=0.556\eta_e = 0.556 (eroded) and ηd=0.444\eta_d = 0.444 (dilated), values calibrated to a 10 nm edge shift. Its transmission (0.797 in this continuous representation) dropped to 0.751 when eroded and 0.764 when dilated, a worst-case change of 0.046.

A robust optimization from the same starting density, maximizing the average of the eroded, nominal and dilated transmissions, gave 0.810 nominal, 0.795 eroded and 0.807 dilated: a worst-case change of only 0.015, a third of before, with no loss of nominal performance (Fig. 4, right). The price was three forward and three adjoint runs per iteration, and about three times the run time (19 instead of 7 minutes). The robust design also has fewer small islands (Fig. 3), which is what one expects when fragile features are penalized.

(The nominal values 0.797 and 0.816 for the same single-objective design differ because the bias test uses the continuous filter-and-projection pipeline, which can be eroded and dilated, while 0.816 is the hard-thresholded fabrication mask.)

Left: transmission versus design-region size from 2 to 4.5 micrometres for an Euler bend, rising from 0.47 to 0.97, and for the topology-optimized bend, rising from 0.69 to 0.96; the gap is largest at small sizes and closes by 4 micrometres. Right: grouped bars of transmission for eroded, nominal and dilated versions: the single-objective design drops from 0.80 to 0.75 and 0.76, while the robust design stays between 0.795 and 0.81.
Figure 4. Left: transmission at 1.35 µm of an Euler bend and of the topology-optimized bend at matched footprints (resolution 40, binarized designs). Right: transmission of the single-objective and robust designs when eroded (−10 nm), nominal and dilated (+10 nm). From notebook 04 Section 3, conventional_reference.json and si/data/design_points/bend_topopt_robust.yaml.

Example 3: adjoint gradients for just two parameters

The adjoint method is not tied to topology optimization. In the grating coupler work, a conventional silicon-nitride grating has a fixed period and two free parameters: the tooth width and the etch depth. They were optimized for fiber-coupling efficiency with Meep adjoint gradients and Adam (30 steps, learning rate decaying from 20 nm to 2 nm per step), from three deliberately different starting points.

All three runs reached nearly the same efficiency (Fig. 5): 0.371, 0.354 and 0.368 at the optimization resolution, from starts of 0.350, 0.021 and 0.033. With only two parameters, the whole landscape could also be mapped directly on a 7 × 7 grid; its best grid point, 0.360, lies slightly below the Adam results because the optimizer is not restricted to the grid. Re-evaluated at 160 pixels/µm, the best design gives −4.14 dB.

This example shows the division of labour in Fig. 1. The formulation here is parameter optimization, not topology optimization, yet the gradient still comes from the adjoint method and the update from a standard optimizer. With two parameters, mapping the landscape is affordable and confirms the optimum; with ten thousand pixels, it is not, and the adjoint gradient is the only practical route.

Coupling efficiency versus Adam iteration from 0 to 30 for three starting points. One start begins near 0.35 and rises to 0.37; the other two start near 0.02 and 0.03, rise steeply and settle between 0.35 and 0.37. A dashed line at 0.36 marks the best point of the mapped grid.
Figure 5. Adam with adjoint gradients on the two-parameter SiN grating (tooth width and etch depth), from three starting points (efficiency at the optimization resolution of 60 pixels/µm). Dashed: best point of a 7 × 7 grid scan of the same two parameters. From meta/data/step2 (meta/notebooks/02_uniform_adam.ipynb).

Summary

PartRoleIn the examples
Problem formulationwhat the design variables are10 201 pixel densities (bend); 2 dimensions (grating)
Gradient computationadjoint method: one forward + one adjoint simulationthe same in both examples
Update algorithmuses the gradient to choose the next designMMA (bend), Adam (grating)
Fabricationfilter, projection, robust objective0.2 µm filter, β = 4→32, ±10 nm robust average

Topology optimization decides what may change, the adjoint method makes the gradient cheap, and the optimizer decides how to move. Good results come from choosing each part deliberately: a footprint where freedom actually helps, a filter that matches the process, a β\beta schedule that lets the topology form, and an objective that includes the variations the real device will see.

Code and data


日本語

トポロジー最適化は、デバイスのどこに材料を置くかを最適化アルゴリズムにピクセル単位で決めさせ、性能目標を最大化する設計手法です。フォトニクスでは、他の2つの要素と組み合わせて使います。設計を一歩ずつ更新する勾配法による最適化と、すべてのピクセルに対する勾配をわずか2回の電磁界シミュレーションで計算する随伴法です。この3つが合わさって、フォトニクスの逆設計(用語注1)の中核を成しています。

概要

これらの手法が解く問題

従来のフォトニクス設計では、既知の形(ベンドの半径、カプラの長さ、グレーティングの周期)から出発し、物理的な見通しと掃引で少数のパラメータを調整します。逆設計は向きを逆にします。設計者はデバイスが何をすべきか、たとえば「2.5 µm以内で90°の角を曲がる光をできるだけ多く通す」と指定し、アルゴリズムがそれを実現する構造を探します。その結果、どのパラメータ掃引でも見つからなかったような、小型で直感に反する形が得られることがあります1 2。

3つの用語はしばしば区別なく使われますが、手法の異なる部分を指しています(図1)。

  • トポロジー最適化は問題の定式化です。設計領域の各ピクセルの密度で設計を表すので、最適化アルゴリズムは構造を自由に生み出し、つなげ、消すことができます。
  • 勾配法による最適化は更新アルゴリズムです。最急上昇法、Adam、L-BFGS、MMAは、目的関数の勾配を使って次の設計を選びます。
  • 随伴法は勾配の計算方法です。順方向と随伴の2回のシミュレーションで、すべての設計変数に対する微分が一度に得られます。

それぞれは他と切り離しても使えます。2つのパラメータの設計を随伴法の勾配とAdamで最適化することもできます(例は後で示します)。トポロジー最適化も原理的には勾配なしで行えますが、それはピクセルがごく少ない場合だけです。実際には、大規模なフォトニクスのトポロジー最適化が可能なのは、随伴法の勾配によって、ピクセル数によらず1反復のコストがシミュレーション2回で済むからです。

最適化ループの流れ図。設計変数がフィルタと投影を経て誘電率になり、順方向シミュレーションで目的関数が、随伴シミュレーションで誘電率に対するその微分が得られ、連鎖律で設計変数に対する微分が求まり、勾配法による更新で設計変数に戻る。ラベルが箱を、問題の定式化、勾配の計算、更新アルゴリズムにまとめている。
Figure 1. 随伴法によるトポロジー最適化の1反復。問題の定式化(藍)が設計変数を誘電率に写し、随伴法(青緑)が順方向と随伴のシミュレーションから勾配を求め、勾配法の最適化アルゴリズム(オリーブ)が設計を更新する。3つの部分は独立で、異なる組み合わせも可能。

理論

最適化問題

どの最適化も3つの選択から始まります。何を最大化するか(目的関数(用語注2))、何を変えてよいか、何を守らなければならないかです。形式的に書くと次のとおりです。

max⁡p  F(E(p))subject toA(p) E=b,0≤pi≤1\max_{\mathbf{p}}\; F\big(\mathbf{E}(\mathbf{p})\big) \quad \text{subject to} \quad \mathbf{A}(\mathbf{p})\,\mathbf{E} = \mathbf{b}, \quad 0 \le p_i \le 1

この制約は省けません。場 E\mathbf{E} は自由ではなく、そのときの構造についてMaxwell方程式を満たさなければなりません。そのため FF の評価1回ごとに電磁界シミュレーションが必要になり、工夫して計算しない限り勾配は高くつきます。

フォトニクスの設計問題はほぼ必ず非凸で、多くの局所最適解(用語注3)をもちます。勾配法が見つけるのは出発点の近くのよい設計であって、ありうる最善の設計ではありません。そのため出発点と最適化のスケジュールが重要になります。

パラメータ最適化とトポロジー最適化

2つの定式化は、p\mathbf{p} が何を表すかで異なります。

  • パラメータ(形状)最適化では、p\mathbf{p} は少数の寸法(歯の幅、エッチ深さ、半径など)です。トポロジー(いくつの部品に分かれるか、穴がいくつあるか)は設計者が決めます。
  • トポロジー最適化では、設計領域を NN 個のピクセルに分け、各ピクセルが0(クラッド)から1(コア)の密度 ρi\rho_i をもちます3。誘電率は材料補間によって密度から決まります。
εr(ρˉi)=εclad+ρˉi (εcore−εclad)\varepsilon_r(\bar\rho_i) = \varepsilon_\text{clad} + \bar\rho_i\,\big(\varepsilon_\text{core} - \varepsilon_\text{clad}\big)

すべてのピクセルが変われるので、最適化の途中で構造が現れ、つながり、消えることができます。探索中は問題を連続で微分可能にするため中間の密度(「灰色」のピクセル)を許しますが、それは作製できないので、最終設計は0か1に押しやる必要があります。

勾配法による更新

勾配 ∇F=(∂F/∂p1,…,∂F/∂pN)\nabla F = (\partial F/\partial p_1, \dots, \partial F/\partial p_N) が与えられたとき、最も単純な更新は坂を上る方向に進むことです。

p(k+1)=p(k)+α ∇F(p(k))\mathbf{p}^{(k+1)} = \mathbf{p}^{(k)} + \alpha\,\nabla F\big(\mathbf{p}^{(k)}\big)

実用的な最適化アルゴリズムはこれを改良したものです。Adam(用語注4)は勾配とその2乗の移動平均を保ち、変数ごとにステップを適応させてノイズを抑えます4。L-BFGSは過去の勾配から曲率の近似を組み立てます5。移動漸近線法(MMA)(用語注5)は単純な凸近似の列を解き、上下限や制約をうまく扱えるので、トポロジー最適化の定番になっています6。どれも勾配を必要とし、高くつくのはその勾配です。

随伴法:2回のシミュレーションで勾配全体を得る

勾配を得る素直な方法は差分です。各 pip_i を少し変えて再びシミュレーションします。これには1反復あたり N+1N+1 回のシミュレーションが必要で、101×101101\times101 ピクセルの設計なら約 10410^4 回です。随伴法(用語注6)は同じ勾配を2回で求めます7 8。

離散化したMaxwell方程式 A(p) E=b\mathbf{A}(\mathbf{p})\,\mathbf{E} = \mathbf{b} から出発し、1つの設計変数で微分します。光源は設計に依存しないので、微分すると次の式が得られます。

∂A∂pi E+A ∂E∂pi=0,∂E∂pi=−A−1 ∂A∂pi E\begin{aligned} \frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E} + \mathbf{A}\,\frac{\partial \mathbf{E}}{\partial p_i} &= 0,\\ \frac{\partial \mathbf{E}}{\partial p_i} &= -\mathbf{A}^{-1}\,\frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E} \end{aligned}

複素数の場の実数値の目的関数では、連鎖律から dF/dpi=2 Re[(∂F/∂E) ∂E/∂pi]dF/dp_i = 2\,\mathrm{Re}\big[(\partial F/\partial\mathbf{E})\,\partial\mathbf{E}/\partial p_i\big] です。上の式を代入して因子のくくり方を変えると、次の随伴法の式が得られます。

dFdpi=−2 Re ⁣[λT ∂A∂pi E],ATλ=(∂F∂E)T\begin{aligned} \frac{dF}{dp_i} &= -2\,\mathrm{Re}\!\left[\boldsymbol{\lambda}^{T}\,\frac{\partial \mathbf{A}}{\partial p_i}\,\mathbf{E}\right],\\ \mathbf{A}^{T}\boldsymbol{\lambda} &= \left(\frac{\partial F}{\partial \mathbf{E}}\right)^{T} \end{aligned}

要点は、λ\boldsymbol{\lambda} が ii によらないことです。順方向シミュレーション1回で E\mathbf{E} が、随伴シミュレーション1回で λ\boldsymbol{\lambda} が得られ、あとは勾配のどの成分も安い局所的な積で求まります。相反性のある材料では AT=A\mathbf{A}^T = \mathbf{A} なので、随伴シミュレーションは、出力モニタの位置に光源を置いた普通のシミュレーションです。∂A/∂ε\partial\mathbf{A}/\partial\varepsilon は局所的なので、ある点の誘電率に対する感度は、その点での順方向の場と随伴場の重なり Re[E(r)⋅λ(r)]\mathrm{Re}[\mathbf{E}(\mathbf{r})\cdot\boldsymbol{\lambda}(\mathbf{r})] に比例します。Meepの随伴ソルバはまさにこれを行います。時間領域の順方向計算と随伴計算を1回ずつ行い、それらのFourier変換した場から勾配を組み立てます9。

フィルタ、投影、作製可能な設計

ピクセルの密度をそのままにしておくと、市松模様や作製できないほど小さな構造ができてしまいます。そこで、毎回のシミュレーションの前に2つの操作を行います(図2)。

まず密度フィルタ(用語注7)が、生の密度を半径 rr の範囲でぼかします。

ρ~i=∑jwij ρj∑jwij,wij=max⁡(0,  r−∣xi−xj∣)\begin{aligned} \tilde\rho_i &= \frac{\sum_j w_{ij}\,\rho_j}{\sum_j w_{ij}},\\ w_{ij} &= \max\big(0,\; r - |\mathbf{x}_i - \mathbf{x}_j|\big) \end{aligned}

次に投影(用語注8)が、なめらかなしきい値処理によって、ぼかした場を0か1へ押し戻します11。

ρˉi=tanh⁡(βη)+tanh⁡(β(ρ~i−η))tanh⁡(βη)+tanh⁡(β(1−η))\bar\rho_i = \frac{\tanh(\beta\eta) + \tanh\big(\beta(\tilde\rho_i - \eta)\big)}{\tanh(\beta\eta) + \tanh\big(\beta(1-\eta)\big)}

β\beta は最適化の途中で段階的に大きくします(β\beta の段階的増加)。トポロジーができあがるまでは小さな β\beta で問題をなめらかに保ち、最後に大きな β\beta で設計をほぼ二値にします。フィルタ半径としきい値が合わさって最小寸法(用語注9)が決まります。rr に関係する大きさより細い構造や隙間は抑えられ、これが作製上の制限を最適化に取り込む方法です11 12。

しきい値は作製誤差の簡単なモデルにもなります。η\eta を0.5より上げるとすべての構造がわずかに細くなり(侵食した設計、エッチしすぎに相当)、下げるとすべての構造が太くなります(膨張)。ロバスト最適化(用語注10)は、同じ変数から作った侵食・公称・膨張の設計について目的関数の平均(または最悪値)を最大化するので、結果は既知の偏りに対して最初から強くなります11。

1次元の簡単な例での密度と位置の関係の2パネル。左:0と1の間でばらつく生の密度と、そのなめらかなフィルタ後の分布。右:フィルタ後の密度をtanh投影したもので、β = 4ではまだ一部が灰色、β = 32ではほぼ0と1の矩形波、β = 32でしきい値0.556では構造がわずかに細くなる。
Figure 2. 1次元の簡単な密度分布に対するフィルタと投影(閉じた式による例示で、シミュレーションではない)。左:円錐フィルタがピクセル単位のノイズを取り除く。右:β = 4のtanh投影ではまだ灰色の値が残り、β = 32ではほぼ二値になる。しきい値を η = 0.556 に上げると、すべての構造がわずかに細くなる(侵食した設計)。

設計の早見表:何を変えると何が変わるか

ほとんどの逆設計の結果は、同じ少数の設定で決まります。以下にその効果と理由をまとめます。

シミュレーション

ここで示すもの

以下の例は、photonics simulation toolkitでMeepの随伴ソルバを使い2次元で計算した保存済みの結果を再利用しています(等価屈折率のシリコン細線、ncore=2.7n_\text{core}=2.7、nclad=1.44n_\text{clad}=1.44、導波路幅500 nm、TE偏波)。本記事のために新たな最適化は行っていません。すべての計算で使っているFDTD法については、FDTD、FEM、RCWAの記事で説明しています。

例1:小型ベンドのトポロジー最適化

課題は、2.5 µm × 2.5 µm(約1.85波長)の設計領域の中での90°導波路ベンドです。領域は 101×101=10 201101 \times 101 = 10\,201 ピクセル、円錐フィルタの半径は0.2 µm、目的関数は1.35 µmでの透過率 ∣S21∣2|S_{21}|^2 です。最適化アルゴリズムはNLoptのMMAで、β=4,8,16,32\beta = 4, 8, 16, 32 の4段階を20反復ずつ、計80反復行いました。学習時の分解能は30 pixels/µmで、最終的な二値化設計は40 pixels/µmで独立に測り直しています。初期密度は角に偏ったランダムな場で、一様な灰色から始める方法も試しましたが、止まってしまいました。

図3は、目的関数が80反復で0.026から0.883まで上がる様子(各 β\beta の切り替えで段差が見える)と、最終設計です。各反復は順方向と随伴のFDTD計算を1回ずつ要したので、10 201成分の勾配を80回、シミュレーション160回分のコストで計算したことになります。差分なら約80万回が必要でした。

左:単一目的とロバスト最適化の目的関数と反復1から80の関係。どちらも約0.03から反復20で約0.6、反復80で約0.88まで上がり、β = 4、8、16、32の切り替えに点線がある。中央と右:2.5マイクロメートルの設計領域の最終的な二値化設計を緑と白のピクセル図で示したもの。曲がった主経路と縁付近のいくつかの小さな島からなり、ロバスト設計の方が小さな島が少ない。
Figure 3. 90°ベンドの随伴法によるトポロジー最適化(設計領域2.5 µm、101 × 101ピクセル)。左:単一目的とロバスト(3通りの平均)最適化の学習時の目的関数 |S₂₁|²(1.35 µm)。βの段階を示す。中央と右:最終的な二値化設計(緑:コア)。data/sparams/bend_topopt_robust/final(ノートブック04と04b)より。

その結果に意味はあるでしょうか。図4(左)は、最適化したベンドと、同じ大きさに収めた従来のEulerベンドを、どちらも40 pixels/µmで測って比べたものです。2.5 µmでは、最適化した設計の透過率0.816に対しEulerベンドは0.625です。大きさが増えると利点は縮みます。4.05 µmでは両者の差は0.3 %以内で、4.5 µmではEulerベンドの方がわずかによくなります(0.968対0.964)。トポロジー最適化が効くのは、なめらかな形には狭すぎる空間であって、なめらかな形がすでにうまく働く場合ではありません。

例2:作製に強いベンドにする

次に、単一目的の設計を±10 nmの境界の偏りのもとで試しました。同じ変数をしきい値 ηe=0.556\eta_e = 0.556(侵食)と ηd=0.444\eta_d = 0.444(膨張)で投影して偏りを模擬しています。これらの値は10 nmの縁のずれに対して較正したものです。透過率(この連続表現では0.797)は、侵食で0.751、膨張で0.764まで下がり、最悪の変化は0.046でした。

同じ初期密度から、侵食・公称・膨張の透過率の平均を最大化するロバスト最適化を行うと、公称0.810、侵食0.795、膨張0.807となりました。最悪の変化はわずか0.015で以前の3分の1になり、公称性能も損なわれていません(図4右)。代償は1反復あたり順方向・随伴の計算が3回ずつになることで、計算時間はおよそ3倍(7分に対して19分)でした。ロバスト設計は小さな島も少なく(図3)、壊れやすい構造を罰すれば期待どおりの結果です。

(同じ単一目的の設計の公称値が0.797と0.816で異なるのは、偏りの試験では侵食・膨張できる連続的なフィルタ・投影の表現を使い、0.816はしきい値で完全に二値化した作製用マスクの値だからです。)

左:設計領域の大きさ2から4.5マイクロメートルに対する透過率。Eulerベンドは0.47から0.97へ、トポロジー最適化したベンドは0.69から0.96へ上がり、差は小さい領域で最も大きく、4マイクロメートルでほぼなくなる。右:侵食・公称・膨張版の透過率の棒グラフ。単一目的の設計は0.80から0.75と0.76に下がり、ロバスト設計は0.795から0.81の間にとどまる。
Figure 4. 左:同じ大きさでのEulerベンドとトポロジー最適化したベンドの1.35 µmでの透過率(分解能40、二値化設計)。右:単一目的とロバストの設計を侵食(−10 nm)、公称、膨張(+10 nm)したときの透過率。ノートブック04の3節、conventional_reference.json、si/data/design_points/bend_topopt_robust.yaml より。

例3:2つのパラメータだけに随伴法の勾配を使う

随伴法はトポロジー最適化に限ったものではありません。グレーティングカップラーの研究では、従来型の窒化シリコングレーティングは周期が固定で、自由なパラメータは歯の幅とエッチ深さの2つです。これを、Meepの随伴法の勾配とAdam(30ステップ、学習率は1ステップあたり20 nmから2 nmへ減衰)で、意図的に異なる3つの出発点からファイバ結合効率について最適化しました。

3つの計算はいずれもほぼ同じ効率に達しました(図5)。出発点の0.350、0.021、0.033から、最適化の分解能でそれぞれ0.371、0.354、0.368です。パラメータが2つしかないので、7 × 7の格子で地形全体を直接調べることもできました。その最良の格子点0.360がAdamの結果をわずかに下回るのは、最適化アルゴリズムが格子に縛られないからです。160 pixels/µmで評価し直すと、最良の設計は−4.14 dBです。

この例は図1の役割分担を示しています。ここでの定式化はトポロジー最適化ではなくパラメータ最適化ですが、勾配はやはり随伴法から、更新は標準的な最適化アルゴリズムから得ています。パラメータが2つなら地形を調べるのも安く、最適解を確かめられます。1万ピクセルではそれは不可能で、随伴法の勾配が唯一の現実的な方法です。

3つの出発点についてのAdam反復0から30に対する結合効率。1つは約0.35から0.37へ上がり、残り2つは約0.02と0.03から急に上がって0.35から0.37の間に落ち着く。0.36の破線が格子走査の最良点を示す。
Figure 5. 2パラメータ(歯の幅とエッチ深さ)のSiNグレーティングに対する、随伴法の勾配を使ったAdam。3つの出発点から(効率は最適化の分解能60 pixels/µmでの値)。破線:同じ2つのパラメータの7 × 7格子走査の最良点。meta/data/step2(meta/notebooks/02_uniform_adam.ipynb)より。

まとめ

部分役割例での対応
問題の定式化設計変数が何か10 201個のピクセル密度(ベンド)、2つの寸法(グレーティング)
勾配の計算随伴法:順方向1回 + 随伴1回のシミュレーション両方の例で同じ
更新アルゴリズム勾配を使って次の設計を選ぶMMA(ベンド)、Adam(グレーティング)
作製フィルタ、投影、ロバストな目的関数フィルタ0.2 µm、β = 4→32、±10 nmのロバスト平均

トポロジー最適化は何を変えてよいかを決め、随伴法は勾配を安くし、最適化アルゴリズムはどう動くかを決めます。よい結果は、それぞれを意図して選ぶことから生まれます。自由度が実際に役立つ大きさの設計領域、プロセスに合ったフィルタ、トポロジーが形づくられる余裕のある β\beta のスケジュール、そして実際のデバイスが受けるばらつきを含む目的関数です。

コードとデータ


References / 参考文献

Footnotes

  1. S. Molesky, Z. Lin, A. Y. Piggott, W. Jin, J. Vučković and A. W. Rodriguez, “Inverse design in nanophotonics,” Nature Photonics 12, 659–670 (2018). doi:10.1038/s41566-018-0246-9 ↩ ↩2

  2. J. S. Jensen and O. Sigmund, “Topology optimization for nano-photonics,” Laser & Photonics Reviews 5, 308–321 (2011). doi:10.1002/lpor.201000014 ↩ ↩2

  3. M. P. Bendsøe and O. Sigmund, Topology Optimization: Theory, Methods, and Applications (Springer, 2004). doi:10.1007/978-3-662-05086-6 ↩ ↩2

  4. D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” arXiv:1412.6980 (2014). arXiv:1412.6980 ↩ ↩2

  5. D. C. Liu and J. Nocedal, “On the limited memory BFGS method for large scale optimization,” Mathematical Programming 45, 503–528 (1989). doi:10.1007/BF01589116 ↩ ↩2

  6. K. Svanberg, “The method of moving asymptotes—a new method for structural optimization,” International Journal for Numerical Methods in Engineering 24, 359–373 (1987). doi:10.1002/nme.1620240207 ↩ ↩2

  7. M. B. Giles and N. A. Pierce, “An introduction to the adjoint approach to design,” Flow, Turbulence and Combustion 65, 393–415 (2000). doi:10.1023/A:1011430410075 ↩ ↩2

  8. C. M. Lalau-Keraly, S. Bhargava, O. D. Miller and E. Yablonovitch, “Adjoint shape optimization applied to electromagnetic design,” Optics Express 21, 21693 (2013). doi:10.1364/OE.21.021693 ↩ ↩2

  9. A. M. Hammond, A. Oskooi, M. Chen, Z. Lin, S. G. Johnson and S. E. Ralph, “High-performance hybrid time/frequency-domain topology optimization for large-scale photonics inverse design,” Optics Express 30, 4467 (2022). doi:10.1364/OE.442074 ↩ ↩2

  10. T. W. Hughes, M. Minkov, I. A. D. Williamson and S. Fan, “Adjoint method and inverse design for nonlinear nanophotonic devices,” ACS Photonics 5, 4781–4787 (2018). doi:10.1021/acsphotonics.8b01522 ↩ ↩2

  11. F. Wang, B. S. Lazarov and O. Sigmund, “On projection methods, convergence and robust formulations in topology optimization,” Structural and Multidisciplinary Optimization 43, 767–784 (2011). doi:10.1007/s00158-010-0602-y ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  12. A. M. Hammond, A. Oskooi, S. G. Johnson and S. E. Ralph, “Photonic topology optimization with semiconductor-foundry design-rule constraints,” Optics Express 29, 23916 (2021). doi:10.1364/OE.431188 ↩ ↩2