## 2 Methods
### Inverse Design of Electromagnetic Structures  
We have developed a program, Holo-RCWA, based on the traditional RCWA algorithm process. The program exhibits excellent robustness and efficiency in solving the electromagnetic response of holographic recording materials using photoresist. Additionally, it overcomes the weakness of the slow convergence speed of the traditional RCWA algorithm when TM-polarized incidence is applied.  
As shown in Figure 8a, when using the 2D holographic grating prepared using photoresist as holographic recording materials, which was calculated by the Holo-RCWA program developed, only five Fourier harmonics are required in each direction (x and y) to achieve convergence. This is because the 2D holographic grating produced by the photoresist preparation method does not have a refractive index jump like rectangular gratings produced by methods such as nanoimprinting, thus requiring fewer Fourier harmonics to converge the calculation. The 2D holographic grating model of the photoresist established in Section 2.4 is compared based on z-axis co-ordinates with the remaining height of the etched photoresist. If the z-axis co-ordinate is greater than the remaining height of the photoresist at that point, the refractive index is set to air; if the z-axis co-ordinate is less than or equal to the remaining height of the photoresist at that point, the refractive index is set to the refractive index of the photoresist. The modeling of the photoresist holographic grating is in line with the calculation process of the RCWA algorithm.  
As shown in Figure 9, the x-z profile of the 2D holographic grating is characterized by periodic modulation. When RCWA calculates the electromagnetic waves passing through the structure, it divides the structure by a plane perpendicular to the z axis. Holo-RCWA adopted an even division strategy. As shown in Figure 8b, when Holo-RCWA calculates 2D holographic gratings prepared by photoresist, the calculation results converge quickly with the number of layers; when the number of layers is 7, the calculation results tend to be stable, while, when the number of layers is 20, the calculation results remain stable. At the same time, the total diffraction efficiency is always conserved. These two points together explain the reliability of the calculation results. Figure 8c shows the results of commercial software calculations. When the number of layers is divided into 25 layers, the calculation results still do not show the trend of convergence. Compared with Figure 8b,c, when Holo-RCWA solves the 2D holographic grating proposed in this work, the convergence rate of the calculated results is significantly faster than that of commercial software, and the results are stable and have excellent robustness. Figure 8d shows the calculation results of Holo-RCWA at TM mode incidence. When the number of divided layers is less than five layers, the calculation results show great volatility, which is consistent with the performance of the traditional RCWA algorithm in the same scenario. However, when the number of layers is greater than 10, the calculation results jump out of the oscillation period quickly and remain stable with the increase in the number of layers. As shown in Figure 8, the Holo-RCWA program proposed in this paper has excellent performance, and its ability to solve complex problems is significantly enhanced compared with the traditional RCWA program.