The Lumerical Sub-Wavelength Model (LSWM) can be used to model nanoscale structures with planar layers and/or periodic patterning as optical property in Ansys Speos or Zemax OpticStudio for optical simulation. Typical examples of these structures are coatings and diffraction gratings with feature sizes comparable or smaller than the wavelength of light. The data describing the surface scattering is saved in a JSON file format and loaded in Speos or Zemax OpticStudio as a surface property.

This article explains how to extract the scattering data from simulation with Lumerical solvers. For information on how to use the LSWM in Speos see Lumerical Sub-wavelength Model: Usage in Speos. For information on how to use the LSWM in Zemax OpticStudio see How to load grating data from Lumerical into OpticStudio.

## Introduction

With the LSWM, the coating or diffraction grating is simulated in Lumerical FDTD, RCWA, or STACK and the properties of the surface are saved in a JSON data file. This data file can then be imported into Speos or Zemax OpticStudio as a surface property to model the properties of the subwavelength structures in a ray tracing simulation. Different solvers are used for different types of structures:

- Coatings are modelled as surfaces with specular scattering and transmission. They can be simulated with Lumerical STACK.
- Diffraction gratings, which are periodic devices, are modelled as surfaces that scatter light to the supported grating orders. The LSWM model supports 1D and arbitrary 2D grating lattices. The diffraction gratings can be simulated with Lumerical FDTD or RCWA. For a comparison between FDTD and RCWA, please see the RCWA Solver Introduction.
- Idealized coating or grating properties can also be generated with a Lumerical script and exported to a data file.

**Note:** Lumerical FDTD and RCWA currently support only 1D or 2D cartesian gratings, or gratings that can easily be simulated as a cartesian grating, such as a triangular lattice where the unit cell can be doubled in size to create a rectangular unit cell. However, the LSWM does allow for arbitrary 2D lattice data in the JSON file.

## Exporting Surface Properties from Lumerical

A script-based approach is used to calculate and export the surface properties from Lumerical tools. The attached script files contain functions that automate running the required simulations and saving the results in the correct format. The required functions can be imported into the **Script Workspace** using the script command feval to load the corresponding file with the function definitions.

The user must define the range of incident angles and wavelengths that will be calculated. It is always assumed that the Z axis is normal to the surface. The directions of incident light are defined using theta and phi angles in these examples. The precise definition is given in the Appendix. Note that if a single value is specified for theta, phi or wavelength, then the surface is assumed to be independent of that variable. For example, for an azimuthally symmetry coating, a single value \(\phi = 0\) should be used. Similarly, for a wavelength-independent surface, a single value of wavelength should be used.

The general workflow for exporting surface properties from simulations is as follows:

- Define the sub-wavelength geometry, material properties, and required simulation objects. In the case of STACK this may be done entirely in script.
- Define the wavelength and range of incident angles for the source in a script file.
- Run a script file to launch the necessary simulations and export the results to a JSON file.

The details of these steps will depend on the type of surface and the solver used for the simulation. In each case a driver script (“GratingExport_*_workflow.lsf”) is necessary to call all the required functions from the “GratingExport_*_functions.lsf” scripts. For a detailed description of the syntax and parameters for these functions, see the header section of the corresponding script file.

The “GratingExport_utility_functions.lsf” script file contains general-purpose functions that can be used along with the solver-specific ones. The main utility functions are:

- “WriteGratingData” to write the JSON file that can be imported into Speos or Zemax OpticStudio with the data from RCWA/FDTD.
- “ReadGratingData” to read the data from a JSON file and save it as matrix datasets that can be easily visualized.
- “validateWithLegacySupport” to check the format of the generated JSON file against the provided file “schema grating-surface-schema.json”.

### Coatings (STACK)

When simulating coating structures with the STACK solver, the geometry and simulation parameters are all defined in a script file. The “layerSTACK” and “dielectric_interface” functions in the file “GratingExport_STACK_functions.lsf” run the STACK simulations and export the results to JSON file. The detailed description of the function can be found in the header of the file "GratingExport_STACK_functions.lsf". It is worth noting that most of the arguments of the “layerSTACK” function are identical to the arguments of stackrt script command.

For an example script that uses these functions to run a STACK simulation, see “GratingExport_STACK_workflow.lsf”.

### Diffraction Gratings (RCWA)

As with a typical RCWA simulation, the geometry and material properties are defined in an FSP file. The span of the RCWA simulation is defined by an FDTD simulation region. Only the geometry objects and the FDTD region are required for the FSP file. The x and y spans of the RCWA solver (in other words, the grating periodicity) will be taken from the FDTD region.

The “RCWAGratingSimulations” function in the “GratingExport_RCWA_functions.lsf” file is used to run the RCWA simulations and extract the results into a struct that can be passed to the “WriteGratingData” function in the “GratingExport_utility_functions.lsf” file to generate the JSON data file for Speos or Zemax OpticStudio simulation.

#### RCWA Workflow Example

