# Grating projections in DGTD overview

Grating projections calculate the far field from a sample of the near field in a periodic structure or grating. The near field data is typically collected over a unit cell of the periodic structure using a frequency domain monitor. A grating projection decomposes the near field into a discrete set of plane waves propagating at different angles and returns the relative power carried by each of them.

If your structure is not periodic, consider using far field projections. If you're using FDTD, see Grating projections in FDTD overview.

## Calculating a grating projection

To perform a grating projection, a script command called gratingprojection is provided within the DGTD script environment. This command requires four different inputs, which typically come from four different objects in a simulation. The next section describes what the necessary inputs are and how to collect them.

## Inputs

- An unstructured data set with the near \(\overrightarrow{E}\) field as an attribute named 'E'. The attribute must be parameterized by frequency or wavelength. Such a data set is provided as a standard result by frequency domain monitors in DGTD. The grating projection command automatically calculates the far fields for all the frequencies specified in the frequency parameter.
- The periodicity vectors \(\overrightarrow{p}_{1}\) and \( \overrightarrow{p}_{2}\) of the structure (see the above diagram). These can be retrieved directly from the DGTD solver object using the getperiodicity script command.
- The normalized wave vector \(\hat{k}\) of the source. The normalized wave vector can be collected directly from a Gaussian or plane wave source using the getsourcedirection script command.
- The background refractive index \(n_s\) of the medium where the near \(\overrightarrow{E}\) field was sampled. The electric field must be sampled over a cross section of the unit cell (\(S\) in the above diagram) where the refractive index is uniform. The refractive index of any material for any given frequency can be retrieved using the getdgtdindex script command.

## Results

The grating projection command returns the relative power carried by each plane wave propagating in each of the allowed propagation angles. To preview the grating angles without having to compute a full far field decomposition, the gratingorders script command is provided. The remaining sections describe the results returned by the grating projection and grating order commands.

## Grating orders

The allowed propagation angles are determined by a set of integers \(n,m\) usually referred to as the grating orders. The values of \(n,m\) that correspond to propagating plane waves are determined by the grating conditions:

$$\left|\frac{1}{n_s}\left((\hat{k}\cdot\hat{p_1})\;\hat{p_1} + n\;\frac{\hat{p_1}}{|\overrightarrow{p}_1|}\lambda_0\right)\right|\leq1 \quad \forall \quad n=\{...-2,-1,1,0,1,2,...\}$$

$$\left|\frac{1}{n_s}\left((\hat{k}\cdot\hat{p_2})\;\hat{p_2} + m\;\frac{\hat{p_2}}{|\overrightarrow{p}_2|}\lambda_0\right)\right|\leq1 \quad \forall \quad m=\{...-2,-1,1,0,1,2,...\}$$

The grating projection and grating order commands use these conditions to determine the set of positive and negative values of \(n,m\) that support propagating plane waves given the input source wave vector \(\hat{k}\), periodicity vectors \(\overrightarrow{p}_{1}\) and \( \overrightarrow{p}_{2}\), and free space wavelength \(\lambda_{0}\).

## Wave vectors

For each pair of \(n,m\) values, there is a corresponding set of angles specifying the direction in which each plane wave propagates. These grating angles are defined with respect to a set of unit vectors \( \hat{u}_{nm} \) pointing in the direction of the wave vector \(\hat{k}_{nm}\) of each propagating plane wave. The \( \hat{u}_{nm} \) unit vectors are calculated from the periodicity vectors \(\overrightarrow{p}_{1}\) and \( \overrightarrow{p}_{2}\) and the normalized source wave vector \(\hat{k}\) in the following manner:

$$\hat{u}_{nm}=\left(\sqrt{1-|\overrightarrow{t}_{nm}|^{2}}\right)\hat{n}+\overrightarrow{t}_{nm}$$

$$\hat{n}=\text{sign}\left(\hat{k}\cdot\hat{p}_1\times\hat{p}_2\right)\hat{p}_1\times\hat{p}_2$$

