This work presents a novel finite element solution to the problem of scattering from an infinite periodic array of two-dimensional cavities in metallic walls. The finite element formulation is applied inside only one cavity to derive a linear system of equations associated with the nodal field values within the cavity. The surface integral equation employing the quasi-periodic Green's function is applied at the opening of the cavity as a boundary constraint to truncate the computational domain. Effect of the infinite array of cavities is incorporated into the system of the nodal equations by the quasi-periodic Green's function. The method presented here is highly efficient in terms of computing resources, versatile and accurate in comparison to previously published methods. The near and far fields are generated for array of cavities with different dimensions, periodicity, and fillings. The numerical simulation results are in close agreement with methods published earlier.
 Extensive recent interest in manipulation and localization of the light in novel applications of plasmonic resonance such as near-field microscopy, surface defect detection, subwavelength lithography, and developing tunable optical filters has renewed interest in modeling wave scattering from grating surfaces. When solving the problem of scattering from large periodic array of identical cavities or holes, it is useful to approximate the structure as an infinite array and take advantage of the periodicity of the electromagnetic fields. Several methods were reported in the literature to solve the problem of scattering from an infinite array of cavities or holes engraved in metallic or dielectric screens. Among these methods is the coupled-wave method (CWM) where the permittivity of the grating is expanded in the Fourier series and the component of the wave number along the grating is determined by the Floquet condition as given by Moharam and Gaylord . Theoretically, an infinite number of the space harmonics is needed to expand the fields. In practice, a large number of space harmonics must be considered to achieve accurate results. However, the convergence rate, especially for the TE polarization case (where the magnetic field has a component only along the axis of the cavities), is very slow as given by Li and Haggans .
 The problem of diffraction by an infinite periodic conducting grating was investigated using a hybrid method combining the finite element method (FEM) and the method of moments (MoM) by Gedney and Mittra . Using the equivalence theorem, the fields inside of the cavities or holes were decoupled from the outside region by closing the apertures with a perfect electric conductor (PEC) surface and introducing the equivalent magnetic currents over the openings. Using Floquet theorem, the scattered fields outside the cavities or holes are produced by the periodic equivalent magnetic current and the fields inside the single cavity or hole were calculated using FEM. Imposing field continuity as the boundary condition at the aperture of the single cavity or hole results in a set of equations describing the unknown equivalent magnetic current. The MoM is employed to determine the unknown magnetic current coefficients. In the works of Delort and Maystre  and Pelosi et al. , a hybrid FEM and Floquet mode expansion of the scattered fields was used to analyze the problem of scattering from periodic structures where the FEM is applied inside the unit cell which encloses all inhomogeneities and the periodic boundary condition is applied on the lateral boundaries of the unit cell. In addition, field continuity is forced on the upper and lower boundaries of the unit cell. In this method the upper and lower boundaries must be chosen in a homogenous medium (i.e., in upper half-space above the cavity) to achieve fast convergence that results in a prohibitive increase of the solution domain.
 In the work of Ichikawa , the finite difference time domain method (FDTD) is used to analyze the problem of electromagnetic scattering from a dielectric gratings. The FDTD algorithm is applied in the unit cell of the grating, including two different dielectric materials. The periodic boundary condition and the absorbing boundary condition (ABC) are applied on the lateral walls of the unit cell and top and bottom boundaries of the unit cell, respectively, to truncate the mesh region. Placing the ABC close to the scatterer results in nonphysical reflections into the solution region yielding numerical errors. To minimize these errors, the domain truncating boundaries (i.e., top and bottom boundaries) should be chosen far enough from the cavity. However, placing the boundaries of the computational domain far from the cavity leads to a prohibitive increase in the computational cost. The infinite array of bottle-shaped cavities is investigated by Depine and Skigin  using the mode-matching technique (MMT). Although the mode-matching technique is a highly accurate and efficient, it cannot be used for cavities having inhomogeneous or anisotropic fillings.
 Recently, the method of moment is applied to solve the problem of scattering from an infinite array of rectangular cavities in an impedance screen as given by Baranchugov et al. . The image theory is applied to reduce the infinite array to a single cell of one period. Due to the periodicity, the scattered fields are expanded in terms of Floquet series. Also the fields inside the cavities are expressed in terms of the eigenfunction series of the parallel plate waveguide with impedance walls. By forcing the continuity of the fields at the aperture of the cavity, the integral equation is derived and solved using the MoM. Another method using the overlapping T-block method (OTM) and the Floquet theorem was reported by Cho . The array is divided into the infinite T blocks associated with each cavity. The fields inside each T block are calculated using the Green's function and the mode-matching techniques. By superposing the fields in overlapping T blocks and using the Floquet theorem, the total fields are expressed in the closed form. However, this method is limited to cavities with canonical shape and homogenous fillings.
 In this paper we develop a new FEM-based method to solve the problem of scattering from an infinite periodic array of identical cavities engraved in an infinite perfect electric conductor screen. Using the two-boundary formulation that was initially reported by McDonald and Wexler  and then applied to the problem of finite array of cavities by Alavikia and Ramahi , the solution domain is confined to only one cavity that is divided into interior and exterior regions. The finite element formulation is applied inside the interior regions to obtain the solution of the Helmholtz's equation. The surface integral equation using the free-space Green's function, which was reported by Alavikia and Ramahi , is applied at the openings of all cavities as a global boundary condition. Taking advantage of the field's periodicity at the apertures of the cavities, the free-space Green's function is replaced by the quasi-periodic Green's function, thus limiting the surface integral equation to the aperture of only one cavity. The Neumann or Dirichlet boundary condition is applied on the wall of the cavity for the TE or TM polarization, respectively. The advantage of this method is that no periodic boundary condition that would require a constrained mesh scheme is used in this formulation. Also, we emphasize that in the method presented here, the surface integral equation using the quasi-periodic Green's function is used to derive a linear system of equation as a constraint that connects the field values on the boundary to the field values on the apertures of the single cavity in the array by considering the coupling between all cavities. The attractive feature of two-boundary formulation combined with quasi-periodic Green's function is that no singularities in Green's function arises while applying the surface integral as a boundary constraint.
