Grid Sag

The Grid Sag surface has a shape defined by a base plane, sphere, conic asphere, polynomial asphere, or Zernike asphere plus additional sag terms defined by a rectangular array of sag values. The surface shape is determined by either a linear or a bicubic spline interpolation of the sag values. The sag can be described at discrete points by

Where

and the Zi terms are the Zernike standard terms as described in "Zernike Standard Sag". The terms delx and dely are the spacings between grid points in the x and y directions, xdec and ydec are optional decentration coordinates, and nx and ny are the number of points in the grid in each direction. The nx and ny values must be no smaller than 5. The terms defining Zbase are identical to those defined for the even asphere surface. Note that the sag defined by the grid points may be decentered relative to the sag defined by the base aspheric shape. There are also Zernike decenter terms in parameters 9 and 10, which are optionally used to decenter just the Zernike expression relative to the surface vertex. OpticStudio computes the effective paraxial curvature using the vertex radius of curvature, asphere coefficient data, and grid data points when computing paraxial power for this surface.

Importing Grid Data

All of this data must be computed and tabulated outside of OpticStudio, arranged in the proper file format, and then read using the Import section of the Surface Properties. The proper file format is as follows:

 
nx ny delx dely unitflag xdec ydec 
z dz/dx dz/dy d2z/dxdy nodata
.
.
.
 

The first line in the file contains seven values, which define the (integer) number of points in the x and y directions, the (floating point) increment in the x and y directions (positive values are assumed, only the absolute values of delx and dely are taken into account), an (integer) flag indicating the units of the data: 0 for mm, 1 for cm, 2 for in, and 3 for meters, and the (floating point) decenter of the grid points relative to the base surface in x and y. Any required scaling to the current lens units will be performed. Note that sag and cross derivative values have dimensions, and are therefore scaled, but first derivative values are dimensionless, and are not scaled.

The remaining nx*ny lines of the file contain four (floating point) numbers and (optionally) one integer each. The four floating point values are the sag, the x derivative of the sag, the y derivative of the sag, and the cross derivative d/dxdy. The optional fifth data entry is an integer flag that indicates if the data is invalid. Valid measured data should either have a zero or blank space for the nodata flag. Points for which the data is not valid should have a nodata value of unity.

If the nodata value is unity, the whole line of entries will be replaced with zeros and only the base portion of the sag will be used for calculations. If any entry in the grid sag table is not a number, the entry is replaced with zero.

The first data line in the file corresponds to the upper left corner of the surface, that is, the corner defined by -x and +y limits. Each point that follows is read across the face of the surface from left to right. After nx points, the nx+1 point is read in as the first value in row 2, and so on until nx*ny points have been read in. The file must be in ASCII and end in the extension .DAT (for files used by NSC objects, the extension should be .GRD).

The derivative values are required for smooth bicubic interpolation of the sag between the data points. The derivative values are not used by the linear interpolation algorithm. If all of the derivative values (dz/dx, dz/dy, and d2z/dxdy) are zero for every point in the file, then OpticStudio will automatically estimate the derivatives using a finite difference method.

The grid sag file format also supports comment lines. Any line starting with the "!" character is ignored.

Bicubic Spline vs. Linear Interpolation

The sag of the surface at any arbitrary point is computed using either of two interpolation algorithms. The bicubic spline algorithm is used by default, and provides an interpolation that is smooth in both sag and the first derivative of the sag. The bicubic spline is the preferred algorithm for reasonably smooth data. For noisy pseudo- random like data, or grid data with sharp discontinuities, bicubic spline can cause "overshoot", which means the interpolation of the surface data can yield sag points which are far from the grid points. For these cases, a linear interpolation algorithm may provide more useful results. The choice of bicubic spline or linear interpolation is user selectable as one of the parameters.

Suggestions for Using the Grid Sag Surface

For important information about the limitations of splines, see "Comments about spline surfaces". To use the grid sag surface, first change the surface type to grid sag. Then go to the Import section of the Surface Properties dialog, and select the DAT file name. The data will be loaded into memory, but will not be displayed on the Lens Data Editor. The reason for not displaying the data is the potentially large number of points. Once the grid file is loaded, the values can be checked using the Surface Data Report. The data is thereafter stored with the lens file, and the original DAT file is ignored. If the DAT file must be changed, the file needs to be reloaded using the Import feature in the Surface Properties dialog.

The grid size is only limited by available memory. Each point in the grid requires 4 8-byte double precision values and 1 1-byte value, or 33 bytes. A 255 by 255 grid file would require approximately 2 Megabytes of memory. Surfaces using Grid Sag surfaces with many points can be slow to edit and read and write from files. One way to speed up editing is to turn off the "disk multi step" undo feature in OpticStudio. See the "Editors" section of "OpticStudio Preferences" (from the Setup Tab).

The bicubic interpolation algorithm is smooth to third order, with exact results at the grid points, and large grid files are generally not required for reasonably smooth surface shapes. However, like all low order spline models of surfaces, the Grid Sag surface can never closely model a high order asphere surface. The reason is that no reasonable number of piece-wise third order polynomials can accurately follow a higher order shape. The Grid Sag surface is intended to model arbitrary low order shapes without higher order undulations.

The Grid Sag surface is not defined outside of the bounds of the grid. Rays traced outside the grid area are treated as a ray miss error. It is a good idea to make the valid data portion of the grid slightly larger than the maximum area illuminated by rays; specifically, do not define the grid to be exactly the same size as the beam print. Rays nearly exactly at the edge of the grid may not trace as intended.

For Grid Sag surfaces that model steeply curved optics, such as fast mirrors, it is better to use the base radius and conic to define the parent shape, and then use the Grid Sag data to define the deviations from the base shape; rather than to embed the entire sag definition for the surface in the grid data. The reason is OpticStudio can use the base radius and conic to find a good "first guess" to the ray-surface intercept, then use the additional grid sag data to iterate to the exact solution. It is difficult and slow for OpticStudio to find the correct intercept between a steeply incident ray and a steeply curved Grid Sag surface if the base spherical surface is flat.

An example C language program, GRIDSAMP.C, can be found in the folder <objects>\Grid Files (see "Folders"). This sample program shows the correct method for creating a grid DAT file; the example used is a spherical surface. The GRIDSAMP program also shows how to use finite differences to compute the derivatives when only the sag formula of a surface is known analytically.

No optimization or tolerancing of grid data is possible.

PARAMETER DEFINITIONS FOR GRID SAG SURFACES

Parameter # Definition
0 Interpolation method. Use 0 for bicubic spline, 1 for linear. See "Bicubic spline vs. linear interpolation".
1 - 8 α1 - α8
9 Zernike decenter X in lens units
10 Zernike decenter Y in lens units
13 Number of terms (up to 231)
14 Normalization radius. Coordinates are normalized by this value.
15-245 Coefficients on Zernike polynomials 1 - 231, respectively, in lens units.

Next: