This Blog is part a series of walking through the 5 RCWA DLLS available Diffraction Gratings within Zemax. We will explain each parameter and build a model together using the srg_trapezoid_RCWA.dll.
Downloadable Files
srg_trapezoid_RCWA_dll_example_file.zip
It is assumed the reader understands the basic physics involved with Surface-Relief Gratings and understands the plug-in used only supports 1-dimensional gratings.
It is assumed the reader has a premium or enterprise level Ansys OpticStudio Zemax license subscription. Legacy versions will not work for these DLLs. Please contact Eden.Thompson@ozeninc.com for details.
START: STEP 1:
Open a fresh Ansys OpticStudio Zemax session. Navigate to Non-Sequential Mode. Insert a Rectangular Source Rectangle at (0,0,0), (X,Y,Z) . Insert a 2nd Object "User Defined Object" and select "DiffractionGrating.DLL" for the Data File, and press OK.
You will see a Geometry Error. Place your User Defined Object at (0,0,10).
STEP 2:
Click your User Defined Object and open the Object Properties. In the Object Properties drop down, select Diffraction. In the DLL: field select srg_trapezoid_RCWA.dll. Next Add a material to use User Defined Object.
You will get a Geometry Error.
Lets got through the parameters: The Copy -> button is because the Reflect column should always be identical to the Transmit column.
1. Start Order and Stop Order: Which harmonics are actually traced in your ray trace once "Split NSC Rays" is turned on and which orders are calculated by RCWA for the specific ray-tracing output.
2. +Period/-Freq (um): Is the groove period in um. Use a positive value for a groove period [um]. Use a negative value for a groove frequency [1/um]. Period and Frequency are reciprocals of each other. The period should be less than 100*wavelength. A good rule of thumb for this parameter: 0.5*wavelength < period < 10*wavelength. If the period is much smaller diffraction angles can exceed 90 degrees, causing evanescent orders. If the period is much larger many diffraction orders can propagate.
3. Max Order: This is the resolution of the grating's electromagnetic field internally. In other words this defines the internal truncation limit of the RCWA Fourier Expansion. The more you consider here the more accurate, but slower computation time. You can calculate many internal harmonics but choose to trace only a subset use the Start Order and Stop Order. Limit is 10. You can contact the support time to increase to 50. A rule of thumb for the Max Order initial value is to set it equal to 3*(grating period)/(light wavelength).
4. Depth (um): Depth is the grating height in um. The Depth for trapezoidal gratings determines the phase modulation of the diffracted light. Often slightly shallower depths than rectangular gratings for easer fabrication and smoother diffraction. A good rule of thumb is to keep the depth <= to the period or 0.2*wavelength/(n-1) < Depth < 1.0*wavelength/(n-1). The Lower limit is to allow enough phase modulation to start producing significant diffraction. The Upper limit is to allow a Full 2pi phase shift -> max efficiency into the chosen diffraction order. The Trapezoid slope spreads the phase linearly, but the overall height difference is what determine the total phase swing.
5. Fill Factor: is a dimensionless number between 0 and 1 that represents the ratio of the grating's bottom (base) width to its period. It plays a key role in shaping the trapezoid's sidewall slope and consequently its diffraction behavior. A smaller fill factor produces narrower bases and steeper slopes, effectively "blazing" the grating to direct light into a referred diffraction order, while a larger fill factor yields wider bases and more symmetric diffraction. Defines overall "blaze potential".
-
- Smaller than 0.5: base width is less than half the period, trapezoid has narrower base, steeper sides.
- Equal to 0.5: base width is half the period, symmetric slope if top width is set accordingly.
- Larger than 0.5: base width is more than half the period, trapezoid base dominates the period, shallower slope.
6. Alpha (deg): is the angle of the left sidewall, measured from the base toward the top of trapezoid. It determines how steeply the left side rises across the period, directly influencing how light is directed into different diffraction orders. A larger value creates a steeper slope, [positive in the drawing above] which can enhance the grating's blazing effect toward a preferred diffraction order, while a smaller value produces a shallower slop and a more symmetric diffraction pattern. Changing the sign of Alpha does not change the diffraction angles (those are set by period and the wavelength). Negative values reverse the diffraction efficiency to the opposite orders. The angles stay the same, but the intensity distribution among orders change.
- Avoid +/-90 deg. Slopes too shallow (<5 deg) may be inefficient; slopes too steep (>75 deg) are hard to fabricate and can cause RCWA convergence issues.
7. Beta (deg): is the angle of the right sidewall, measured from the base toward the top of trapezoid. Independent from Alpha and allows you to create asymmetric shapes. Together with Alpha, Beta gives fine control over the grating's blaze and overall diffraction efficiency, enabling optimization for particular wavelengths, incident angles, or target diffraction orders. [negative in the drawing above].
- Avoid +/-90 deg. Slopes too shallow (<5 deg) may be inefficient; slopes too steep (>75 deg) are hard to fabricate and can cause RCWA convergence issues.
IMPORTANT: GEOMETRY CHECK: Top Width must be greater than 0. Top Width > 0.
Base Width = Fill Factor * Period.
Top Width = Base Width + Depth*(tan(Beta) - tan(Alpha)).
8. Coat Thick Top (um): Refers to the the thickness of the coating applied to the top surface. This parameter is critical in ensuring optical or protective properties, as variations can affect reflectivity, transmission, or durability. Typical values are ~wavelength/4 for AR. Up to 5 wavelengths for multilayer dielectric coatings.
9. Coat Thick Side (um): Refers to the thickness of the coating applied to the the side surfaces. Side coating thickness is important for consistent edge performance, environmental protection, and maintaining design tolerances. Typical values
10. Number of Layers: A key concept in RCWA is the use of layers. The theory assumes that the grating structure is uniform along the Z-direction (the thickness of the device) and periodic in the XY plane (the repeating pattern across the surface). “Uniform in Z” means that the material properties — like refractive index — do not change within a single layer. “Periodic in XY” means the pattern repeats regularly across the surface, such as ridges in a diffraction grating.
When the structure varies along Z, for example in a trapezoidal or curved ridge, RCWA divides it into multiple thin layers, each approximately uniform in Z. Each layer is solved individually and then stacked to approximate the full structure. Increasing the number of layers improves the Z-resolution: the more layers you use, the more accurately the simulation captures changes along the thickness. However, more layers also increase computation time, so designers must balance accuracy and speed.
11. Use Coating File: This parameter is a flag. If it’s a non-zero positive integer, it indicates that the dispersion data (index vs wavelength) is defined in a text file. The text file must be saved in {Zemax}\Coatings\COATING_xx.dat, where xx is a positive integer specified in the “Use Coating File” parameter.
For example, if Use Coating File is set to 7, the dispersion data will be read COATING_7.dat.
In the COATING_xx.dat file, the dispersion data is defined as described in the Help files under The Libraries Tab > Coatings Group > Defining Coatings > The MATE Data Section. The material name should always start from RCWAxx, where xx is a two-digit integer. Any text can then follow.
12. Index Grate (R): Represents the real part of the refractive index within the grating region. It determines how light bends and propagates through the grating material, directly influencing diffraction efficiency and phase behavior. This implies that the grating region is a substrate and not etched into the block of material.
13. Index Grate (I): Represents the imaginary part of the refractive index in the grating region, which corresponds to optical absorption or loss. A higher value indicates that more light is absorbed as it passes through the grating.
14. Index Env (R): Defines the real part of the refractive index of the environment surrounding the grating—typically air or a substrate. It affects how light enters and exits the optical structure and plays a key role in matching boundary conditions.
15. Index Env (I): Represents the imaginary part of the environmental refractive index, describing losses or absorption in the surrounding medium. It is usually very small or zero for transparent environments like air or glass.
16. Index Coat (R): Describes the real part of the refractive index of the coating layer applied to the optical surface. This value determines how the coating modifies reflection and transmission to optimize optical performance.
17. Index Coat (I): Represents the imaginary part of the coating’s refractive index, associated with absorption or attenuation of light within the coating material. It helps model realistic coating behavior, especially for metallic or lossy layers.
There are rules specific to how the RCWA DLL interprets index values — they don’t change the physical meaning of the grating or environment, just how the software reads them.
In grating simulations, each optical region is defined using complex refractive indices, with clear rules for how to assign values:
- Grate Region (Index Grate R & I):
- The real part (R) controls light propagation through the grating.
- The imaginary part (I) represents absorption or loss.
- Special rules:
- If R = 0, the grating uses the substrate index from the optical system.
- If R < 0, the index is read from a dispersion file for wavelength-dependent materials.
- Environment Region (Index Env R & I):
- The real part (R) sets the refractive index of the surrounding medium.
- The imaginary part (I) defines absorption in the environment.
- Special rules:
- R = 0 uses the Outside Index (typically air).
- R < 0 pulls data from a dispersion file.
- Coating Layer (Index Coat R & I):
- The real part (R) governs how the coating modifies reflection and transmission.
- The imaginary part (I) models absorption within the coating.
18. Rotate Grating: this parameter controls the orientation of the grating lines relative to the local coordinate system. By default (set to 0), the grating lines run along the Y direction, causing rays to diffract along X. Setting a non-zero value rotates the grating lines: positive values rotate them counter-clockwise (+X → +Y), while negative values rotate them clockwise. This allows precise control over the diffraction direction based on the grating’s alignment in the system.
19. Interpolation: this parameter controls how the DLL caches and reuses RCWA data to speed up ray tracing.
-
0: Interpolation is off; the DLL calculates RCWA data for every ray individually.
-
Positive integers: Interpolation is enabled. The DLL creates a sampling grid in the LM space (direction cosines of the rays). When a ray hits the grating, its diffraction data is interpolated from the nearest grid points, which dramatically speeds up calculations for systems with many rays.
-
1: 201 × 201 grid
-
>1: Defines a custom grid size (minimum 21 × 21)
-
-
Negative integers: Use the absolute value for the grid size, but apply a more accurate (slower) interpolation method.
This caching and interpolation process accounts for phase, polarization, and amplitude, ensuring accurate modeling even when efficiency or fields are interpolated. The DLL recalculates the cache if grating parameters or wavelength change, so interpolation speeds up simulations most effectively when tracing many rays (>1000) or during optimizations. For very few rays (<10), turning it off may be better.
20. Test Mode: this parameter is used for diagnostic and verification purposes within the DLL.
-
0: Normal operation; the DLL calculates diffraction as usual.
-
Non-zero: Test Mode is enabled. In this mode, the DLL performs internal checks to help identify issues, such as errors in input parameters, geometry, or grating configuration.
-
This mode is useful for debugging complex grating designs or when unexpected results occur. Any errors detected are typically logged to a text file for review.
Test Mode is generally left off during regular simulations but can be invaluable when troubleshooting or validating a new grating setup.
21. Only these orders: better is used in the RCWA visualization tool in Programming tab. This parameter allows you to select specific diffraction orders to trace in transmission and reflection.
-
0 or negative: All orders are traced, as usual.
-
Positive integer: Only the specified orders are traced. Each diffraction order is assigned a unique positive number, and the parameter value is calculated as the sum of 2^(order number).
Example: To trace the zero-order reflection (R0) and first-order transmission (T+1), the value is calculated as 2^0 + 2^5 = 1 + 32 = 33
.
The selected orders must fall within the range defined by the Start Order and Stop Order parameters. For convenience, this parameter can also be set using the DLL’s RCWA visualization tool, which simplifies the process without manual calculations.
22. Stochastic Mode: (also called Monte Carlo or probabilistic splitting) controls how the DLL handles diffraction for individual rays.
-
0: Standard operation; all diffraction orders are calculated deterministically.
-
Non-zero: Stochastic Mode is enabled. In this mode, each incident ray is diffracted randomly into one of the possible orders, with the probability proportional to the energy fraction in each order. This is useful for simulating large numbers of rays efficiently, as only a single ray is traced per interaction while still statistically representing the energy distribution.
When enabled, the DLL also generates an error log (*.txt
) in {Zemax}\DLL\Diffractive\
to report calculation issues. Typically, this is left off unless troubleshooting unknown errors.
-
The thickness affects how much phase delay the grating introduces and therefore influences the diffraction efficiency and overall optical performance.
-
In simulations, the NIL layer is treated like any other layer in RCWA: it can be uniform in Z within the layer or divided into multiple slices for higher accuracy.
-
Choosing the correct NIL thickness ensures that the modeled grating closely matches the fabricated structure, which is critical for predicting real-world optical behavior.
STEP3: Design
1. Choose Period
Diffraction occurs only if the desired order propagates:
2. Choose Depth
Depth controls phase modulation:
3. Choose Fill Factor
4. Determine blaze angles
Control diffraction efficiency and direction:
5. Set RCWA layers:
6. Set Refractive Indicies:
STEP 4: RCWA Visualization
Go to Programming Tab --> User Extensions --> RCWAVisualization
Input the values from above and check if our Geometry Calculations were good.
STEP 5: Input Values into Object Properties -> Diffraction
Make sure NSC Split is checked in the NSC 3D Layout.
Set Face 1 to reflective coating instead of default.
IMPORTANT: MOST LIKELY WILL SEE A GEOMETRY ERROR. THIS DOES NOT MEAN THE TRAPEZOID GRATING IS GEOMETRICALLY INCORRECT BECAUSE WE ALREADY CONFIRMED IT IN THE RCWA VISUALIZER. WHAT IS HAPPENING IS THERE ARE RAYS THE LAYOUT IS HAVING TROUBLE TRACING.
SOLUTION: DROP MAX ORDER TO 1 & DROP LAYOUT RAYS TO 1.
Downloadable Files
srg_trapezoid_RCWA_dll_example_file.zip
Ozen Engineering Expertise
Ozen Engineering Inc. leverages its extensive consulting expertise in CFD, FEA, optics, photonics, and electromagnetic simulations to achieve exceptional results across various engineering projects, addressing complex challenges such as antenna design, signal integrity, electromagnetic interference (EMI), and electric motor analysis using Ansys software.
We offer support, mentoring, and consulting services to enhance the performance and reliability of your electronics systems. Trust our proven track record to accelerate projects, optimize performance, and deliver high-quality, cost-effective results. For more information, please visit https://ozeninc.com.
If you want to learn more about our consulting services, please visit: https://www.ozeninc.com/consulting/
CFD: https://www.ozeninc.com/consulting/cfd-consulting/
FEA: https://www.ozeninc.com/consulting/fea-consulting/
Optics: https://www.ozeninc.com/consulting/optics-photonics/
Photonics: https://www.ozeninc.com/consulting/optics-photonics/
Electromagnetic Simulations: https://www.ozeninc.com/consulting/electromagnetic-consulting/
Thermal Analysis & Electronics Cooling: https://www.ozeninc.com/consulting/thermal-engineering-electronics-cooling/
Sep 30, 2025 2:57:19 PM