2. Finite Element Formulation of the Problem
Figure 1 shows a two-dimensional (2-D) perfectly conducting screen containing infinite periodic identical cavities illuminated by an obliquely incident plane wave. The periodicity and width of the aperture of the cavities are denoted by P and W, respectively. θinc represents the angle of the incident wave, and uinc, uref, and us denote the incident and reflected fields from the PEC screen and scattered field from the aperture of the cavities, respectively, along the axis of the cavities. The infinite periodic array of cavities can be divided into unit cells. The width of each unit cell equals the periodicity of the array. We index the unit cells by p where p = −∞…, −1, 0, 1, …∞.
Figure 2 shows three successive unit cells as part of an infinite array of cavities. For a cavity in each unit cell (i.e., the pth unit cell), we define ΓB to be the contour at the opening of the cavity and ΓO as the top contour in close vicinity of ΓB such that the region between ΓB and ΓO is devoid of field nodes. Also let Ωinp denote the interior region of the pth cavity bounded by the PEC surface of the cavity and ΓO. We use finite element formulation inside Ωinp to obtain the weak form of Helmholtz's equation:
where ut is the total field. The time harmonic factor exp(jωt) is assumed and suppressed throughout. (x, y) and (x, y) are defined as μr (x, y) and ɛr (x, y), respectively, for the TM polarization, or ɛr (x, y) and μr (x, y), respectively, for the TE polarization, and k0 is the propagation constant of the wave in free space. The weighted-residual integral is defined as
where wi is the weighting function.
 Next, the solution domain Ωinp is discretized into triangular elements. We emphasize, however, that rectangular or other types of elements can be used without affecting the theoretical development presented here. The unknown field over each element is described by a set of interpolating functions given by
where m is the number of nodes at which the unknown field is defined, and αi (x, y) is an interpolation function. Using the Galerkin's method, we set wi = αi (x, y). Consequently, the residual matrix R can be expressed as
where [u]p represents the unknown field value at each node of the pth cavity. The [F]p matrix represents impressed sources at each node; therefore, for the problem of scattering from cavities considered in this work, [F]p is zero. Equation (4) can be represented symbolically as
where ui, ub, and uo represent nodal field values inside the cavity, on ΓB, and on ΓO, respectively. Extending the formulation to all cavities, Ωin−∞ … Ωin∞, we have the following system of matrix equations:
where each matrix equation in the system in (6) can be represented symbolically as equation (5).
 The systems of equations in equation (6) are coupled to each other only through the surface integral equation. It is impossible to solve all systems of equations in equation (6) simultaneously. In the next section, we develop an algorithm that solves the problem of array of infinite cavities by considering only one system of equations corresponding to a single cavity while incorporating the effect of all other cavities. This will be accomplished by making use of the quasi-periodic Green's function in conjunction with the surface integral equation. More specifically, the linear system of equations in equation (5) represents the relationship between the nodal field values for the pth cavity without any external constraint represented by the infinite array of cavities and incident plane wave. The imposition of a specific excitation represented by the incident plane wave has to be taken into consideration through a boundary constraint that establishes a relationship among the incident field, the boundary nodes, and the interior nodes.
