Accurate near-field calculation in the rigorous coupled-wave analysis method

The rigorous coupled-wave analysis (RCWA) is one of the most successful and widely used methods for modeling periodic optical structures. It yields fast convergence of the electromagnetic far-field and has been adapted to model various optical devices and wave configurations. In this article, we investigate the accuracy with which the electromagnetic near-field can be calculated by using RCWA and explain the observed slow convergence and numerical artifacts from which it suffers, namely unphysical oscillations at material boundaries due to the Gibb's phenomenon. In order to alleviate these shortcomings, we also introduce a mathematical formulation for accurate near-field calculation in RCWA, for one- and two-dimensional straight and slanted diffraction gratings. This accurate near-field computational approach is tested and evaluated for several representative test-structures and configurations in order to illustrate the advantages provided by the proposed modified formulation of the RCWA.


Introduction
The study of the interaction of electromagnetic waves with matter has spawned a large variety of methods to analytically or numerically solve the Maxwell equations (MEs). The results obtained from those methods are invaluable for understanding, validating, predicting, and guiding experimental efforts and for the design process of electromagnetic and optical devices. Amongst the numerical methods used in computational electromagnetics, one can fundamentally distinguish between time-domain methods, which directly incorporate the transient behavior of electromagnetic waves, such as the finite-difference time-domain method [1], and frequency-domain methods, like the finite-element frequency-domain method [2], which directly determine time-harmonic solutions to MEs. The former methods are general purpose methods and are capable of simulating virtually any electromagnetic structure comprising metallic or dielectric objects of arbitrary size and shape. However, for certain structures and applications, other methods can be superior in terms of runtime and accuracy. For example, the multiple scattering method [3] is a series expansion method in the frequency domain that is tailored to calculate interaction of light and clusters of spherical particles [4] or cylindrical rods [5], and as such it is superior to other methods when applied to these particular geometries.
It is a modal method in the frequency domain and is based on the decomposition of the periodic structure and the pseudo-periodic solution of MEs in terms of their Fourier series (FS) expansion, hence the periodicity is naturally incorporated into the numerical method. RCWA was initially developed for modeling one-dimensional (1D) diffraction gratings, but with the introduction of fast converging Fourier factorization rules for modeling 1D [17,18] and two-dimensional (2D) [19][20][21] structures, its formulation for isotropic and anisotropic materials [22] as well as multilayered [23] and oblique structures [24], RCWA has evolved to describe arbitrary, 2Dperiodic structures. The method has been successfully applied to model diffraction gratings, diffractive optical elements, surface coatings, spectroscopic applications, photonic crystals, and periodic metamaterials. It should be noted, that in most cases the functionality of these applications of periodic structures depends on the electromagnetic far-field, i.e. the propagating diffraction orders, and it is known that the RCWA delivers fast converging and accurate far-field results, as reported in many works [14][15][16][17][18][19][20][21][22][23][24].
There is, however, a range of novel applications, which rely on the optical near-field of a periodic structure, especially at their surface, such as surfaceenhanced Raman spectroscopy [25], surface secondharmonic generation [26][27][28], and near-field sensing [29][30][31][32]. These applications require a suitably designed near-field distribution, usually optimized for maximum field enhancement within specific spatial domains. Although there have been significant advances in experimental optical near-field measurement techniques [33], these techniques are still in their development state and not readily available to accurately characterize complex photonic nanostructures. These applications and experimental shortcomings lead to a critical demand for numerical methods for periodic structures that can facilitate an accurate calculation of electromagnetic near-fields, and more importantly, the design of gratings with optimized near-field patterns.
With very few exceptions [20,34], a thorough investigation of numerically calculated near-fields in the RCWA has been largely neglected during the development of the method, as it is often merely considered a postprocessing step. Moreover, additional reasons for the scarcity of reports on the convergence and the accuracy of the numerically computed electromagnetic near-field in RCWA, are the slow near-field convergence and spurious oscillations displayed by these fields [34].
In this paper we address the issue of inaccurate near-field calculations in the RCWA in several ways. First, we use some generic cases of diffraction gratings to illustrate the slow convergence of RCWA for nearfield calculations and reveal the reasons for this behavior. Based on this analysis and the continuity properties of the electromagnetic fields, a new formulation of the field evaluation is proposed, which yields faster convergence of the electromagnetic nearfields and explicitly fulfills the continuity properties of the electromagnetic field at material interfaces. This improved formulation of the numerical evaluation of the near-fields is then benchmarked against the current formulation, with the aim of making RCWA an effective numerical method for modeling modern nanophotonic applications that rely on highly accurate near-field calculations.
The remainder of the paper is organized as follows: Section 2 will introduce the reader to the problem of inaccurate/spurious near-fields in RCWA for 1D structures and explain the overall strategy for the accurate field evaluation. Section 3 will extend the ideas gained from the analysis of 1D structures to arbitrary, straight or obliquely etched 2D gratings and will present the underlying mathematical formalism. Then in section 4, computational results for 2D gratings will be presented and discussed. Section 5 will investigate near-and far-field convergence of the modified method for slanted gratings, before final conclusions about the capability of the improved RCWA for modeling electromagnetic near-fields will be drawn in section 6.
2. Accurate near-field evaluation for 1D-periodic structures Although the last major roadblock that was precluding RCWA from becoming a highly effective method for modeling 1D periodic structures has been removed when the correct Fourier factorization rules for transverse magnetic (TM) polarization were introduced [17,18], a few topics have continued to attract attention, namely the convergence for slanted 1D-periodic gratings [24] and the numerical instabilities associated to highly-conductive gratings [35]. These improvements and refinements of the method are concerned with the accuracy of the far-field calculation and they achieve excellent convergence results for the coefficients of and power carried by the diffraction orders in the cover and substrate regions of a grating, namely the far-field. This picture changes if the near-field is considered. Thus, in this section we investigate the numerically calculated near-field inside the periodic grating region via RCWA, and explain its slow convergence and the origin of the observed high spatial frequency oscillations. We also propose an improved field evaluation approach, which yields faster converging near-field profiles free of numerical artifacts.
The ideas developed in this paper are applicable to any periodic grating structure with sharp boundaries, but in order to conduct a comprehensive assessment of the accuracy of the near-field calculations achievable with the improved RCWA introduced in this work, a number of generic test structures (1D-and 2Dperiodic, straight and slanted) have been chosen, as per figure 1. To widen the spectrum of test configurations, three different materials are considered for the grating: silica (SiO 2 ) as a dielectric with low index of refraction (n g = n SiO2 = 1.45), silicon (Si) as a high refractive index dielectric (n g = n Si = 3.4) and a metal, gold (Au), with index of refraction n g = n Au = 0.97 + 1.87i [36]. In all examples the substrate is SiO 2 (n s = n SiO2 ). Normal incidence and TM-polarization is considered in all of the sections, i.e. the incident electric field amplitude is oriented along the x-axis: The example considered in this section is depicted in figure 1(a). It consists of a binary grating with period, Λ 1 = 1 µm, height, h = 0.25 µm, and filling Figure 1. Grating structures mounted on a homogeneous substrate (refractive index, ns) considered in this study: a) 1D binary grating, filling factor, ρ; b) 1D binary grating, slanted by θ = π/4 w.r.t. the x-axis. c) 2D grating with rectanglesemi-circular cross-section. d) 2D cylindrical grating, slanted by θ = π/4 w.r.t. the x-axis. The height of all gratings is denoted with h, their period is Λ 1 (and Λ 2 for 2D-periodic gratings), and their refractive index is denoted by ng. The cover medium is vacuum with nc = 1.
As the first step of our investigation, we used RCWA to calculate the far-field. In order to quantify the convergence of the RCWA method, the relative error of the far-field is defined as: where T (N ) (R (N ) ) denotes the relative transmitted (reflected) power corresponding to a discretization with 2N + 1 complex FS coefficients. The discretization parameter, N , represents the number of harmonics retained for each dimension. Specifically, in order to achieve a self-error of e F (N ) < 1% (as a generic criterion adopted here for an accurate farfield calculation), for the three materials, silica (red crosses), silicon (blue stars), and gold (green triangles), a relatively small number of harmonics is necessary, namely N > 5, N > 25, and N > 13, respectively.
As mentioned in the introductory section, the far-field of optical gratings and periodic structures has been the physical quantity of most interest from experimental point of view, hence the characterization of a numerical method by means of the far- field convergence has usually been the adopted strategy. This approach, however, largely neglects the electromagnetic near-field predicted by a specific method.
On the other hand, the near-field is of fundamental importance for modeling plasmonic effects or optical nonlinear phenomena in devices with size comparable to or smaller than the operating wavelength, effects whose description relies on accurate calculations of the electromagnetic near-field.  3. Self convergence of the tangential and normal electric field components Ez and Ex andẼx inside the grating structure described by their self-errors ∆Et(N ) (green triangles), ∆En(N ) (red crosses) and ∆Ẽn(N ) (blue circles), respectively for the three benchmark structures made of Silica (a), Silicon (b) and Gold (c).
In order to characterize the numerically obtained near-fields, we define the grating norm, · G , of a scalar or vectorial function, f , in the grating region as follows: where the z-integration extends over the bulk of the periodic region. The grating norm is used to define the near-field error, e E (N ) α , of the scalar field components E (N ) α , α = x, y, z, of a near-field, E (N ) , numerically obtained using N harmonics: Here, E (N ) α denotes the FS reconstruction given by the 2N + 1 central Fourier coefficients, E αn , which are calculated by RCWA: Similarly to the far-field calculations, The near-field selfconvergence for the tangential component, E t = E z , and the normal component, E n = E x , of the electric field is depicted in figure 3. For all three materials, the self-convergence of E t (blue circles) is fast and comparable to the far-field self-convergence (see figure 2). The normal component, E n (red crosses), however, exhibits much slower convergence and even at the highest numerical resolution of N = 640 a relative error of e E (640) x > 0.9% still remains, whereas the error of the tangential field, e E (640) z < 0.08%, for all materials.
One intriguing question raised by the data plotted in figures 2 and 3 is why the normal component of the near-field converges much more slowly than the farfield power and the tangential component of the nearfield. Or put it the other way around: how can the far-field converge quickly when the near-fields have not converged yet? There are two factors that explain this behavior: i) The far-field consists of a superposition of a small number of propagating diffraction orders, i.e., plane waves. Hence, the far-field requires a small number of FS components to be reconstructed and does not suffer from Gibb's phenomenon. ii) RCWA does not depend on the representation of the discontinuous normal field E n .
Instead, the method relies on the correct Fourier factorization of the continuous normal component of the displacement field, D n , which can be accurately described by a FS, i.e. without spurious oscillations. The second observation is at the core of the accurate near-field calculation that is introduced in this work. Specifically, instead of reconstructing a discontinuous physical quantity, i.e. E n (x), directly from its FS coefficients, it is more effective to reconstruct a continuous quantity, the normal component of the displacement field, D n (x), and then divide it by a discontinuous quantity, the electric permittivity, ε 0 ε(x), which is known in the space-domain where one seeks to solve the diffraction problem.
For 1D-periodic gratings, we define the modified a) conventional N=21 normal component of the electric field: where ε 0 is the vacuum permittivity and ε(x) the relative permittivity at position, x. Note that E n (x) represent the same physical quantity, namely the normal component of the electric field. However, whereas the former is found by using RCWA to solve directly for the electric field, the latter one is determined by first calculating the displacement field and then the electric field via equation (4).
The error, e Ẽ (N ) n , of the modified normal component,Ẽ n , is shown in figure 3 and encoded in green triangle. It is found to converge as fast as the fast-convergent tangential component, E t , and as fast as the power in the far-field shown in figure 2. Even at the highest considered resolution, N = 640, the conventional formulation of the RCWA yields a self error of e E (640) n > 9 · 10 −3 for all three materials. By contrast, the same self error e Ẽ (N ) n < 9 · 10 −3 of the modified normal fieldẼ n can be achieved by using as few as N = 70 harmonics.
The spatial profile of the electric field in the grating region illustrates the full benefits of the modified field calculation. Figure 4(a) depicts the conventional normal field component |E |E (21) x | in the gold grating for a moderately coarse discretization of N = 21 harmonics. It can be seen that |E (21) n | exhibits unphysical oscillations with a spatial frequency equal to the period of the smallest spatial frequency component in the FS expansion of the solution. This is the well known Gibb's phenomenon, which occurs when describing a discontinuous function with a truncated FS. On the other hand, the modified normal field,Ẽ n , does not suffer from such spurious oscillations at the interface. In particular, even for a small number of harmonics, N = 21,Ẽ The improved formulation of RCWA exhibits another benefit, namelyẼ n is by construction discontinuous and exactly fulfills the corresponding boundary condition, at surface points of the grating, x s , where E in and ε (in) (E out and ε (out) ) denote the electric field and permittivity inside (outside) the grating, respectively, and n is the unit vector normal to the surface. In the conventional formulation of the RCWA, the field E (N ) n does not satisfy equation (5), because E It should be clear now that the modified normalfield evaluation in 1D by means of the displacement field represents an improvement of the conventional evaluation of E n in two ways: First, it exhibits optimal self-convergence in the sense that it is as accurate as the far-field and the continuous tangential field component. Second, it explicitly fulfills the boundary condition (5) at the material interfaces. Equally important, the improved near-field calculation is achieved with minimal additional computational cost and does not alter the mathematical framework of the core RCWA algorithm in 1D.

