## 3 Results and Discussion
### Responses and Optimization
#### 3.1.1 Optimization  
The merit function map in terms of the geometrical parameters of the grating (GW and GH) is presented in Figure 3a, It shows regions where the merit function reaches a high absorption at the perovskite layer. If we plot reflectance, we obtain a similar map with the same regions showing minimum reflectivity. The black circle in Figure 3a locates the highest absorption for the selected wavelength. The value is 57% in absorption at the active layer. This high value is due to SPR. Actually, this result contrast with the 4% in absorption when only a silver layer replace the ITO electrode (without dielectric grating). The geometrical parameters for this maximum in the merit function are: GW = 215 nm and GH = 1560 nm. The tolerance that maintains almost the same values is \(\pm\)25 nm that could be achieved easily using the available lithographic techniques.  
The absorption in the Ag and perovskite layers, and the total reflectance are shown in Figure 3b for the optimized geometry. To better understand the effect of the optimization, we have also plotted the absorption at the perovskite layer for the non-optimized values (see dotted line) used in Figure 2c.  
Figure 3: (a) Optical absorption in the perovskite layer with the grating parameters GW, and GH for a fixed Period \(P\) 600 nm at a single wavelength at, \(\lambda=610\) nm, using TM polarized light of 1 A/m amplitude the highlighted black dashed circle defines the location of the point where the absorption in perovskite is maximized. (b) The absorption in perovskite layer (red line), absorption in Ag top contact (blue line), the total reflectance of the whole device (black line) for the optimized geometry, and the absorption in perovskite layer (brown dashed line) for the arbitrarily selected geometry before optimization.  
Although the intensity has not increased significantly, we can see how the lineshape is much narrower in the optimized case. This will be of importance when evaluating the system as a refractometric sensor.  
It is important to check the capability to tune the response at different wavelengths in order to adjust the device using available commercial light sources or to detect at a specific detection band. We fix all the parameters except the period of the grating \(P\), and we only change the grating period. As expected, Figure 4a show a blue shifting when reducing \(P\), and a red-shifting when increasing it. As far as perovskite solar cells have a wide absorption band that covers the VIS-NIR (typically from 300 nm to 800 nm), we can use the period \(P\) to tune the response to any desired wavelength in this band.  
The metal thickness, \(t_{\text{Ag}}\), is an important parameter of the device. Figure 4b shows the absorption within the perovskite layer. We can see how the top contact becomes almost transparent when the silver layer is 10 or 20 nm thick. In these conditions, the SPR does not reveal itself in the lineshape. This happens with thicker silver layers. Actually, the peak in absorption becomes spectrally narrower as the thickness of the metal increases. However, a thick silver layer is not practical because it blocks the light coming to the perovskite layer. In this sense, we choose a thickness for Ag as \(t_{\text{Ag}}=50\) nm because at this value we have both high absorption and narrow response. A thickness of 40 nm could achieve a little better absorption but the linewidth is wider than the case of 50 nm thickness.