3. Surface Integral Equation
 The surface integral equation using the free-space Green's function will first be used to express the nodal field values on ΓO of each cavity in terms of the nodal field values on ΓB of all cavities (see Figure 3). Next, we develop an algorithm to limit the surface integral equation to the aperture of one cavity by replacing the free-space Green's function by the quasi-periodic Green's function that takes into account the effect of all cavities.
3.1. Surface Integral Equation for TM Polarization
 For TM polarization where the electric field vector is parallel to the axis of the cavities, the surface integral equation is written as given by Alavikia and Ramahi 
where ρ and ρ′ represent the position of the nodes on ΓO and ΓB, respectively. Note that the integration is performed only at the aperture of the cavities. Ez(ρ) on the left-hand side of the equation (7) represents the total field value at any point in upper half-space above the cavities. Also Ezinc(ρ) and Ezref(ρ) on the right-hand side represent the incident field and reflected field by the PEC screen, respectively. The last term in equation (7) represents the scattered field due to aperture of the cavities. In equation (7), Ge(ρ, ρ′) is the free-space Green's function of the first kind satisfying the boundary condition Ge(ρ, ρ′)|y=0 = 0 (i.e., Ge = 0 on Γ) and the Sommerfeld radiation condition at infinity. Ge(ρ, ρ′) is found to be the zeroth-order Hankel function of the second kind:
 In equation (7), each node on ΓO is connected via the surface integral equation to the all nodes on the aperture of all cavities, ΓB (see Figure 3). In other words, the cavities are coupled to each other only through the surface integral equation.
 To calculate the last term in equation (7), the aperture, ΓB of each cavity, and ΓO are discretized into n segments with length of Δx′. We then expand Ez(ρ′) over ΓB in terms of piecewise linear interpolating functions as
where x′ and y′ are Cartesian components of ρ′. Equation (7) can be represented in discrete notation as
where uoip and Tip represent Ez(ρ) and [Ezinc(ρ) + Ezref(ρ)], respectively, at the ith node on the ΓO of the pth cavity. Also the ubjq represents Ezj at the jth node on the ΓB of the qth cavity. It is noticeable that in equation (10), integration is performed on the jth segment of the ΓB of the qth cavity.
 Physically, the cavities are indistinguishable in structure, therefore we expect similar distribution of the field magnitude at the apertures of all cavities. Now, we assume similar discretization of ΓB of all cavities. This assumption does not pose any limitation on the generality and versatility of this method but helps to simplify the algorithm by using Floquet theorem. In practice we create a mesh and apply the formulation on one cavity. By similar discretization of the ΓB of all cavities and same local numbering of the nodes, the total field value at two nodes with same position with respect to the edge of the cavities (i.e., the jth nodes of the qth and pth cavities) are related as
where k0|| = k0 sin(θinc) and P is periodicity of the array. Note that the coordinates of such nodes are related as
 Without loss of generality, we choose p = 0 for a cavity located at the origin and suppress the superscript p throughout. Replacing equation (11) and equation (12) into equation (10) results in the following:
 Note that since the mesh scheme is assumed to be identical for all cavities, the interpolating function ψj(xj′ + qP) is the same as ψj(xj′). Changing the order of the summations and integral, equation (13) can be rewritten as
 The quasi-periodic Green's function of the first kind for the periodic structures is defined as
 By replacing the sum containing the free-space Green's function with the quasi-periodic Green's function as in equation (15), the surface integral equation is limited to the aperture of one cavity only. Equation (14) can be represented in matrix form as