Formulation of accurate near-field evaluation for 2D-periodic structures
The ideas of the previous section are straightforward to implement because in 1D-periodic structures there is a trivial and unambiguous distinction between the tangential and normal components of E. However, this situation becomes more intricate in the case of 2D-periodic diffraction gratings.
As it will be shown now, accurate near-field evaluation is strongly related to correct Fourier factorization in 2D-periodic structures.
Fourier factorization means in this context the decomposition of a product of periodic functions, f = g · h, into its periodic factors g and h. Depending on the continuity properties of the factors and the product, different rules must be applied in order to obtain fast convergence when increasing the number of FS terms. According to these rules, if f and h possess simultaneous discontinuities, but g is continuous at those locations, the product rule yields fast convergence with respect to the number of FS terms, namely one uses f = g · h. Moreover, if g and h are simultaneously discontinuous, but f is continuous, the inverse rule should be used, i.e., f must be factorized as f = (1/g) −1 ·h. A rigorous explanation of these rules and the solution to the 1D Fourier factorization problem is given in [18].
Because of the trivial distinction between the continuous (tangential) and discontinuous (normal) components of the electric field in 1D, Fourier factorization is straightforward in that case. But for 2D-periodicity, three different approaches to achieve the correct Fourier factorization have been proposed: i) Approximate the material boundaries by a coordinatesaligned staircase-contour [19]. ii) Devise a coordinate system in which a given grating geometry is coordinate system aligned and use approach i to obtain the correct Fourier factorization [20,37]. iii) Construct a normal vector field (NVF) to decompose E into its normal and tangential components and then apply the corresponding correct factorization rules to them [21].
Since the accurate near-field evaluation relies on the decomposition of the electric field into normal and tangential components, it is natural to use the factorization approach (iii), the NVF approach. It is out of the scope of this paper to derive the full formulation of 2D-RCWA, so that only the crucial and unconventional steps will be given here. Thus, the normal and tangential components of D = εE have to be decomposed using the product-and inverse rule, respectively. This leads to the following relations for the α-component of the displacement field [21,24,38]: where δ αβ is the Kronecker delta.
Here, [f ] denotes the vector of FS coefficients of a scalar function f , g is the Toeplitz matrix of FS coefficients of g, and the matrix ∆ αβ is given by and N α is the α-component of the NVF, N = (N 1 , N 2 , N 3 ) T , of the material boundary. The matrix δ α,β ε − ∆ αβ implements the three steps of the Fourier factorization: the decomposition of E into normal and tangential components (N β in N α N β ), factorization using either the inverse rule ( 1/ε −1 ) or the product rule ( ε ), and back-projection to Cartesian coordinates (N α in N α N β ).
Note that one can also use asymptotically equivalent definitions of ∆ αβ . However, our investigations have shown that despite the fact that the choices ∆ αβ = ∆ N α N β and ∆ αβ = N α N β ∆ produce similar convergence speed, they do not conserve the power for lossless structures, whereas the choice ∆ αβ = N α ∆ N β yields power conservation but at the price of slower convergence. All three formulations are asymptotically equivalent with respect to the number of terms in the FS expansion, due to the commutation of Toeplitz operators [38].
Normal vector fields can be constructed analytically for a variety of structures and automated algorithms to obtain a NVF for arbitrary grating geometries have been developed [39]. It should be noted that this formulation allows inclined NVFs, i.e. NVFs with simultaneously non-vanishing x, y, and z components. Such a NVF is required to accurately model obliquely etched structures (see figure 1(d)) and hence can be viewed as a generalization of the methods presented in [24] (N y = 0, figure 1(b)) and [21] (N z = 0, figure 1(c)).
Given the constitutive relation (6), one can derive the RCWA eigenvalue-problem for the electromagnetic modes described by [S] and [U ] and propagation constant, β. The most general formulation of the system-matrix M reads: The matrices K α = diag (k αn ) are diagonal matrices of the in-plane propagation constants, k xn for α = x and k yn for α = y, of the diffraction orders and I is the identity matrix. The size of matrices B, C α , K α , and I is N 0 × N 0 , whereas the size of M is 4N 0 × 4N 0 , where N 0 = (2N + 1) 2 is the total number of FS coefficients in the calculation and the same number of FS terms for the truncation of the FS in the x-and y-direction is assumed.
The mode amplitudes [S] and [U ] are determined by matching the tangential components of the electromagnetic field at the top and bottom of the grating region, whereas multilayered structures are described by the staircase approximation in conjunction with the numerically stable S-matrix algorithm. This yields the FS coefficients, [E], of the electric field everywhere in the grating region, in the cover, and the substrate.
This relation does not take into account the continuity properties of the different components of E and hence will lead to spurious oscillations and slow convergence of the near-field as it was seen in section 2. The modified field evaluation for 2D-periodic diffraction gratings requires one to define the continuous normal component of D and the tangential component of E. Their FS coefficient vectors are given by:  (10) and is expected to yield fast near-field convergence and non-oscillatory spatial field profiles. To investigate the validity of these predictions, the accurate field evaluation was implemented in a commercially available RCWA computer software, OmniSim/RCWA [40].
It should be noted that the other electromagnetic fields can be easily calculated with our improved method, too. Specifically, the displacement field, D, can be evaluated using the modified electric fieldẼ, namely D (N ) (x) = ε 0 ε(x)Ẽ (N ) (x), and hence will have the same convergence properties asẼ. The magnetic induction B and the magnetic field H = µB do not require special attention, because they are continuous in non-magnetic materials and hence behave similar to the continuous tangential component of the electric field.

