in Fig. \[fig:schematic\], with a wavenumber $k$ and incidence angle $\theta_{\mathrm{inc}}$ relative to the $z$-axis. We take the entire structure to be a supercell of length $L_{x}$, with quasi-periodic boundary conditions (see below). The electric and magnetic fields in the structure are governed by Maxwell’s equations: $$\begin{aligned}
\begin{aligned}
\nabla \times \mathbf{E} &= ik\mathbf{H},\\
\nabla \times \mathbf{H} &= -ik\varepsilon\mathbf{E}.
\end{aligned}
\label{eq:Maxwell}\end{aligned}$$ We consider the case where the electric field is $s$-polarized, $\mathbf{E}=E\hat{y}$, so that the magnetic field has the form $\mathbf{H}=H_{x}\hat{x}+H_{z}\hat{z}$. The quasi-periodic boundary conditions are: $$\begin{aligned}
\begin{aligned}
\mathbf{E}(L_{x}/2,z) &= \mathbf{E}(-L_{x}/2,z)\exp(ik_{x}L_{x}), \\
\mathbf{H}(L_{x}/2,z) &= \mathbf{H}(-L_{x}/2,z)\exp(ik_{x}L_{x}),
\end{aligned}\end{aligned}$$ where $k_x = k\sin \theta_{\mathrm{inc}}$ is the $x$-component of the incident wave vector ${\mathbf{k}}$.

The scattered electric field is defined as $$E_s(\mathbf{r}) = E_{\mathrm{tot}}(\mathbf{r}) - E_{\mathrm{inc}}(\mathbf{r}), \hspace{1cm} [\,\mathbf{r}\equiv (x,z)\,],$$ where $E_{\mathrm{tot}}$ and $E_{\mathrm{inc}}$ are the total and incident electric fields, respectively. The magnetic field is split similarly. The scattered field is purely outgoing on both the upper side (towards the negative $z$-direction) and the lower side (towards the positive $z$-direction) of the structure.

Fig. \[fig:discretization\](a) shows the discretization scheme for FLAME. The structure is discretized into $N_x$ grid points in the horizontal direction. In the vertical direction, the number of layers is deliberately limited to 