3.2. Surface Integral Equation for TE Polarization
 For the TE polarization where the magnetic field vector is parallel to the axis of the cavities, the surface integral equation is written as given by Alavikia and Ramahi 
 The integration is performed at the aperture of all cavities. Similar to the TM case, Hz(ρ) on the left-hand side of the equation (19) represents the total field value at any point in upper half-space above the cavities. Also Hzinc(ρ) and Hzref(ρ) on the right-hand side represent the incident field and reflected field by the PEC screen, respectively. The last term in equation (19) represents the scattered field due to aperture of the cavities. In equation (19), Gh (ρ, ρ′) is a free-space Green's function of the second kind satisfying the boundary condition ∂Gh(ρ, ρ′)/∂n′∣y=0 = 0 (i.e., ∂Gh(ρ, ρ′)/∂n′ = 0 on Γ) and the Sommerfeld radiation condition at infinity. Therefore Gh(ρ, ρ′) can be represented in terms of the zeroth-order Hankel function of the second kind as
 To calculate the last term in equation (19), the partial derivative ∂Hz(ρ′)/∂n′ can be conveniently expressed as a first-order finite difference as
(note that the negative sign on the right-hand side of equation (21) is because = −), and then the aperture ΓB, and ΓO of each cavity are discretized into n segments with length of Δx′. By expanding both Hz(y) and Hz(y′) over the aperture of the cavity in terms of step functions as
 In equation (23), uoip, and Tip represent Hz(ρ) and [Hzinc(ρ) + Hzref(ρ)], respectively, at the ith node on the ΓO of the pth cavity. The uojq and ubjq represent nodal field value at the jth node on the ΓO and ΓB of the qth cavity, respectively. Note that in equation (23), the integration is performed on the jth segment of the ΓB of the qth cavity.
 By considering the fact that the cavities in the infinite array are identical, and assuming similar discretization of the ΓB and ΓO of the all cavities, we can express the field values and coordinates of the two nodes with same position in two different cavities through equations (11) and (12). Similar to the TM case, without loss of generality, we choose p = 0 for a cavity located at the origin and suppress the superscript p throughout. Replacing equations (11) and (12) into equation (23) results in the following:
 In equation (24), we can replace the interpolating function ψj(xj′ + qP) with ψj(xj′) since we assumed identical mesh scheme at the aperture of all cavities. By changing the order of summations and integral, equation (24) can be rewritten as
 The quasi-periodic Green's function of the second kind for the periodic structures is defined as
 Similar to the TM case, by replacing the sum containing the free-space Green's function with the quasi-periodic Green's function, the surface integral equation is limited to the aperture of one cavity. Equation (25) can be represented in matrix form as
 Once the system of equations, equation (18) for the TM polarization or equation (30) for the TE polarization, is derived, its solution, which is the field values at the aperture of the pth cavity, can be obtained using commonly used methods for solving linear systems. Using equation (11), the field values at the aperture of any cavity can be determined. Since structures having infinite periodic cavities are nonphysical, the infinite periodicity is typically used to approximate an array with large number of cavities where the interest lies in determining the field distribution at the center of the array. In this section, we provide examples of infinite array of cavities with different dimensions, periodicity, and fillings.
 To validate the method presented here, comparison was made to the results calculated by the finite element method using local boundary conditions and the MMT. While using finite element method for the comparison purpose, the solution region was bounded to a unit cell and the periodic boundary condition (PBC) was applied at the lateral boundaries of the unit cell. To truncate the computational domain above the unit cell, we employed either second-order Bayliss-Grunzburger-Turkel (BGT-II) boundary operator or the perfectly matched layer (PML). Throughout this work, we refer these solutions as FEM-BGT-II and FEM-PML, respectively. Without loss of generality, the magnitude of the incident electric field is assumed to be unity throughout this work. The solution domain is discretized using first-order triangle elements with mesh density of approximately 20 nodes per λ for the TM case. Since there is a discontinuity in the electric field at the edges of the cavities in the TE case, we use mesh density of 100 nodes per λ.
 In the first example, we consider an infinite array of 0.6λ × 0.4λ (width × depth) rectangular cavities where λ is the wavelength in free space. The periodicity of the array is P = 1λ. The cavities are filled with material having relative permittivity of ɛr = 1.4 − j0.01. Figure 4 shows the total electric field at the aperture of the 0th cavity for TM incident plane wave for an obliquely incident angle of 30°. The results in Figure 4 show strong agreement between the calculations using our method and those calculated using FEM-BGT-II and FEM-PML. However, it is important to note that the necessary computational domain to achieve the accurate results in FEM-BGT-II and FEM-PML is 4λ2 and 1.2λ2, respectively. On the other hand, the solution region in our method is confined only to the area of the cavity, which is 0.24λ2. The large solution region used in the FEM-BGT-II and FEM-PML solutions is needed to minimize the effect of evanescent waves on the absorbing boundary condition or PML at the top boundary. The solution time needed for the methods employing PML and BGT-II were approximately 75 s and 220 s, respectively, while only 9 s were needed to solve the same example using the method of this paper. We emphasize, however, that all our algorithms were not necessarily optimized for maximum efficiency; nevertheless, this solution-time comparison gives a perspective on the difference in execution time between the different methods. Figure 5 shows the total magnetic field at the aperture of the 0th cavity in the same array for the case of TE incident plane wave. The results in Figure 5 shows strong agreement between the results obtained by this method and those obtained using FEM-BGT-II. We observe, however, a small deviation between results obtained by our method and those obtained by the mode-matching technique when applied to a finite array of 31 cavities.
 To show the versatility of the proposed method in solving cavities with inhomogeneous fillings, we consider an infinite array of 0.9λ × 0.5λ rectangular cavities filled by three layer of dielectric materials as shown in the inset of Figure 6. The layers have equal width of 0.3λ. The center layer has a permittivity of ɛr = 4 while the other layers have a permittivity of ɛ = 2.1. The periodicity of the array is P = 1λ. Figure 6 and 7 show the total electric and magnetic fields at the aperture of the 0th cavity for an obliquely incident plane wave with incident angle of 10°, for the TM and TE cases, respectively. The results show strong agreement between the results obtained using our method and those obtained using FEM-BGT-II. The computational domain needed for the FEM-BGT-II solution is approximately 11 times larger than that used by our method.
 Next, we consider an infinite periodic array of bottle-shaped cavities engraved in a PEC surface. This problem was presented by Depine and Skigin . The schematic of the bottle-shaped cavity is shown in Figure 8. The cavities have minimum and maximum widths of w1 = 0.4λ and w2 = 1λ, respectively. Also the total depth of the cavities is d1 + d2 = 0.4λ + 0.5λ = 0.9λ. The neck and the body of the cavities are filled by dielectric materials with permittivities of ɛr1 = 2.1 and ɛr2 = 4, respectively. The periodicity of the array is P = 1.2λ. Figure 9 shows the total electric field at the aperture of the 0th cavity for a TM incident plane wave having incident angle of 45°. The results in Figure 9 show strong agreement between the calculations using our method and those calculated using FEM-BGT-II.
 To validate the far-field calculation using the method proposed in this work, we consider an infinite array of air-filled bottle-shaped cavities with the dimensions similar to those of Depine and Skigin . Figure 10 shows grating efficiency of the zero-order diffraction as a function of the depth of the cavities for TM-polarized obliquely incident plane wave. The results in Figure 10 show strong agreement between our calculation and those of Depine and Skigin  that were obtained using modal methods.
 The finite element method and the surface integral equation were used to solve the problem of scattering from an infinite array of two-dimensional cavities in metallic walls. The surface integral equation as a global boundary condition using the quasi-periodic Green's function was used to truncate the solution region to one cavity, resulting in a highly efficient solution procedure. In this formulation, no singularities in the quasi-periodic Green's function arise while applying the surface integral equation as a boundary constraint. The formulation is based on the total field and is applicable to both TM and TE polarizations. Numerical examples were presented for infinite array of cavities with different dimensions, spacing, and fillings. The solutions using the method presented in this work were in close agreement with other methods presented in the literature. Furthermore, our method is very versatile in handling infinite arrays of cavities with complex shapes and inhomogeneous fillings without any modification to the algorithm. The run-time and solution efficiency of our technique are two major attractive features, making it well suited for optimization problems involving scattering from infinite gratings in metallic screens. Finally, we note that the method presented here imposes no restriction on the size of the cavities, thus making it suitable for the important class of problems involving scattering from a periodic array of subwavelength cavities.
 This work was supported by Research in Motion and the Natural Sciences and Engineering Research Council of Canada under the RIM/NSERC Industrial Research Chair Program.