Quantification the accurate near-field evaluation in 2D-periodic structures
In this section, the improved formulation for accurate near-field calculations in 2D-periodic structures is assessed using two test structures under different configurations. To this end, we first extend the definition of the grating norm (2) of a scalar or vector function, f , to 2D-periodic structures in the following straightforward way: where the integral is evaluated over the threedimensional grating region.

Analysis of a 1D-periodic grating using 2D-RCWA
The first 2D-periodic diffraction grating under consideration is a 1D binary grating, as shown in figure 1(a), rotated by π/4 in the x − y-plane. It should be obvious that it can be modeled as a double-periodic 2D grating with periods Λ 1 = Λ 2 = √ 2Λ = √ 2 µm, whereΛ = Λ 1  is the period of the grating when it is viewed as a 1Dperiodic structure. For clarity, the primary unit cell of the grating is depicted in the inset of figure 6(a). With this choice, the reference quantities R ref , T ref , and E ref can be calculated using 1D simulations, an approach inspired by an example in [21].
The error in the calculation of the far-field, e F from equation (1), when 2D simulations are employed is depicted in figure 6(a). The convergence of the calculations for the silicon and gold gratings closely follows the convergence trends observed when 1D simulations are performed and, as expected, it shows somewhat worse, yet still good, agreement for the silica structure. This difference is explained by the fact that the NVF introduced in the 2D-RCWA formulation is discontinuous away from material interfaces and hence it can degrade the convergence rate, especially for the low-index of refraction contrast case.
The conclusions of our analysis of the convergence of the near-field are summarized in figures 6(b)-6(d). Thus, for both the silica and gold diffraction gratings, the normal component of the modified electric field, E, exhibits faster convergence than this same field component calculated using the conventional form of RCWA. In both cases, e Ẽ (20) n is one order of . For the silicon grating, only marginal differences between the two formulations can be observed. This is in agreement with the results obtained in the 1D case, as per figure 3(b).
For small N ,Ẽ (N ) and E (N ) are determined with a comparable degree of accuracy, but for the larger number of harmonics considered in figure 6(c), i.e. N = 30, a higher accuracy of our improved formulation of the RCWA can clearly be observed.
These conclusions are further validated by the profile of the electric field, as presented in figure 7. This figure shows the spatial distribution of the normal component of the electric fields, E (27) andẼ (27) , calculated in the median plane of the grating. A simple examination of these field profiles confirms that the spurious oscillations of the fieldẼ (27) near the surface have much smaller amplitude as compared to that of the variations of E (27) . Moreover, a closer inspection of the surface-fields shows that the boundary condition (5) is fulfilled byẼ (27) only. This first test-case already reveals that the improved near-field evaluation is more accurate in the case of 2D-periodic structures, too.

