OpticStudio grating tools beta function update history

  • 5 February 2021
  • 0 replies

Userlevel 4
Badge +1

This forum post is a place to collect update history of diffractive tools beta functions, which includes all RCWA DLLs (and visualization API), polygon DLL, and Zemax Grating Data (ZGD) DLL.



1. Overview
2. Resources
3. Change history



Currently in OpticStudio, we are adding some useful DLLs to enhance the ability of fully simualting gratings. They allow OpticStudio to consider the efficiency when rays pass through diffractive optical elements (DOE), such like 1D/2D gratings, binary optics, or volume holograms. These extensions can be found in OpticStudio installations.

These tools improve frequently based on users’ feedback. We decide to provide functions with DLL so it can be updaetd fast upon users' request. Between each OpticStudio public releases, there might be several minor updates and bug fixes. This forum post is a place for changes history.

Note all tools provided here are only available with OpticStudio Premium Subscription. If users are interested in these functions, they can wait stable version until next the OpticStudio release. Or they can send an email to support inbox to request for latest beta DLLs.



  1. Simulating diffraction efficiency of surface-relief grating using the RCWA method
  2. Simulating diffraction efficiency of a volume holographic grating using Kogelnik's method
  3. How to simulate exit pupil expander (EPE) with diffractive optics for augmented reality (AR) system in OpticStudio: part 1 (part 2, part3)
  4. EMPossible
  5. Kogelnik, H., 'Coupled wave theory for thick hologram gratings, ' Bell Syst. Tech. J. 48, 2909-2947 (1969).
  6. Elias N. Glytsis and Thomas K. Gaylord, 'Rigorous 3-D coupled wave diffraction analysis of multiple superposed gratings in anisotropic media,' Appl. Opt. 28, 2401-2421 (1989)
  7. M. G. Moharam, Drew A. Pommet, Eric B. Grann, and T. K. Gaylord, 'Stable implementation of the rigorous coupled-wave analysis for surface-relief gratings: enhanced transmittance matrix approach,' J. Opt. Soc. Am. A 12, 1077-1086 (1995)
  8. Han-Hsiang Cheng and Xiaochaoran Tian 'An advanced ray-tracing model for multi-color holographic optical elements', Proc. SPIE 11188, Holography, Diffractive Optics, and Applications IX, 1118817 (18 November 2019); https://doi.org/10.1117/12.2537762


Change history


When using Stochastic mode, there was a bug where the diffracted ray’s power is larger than expected when metal is used in the grating. Note this is fixed.

Note from this version, the Stochastic mode 1 and 2 are deprecated and it’s always same as mode 3 in old version as long as this parameter is set as non-zero.

Now FFF is by default turned on. To turn it off, see the following explanations for the parameter “Test Mode”.
A new parameter “Test Mode” is added. By default, it should be zero, which means normal system. If it’s a positive value, some testing functions are triggered as below.

  • Adding the value by 2^0 = 1: the DLL will report any coreerrors in a log text file.
  • Adding the value by 2^1 = 2: the DLL will report more information mainly for debug.
  • Adding the value by 2^2 = 4: the DLL will turn off Fourier Factorization Factor.
  • Adding the value by 2^3 = 8: the DLL will turn on another algorithm T-Matrix. Note this is not yet ready at this timing with some bugs.


A benchmark has been done for FFF. The tested structure is from the following reference.

Convergence of the coupled-wave method for metallic lamellar diffraction gratings, Lifeng Li and Charles W. Haggans, Journal of the Optical Society of America A Vol. 10, Issue 6, pp. 1184-1189 (1993)


Implement Fast Fourier Factorization to improve the convergence of metal material.

Some other minor stability improvements.


The function of manual sizing of visualization tool window was broken and now is back.


The efficiency plot in visualization tool doesn’t show correct data. Now it’s fixed.


All DLLs are added with a new parameters “FFF”. When this parameter is set to non-zero, a method called “Fast Fourier Factorization” is used to calculate. Theoretically, this can make the convergence faster when there is a metal layer in the grating. In other words, less number is required for “Max Order” when metal material exists in the grating. This is still in experiment and should be used carefully.


Tow bug fixes.

  1. In some cases, if the PC has more than 10 cores, the calculation speed would be very slow because all threads compete for getting shared resources. This is fixed now.
  2. When the given parameter period is negative, it means frequency in micron^-1. However, the period was wrongly multiplied by 1e6 times. This is fixed now.

Polygon grating DLL has been updated to include Scale X and Scale Y.


The DLLs didn’t consider the linear phase introduced by grating and now it’s fixed. This only affects if designers what to calculate Huygens PSF a shown below.



Now if Outside material is not specified, when click “Calculate” button, there will be an error message to warn the calculation would be wrong.



Fixed a bug that editing thickness and section data in layers & section table would fail.



A bug is fixed in visualization tool. If a section in a layer has Width = 1, this section would not be drawn. Now it works correctly.



