The Lumerical Sub-Wavelength Model (LSWM) plugin enables the simulation of optical surfaces with sub-wavelength structures, such as diffraction gratings, thin-film coatings and polarizers, within raytracing software Ansys Zemax OpticStudio and Ansys Speos. This is achieved using input data generated from Ansys Lumerical simulations’ results. For certain applications, such as augmented reality glasses, it is necessary to spatially vary the gratings along specific directions.
In this article, we will explain how to model and simulate a diffraction grating with spatial variation using the LSWM plugin.
Introduction
A single .json file can contain multiple grating simulation data. The basic principle is to define a grid of points, each labeled with an index. When a ray intersects the grating at a given spatial location, Zemax or Speos raytracing software identifies the corresponding grating orders based on its position on the ray's position on the surface.
The main intention for this feature is to simulate primarily grating with smooth variation. If a ray hits at a location between several grid points, a linear interpolation is made (though it can be deactivated) between the different responses (e.g. direction of the diffraction order, or efficiency) of the closest surrounding grid points. Then, for a region with a linear variation (or no variation at all), it is only necessary to define the response of the extreme points of the region. On the other hand, very fast variation would require many data points with a fine sampling.
For each grating variant, it is possible to completely customize the parameters (period, material, height, duty cycle, etc…).
How to generate the .json file with Ansys Lumerical FDTD
The most complex part of this workflow is the generation of the .json file with all the required spatial information. The process is described step by step as follows:
- Definition of the grid of sampling points
- Definition of the index map
- Definition of the reciprocal lattice vectors
- Generation of the .json file with the response computed with the RCWA solver
Definition of the grid of sampling points
The 1st step to generate the data is to define a map of points for the spatial variation. There are 3 options to construct a map for the spatial variation:
- Cartesian coordinates (x,y)
- Polar coordinates (r,\(\theta)\)
- Custom parameter scan: this special case enables to call for the index number directly rather than a spatial coordinate.
Definition of the index map
Each grid point is labeled with an index going from 0 to M. M must be an integer inferior or equal to the number of grid points defined in the spatial map. If several points have the same index, it means the same grating is used at each of these points.
If an index is set to 0 (or any value smaller than 1), it means there is no grating at this location and the Fresnel law will be applied for the ray interaction.
Note that the sampling needs to be a regular rectangular grid of points. To define a non-rectangular region, set the index of the points outside of the grating region to 0.
Definition of the reciprocal lattice vector
The .json file is not containing specific information about the nature of the grating (e.g. height, duty-cycle, slant angle), it only contains a set of response computed by the RCWA. However, it is necessary to specify the period of the grating so that the ray tracing software (Ansys Zemax OpticStudio or Ansys Speos) reading the data can not only provide the correct efficiency of the given diffractive orders, but also figure out its direction. Then, in addition of the index, it is also necessary to provide the reciprocal lattice vectors defining the period and the orientation of the grating at each particular grid point. Since 2D gratings are supported, there are 2 reciprocal lattice vectors that can be provided at each points, labelled 1 and 2. For 1D gratings, the 2nd vector can simply be set at 0.
Generation of the .json file with the RCWA solver information
We do not cover in this article how to model a diffractive grating and setup a RCWA solver region in Ansys Lumerical FDTD (RCWA solver). For more information on basic cases, see Lumerical Sub-Wavelength Model: Introduction and Data Generation.
For simple cases without spatial variation, it is possible to simply right click on the RCWA results to export them as a .json file. However, in the case where a spatial variation is defined, the RCWA solver needs to be run several times, once for each grating variant defined with a different index as described in the previous sections. Attached are a few example scripts that can be used as templates (see the "Examples" section).
Below is a list of the different parameters that need to be set in the script:
-
Spatial map:
- spatial_variation_or_parameter_scan.pos_x # Vector of size 1 x N1
- spatial_variation_or_parameter_scan.pos_y # Vector of size 1 x N2 OR
- spatial_variation_or_parameter_scan.pos_rad # Vector of size 1 x N1
- spatial_variation_or_parameter_scan.pos_pol # Vector of size 1 x N2 OR
- spatial_variation_or_parameter_scan.par_1 # Vector of size 1 x N1
- spatial_variation_or_parameter_scan.par_1_name # String
- spatial_variation_or_parameter_scan.par_2 # Vector of size 1 x N2
- spatial_variation_or_parameter_scan.par_2_name # String
-
Index map:
- spatial_variation_or_parameter_scan.index_map # Matrix of size N2 x N1
-
Reciprocal Lattice Vector:
- reciprocal_lattice_vector_1 # Matrix of size M x 2
- reciprocal_lattice_vector_2 # Matrix of size M x 2
where M is the maximum index number in spatial_variation_or_parameter_scan.index_map.
Note that even if there is no variation of the period induced (e.g. variation of another parameter, or no variation), it is necessary to copy the reciprocal lattice vector into the matrix so that it holds M lines.
It is also important to note that when running the RCWA for the different variant of the grating it is possible that they don't have all the same output orders (e.g. order +2 exist in one case and not in another). However, the set of RCWA runs for each case should have the same size. In the template scripts provided (see examples below), the list of orders to be read is specified to ensure all datasets have the same dimension.
Usage in Ansys Zemax OpticStudio
The usage with OpticStudio is similar to the case without spatial variation, the .json file is selected from the drop-down list. For more information, see Lumerical Sub-wavelength Model: Usage in Zemax OpticStudio. The DLL from version 2024.R2.2 and beyond supports .json files with spatial variation. A few additional parameters are available compare to older versions:
- Stochastic Mode:
Trace the ray in stochastic mode instead of splitting into multiple rays.
- Test mode:
This variable is used for troubleshooting. It can be set to different values to output different level of information in a log file. The log file is generated in the folder Zemax DLL diffractive where the .json file is also located.
- 0: nothing logged
- +1: log for major issue
- +16: logs for every ray
- +32: DLL exports a detailed log file (File can be heavy with many rays)
- Rotate Grating (degrees):
Enable to rotate the gratings from a certain angle in degree
- Check Environment index:
This is a flag to avoid using a grating in a configuration different than the environment in which it was characterized with the RCWA. If set to 1, the index of the material defined in Zemax OpticStudio will be compared to the value of the index material written in the .json file. If they are different, an error will occur un the ray tracing.
- Parameter Scan 1 and 2:
These parameters are used when the map is defined with the custom method. This variable then enables to call the desired index directly from the .json file.
- No Interpolation:
This variable is used to deactivate interpolation. The closet point is then used to determine the grating parameter at any given location. Different level of interpolation can be deactivated depending on the entry value of this parameter:
- 0: Interpolation is active
- +1: no interpolation for wavelength
- +2: no interpolation for angle
- +4: no interpolation for xy
e.g. if set to 6, the interpolation will be deactivated in angle and xy. 7 would mean no interpolation at all.
Usage in Ansys Speos
The usage with Ansys Speos is similar to the case without spatial variation, there are no additional parameters. For more information, see Lumerical Sub-wavelength Model: Usage in Speos.
Note that with the spatial variation, the grating region is defined on the specified spatial region of the surface, the UV map cannot be used to rescale or rotate it. The orientation of the grating can be modified by rotating manually the axis system attached to the surface.
Examples
For these examples to run properly, note that the .json files should be located in the folder Zemax\DLL\ Diffractive.
Example 1: Simple map with XY coordinates
With Ansys Zemax OpticStudio
The .json file for this example is generated with the script [[Generate_JSON_XY_map_simple.lsf]]. Then, open the file [[test_xy_variation.zprj]] to observe how it behaves in the ray-tracing environment. In the diffraction properties of object 2, the file "1D_diffraction_grating_xy_variation_simple.json" should already be loaded. For a better visualization, the sources 4-8 are set to show rays in the layout.
We define a grating region of 2mm x 2mm, with only 4 points (at the 4 corners of the square). At 2 points of this square, we define a grating of period 5µm, and we set the period to 9µm for the 2 other points. In the Lumerical scripts to generate the .json file, it looks like this:
The rest of the script consists of running the RCWA for these 2 cases and writing the results in a .json file. In Zemax OpticStudio, the result looks like this:
With Ansys Speos
The same .json file can be read with Ansys Speos. Open the file [[LSWM_test_XY_variation.scdocx]]. In the simulation tab, ensure the [[.sop]] and the [[.json]] files are selected in the properties of "Surface_json". Then, run the simulation "Direct_Normal_Source".
Example 2: Simple map with Polar coordinates
The .json file for this example is generated with the script [[Generate_JSON_polar_map_simple.lsf]]. Then, open the file [[test_xy_variation.zprj]] to observe how it behaves in the ray-tracing environment. In the diffraction properties of object 2, load the file "1D_diffraction_grating_xy_variation_pol_simple.json". For a better visualization, set the sources 10-17 to show rays in the layout.
In this example, we define a variation along a line of 2mm long. Since we consider only one angle, the variation is then induced in a similar way for all polar angles, i.e. the variation is rotationally symmetric.
Example 3: Advanced map
The .json file for this example is generated with the script [[Generate_JSON_polar_map_simple.lsf]]. Then, open the file [[test_xy_variation.zprj]] to observe how it behaves in the ray-tracing environment. In the diffraction properties of object 2, load the file "1D_diffraction_grating_xy_variation_advanced_map.json". For a better visualization, set the source 19 to show rays in the layout.
In this example, we show how to define a non rectangular grating region with a grid of XY points. The idea is simply to set to 0 the index of all points outside of the desired region.