Near-field calculations for an intrinsically 2D-periodic grating
In order to thoroughly test the near-field evaluation for 2D-periodic structures using the improved RCWA presented in this article, in what follows we consider the challenging test structure depicted in figure 1(c). The grating region consists of a coordinate system aligned parallelepiped with the length of the sides aligned to the x-, y-, and z-axis being a = 0.5Λ 1 , 2a, and h, respectively, placed adjacently to a semicircular cylinder with radius a and height h, with Λ = Λ 1 = Λ 2 = 0.25 µm. The structure is illuminated normally  by a x-polarized plane wave with wavelength λ = 0.5 µm.
Since it is generally computationally time consuming to obtain high-accuracy solutions in the case of 2D-periodic structures and due to the fact that the higher the ratio Λ/λ and the refractive index |n|, the more harmonics are necessary to achieve convergence [34], a relatively small period-to-wavelength ratio of Λ/λ = 0.25 µm/0.5 µm = 0.5 is chosen for this example.
As reference values in the definition of the far-field error, e F from equation (1), T ref = T (31) and R ref = R (31) , namely results obtained from simulations with N = 31 are chosen. The convergence of the farfield, e F (N ), is shown in figure 8(a), where the farfield physical quantity considered are the transmission and reflection coefficients, T and R, respectively. As expected, the fastest convergence can be observed for the silica grating, because it has a low refractive index. The numerical error obtained for the gratings made of gold and silicon are one and two orders of magnitude larger than in the case of the silica grating, respectively. This behavior is similar to that seen in the 1D case for a small number of harmonics, N < 30 (cf. figure 2). Figures 8(b)-8(d) contain the dependence of the near-field self-error determined for the three material configurations, silica, silicon, and gold, respectively.
The three physical quantities plotted in each case are the z-component of E and the in-plane components, E xy := (E x , E y , 0) T andẼ xy := (Ẽ x ,Ẽ y , 0) T , obtained by using the conventional and improved versions of RCWA, respectively. Note that the inplane component contains the discontinuous normal component, N·E (N·Ẽ), and the continuous tangential component, ( It can be seen that in all cases, the z-component of E, which is continuous at vertical surfaces inside the grating region, converges much faster than the in-plane component, in both the conventional and modified formulations. In addition, the modified formulation leads to a somewhat smaller error than the conventional formulation. Specifically, it was found that e Ẽ (N ) Hence, the inexact field decomposition by N introduces an additional error. ii) The field of normal vectors characterizing the structure is only uniquely defined at the interfaces defining the grating, except at the corners, and, more importantly, away from the grating surface. This ambiguity allows and can lead to choices of NVFs, which are not optimal for the convergence and accurate calculation of the near-field. iii) The normal vector field itself has discontinuities, which can cause additional oscillations in the spatial profile of the electromagnetic field.
It is also worthwhile to investigate the spatial profile of the near-field. The dominant x-component of the electric field in a horizontal cross-section through the grating region at z = h/2 is depicted in figure 9. As in the 1D case, these maps show that the fieldẼ x exhibits spatial oscillations with smaller amplitude as compared to the variations of the field E x , especially at y-aligned interfaces (outlined with blue dashed lines in figure 9). dicular onto the grating plane. Each computational slice is assumed to be a z-independent structure, for which the eigenmodes can be found numerically by solving equation (7). The field in each computational layer is then found by using the boundary conditions at the top and bottom interfaces of the grating, employing a numerically stable S-matrix formulation. The validity of this staircase approximation for 1D-periodic gratings under TE-polarization has been proven in [34].
In the context of the NVF formulation of RCWA for oblique 1D-periodic structures, it has been found that the use of an out-of-plane NVF, i.e. N = (N x , 0, N z ) T , is beneficial for the far-field convergence speed [24,34]. In this section we will study the relation between the accurate field formulation (10) and the near-field convergence speed for slanted 1D-periodic structures.
The situation for oblique 2D-periodic structures has not yet been explored in the context of RCWA. However, based on the results presented so far, one can conjecture that both the near-and far-field convergence of RCWA can be improved by using an out-of-plane 3D NVF, N = (N x , N y , N z ) T = 0, and that the near-field evaluation would be more accurate as well. The validity of this supposition will be explored in the second part of this section.

Analysis of slanted 1D-periodic binary diffraction gratings
In order to analyze oblique 1D-periodic structures, we consider the slanted binary grating depicted in figure 1(b). The period of the grating is Λ = 1 µm, the filling factor, ρ = 0.5, the height, h = 0.25 µm, and the slanting angle is θ = π/4. Only the gold grating is considered in this section as this would be the most challenging case. If the unit cell is assumed to extend from x = −Λ/2 to x = Λ/2 and the center of the binary grating is set to be x = 0, z = h/2, a suitable out-of-plane NVF is given byÑ(x, y, z) = sign (x − z) √ 2 (1, 0, 1) T . The two formulations of the RCWA compared in this section are the in-plane NVF, which is used in conventional RCWA together with the conventional field evaluation (8), and the out-of-plane NVF, N, combined with the improved field evaluation formulation (10). In contrast to the results presented in the previous sections, the two formulations yield different results for both the near-and far-field quantities. Moreover, for the sake of the clarity of the presentation, all physical quantities corresponding to the out-of-plane NVF formulation are denoted with a tilde symbol.
Numerical results for increasing number of harmonics, N = 2, . . . , 320, and number of computational layers, M = 2, . . . , 256, are presented in figure 10. It can be inferred from this figure that the in-plane formulation requires both a high number of FS coefficients, N , and layers, M , to achieve convergence to a result of R ref = 0.28788, whereas the out-of-plane formulation yields fast convergence toR ref = R (320,256) = 0.28837 with respect to N , as per figures 10(a) and 10(b), respectively. This behavior is in agreement with the findings reported in [24]. The convergence of the calculated |E| a) Figure 11. a) Spatial distribution of the electric near-field, |E (40,256) x |, determined using the conventional in-plane NVF. b) Spatial distribution of the electric near-field, |Ẽ (40,256) x |, determined for the same grating parameters as in a) but using the modified out-of-plane NVF formulation.
near-field, illustrated in figures 10(c) and 10(d), exhibits similar features. Specifically, the in-plane NVF formulation requires both high N and M to achieve a small self-error of e E (226,256) = 4.7 · 10 −2 , whereas this self-error can already be achieved with N = 10, M = 256 in the out-of-plane formulation. This clearly demonstrates a drastically improved efficiency to the calculation of the near-field of oblique diffraction gratings of the approach based on the combination of outof-plane NVF and the accurate near-field formulation. The highly improved near-field profile is illustrated in figure 11(b), which exhibits no unphysical oscillations near the gold-vacuum interface. This is in sharp contrast to the conventional field evaluation of the in-plane formulation (cf. figure 10(a)), which clearly suffers from spurious oscillations.

