Soon, we will launch a new and updated customer portal, which is an important step toward providing our customers with one place to learn, interact, and get help.
Learn more.

NSC Sag Map User Analysis

This article talks about the basics of the NSC Sag User Analysis feature and how to setup a file with a complex CAD part to get the sag values for a specific face.
Michael Humphreys
05/03/2018

Background

Sequential mode has an analysis feature titled Surface Sag which provides the sag, or change in z-position, of a surface from the local vertex as a function of x- and y-positions on the surface.  OpticStudio does not have a built-in function which provides the same functionality in non-sequential mode, but the software does have a robust application programming interface (API) which allows users to write their own custom analysis features.  This article will show how to use an API built user analysis which calculates the surface sag for non-sequential objects.  It will also discuss the internal calculations and some techniques for creating a custom user analysis.

NSC Sag Calculation

The NSC Sag User Analysis performs several steps to calculate the sag value of a given Object’s Face in non-sequential mode:
  • A temporary copy of the system is created in memory
  • All objects except the selected object is set to ignore
  • The selected object’s material is removed to potentially account for the back face of the object
  • A single source ray is placed in the system
    • By default the source ray is placed at XYZ of (0, 0, -50) and pointing at LMN of (0, 0, 1), but these values can be changed in the advanced section (bottom right of screen)
    • A rectangular array is then applied to the source that corresponds to the sampling and width
  • A ray trace is performed and the ZRD file is saved
  • X_HITFACE filter string is applied to the ray trace to only get the Z values for the desired face
  • A Z offset is applied to the ZRD file to attempt to zero out the vertex
    • The Z offset is automatically calculated for Standard Lens, Biconic Zernike Surface, Even Asphere Lens, Odd Asphere Lens, and Toroidal Lens
    • The Z offset can be manually changed to account for any other type of surface
 
The result of the calculation is either a 1D (line)/2D (false color) graph or a text output, which can be changed in the Settings windows.  The User Analysis can be used on simple non-sequential systems such as a converted Double Gauss or a complex system with imported CAD parts:
 

Figure 1: Standard Lens



Figure 2: Biconic Zernike Surface



Figure 3: Complex CAD Part
 

Running NSC Sag

The NSC Sag is a User Analysis and the NSC Sag.exe needs to be located in Zemax\ZOS-API\User Analysis folder.  Once the executable is copied to the correct folder, OpticStudio needs to be restarted.  To launch the User Analysis, click on Programming > User Analysis > NSC Sag:
 

 
The first time the analysis is launched, the user will need to click on the Settings icon to launch a Windows form dialog box and enter the settings:

 
The Settings window has the following sections (all length values are in lens units):

  1. Object – only valid objects (non-source and non-detector) are listed
  2. Face – once a valid object is selected, only the actual object’s faces are listed
  3. Sample Size – number of data points (32, 64, 128, 256, 512, or 1024)
  4. Z Offset – constant value added/subtracted from all Z values during calculation
  5. Rotation – Z-axis rotation of object (values should be between 0° and 360°)
  6. X/Y Width – with of array of rays
  7. X/Y Decenter – center of array of rays
  8. Show As – data type to display (False Color, Text, or Cross Section)
  9. Auto Offset – automatically “guesses” the correct values for Z Offset & X/Y Width for common objects & faces
  10. Advanced – exposes advanced settings:
    1. Z starting position of array of rays
    2. Preserves original XY tilt of object
    3. Saves intermediate ZMX and ZRD files
  11. Buttons – OK runs the analysis and Cancel closes settings without performing calculations

Measuring a CAD File

The NSC Sag User Analysis can measure the sag on any non-sequential object, including CAD parts.  For native OpticStudio objects which are centered on the object’s local vertex, the User Analysis should work without much setup on the user’s behave.  However, for imported CAD parts including STEP and SLDPRT files, which could have an offset and rotation for the center of the part with respect to the local vertex, some setup could be required.
The first thing to determine is which face you actually want to run the analysis on.  To determine the face number, click on the View Current Object icon in the Non-Sequential Editor toolbar.  This will open an interactive viewer where you can click on the desired surface and the surface will turn orange.  The highlighted face number will appear in the viewer’s tab:



Next, to determine the proper tilts and decenters, you should insert a new a object below the CAD part and change the object to Source Ray; set the Z Position to -50mm (the default value for the NSC Sag analysis) and the # Layout Rays to 1.  Now open the NSC 3D Layout and see how the ray interacts with the CAD part. 



If the ray is currently centered on the CAD part, no modification is required.  However, if the part is rotated with respect to the ray or the ray is not at the center of the part, then you will have to change the Tilt About X/Y of the CAD Part or the X/Y/Z Position of the ray.  The easiest way to quickly change the tilt of the CAD part is to set the Tilt About X/Y/Z as a variable and launch the Visual Optimization from the Optimization ribbon toolbar.  Change the start and stop values for all tilts to -180 and +180 respectively.  Now modify the values until the CAD part is aligned with the Source Ray.  Make sure to click Keep and Exit once you have rotated the part:



For the attached sample file, the Tilt About X of the RandomCurve.STEP should be -79.2 and the (X, Y, Z) positions should be (260, 500, -400):


Now, you can open up the NSC Sag User Analysis and click on the Settings button in the upper left hand corner of the toolbar.  You can estimate the X/Y Width by using the Active Cursor o the NSC 3D Layout plot.  You should make your settings look like the picture below.  To show the Advanced tab, click on the arrow in the bottom right corner; make sure to uncheck the Remove XY Tilt and check the Keep Saved Files:



After you click OK and the analysis finishes, take a look at the actual analysis result.  Although the Sample Size was set very low, there should be a false color plot which shows some sag:



There will be a new file in the current folder called nsc_sag_map.zmx.  Open this file and look at the NSC 3D Layout.  You will notice that the single Source Ray is repeated on a (N+1)x(N+1) grid with a spacing that correlates to the X/Y Width from the Settings form.



Now that you have verified that there is data in the plot and the saved file is fully covered with rays, you can increase the sampling and tweak the widths & decenters to get the best image.  The following Settings will produce the final image: