## 2 Inverse Design of Silicon Photonics with Iterative Optimization Algorithms
### Optimization of Irregular Structures  
An irregular structure owns the highest DOF since the whole design area is segmented into very small pixels [15]. Different from QR-code like structure which also pixelates the design area with 100 or 200 nm resolution, an irregular structure is more intricate with ultra-high resolution (10 or 20 nm scale). It would be extremely time-consuming for gradient-free algorithms discussed above to optimize an irregular structure with thousands of DOF, as the required simulations is proportional to the number of DOF. Fortunately, gradient-based algorithms cast light on this time-consuming problem, where all the parameters are updated with the fewest simulations. Figure 3: Schematic of DBS-assisted PBS design based on QR-code like structure. To describe the optimization process, a mathematical model which tries to optimize the FOM at the constraints of Maxwell equations is built as in Equation (1):  
\[ \begin{split}\underset{\epsilon,\mu}{\text{max}}& F(\mathbf{E}, \mathbf{H})\\ & s.t.\ \left\{\begin{array}{c}\
abla\cdot e\mathbf{E}=\rho\\ \
abla\cdot\mu\mathbf{H}=0\\ \
abla\times\mathbf{E}=-j\omega\mu\mathbf{H}\\ \
abla\times\mathbf{H}=J+j\omega e\mathbf{E}\end{array}\right.,\end{split}  \tag{1}\]  
where FOM \(\text{F}(\cdot)\) is the function of electric field \(\mathbf{E}\) and magnetic field \(\mathbf{H}\). Permittivity \(\epsilon\) and permeability \(\mu\) in the design area are variables to be tuned for better FOM. Objective-first (OF) method [56] and topology optimization (TO) with adjoint method [70] have been proposed to solve Equation (1). We take irregular PBS in reference [71] as an example to illustrate the TO process. As shown in Figure 4a, the design domain \(D_{s}\) is optimized by adjoint method for two FOMs. The first FOM is the transmission of TE mode at the upper arm while the second FOM is the transmission of TM mode at the lower arm. As the optimization processes of two arms are similar, we only give detailed derivation of TE mode here. In the objective domain \(D_{o}\), the actual EM fields are optimized towards fundamental TE mode. The targets at each position \(\mathbf{x_{o}}\) in the objective domain is defined in the form of Poynting vectors [70] as in Equation (2):  
\[f(\mathbf{E}(\mathbf{x_{o}}),\mathbf{H}(\mathbf{x_{o}}))=\mathbf{E}(\mathbf{x_ {o}})\times\overline{\mathbf{H_{T}}(\mathbf{x_{o}})}+\overline{\mathbf{E_{T}}( \mathbf{x_{o}})}\times\mathbf{H}(\mathbf{x_{o}}), \tag{2}\]  
where \(\mathbf{E},\mathbf{H}\) are the actual EM fields from the simulation, and \(\overline{\mathbf{E_{T}}}\), \(\overline{\mathbf{H_{T}}}\) are the constant conjugated EM fields of the fundamental TE mode. The best target \(f(\mathbf{E}(\mathbf{x_{o}}),\mathbf{H}(\mathbf{x_{o}}))\) requires the value of actual EM fields to be the largest and the direction of actual EM fields to be the same with fundamental TE mode at position \(\mathbf{x_{o}}\). However, it is still hard to determine whether the FOM is good or not when some positions get better targets while others get worse. Therefore, the total FOM is defined as the integral of all the targets in the objective domain as in Equation (3):  
\[F(\mathbf{E},\mathbf{H})=\int_{\mathcal{D}_{\delta}}f(\mathbf{E}(\mathbf{x_{o }}),\mathbf{H}(\mathbf{x_{o}}))\mathrm{d}^{3}\mathbf{x_{o}}. \tag{3}\]  
Figure 4: Topology optimization of a PBS via adjoint method. (**a**) Schematic diagram of adjoint method. (**b**) Optimization process for the design area of PBS. (**c**) Final structure of optimized PBS. The derivative of total FOM to permittivity and permeability in the design domain \(D_{\rm s}\) is calculated using chain rule.