Analysis of slanted 2D-periodic cylindrical diffraction gratings
In this section we investigate the efficiency of using the accurate field evaluation and the out-of-plane NVF formulation to model a challenging, slanted 2Dperiodic diffraction grating. The grating with periods, Λ 1 = Λ 2 = Λ = 1 µm, is schematically depicted in figure 1(d) and consists of a cylindrical rod with radius r = 0.3 µm and height h = 0.125 µm, which is slanted by θ = π/4 along the x-axis. Again, only the gold grating is considered in this section. Finally, the incident plane wave is impinging onto the grating along the normal direction, is polarized along the x-axis, and has a wavelength of λ = 2 µm.
The reflection coefficient calculated for N = 3, . . . , 19 harmonics and M = 2, . . . , 32 layers is shown  in figure 12(a) and figure 12(b) and was determined by using the conventional in-plane NVF and the out-of-plane NVF formulation, respectively. It can be seen that both approaches converge rather slow, neither one achieve convergence even for the highest considered values of M = 32 and N = 19. Moreover, in order to characterize the error of the near-field calculations in the two formulations, the self-error with respect to the reference solutions obtained with N = 19 and M = 32 is presented in figures 12(c) and 12(d). The in-plane formulation achieves a relative self-error of e E (13,32) = 0.625, whereas for the same values of N and M , the modified field evaluation in conjunction with the out-of-plane NVF achieves a substantially lower self-error of e E (13,32) = 0.261. It has to be stressed, that the necessary accuracy for full convergence could not be achieved in our simulations.
The evolution of the computational results for the shown values of N ≤ 19 and M ≤ 32 however can be interpreted in favor of the out-of-plane NVF formulation, due to the lower near-field selferror e E (13,32) < e E (13,32) . It can be supposed that future simulations with finer discretization will reveal the practical benefit of the out-of-plane NVF formulation in conjunction with the modified field formulation for 2D-periodic slanted structures, similar to the case of 1D-periodic slanted diffraction gratings.