For an example script that uses these functions to run an RCWA simulation, see “GratingExport_FDTD_RCWA_workflow.lsf”.

Initially, we suggest running GratingExport_FDTD_RCWA_workflow.lsf with only normal incidence light and 25 wavelengths. This allows us to quickly compare the FDTD and RCWA results. Later, a full range of angles and wavelengths can be simulated relatively quickly using RCWA. The key settings in GratingExport_FDTD_RCWA_workflow.lsf for an initial run are:

- solver = “RCWA”
- theta_min = theta_max = 0 and N_theta = 1
- phi_min = phi_max = 0 and N_phi = 1
- wavelength_start = 0.4 microns, wavelength_stop = 0.7 microns and N_wavelength = 25
- num_layers = 10
- num_k_vectors = 10
- grating_dimension = 1 because this is a 1D grating defined in the x-z plane

Running this file will create the JSON file for Speos or Zemax OpticStudio and then load it for schema validation and visualization using the “ReadGratingData” and “validateWithLegacySupport” utility functions. For example, to look at the transmission from air to glass, for the 3 different orders, for S polarized light, we can look at the third visualizer (“RCWA_upper_T” data set) with these settings:

### Diffraction Gratings (FDTD)

There are many similarities between the workflow for FDTD and RCWA diffraction grating simulations. As with the RCWA workflow, an FDTD grating simulation needs to be set up in an FSP file. The FSP file must include an FDTD simulation region and the “Grating S parameters” analysis group from the Object Library. This FDTD simulation will be run as-is by the export workflow, so simulation settings like boundary conditions and simulation time should be set properly by the user in this file.

Unlike the RCWA workflow, there are separate functions for running the FDTD simulations (“RunFDTDGratingSimulations”) and converting the data into the correct format (“LoadFDTDGratingSimulations”). Both functions are found in the “GratingExport_FDTD_functions.lsf” file (see header for more information).

The “LoadFDTDGratingSimulations” function returns a struct with the same format as “RCWAGratingSimulations”, and so the rest of the workflow is the same as for RCWA: the data in the struct is saved in JSON format (“WriteGratingData”), which can also be validated (“validateWithLegacySupport”) and visualized (“ReadGratingData”).

#### FDTD Workflow Example

For an example script that uses these functions to run an FDTD simulation, see “GratingExport_FDTD_RCWA_workflow.lsf”.

As mentioned in the RCWA section, we initially suggest running GratingExport_FDTD_RCWA_workflow.lsf with only normal incidence light and 25 wavelengths to quickly compare the FDTD and RCWA results. The key settings in GratingExport_FDTD_RCWA_workflow.lsf for an initial run with FDTD are

- solver = “FDTD”
- theta_min = theta_max = 0 and N_theta = 1
- phi_min = phi_max = 0 and N_phi = 1
- wavelength_start = 0.4 microns, wavelength_stop = 0.7 microns and N_wavelength = 25
- source_type = 1 which disables BFAST. This is appropriate because we are only simulating at normal incidence.

Running this file will create the JSON file for Speos or Zemax OpticStudio and will open four visualizers to show the results. For example, to look at the transmission from air to glass, for the 3 different orders, for S polarized light, we can look at the third visualizer with these settings, which we see compares favorably with the RCWA results shown above:

### Comparing FDTD and RCWA

After running both the simple FDTD and RCWA examples above, you can run the script file compare_FDTD_RCWA_results.lsf. It reads both JSON files and displays each of the 4 results in the same visualizer. It also plots the transmission from air to glass for the 3 supported orders as a function of wavelength for S and P polarization, shown below. We can see good agreement between the solvers, which could be further improved by increasing the mesh accuracy in FDTD (beyond the current setting of 2) and by increasing the number of layers and number of k vectors in RCWA.

### Example: Full Grating Characterization

To create a JSON file which fully characterizes the structure for all angles of incidence and wavelengths, the following changes to the GratingExport_FDTD_RCWA_workflow.lsf file can be made:

solver = “RCWA”

theta_min = 0, theta_max = 85 and N_theta = 18 which gives 5 degree increments

phi_min = 0, phi_max = 360 and N_phi = 37, which will give 10 degree increments

wavelength_start = 0.4 microns, wavelength_stop = 0.7 microns and N_wavelength = 25

This can take one to several hours on a computer to complete. The same process can be done in FDTD but it would typically take much longer.

### Idealized Surfaces

The “GratingExport_test_functions.lsf” script file contains several functions for creating the JSON files for idealized surface structures without the use of simulation. The following surface types can be created:

- Specular reflection with user-specified transmission/reflection (“simpleRT”)
- Surfaces based on Jones matrices (“jonesMatrix”)
- Diffraction gratings with user-specified order efficiencies, including:
- Gratings with equal response for upper and lower incidence (“grating_test_symmetrical” and “grating_test_simple_cartesian”)
- Gratings with different response for upper and lower incidence (“grating test”)
- 1D gratings (“grating_test_1D”)