$$\overrightarrow{t}_{nm}=\frac{1}{n_s}\left(\hat{k}-\left(\hat{k}\cdot\hat{n} \right)\hat{n}+\lambda_0\left(n \frac{\hat{p_1}}{|\overrightarrow{p}_1|}+m \frac{\hat{p_2}}{|\overrightarrow{p}_2|}\right)\right)$$

The intermediate unit vector \(\hat{n}\) (not to be confused with the grating order index \(n\)) is simply a unit vector normal to the plane defined by the two periodicity vectors \(\overrightarrow{p}_{1}\) and \(\overrightarrow{p}_{2}\). The intermediate vector \( \overrightarrow{t}_{nm}\) represents the projection of the \(\hat{u}_{nm}\) unit vector into the plane of periodicity defined by \(\overrightarrow{p}_{1}\) and \(\overrightarrow{p}_{2}\). The wave vectors of each plane wave can be easily constructed from the \( \hat{u}_{nm} \) vectors:

$$\overrightarrow{k}_{nm}=k_0 n_s\hat{u}_{nm}, \quad k_0=\frac{2\pi}{\lambda_0}$$

To give users the ability to compute the wave vectors for every propagating plane wave, the \( \hat{u}_{nm} \) unit vectors are returned as a results of the grating projection and grating order script commands. Observe that, for a 2D simulation with only one dimension of periodicity, the second periodicity vector will vanish and the only possible solution to the second grating condition is \( m=0 \).

## Grating angles

The grating angles are defined with respect to the \( \hat{u}_{nm} \) vectors as shown in the following diagram:

The grating order and grating projection commands compute angles \(\theta_{nm}\) and \(\phi_{nm}\) as follows:

$$\theta_{nm}=\text{cos}^{-1}\left(\hat{p}_1\times\hat{p}_2\cdot\hat{u}_{nm}\right), \quad 0\leq\theta_{nm}\leq180^o$$

$$\phi_{nm}=\text{tan}^{-1}\left(\frac{\hat{p}_2\cdot\hat{u}_{nm}}{\hat{p}_1\cdot\hat{u}_{nm}}\right), \quad -180^o\leq\phi_{nm}\leq180^o$$

For a 2D simulation with \(\overrightarrow{p}_{1}\) as the only one direction of periodicity, index \(m\) vanishes, \(\phi_n=0\) for all \(n\), and the grating angle \(\theta_{n}\) is computed as follows:

$$\theta_{n}=\text{sin}^{-1}\left(\hat{p}_1\cdot\hat{u}_{n}\right), \quad -90^o\leq\theta_{n}\leq90^o$$

## Relative power

Finally, the key result in a grating projection is the power carried by each propagating plane wave in the far field. The average power \(P_{nm}\) (in Watts per square meter) carried by each grating order can be determined by performing the following integral:

$$ P_{nm} = \frac{n_s}{2\eta_{0}} \left|\left| \int_{S} \overrightarrow{E} e^{-i(\overrightarrow{r}\cdot\overrightarrow{k}_{nm})} \hat{n} \cdot d\overrightarrow{S} \right|\right|^2 $$

where \( \eta_{0} \) is the intrinsic impedance of free space, \(n_s\) is the refractive index of the background medium and \( \overrightarrow{k}_{nm} \) is the wave vector of each plane wave propagating in the far field. Notice that the unit vector \(\hat{n}\), which is normal to the plane of periodicity, is parallel to the differential element of area \(d\overrightarrow{S}\) only for a flat axis aligned monitor. If a curved monitor is used as implied in the first diagram, the inner product \( \hat{n} \cdot d\overrightarrow{S} \) is spatially dependent. The above power result is returned by the grating projection command normalized so that the sum of the power into all grating orders is equal to one.

### Related publications

Allen Taflove, Computational Electromagnetics: The Finite-Difference Time-Domain Method. Boston: Artech House, (2005).

John B. Schneider, Understanding the Finite-Difference Time-Domain Method, Chapter 14: Near-to-Far-Field Transformation, (2010).

### See also

Grating projections in FDTD overview

Grating projection script commands