Abstract
Achieving uniform light output remains a key challenge in waveguide-based optical systems due to the inherent depletion of guided optical power along the propagation path. In conventional waveguide designs, the light-extraction efficiency of the out-coupler is typically fixed, causing successive interactions between the guided rays and the extraction grating to progressively reduce the available optical power. As a result, the emitted intensity becomes non-uniform across the waveguide, limiting overall system performance.
To address this challenge, a spatially varying out-coupler design was investigated using a simplified one-dimensional (1D) waveguide model in Zemax OpticStudio. Instead of dividing the out-coupler into multiple grating zones, the spatial variation is implemented within a single grating region, where the grating parameters are defined as functions of position. A dynamic link with Ansys Lumerical is used to compute the local RCWA response at each ray-interaction point, enabling continuous variation of the extraction efficiency along the waveguide.
A hybrid Zemax–Ansys Lumerical workflow is employed, in which the input coupler is modeled through a static link using a precomputed .lswm (or .json) exchange file, while the output coupler utilizes a dynamic link to a Lumerical .fsp project. During ray tracing, Zemax automatically invokes the Lumerical project in the background to recompute the local RCWA response as needed. This enables grating parameters to vary continuously as a function of position within a single grating region, eliminating the need to segment the out-coupler into multiple discrete zones.
Simulation results demonstrate that controlled spatial modulation of the out-coupler significantly improves output uniformity while maintaining a compact and computationally efficient model. Furthermore, the dynamic-link approach enables direct optimization of grating parameters using system-level performance metrics, such as eyebox uniformity and total extracted flux. The proposed methodology provides an efficient and flexible framework for waveguide optimization and is particularly applicable to augmented reality displays, illumination systems, and integrated photonic devices where uniform light distribution is critical.
Overview
Understand the simulation workflow and key results
In this article, we present the design of a diffraction-grating-based waveguide and the optimization of the uniformity from the output coupler using Spatial Grating Parameters. The input coupler grating was designed with static link in Ansys Lumerical, incorporating grating slant-angle variations to achieve maximum coupling efficiency.
To enhance the uniformity of illumination at the output, the output coupler grating is designed with Dynamic link with spatial variation. The Grating parameters were optimized in Ansys Zemax OpticStudio using the Spatial Grating feature in combination with a Merit Function, the grating parameters were systematically optimized to achieve highly uniform output illumination from the waveguide.
This workflow supports the direct import of grating designs from Lumerical into Zemax OpticStudio using .fsp files. By leveraging the interoperability between the two tools, users can efficiently optimize waveguide designs and achieve improved output uniformity through spatial variation and optimization process. The user can try to use their own Grating file for Optimization using these parameters.
Step 1: Grating design in Lumerical
In this workflow, a slanted grating is used to achieve high coupling efficiency and improved illumination uniformity from the output coupler. The input coupler is modeled using a static link with a precomputed .json (or .lswm) file, while the output coupler utilizes a dynamic link to a Lumerical .fsp project. This workflow enables the grating simulation results generated in Ansys Lumerical to be transferred directly to Zemax OpticStudio for system-level analysis.
The operations to simulate and export .json(.lswm) files in Lumerical will not be explained in this article. Users should refer to the following Lumerical knowledge base article for more information: Lumerical Sub-Wavelength Model plugin: Introduction and Data Generation – Ansys Optics
Step: 2 Waveguide design in Zemax
The idea is to design a simple 1D waveguide in Zemax, incorporating both input and output couplers (IC/OC). The primary objective is to utilize the spatial variation feature to optimize the grating parameters in the output coupler to achieve a more uniform intensity distribution at the output.
Step: 3 Grating parameters set up in Zemax
The grating models were integrated into Zemax OpticStudio using both Static and Dynamic Link workflows. A User Defined Object (UDO) was inserted in the Non-Sequential Component (NSC) environment, and the provided DLL was used to establish communication between Ansys Lumerical and Zemax OpticStudio for grating simulations. The input coupler was configured using a Static Link with a precomputed grating file, while the output coupler employed a Dynamic Link to enable position-dependent RCWA calculations during ray tracing.
To implement spatial varying grating properties, a spatial link file was generated and linked to Zemax. The grating geometry was parameterized using the variables p0–p24 along with the slant-angle parameters, allowing the grating characteristics to vary continuously across the output-coupler region and enabling optimization of the light-extraction profile for improved uniform illumination from the Output Coupler.
Step:4 Optimization for uniformity at Detector
The objective is to achieve a uniform illumination profile at the output coupler. To accomplish this, the merit function is defined to minimize the standard deviation of the intensity distribution measured on the detector. However, minimizing the standard deviation alone can result in a non-physical solution in which very little or no light reaches the detector, producing an artificially uniform intensity distribution. To avoid this, an additional merit function operand is introduced with a large weight to constrain the total optical power on the detector, ensuring that it remains above a specified threshold.
When a negative weight is assigned to this operand, it is treated as a Lagrange multiplier. In this formulation, the optimization algorithm is forced to satisfy the power constraint exactly, regardless of its impact on the other merit functions. This ensures that the final solution achieves the desired illumination uniformity while maintaining the required power level at the detector.
Run and Results
Step 1: Grating design in Lumerical – Slant Variation
Open and run the attached grating file in Coupler.lswm, and out Coupler.fsp in Lumerical
There are two workflows in which the Grating data has been exchanged between Lumerical and OpticStudio. One is dynamic and the other one is static. The two workflows have different flexibility, and no one is superior to the other. Users should consider which one to use based on their design case.
Here in this example will use static link for Input coupler and dynamic links between Zemax and Lumerical to optimize the Grating parameters for the Output Coupler.
The grating used in this example is a slanted grating.
To better understand its performance, a parametric sweep of the slant angle was conducted from 10° to 60° in 1° increments.
Within the waveguide, the central propagation angle is approximately 51°. Based on the grating geometry and propagation conditions, the highest diffraction efficiency is expected in the +1-diffraction order (Tss polarization) when the slant angle is close to 10°.
This sweep helps identify the optimal slant angle that maximizes coupling efficiency and provides insight into the relationship between grating orientation and diffraction performance.
For the Input Coupler, we use a fixed grating (static link, no spatial variation) with a slant angle of 10°.
For the OC, we are going to use Dynamic Link with spatial variation. The spatial link grating has been created in Ansys Lumerical and linked using the DLL in Zemax.
The grating file used in this example is provided in the Attachments section and is available in .fsp and .lswm format for use in Zemax and link to Ansys Lumerical in the background.
For additional details on the grating design methodology, simulation setup, and the various grating parameters, please refer to the accompanying articles attached to this document. These resources provide comprehensive information on the design process, parameter definitions, and optimization techniques used in this workflow.
Details about the documentation and various parameters in Zemax and Lumerical can be found here: Dynamic workflow between Lumerical RCWA and Zemax OpticStudio – Ansys Optics
Ensure that the DLL,.lswm,.fsp and spatial_vary.txt files are in the folder Zemax>>DLL>>Diffractive to read the attached file in the Article.
Step:2 Waveguide design in Zemax
Open the attached Zemax file and verify that the grating files (In Coupler and Out Coupler) are being used by the DLL through the User-Defined Surface object properties.
The In Coupler is linked via a static link, has been optimized in Lumerical for optimal performance, and is referenced using the In Coupler.lswm file.
The Out Coupler is linked via a dynamic link allowing Lumerical to be invoked and executed in the background during the simulation workflow.
Run the Ray trace and analyze the performance at the detector.
The waveguide was designed and analyzed using Zemax OpticStudio in Non-Sequential Mode (NSC), which allows accurate modeling of complex light propagation, scattering, and multiple reflections within the system. The initial setup consists of five primary components:
• Source – Generates the input optical field.
• Input Coupler – Couples light from the source into the waveguide.
• Waveguide – Guides light through total internal reflection (TIR).
• Output Coupler – Extracts light from the waveguide toward the Detector.
• Detector – Captures the output intensity distribution for performance evaluation.
To model the grating structures used for light coupling, two User Defined Objects (UDOs) were implemented within Zemax. First UDO represents the input grating coupler, while the second UDO represents the output grating coupler.
The layout shows the waveguide schematic in Zemax.
Diffraction gratings were utilized to implement the grating structures in both the Input Coupler (IC) and Output Coupler (OC). The grating response was implemented using a custom DLL linked to the Zemax Diffraction User-Defined Surface, providing an interface between the Lumerical-generated grating data and the OpticStudio simulation environment, allowing the optical response of the gratings to be accurately represented during ray-tracing simulations. The input coupler (IC) design was kept fixed using a static link, with grating parameters pre-optimized in Ansys Lumerical to maximize coupling efficiency into the waveguide. The output coupler (OC) was then optimized in Zemax OpticStudio through the Lumerical–Zemax dynamic link. This optimization enabled position-dependent control of the light-extraction efficiency along the waveguide, resulting in a highly uniform illumination distribution at the output while maintaining efficient optical throughput.
To define the Grating structure in the waveguide, you need to go to the Object properties<<DLL<<Diffractive.
After setup of the Grating in the Zemax, run the ray trace and analyze the uniformity and irradiance at the detector.
In the next step we will set up the spatial link for the OC to optimize the uniformity at the Detector.
Step:3 Spatial link setup at the Grating
3.1 Setting Up Spatial Variation in the Output Coupler (OC) in Zemax
Locate the in coupler.lswm, out coupler.fsp and spatial variation.txt file that was generated from the Lumerical and copy it in the folder Zemax>DLL>Diffractive.
Set up the spatial variation link at the out coupler in the object properties<<DLL<<Diffractive
Setup the spatial variation file# as 8 and made slant angle and variable #1 as variable.
The coordinate system is defined relative to the local coordinate system of the object (Surface 3 in this case). Consequently, the origin (x=0) corresponds to the center of the rectangular region.
To implement the grating structure in Zemax, two User-Defined Objects (UDOs) have been introduced. The Output Coupler is connected to these objects through a Dynamic Link. These UDOs provide a mechanism for defining the desired spatial variation within the system, which is subsequently used as an optimization parameter to improve illumination uniformity at the detector.
In the .fsp file, the 1D grating is defined with its period oriented along the X-axis. However, in our optical setup, the waveguide extends along the Y-axis.
To align the grating structure with the physical orientation of the system, the Object Coordinate (OC) is rotated by 90° about the Z-axis. As a result, although the grating parameters are specified along the X-direction in the settings, the rotation effectively maps this variation onto the Y-direction in the final system.
To illustrate the process, we will intentionally introduce a controlled spatial variation in the system as follows:
• Grating Region: 30mm x 6 mm
• Variation: 1D
• Equation: p2_slant = v0 +x * 5/3 * v1
with v0=35, and v1=1
This gives a linear variation from 10° to 60° in the grating region.
The txt file “spatial_vary_6.txt” used to set it up in Zemax will then look like this:
The Text file needs to be saved in the folder Zemax<<DLL<Diffractive.
To set up the grating file in Zemax:
Navigate to Object Properties → Diffraction.
Set the Split option to “Split by DLL Function.”
Load the required DLL file, and then select the corresponding .fsp file from the dropdown menu.
Enter the Spatial Vary File # as 6, since the text file “spatial_vary_6.txt” has been placed in the DLL folder.
The default value of the Variable V1 to 1.
Enter the P2 (Slant Angle) value as 35, as shown in the reference image
Since the variation is linear and occurs only along one direction, a larger sampling interval in both X and Y has been used to reduce the number of grid points and speed up the computation. Increasing the sampling density will result in longer computation times.
Visualize the effect of the various Grating parameters on Uniformity
If the parameter “Spatial Vary File #” is set to 0, spatial variation is deactivated, and we see the poor uniformity out of the OC.
By setting the parameter to “6”, the file “spatial_vary_6.txt” is considered and spatial variation is induced in the raytracing, and the result is that Uniformity has been increased from the OC as shown in the attached image.
Spatial Variation File – mode 1
So far, we used the parameter “Spatial Vary Mode =0”. In mode 0, the sampling is done in spatial coordinate: the computation is triggered at each sampling point.
In mode 1, the sampling is done in parameter space: in this case in slant angle. For an optimization, it is expected to be faster. This is because in mode 0, you may get a different slant angle at the x sampling point each time you vary the parameter. However, if you already perform the computation in slant angle, the data are all in the cache and it is faster to retrieve rather than re-compute each time.
In mode 1, the spatial_vary.txt file controlling the spatial variation behavior looks like this. The min/max/interval value of the slant angle parameter is set after the equation
Where the last line can be understood as follows:
Step:4 Optimization for uniform illumination at Detector
Create a merit function for uniform illumination by using the standard deviation of the detector output as the optimization criterion.
Optimize the merit function using the Spatial Variation Link to minimize its value and improve illumination uniformity.
Run the ray trace and verify that the illumination uniformity has been increased significantly at the detector
In this example, the objective is to optimize the uniformity of the detector response. To achieve this, the merit function is defined to minimize the standard deviation of the intensity distribution on the detector. However, minimizing the standard deviation alone can lead to an impractical solution where little or no light reaches the detector—resulting in artificially perfect uniformity. To prevent this, an additional operand with a high weight is included to constrain the total power on the detector, ensuring it remains above a specified threshold.
As shown in the Merit Function Editor, the first NSDD operand is used to maximize the intensity at the detector. A higher weight is assigned to this operand to prioritize achieving maximum power at the detector.
To interpret NSDD as the standard deviation, the Data Type is set to –4, as specified in the Zemax Help documentation.
The second NSDD operand is used to evaluate the uniformity at the detector by calculating the standard deviation of the detected intensity.
4.1 Optimization of the slope
Initially, only the slope of the slant variation is defined, while keeping the center point fixed at p0 = 35 degree.
To enable optimization of the slant parameters, it is necessary to define both the center point (p0) and the variable parameter (v1) as variables. This is accomplished using the Multiconfiguration operand NPRO, which allows the specification and control of parameters within the Dynamic Link framework.
To know more about the NPRO Operand, you can refer to the Help file manual: Multi-Configuration Operands
After setting up the above parameters as variable, you can optimize the system by using the Optimization wizard in the Optimization tab.
After running the optimization cycle you get the value of v1 variable at which the merit function is having minimum value.
After running the Optimization run the Ray trace and it shows that Uniformity has been increased at the Detector as shown in the Detector viewer.
The same thing can be plotted using the “Universal Plot 1D” to visualize the expected relation between the variable v1 and the Merit function. Using the Plot, we can be able to identify the value of v1 variable at which the Merit function is having minimum value. The same uniformity can be visualised at the Detector with variable parameter.
4.2 Optimization of the slope + central slant
For getting better uniformity across the Detector, we also add the parameter p0 as a variable in the Multiconfiguration operand “NPRO”. Once again using the Optimization Wizard, we have optimized the system for better uniformity at the detector.
After running the Optimization and getting the minimum value of the Merit function. Run the ray trace and visualize the uniformity at the Detector.
The “Universal Plot 2D” can also be used to visualize how the slant height p₀ and the variable parameter v₁ influence the merit function value. From this plot, it becomes easier to identify the point at which the merit function reaches its minimum.
However, generating such visualizations using the Universal Plot can be time-consuming, especially when multiple variables are involved. Therefore, for designs with a larger number of variables, it is generally more efficient to rely on optimization methods instead.
Important model settings
Description of important objects and settings used in this model
Dynamic Link simulations can become computationally intensive due to repeated RCWA evaluations during optimization. To improve efficiency, use Mode 1, minimize the sampling resolution to the lowest acceptable level, and restrict the number of optimization variables to those with the greatest impact on system performance. Improper simulation settings can significantly increase both system evaluation and optimization time.
During optimization, a large positive weight was assigned to the total-flux operand to ensure that the optical power reaching the detector does not drop below an acceptable level. This prevents the optimizer from converging to trivial solutions that achieve good uniformity at the expense of significantly reduced throughput. Alternatively, the operand can be assigned a negative weight, causing it to be treated as a Lagrange multiplier. In this formulation, the optimization is constrained to satisfy the specified flux requirement exactly, ensuring that the desired power level is maintained while simultaneously optimizing the illumination uniformity.
The spatial parameters are mapped to the system through the Spatial Variation function defined in the .fsp file. During optimization, these parameters are adjusted to minimize the standard deviation of the detector irradiance distribution. A lower standard deviation corresponds to a more uniform illumination pattern, with an ideal target value of zero indicating perfectly uniform intensity across the detector.
A well-constructed merit function is essential for successful optimization. Proper scaling, weighting, and normalization of operands help ensure efficient convergence, while poor operand scaling can lead to slow progress or cause the optimizer to become trapped in local minima.
Updating the Model with Your Parameters
Instructions for updating the model based on your device parameters
The grating files included in this example have been optimized specifically for reference design. You can replace them with your own grating files and re-optimize the system based on your design requirements and performance targets.
The Spatial Link in this example is configured using a linear relationship with two variables. To achieve improved illumination uniformity, you can modify the model to use higher-order polynomial functions or additional optimization variables that better represent your system behavior.
The workflow demonstrated here can be used as a template for your application. Update the model parameters, grating files, and optimization settings as needed to match your design specifications and performance objectives.
Taking the Model Further
Information and tips for users that want to further customize the model
In this example, only one or two variables were optimized, allowing the merit function landscape to be easily visualized using tools such as the Universal Plot. However, for more complex applications, such as waveguide systems with eye-box expansion, the number of design parameters increases substantially, making direct visualization of the optimization space less practical.
After identifying the optimal parameter values, the system can be converted to a static link model. This reduces computational overhead and enables significantly faster ray-tracing and performance analysis while preserving the optimized behavior.
For future work, more advanced optimization approaches, such as higher-order polynomial or nonlinear models, can be explored. These methods can better capture complex relationships between design variables and system performance, leading to more accurate, robust, and efficient waveguide designs.