See the function descriptions at the beginning of the “GratingExport_test_functions.lsf” script file for more information. See the “GratingExport_test_workflow.lsf” script file for examples of the use of these functions.

## Appendix

### Angle and polarization and order definitions

In the JSON file, when a grid of polar and azimuthal angles (\(\theta\) and \(\phi\)) are used, they are defined as \(\theta = acos(|\hat{k}_z|)\) and \(\phi = atan2(\hat{k}_y, \hat{k}_x)\), where \(\hat{k} = \vec{k}/|\vec{k}|\) is the unit vector that defines the direction of the incident or scattered plane wave. The absolute value in the expression of \(\phi\) means that the value of \(\phi\) in the JSON file will always be between 0 and 90 degrees, even for light incident from the upper material, rather than between 90 and 180 degrees, as shown in the diagram above. This definition is different than what is used below to define the S and P polarization convention.

The meaning of S and P polarization is defined with respect to the following s and p unit vectors:

$$\hat{s} = \begin{bmatrix} \sin(\phi)\\ -\cos(\phi)\\ 0\\ \end{bmatrix}$$

$$\hat{p} = \begin{bmatrix} \cos(\theta_2)\cos(\phi)\\ \cos(\theta_2)\sin(\phi)\\ -\sin(\theta_2)\\ \end{bmatrix}$$

where \(\theta_2 = acos(\hat{k}_z)\). Note that the subscript 2 is used to different this polar angle from the one described above and ranges from 0 to 180 degrees.

The diffracted orders are characterized by a pair of integers (n,m) which define the in-plane scattered wave vector as a function of the incident in-plane wavevector and the reciprocal lattice vectors of the grating according to the following equation:

$$\vec{k}^{||}_{out} = \vec{k}^{||}_{in} + n\vec{G}_1 + m\vec{G}_2$$

It is important to note that the reciprocal lattice vectors themselves are defined in the JSON file, and therefore scattering direction for a given value of (n,m) depends on that definition. In the diagram above, we assume a rectangular lattice with reciprocal lattice vectors

$$\vec{G}_1 = \vec{G}_x = \begin{bmatrix} 2\pi/a_x\\ 0\\ \end{bmatrix}$$

$$\vec{G}_2 = \vec{G}_y = \begin{bmatrix} 0\\2\pi/a_y\\ \end{bmatrix}$$

where \(a_x\) and \(a_y\) are the pitch along the X and Y axes respectively. See Additional background information and diffraction grating theory for more information on grating theory.

### JSON schema

The JSON schema is defined in the file grating-surface-schema.json. It should be noted that the suffix upper or lower mean the (z>0) and (z<0) half spaces respectively, as shown in the diagram in Angle and polarization and order definitions, and refers to the direction of incident radiation. For example, grat_results_upper refers to the properties when light is incident from the upper half space.

The data is a function of wavelength as well as incident angle (either defined by a grid of polar and azimuthal angles, or in plane unit vectors, or in plane wave vectors). If any of these is only specified once, it is assumed to be constant. For example, if only one value of azimuthal angle is specified, then the resulting model will be independent of azimuthal angle.

Please contact support if you need more information on each data element in the JSON file.

### Additional Background Information and Diffraction Grating Theory

A simple diffraction grating is shown above. We can calculate the possible output angles for normally incident light by considering the condition for constructive interference:

$$a \sin(\theta) = n\lambda$$

where \(n\) is an integer which is used to categorize the different orders. We can see that when \(n\) is non-zero, the output angle depends on wavelength, which means we can use gratings for applications where we want to separate the wavelengths of light, such as spectrometers.

For more complicated situations, such as light incident at different angles or 2D gratings, the condition of constructive interference can be more easily expressed in terms of the in-plane wavevectors of the input and output light by:

$$\vec{k}^{||}_{out} = \vec{k}^{||}_{in} + n\vec{G}_1 + m\vec{G}_2$$

where \(n\) and \(m\) are integers, and \(\vec{G}_1\) and \(\vec{G}_2\) are the reciprocal lattice vectors defined by \(\vec{G}_i \cdot \vec{a}_j = 2\pi \delta_{ij}\) and \(\vec{a}_j\) are the primitive lattice vectors. For un-patterned surfaces, the reciprocal lattice vectors are zero, and the above equation reduces to Snell’s law. Similarly, for highly subwavelength gratings or meta-surfaces, where \(\vec{G}_1\) and \(\vec{G}_2\) are larger than the wavenumber, only the order with n = m = 0 is supported and we also have Snell’s law.

While the possible output angles of a grating can be easily determined from the wavelength, the lattice period (or primitive lattice vectors), the incident angles and the refractive indices of the surrounding media, the order efficiencies and polarizations cannot. The order efficiency is the fraction of incident power that diffracts to a particular order. To determine the order efficiency (and polarization) we must use a physical solver such as FDTD, STACK or RCWA and save this information to the JSON file.