Two bug fixes.

  1. When the input grating data for User defined DLL includes non-zero imaginary refractive index, the DLL stops work. Now it’s fixed.
  2. When using dispersion data (COAT_x.dat) to define grating material, if that includes non-zero imaginary refractive index, the DLL stops work. Now it’s fixed.

A checking code is added. If defined order filter includes orders that is outside of the range between Start Order and Stop Order Object Property, the DLL stops working. In visualization tool, there is an error message shows.


Polygon grating DLL added a new parameter “Diffract back face”. When it’s set to non-zero, the grating will be on Face 2 instead of on Face 1.

Polygon grating DLL now supports up to 30 points. The download link is included above


Visualization tool has two slight changes in UI

  1. Now it’s possible to change DLL from UI. Note this will directly modify settings in OpticStudio.
  2. Mark text to red if Outside material has never been changed manually. By default it’s 1.0 but it need users to correctly set up.



Bug fix: all DLLs were wrongly set with an expire date after 2021-01-21. Now this is removed.

If you see the following error message when opening your design file. Please fix it with selecting new DLLs.


To make the design file work again, either one of the following methods would work.

Method 1

(1) Copy the beta DLLs, for example the srg_trapezoid_RCWA210122.dll, from zip file to \Documents\Zemax\DLL\Diffractive\

(2) Remove the old DLLs, which is srg_trapezoid_RCWA.dll in this case.

(3) Rename this DLL srg_trapezoid_RCWA210122.dll to srg_trapezoid_RCWA.dll.

(4) Now open the design file. And that should work.

Method 2

(1) Copy the beta DLLs, for example the srg_trapezoid_RCWA210122.dll, from zip file to \Documents\Zemax\DLL\Diffractive\

(2) Open your design file.

(3) You will see the following message. Click OK.


(4) Then go to your grating object > Diffraction Property.  You should see as below. The DLL is wrong.


(5) Select the srg_trapezoid_RCWA210122.dll and the file should work again.



1. Visualization tool now calculated Filling and Wedge and shows the value if the DLL is trapezoid 2 and a or b is not zero. If both a and b are zero, a and b are calculated, using Filling and Wedge data and shows.


2. Polygon grating adding two parameters

---  “Scale”: all x and y points will be multiplied by this value to scale. If it’s zero, it’s converted to 1.0 internally.

---  “Z Center Mode”: If it’s 0, the local origin (0,0,0) is on the Face 1 as usual. If it’s 1, the local origin is shifted by -0.5*Thickness so it’s between the Face 1 and Face 2.


Bug fix:

Wedge in trapezoid 2 is negative when b > a. Exchange a and b to make Wedge positive.






New grating shape (srg_trapezoid2_RCWA.DLL). The shape is defined as following picture. Note that:

  1. If parameters Filling or Wedge are non-zero, then a and b are ignored. Otherwise, a and b are used for the shape definition.
  2. Coating thickness in this DLL can be separately defined for top, left side, and right side.
  3. The speed of interpolation mode is improved by about 15%~20%.








Visualization tool

1. Incident angle is now defined by polar and azimuthal angles (theta and phi). This matches the convention more in both academic and industry.

2. Add a button to calculate efficiency data. The data is saved in RAM and can be plotted by “Plot” button or exported by “Export ZGD” button.

3. Add a button to plot efficiency data.

---  There 3 dimensions, wavelength, polar angle, azimuthal angle, but we need to choose one of them as the X-axis.

---  For the rest dimensions, the data is calculated for those cells with a “*” mark. The “*” mark can be set to other cell by selecting the cell and press Ctrl + Z.

4. Add a button to export Zemax Grating Data (ZGD) file. More information about ZGD can be found by the download link above.

5. Note new DLLs are required in order to use new functions in the visualization tool.

6. Now if the window is resized by user, a scroll bar will appear when needed. This helps users who use notebook.




7. Now the following DLLs support NIL layer: srg_blaze_RCWA, srg_gridwirepolarizer_RCWA, srg_step_RCWA, srg_trapezoid_RCWA. The thickness of this layer can be set by new parameter “NIL sub thick”.


8. The number of output rays when Stochastic mode is used is now fixed to only 1 and is regardless to the value in Start/Stop Order settings in the UI. This makes the settings easier and less confusing. If multiple output rays are desired, please send feedback to support team.

9. Speed of interpolation mode is improved by 15%.

10. A new DLL is created for reading pre-calculated efficiency data for 1D/2D gratings. Lumerical data input is also supported. Check the document in the download link for more information.







A new User Defined Object DLL is created for polygon grating.



Now the DLL compile date can be checked in the visualization tool. Note this will only work with newer DLLs.



Add a new parameter “Coat mode” for us_blaze_RCWA.dll. When it’s set to “1”, the grating now can be shaped as below.




0 replies

Be the first to reply!