Conclusions
To summarize, we have analyzed the numerical near-field calculated using the RCWA and identified the Gibb's phenomenon as the main reason for their slow convergence and the spurious oscillations from which they suffer.
As a solution to these deficiencies of RCWA, we proposed an improvement of this methods that can be applied for modeling arbitrary diffraction gratings and, more generally, periodic optical structures. The modified formulation significantly improves the accuracy of 1D-RCWA calculations, for both straight and slanted gratings, where it speeds up convergence and removes the numerical artifacts from the calculated near-fields. The accuracy of 2D-periodic grating simulations can be enhanced, however, to a lesser extent than in the 1D case. The reduced performance in 2D can be attributed to the discontinuity and non-exactness of the numerical NVF, which is at the core of the modified formulation. Therefore, it might be fruitful to investigate more elaborate NVF-formulations and their suitability for near-field calculations, such as a complex valued NVF [41], which unlike the NVF used here is continuous everywhere in the grating region.
We expect that the proposed modification of the RCWA method will greatly advance its computational capabilities, especially for 1D periodic optical structures. In particular, this improved method could prove instrumental to accurate modeling of periodic plasmonic structures, diffraction gratings, and surfacenonlinear devices, namely to simulation of physical systems whose functionality rely on the electromagnetic near-field at interfaces.