## 3 Results and Discussion
### Responses and Optimization  
From Figure 2a, perovskite solar cells with ITO contacts show high optical absorption at the active layer (red dashed line) within most of the visible spectrum. The losses are mainly due to reflection and parasitic absorption in different layers. As an example, the absorption of the ITO electrode is represented as a green solid line. This figure also compares the behavior of the standard structure when the transparent electrode is replaced with a silver one (50 nm-thick) that reflect most of the incoming light, and account for some absorption mainly at lower wavelngth in the range 300-400 nm  
Figure 1: (**a**) Standard perovskite material arrangement. (**b**) Modified design for sensing applications, where the top ITO contact is replaced with an Ag layer and a dielectric grating with triangular shape with the top medium above the cell with refractive index \(n_{\mathrm{a}}\). In both cases, light is coming from top oscillating in \(Z\) direction and propagating in \(-Y\) direction, the 2D cross section of the structure is contained in the \(XY\) plane, as seen the the coordinate inset in the top middle. The insets in dashed rectangles show the mechanisms at play in this structures. (see blue solid line in Figure 2a. Accordingly, the absorption at the perovskite layer drops, precluding the use of the cell as an energy harvesting device (see black solid line in Figure 2a). The reflectance of the structure for the standard design is represented in Figure 2b as a red dashed curve. We have also plotted the reflectance of the cell when the ITO electrode is replaced with a silver layer (50 nm-thick) on top of the TiO\({}_{2}\) layer, Again, we can see how this metallic layer strongly disturbs the performance of the structure as a energy harvesting device. In Figure 2a,b, neither of the structures contain the pyramidal dielectric grating. The previous spectral behavior changes when including the effect of the dielectric grating. As a matter of fact, we have selected an spectral region where the perovskite cell absorbs the most (\(\lambda=610\) nm). Now we add a Si\({}_{3}\)N\({}_{4}\) pyramidal grating with geometrical parameters: \(P=600\) nm, GW = 350 nm, and GH = 1050 nm. The results for the absorption and reflectance are plotted in Figure 2c around \(\lambda=610\) nm. The reflectance reaches an almost null value within this range (black solid line), which means a high absorption at the silver and active layers (see red and blue solid lines). These results are confirmed when evaluating the magnetic field distribution (see Figure 2d). These three maps represent the incidence of plane wave under normal incidence conditions and with a wavelength of \(\lambda=610\) nm. The plot at the left is for the standard perovskite cell, the map at the middle is for the same cell where ITO is replaced with silver, and the one to the right corresponds with the case of the silver layer plus the dielectric grating. It is worth noting how the field reaches the perovskite  
Figure 2: (**a**) Optical absorption in the active layer and top contact for the planer perovskite solar cells. (**b**) Spectral reflection for this two planer cases without grating. (**c**) The absorption in perovskite layer (red line), absorption in Ag top contact (blue line) and the total reflectance of the whole device (black line) for the proposed design with Ag-grating layer. (**d**) Magnetic field maps for the device with ITO (left), Ag only (middle), and Ag+grating (right) at the resonance wavelength \(\lambda=610\) nm, showing how light reaches the active layer only in the case of ITO and Ag+grating. The case with Ag only does not transmit light to the active layer significantly. layer as hot spots (for the silver plus grating case) instead of a plane wave distribution (when using plane-parallel thin layers). To improve the capabilities of this device as a refractometric sensor for gases, we perform an optimization of the geometry of the device.