LINZIK: The compact optical CAD - Help

LINZIK: The compact optical CAD v1.1d - Help

© 2008, Arkady Vodyanik

Contents:

What is LINZIK

LINZIK is a lens ray tracing program for calculating, in particular, astronomical optics. It includes optimizer, which can choose parameters of surfaces to minimize the goal (merit) function and satisfy the specified restrictions.

LINZIK interprets the same name internal language. Files of optical schemes (*. lnz) and forms for analysis (*.an) save by program in this language. The language has operators for modifying of surfaces and tables. The operators duplicate virtually all menus and input fields.

The language potential enough to write own user optimizers and other complex scenarios.

Of course, LINZIK is just another optical CAD. It did not claim to revolutionary. The author is keen on optical telescope design and is trying to express his vision of the subject matter in a minimalist manner. The word "minimalism" here refers not to functionality, but to minimize the apparent "control room": only necessary for supervision during optimization. It is an attempt to make the user interface is not too ramified and easy extendable.

Version 1.1d - free and does not require registration until the number of variables in the Optimizer is not exceed 4. The program is distributed "as is". The author is not responsible for the possible wrong calculation and/or damage from using the program.

Thank you for your constructive criticism and suggestions.

System requirements

Version 1.1d is tested on Windows XP SP1, SP2 and Vista on computers with 512 MB of RAM. Note: The screen rezolution must be at least 1024x768 pixels.

If you plan to use functions for quick calculation of the spot sizes using ray-tracing as parallel computing on many processors, it will require a video card compatible with NVIDIA CUDA and the related special driver.

The AMD Stream technology is supported also and can be used instead CUDA.

Version 1.1d is tested with NVIDIA GeForce 260 GTX and AMD Radeon HD 4870.

Attention! Letter "d" in the version name means that only double precision supported in CUDA and AMD Stream. So check this capability for your video card.

Entering schemes and editing tables surfaces

The first steps - yet without experience

Expand the "File" menu. Select the "Open". Try to load the scheme from the list.

Scheme "Demo-Film-Runme!. Lnz" is not just a scheme, it is a demo scenario. It imitates the user behaviour and builds achromatic doublet "from scratch".

Setting of angle

Enter the half of scheme view field (degrees) in the "Half Field Angle":

Choice of wavelengths

In the "Select Wavelengths" specify the desired wavelengths.
The current version offers six fixed waves: r, C, d, e, F, g and a wave which the user can specify.

Where is the object

If "Thickness" of "Object"(surface 1) is 0, then it is deemed that the object is in infinity.
Otherwise, the object is located at a distance specified in this field.

Aperture stop

In the current version the aperture stop is at the surface 2.

Editing fields

If the input is completed by Enter key the recalculation of the state occurs. (the same as when you press the button "Recalc").

For a glass in the "Glass" field should input a string, for example, BK7. If glass will found in catalog the glass information will present in the lower left-hand corner of window: refraction indexes, etc.

Catalog of glasses

For add glass to the catalog, click the "Edit Glass" button. Input in the "nr, nC, nd, ne, nF, ng" the refraction indexes. Comments can be added in the "Info". Then click "Save Glass." button.
The glass catalog is in the glasses.dat file.

Importing schemes and glasses from ZEMAX

LINZIK can import basic information from the ZEMAX file format: diameters, curvature radii, thicknesses, glass names. Do it with menu item "File - Import *. zmx."

Is the possible to import the glass catalogues from ZEMAX - menu item "File - Import *. agf (glasses)."

Editing forms and libraries

The "File" menu has items:
"New Analyse / Tool" - the creation of new file analyse.an. If you already have such file, it's content will display in editor.
"Edit Analyse / Tool Source" - the choice of the *.an file and editing them.
"Edit Library.lib" - go to the library editing. The functions described in the library can be called from the field "Cond", "Goal" and "Calc".

Analysis of scheme

Drawing

The right upper third of the main window is busy by layout drawing. Here you can specify an interval for displayed surfaces (field "From" - "to") and the scaling mode: "by Length" or "by Dia"
Here you can make a comment - in the edit box on the left under the drawing.

Spot Diagram

At the spot diagram on the right-secondary part of the main window, you see points of ray intersections with the surface "Image". There wavelengths specified in the "Select Wavelengths".; You can choose reference point and scaling modes.
The characteristics of spot are visible as root mean square (RMS) deviation and maximum deviation of points from a reference point.

Longitudinal Spherical Aberration Diagram

It placed on the middle bottom of the main window. There wavelengths specified in the "Select Wavelengths". You can change the scale of diagram. And on top of diagram is "focuser" - slider for a smooth changing back focal length.

Analysis & Tools

The program generates a list of files with type *.an. The names of these files (forms in language LINZIK) present in the menu. For example, selecting "OPD" we run opd.an form in the window and see the results (in this case, the analysis of difference of optical path lengths).

The form window has the "File-Edit Source" menu item. When it selected the text editor starts with the source text of form. If an error occurs when the form running the control will be passed to the text editor and the error place will be pointed by cursor.

If the form name begins with an underline ("_"), it will be shown in the second section of the menu, where the Tools are clustered rather than actually Analysis. This division made for showing that Tools can modify the table and options while Analysis should not modify them. Of course, this is conditional, and the actual content of Analysis and Tools can be anything, it is not checks by LINZIK. However, the presence of the underline "_" in the form name prohibits updating (restart) of this form when you click on Recalc - if this form are suspended on screen.

The appointments of forms from the installer package:

Analysis:

  • DISTORTION - calculation of distortion
  • fft_MTF - diffraction Modulation Transfer Function calculated using the fast Fourier transform (FFT)
  • fft_PMTF - polychromatic modualation transfer function
  • fft_PSF - diffraction Point Spread Function calculated using the FFT
  • FOCAL_SHIFT - chromatic curve
  • GLASSES_nd_Vd_diagram - Abbe's diagram
  • GLASSES_partial_dispersion - partial dispersions diagram of glasses used in scheme
  • OPD - optical path differences
  • SPOTS - Expanded spot diagram
  • VIGNETTING - a vignetting
  • WAVEFRONT - the wavefront map and calculating the PV and RMS of wavefront error
  • Tools:
  • _SCALE_SYSTEM - scaling system
  • _TEST_PLATES - automatic selecting the standart radii from file plates.txt with optimization.

    Optimizer

    The optimizer dialog is in the lower right corner of the main window.

    By click to the "Search" button the optimizer will try to find such values of variables in the table that the merit function [goal] (described in the the"Goal:" line) will have a minimal value. In this process the optimizer checks the value of function [cond], (described in the the"Cond:" line) which must be TRUE (1). If [cond] have value FALSE (0) the optimizer automatically adds 1000000 to result of [goal].

    In other words, the violation of conditions [cond] increases the value of merit function [goal] and forces the optimizer to avoid this violation.

    By click to the "Search" button (or when the operator SEARCH) executes) the optimizer performs the number of iterations specified in the "N Iter" (or due to the precision required in the "Tol") and stops, shows the value of [goal] and redraws the main window with the achieved optimization results.

    Right on the button "Search" there is a menu to choose the method of optimization. Now the optimizer supports four methods: Simplex, Broyden's, Simulated Annealing and Global-random.

    The choice of optimization method can be performed not only manually, but using the operator of METHOD from forms.

    User (man who clicks on the "Search" or form that called the operator SEARCH) can take a decision to continue searching, analyzing the value [goal].

    If the user (man) decide to abandon the current changes to SEARCH, he can click "Undo".

    If you want to interrupt the iterations, you can click on "Cancel" or "Stop". Clicking on "Cancel" is equivalent to "Stop" and "Undo".

    It should be noted that the contents of the "Cond "and" Goal "is not confined to expressions containing only embedded functions. It is possible to have own user's functions in file library.lib and call them from these fields. Thus, the [goal] and [cond] functions can be very complex.

    The variable can be defined in the table as follows:
    1) Manual: Right-click on the desired field, and then choose the "Variable" from the PopUp menu.
    2) From form: using the VARIABLE operator.

    This field-variable highlights by yellow.

    The field in the table can be "linked" by it's value to the other fields, see PICKUPPLUS, PICKUPMINUS. PICKUPPLUS highlights by reddish fields, and PICKUPMINUS - by bluer colors.

    The field in the table can be make again as not changeable:
    1) Manual: Right-click on the desired field, and then choose the "Fixed" from the PopUp menu.
    2) From form: using the FIXED operator.

    The "Cond & Goal by default" loads fields "Goal" and "Cond" by default definitions.

    The "Test" calculates performance of LINZIK plus computer system ans shows a window with the measured raytracing speed.

    Beginning from Version 0.9 the syntax highlighting of optimizer'z fields was added with the indication of wrong conditions in optimizer: the compare operation ("<", ">", "<=", ">=", "<>") will be highlighted when returns 0 (FALSE).

    Example:
    1 - wrong condition;
    2 - the syntax error;

    Beginning from Version 1.1 added the indicator of currect GPU and button AntiLoop for exit from local minimums using small random variation of optimizer's variables.

    LINZIK: Language description

    LINZIK can be called BASIC-like language. The main difference is a syntax of function call: instead sin (x) should write [sin x]. That is the function call begins with square brackets, followed by the name of the function and its arguments (if present).

    Names consist of letter, or letter and number, or two letters. Only Latin letters are allowed. There is no case-sensitivity. In this guide characters of operators are shown in upper case, and functions in lowercase: to emphasize the difference between the respective corresponding to each other functions and operators. For example, the operator SCALE corresponds to the function [scale].

    There is only one data type - numeric.

    In the lower right corner of the main window is the "Calc". This is the calculator, which can compute any language expression (formulas).

    Operators for modifying tables and options

    NEWSYSTEM

    Starts a new table consisting of two surfaces: Object and Image. This operator is equivalent to clicking on "New" or choosing the "New" from menu.

    INSERT

    Adds new row to the table, below the current selector position. This operator is equivalent to clicking on "Insert After."

    DELETE

    Removes the row from the table. This operator is equivalent to clicking on "Delete".

    DIAM2 s, v

    Sets the half-diameter v for surface s. This operator is equivalent to the manually recording in the table.

    CURVR s, v

    Sets the radius of curvature (v) for surface s. This operator is equivalent to the manually recording in the table.

    THICK s, v

    Sets thickness (v) for surface s. This operator is equivalent to the manually recording in the table.

    ANGLE a

    Sets the value of the half of angle in degrees in the "Half Field Angle."

    WAVE w, v

    Sets checkbox "Select Wavelengths" for wave w. Values of v: 1 - selected 0 - unselected

    BYLENGTH

    Sets that the layout drawing will be shown with such scale that the selected interval of surfaces takes the whole length. This is equivalent to manual selection of radio-button "Scale: by Length."

    BYDIAM

    Sets that the layout drawing will be shown with such scale that the largest diameter in the selected interval of surfaces takes all the proposed height. This is equivalent to manual selection of radio-button "Scale: by Dia".

    LAYOUT f, t

    Sets that the scheme will be shown in the layout drawing from surface f to t inclusive. This is equivalent to manual input of f and t in the "From:" and "to:" respectively.

    RAYS n

    Sets the number of rays on the radius of the entrance pupil. This is equivalent to manual input of n in the "Rays: ". Allowed values of n: 2 .. 40.

    AIRY f

    Sets whether to show the Airy disk on the spot diagram. The values of f: 0 - do not show 1 - show. This is equivalent to manual input of f in the "Airy Dia."

    SCALE v

    Sets size v (microns) of scale ruler on the spot diagram. This is equivalent to manual input of v in the "Scale: ".

    REFERENCE v

    Sets the mode of reference point. The reference point can be set as the centroid of spot, as the chief ray or as a place corresponding to lack of distortion (W/o distorsion). This is equivalent to manual selection in the "Reference".
    Values of v: 0 - Centroid, 1 - Chief Ray, 2 - W/o distorsion.

    LASCALE v

    Sets the scale of longitudinal spherical aberration diagram. This is equivalent to manual input of v. Calling operator LASCALE 0 sets the automatic scaling mode.

    FOCUS v

    Moves "focuser" within the scope of the longitudinal spherical aberration diagram. Value v: -100 .. 100. This is equivalent to manual displacement of the slider located on the diagram.

    DESCRIPT str

    Sets the comment for the layout drawing. This is equivalent to manual input text in the field.

    GLASS s, str

    Sets the name of material (str) for the surface s. This is equivalent to manual input of string str in the table column "Glass" for the surface s.

    GLASSN s, g

    Sets the number of material (g) for the surface s. The number of material can be obtained as a result of the function [glassn ..] or as a content of element of array MEM after calling the operator LOADGLASSES.

    COND str

    Sets the content of field "Cond: " which accessible by function [cond]. The [cond] will interprete string str as an expression. This is equivalent to manual input str in the "Cond: ".

    GOAL str

    Sets the content of field "Goal: " which accessible by function [goal]. The [goal] will interprete string str as an expression. This is equivalent to manual input str in the "Goal: ".

    CALC str

    Sets the content of field "Calc: " This is equivalent to manual input str in the "Calc: ".

    PICKUPPLUS r1, c, r2

    Sets that the value of cell (row r1, column c) will automatically repeat the value of cell (row r2, column c). This is equivalent to the right mouse click and choice the item "Pickup Plus" from PopUp menu with the input in the proposed dialogue.

    PICKUPMINUS r1, c, r2

    Sets that the value of cell (row r1, column c) will automatically repeat the value of cell (row r2, column c) multiplied to -1. This is equivalent to the right mouse click and choice the item "Pickup Minus" from PopUp menu with the input in the proposed dialogue.

    CONIC s, v

    Sets the v (square of eccentricity multiplied to -1) for the surface s. This is equivalent to manual input v in the table column "Conic" for surface s.

    USERWAVE L

    Sets the wavelength L for wave 7, nanometers. This is equivalent to manual input of L in the "Select Wavelength. "

    Operators for working with text and graphics

    FORM x, y, w, h

    Creates a window: x and y are coordinates of the upper left corner, w and h are width and height. All sizes in pixels.

    PIXEL x, y, c

    Draws a pixel with the coordinates x,y and color c.
    The color coded as three components R (red), G (green) and B (blue) using the formula:

    
     B * 256 * 256 * 256 + G + R 
    Values of R,G,R: 0 .. 255.

    PLOT t, x, y, w, h, fx, tx, fy, ty

    Draws the plot of function [eval], for values listed in the interval fx .. tx.
    The plot can be built in the different modes t (values 0 .. 3), the upper left corner has coordinates (x,y) - pixels, the width and height (w,h) (pixels), the estimated interval of values of [eval] is defined as fy .. ty.
    Example: building plot of function [sin x] in the range 0 .. 10, the estimated value -1 .. 1:

    
          EVAL [sin X]
          PLOT 1, 20, 30, 100, 150, 0, 10, -1, 1
     
    Attention! Operator PLOT modifies the value of the variable X.

    Values of t:

    For each point of plot the operator PLOT aumatically executes operator HINT with corresponding number. Thus, if the mouse pointer contacts the curve the ballon appears with this number; then on right-click the pop-up menu will be open for copying this number to clipboard.

    EVAL str

    Loads string str into the internal buffer which available for function [eval]. Function [eval] iterpretes this string and returns its value. Example:

    
          EVAL [sin x] + [cos y]
     

    MOVE x, y

    Moves "pencil" to the point with the coordinates (x, y).
    This movement points the position where the text writing will begin or from where the operator LINE will start draw the line.

    LINE x, y

    Draws a line to a point with the coordinates (x, y). The color of line can be set by the operator COLOR. If the color is not specified there it will be 0 (black).

    COLOR c

    Sets the color for the operator LINE and for the text output using operator - (minus). The color coded as three components R (red), G (green) and B (blue) using the formula:

     B * 256 * 256 * 256 + G + R 
    Values of R,G,R: 0 .. 255.

    BKGND c

    Sets the background color for operator CLEAR and for operator - (minus).

    - (MINUS)

    This operator is a string with character "-" in the first position. The remainder of string will be put to the form window from the "pencil" coordinates. The string can contain the format statements for the numerical output. Syntax of the format statement, here v is the variable name, "^" is character place(s):

    
          ^v^
     
    Example 1:
          -               OPTICAL PATH DIFFERENCE, Waves
     
    Example 2:
          color 0
          move 250,30   
          -^^ak^^ Deg
     
    Example 3:
          -^^x^^^^^^^^ ^^y^^^^^^^^
     

    HINT

    This operator is a string with word "HINT" in the first four positions. The remainder of string will be put to the buffer and associated with the "pencil" coordinates. The string can contain the format statements for the numerical output - same as operator "-". If the mouse pointer contacts with point with these coordinates the balloon appears with this string from buffer. Example:

       move x, y 
    hint ^c^^^^^^ 
    
    Operator HINT can be used for adding the mouse sensitivity to two-dimensional diagrams. For single-dimensional plots drawed by operator PLOT the HINT will be called automatically for each point of curve - with corresponding value.

    FONT f1, f2, f3

    Sets the current font for the "minus" operator. f1 - type of font: 1 - Arial, 2 - Courier New, 3 - MS Sans Serif
    f2 - font size
    f3 - effect 0 - normal, 1 - italic, 2 - fat, 3 - underlined.

    CLEAR

    Clears the content of the form window.

    Operators for optimization

    SEARCH

    Runs the optimizer. This is equivalent of clicking on button "Search". The optimizer works using the method selected in the operator METHOD.

    METHOD m, n, t

    Sets the optimization method. Here:
    m - number of method: 1 - Simplex, 2 - Broyden, 3 - Annealing (global); default selected Simplex;
    n - the number of iterations, the default 10000;
    t - tolerance, the default 0.0000001.

    VARIABLE r, c

    Sets that the cell of table (row r, column c) is a variable for optimization. This is equivalent to the right mouse click and choicing the item "Variable" from the PopUp menu.

    FIXED r, c

    Sets that the cell of table (row r, column c) is not a variable for optimization. This is equivalent to the right mouse click and choicing the item "Fixed" from the PopUp menu.

    DEFAULT

    Sets the default strings in the fields "Goal:" and "Cond:".
    For "Goal:"

    
          [srms 0.0] + [srms [angle], 0]
     
    For "Cond:"
    
          ([Aedge]> 0) & ([Gedge]> 3) & ([Athick]> 0) & ([Vig 0.0] <0.0001)
     
    This is equivalent to clicking on "Cond & Goal by default".

    Control operators

    STOP

    Stops running of form.

    LOCAL v1 ...

    Declares local variables. The values of variables listed in the operator are stored in the stack and will be restored from there by operator RETURN.

    RETURN

    Returns from subroutine.

    RETURN (e)

    Returns from function with value e.

    GOTO label

    Goes to label label.

    : label

    It is a word with length up to 10 characters which is located after the first character ":".

    CALL label

    Calls subroutine labeled by label.

    IF e ...
    ELSE ...
    ELSEIF e ...
    ENDIF

    Conditional operator.

    FOR e1 TO e1 ...
    FOR e1 DOWNTO e1 ...
    ENDFOR

    The loop operator.

    WHILE e ...
    ENDWHILE e

    The loop operator.

    Miscellaneous

    VER v

    Informs the program about the version in which was written the running form. If v is higher than the current version, a warning will be shown.

    ERROR str

    Displays the message str and raises the error situation.

    RECALC

    Runs recalculation of the state. This is equivalent to clicking on the "Recalc.

    DELAY n

    Delays the running of the form on n milliseconds.

    MEM i, v

    Sets in the element with index i of array MEM the value v. Array MEM - the single array in the language. The allowed index values: 0 .. 1000000. The value of the element can be obtained by function [mem i].

    FFT n

    Performs complex two-dimensional fast Fourier transform of array MEM. Array MEM is seen as a square matrix of size n x n. The even elements of MEM are the real parts of complex values and the odd elements are the imaginary parts.

    SHIFT n

    Performs reshuffle of quadrants of square matrix n x n. Left with right upper quadrant becomes lower, and vice versa; top right becomes the left lower quadrant and vice versa.
    This operator is used to bring the result to the operator FFT form when the upper frequencies should not lie in the corners or in the center or vice versa.

    INITVAR

    Initializing the all variables to zero.

    INITMEM

    Initializing the all elements of array MEM to zero

    LOADGLASSES

    Fills the elements of array MEM starting from element 1 by numbers of glasses. These numbers can be used in the operator PRINTGLASS and function [rindex ..]. In element 0 will be entered the total number of glasses so you can use [mem 0] or function [nglasses].

    PRINTGLASS g

    Prints a text in the form window - the name of glass with number g. Number g can be obtained as the element of array MEM after the operator LOADGLASSES or as a result of the function [glassn ..].

    HINTGLASS g

    The glass name with number g will be put to the buffer and associated with the "pencil" coordinates. Number g can be obtained as the element of array MEM after the operator LOADGLASSES or as a result of the function [glassn ..]. Example:

        move x,y 
        hintglass g
    
    When the mouse cursor contacts the glass-point on the diagram the balloon appears near cursor with glass info. On right-click the popup menu (with single position) opens that contains the selected glass name; on click to this menu the glass name will be copied to the clipboard and can be used in "Glass" fields of the scheme editor (Ctrl-V or Shift-Ins). Thus, now this diagrams are more comfortable for navigation and selection in the glass catalog.

    LOADPLATES

    Fills the elements of array MEM starting from element 1 by numbers that are radii of test plates from file plates.txt so you can use [mem 0] or function [nplates]. As the file plates.txt can be used files *.tpd prepared for ZEMAX.

    ? v text_of_question

    Displays a dialog with the invitation text_of_question to inputing the value of variable v.
    Example:

    ? k N of times?

    Functions for accessing data of tables and options

    [edge s]

    The thickness of the edge between the surface s and the surface s +1.
    Result in mm.

    [gedge]

    The function finds the "glass" element with a minimum thickness of the edge and gives this thick.
    The "glass" refers to items with index of refraction, is not equal to 1.
    Result in mm.

    [aedge]

    The function is "air" element with a minimum thickness of the edge and returns this thickness.
    The term "air" refers to items with index of refraction, equal to 1.
    Result in mm.

    [thick s]

    The distance between the surface s and the surface s +1, on axis. In other words, this is an element thickness concluded between the surfaces.
    Result in mm.

    [athick]

    The function returns the minimal thickness of "air" element.
    Result in mm.

    [gthick]

    The function finds the "glass" element with a minimum thickness of the axis, and returns this thick.
    The "glass" refers to items with index of refraction, is not equal to 1.
    Result in mm.

    [angle]

    Returns the content of the field "Half Field Angle".
    Result in degrees.

    [diam2 s]

    Half-diameter (radius) of surface s.
    Result in mm.

    [curvr s]

    The curvature radius of surface s.
    Result in mm.

    [eval]

    Calculates expression recorded in the internal buffer by operator EVAL and returns its value. This function can be used by operator PLOT.

    [wave n]

    If the "Select Wavelengths" with the number n is selected, the function returns a non-zero value, which can be interpreted as a color of wave; this color-number can be used in operators PIXEL and COLOR. If the field is not selected, the result - 0.

    [conic s]

    Returns the square of eccentricity of surface s taken with the minus sign.

    [reference]

    Returns the reference point mode. The reference point can be set as the centroid of spot, as the chief ray, or as a place that corresponding the lack of distortion.
    Modes: 0 - Centroid, 1 - Chief Ray, 2 - W/o distorsion.

    [rays]

    Returns the number of rays on the radius of the entrance pupil which specified by operator RAYS or manually.

    [airy]

    Returns: whether the operator AIRY (or was set by hand) is showing the Airy disk.
    0 - not showing 1 - showing:

    [scale]

    Returns the size of scale ruler on the spot diagram (that was set by operator SCALE or manually). Result in micron:

    [lascale]

    Returns the scale of the longitudinal spherical aberration diagram that was set by operator LASCALE or manually, or automatically.

    [nsurfaces]

    The number of surfaces in the scheme.

    [wlength w]

    Returns wavelength of wave with number w, nanometers. For example, [wlength 4] is 546.07.

    [nglasses]

    Returns number of glasses loaded into the MEM by operator LOADGLASSES.

    [glassn s]

    Returns number of glass for surface with a number s. If air or surface is a mirror, the result - 0.

    [nplates]

    Returns the number of radii of test plates loaded in the MEM. by operator LOADPLATES.

    [variable r, c]

    Returns whether the cell (row r, column c) is a variable for optimization:
    0 - is not
    1 - is
    > 1 - for pickup there is a cell with this number
    <-1 - for minus-pickup there is a cell with this number.

    Functions for raytracing

    [srms a, w]

    Returns the root mean squares (RMS) deviation of points of spot from a reference point. The reference point can be set as the centroid of spot, as the chief ray, or as a place that corresponding lack of distortion (W/o distorsion).
    The current reference point mode is assigned in the field "Reference" or by operator REFERENCE from forms.
    Here:
    a - angle, degrees.
    w - wave number (1 .. 7). If w is 0, the RMS is calculated for all waves selected in the "Select Wavelengths".
    Result in microns.

    [cp_srms a,w]

    Same as [srms a,w] but it will be computed using the optimized accel.dll; twice more faster than [srms a,w].

    [cp_2_srms a1,a2,w]

    This is equvivalent to [cp_srms a1,w]+[cp_srms a2,w]. If the computer has two processors it will be computed twice more faster.

    [nv_srms a,w]

    Same as [srms a,w] but it will be computed using NVIDIA CUDA or AMD Stream.

    [nv_2_srms a1,a2,w]

    This is equivalent to [nv_srms a1,w]+[nv_srms a2,w] but will be computed twice more faster (if number of GPU processors is enough).

    [nv_3_srms a1,a2,a3,w]

    This is equivalent to [nv_srms a1,w]+[nv_srms a2,w]+[nv_srms a3,w] but will be computed thrice more faster (if number of GPU processors is enough).

    [maxr a, w]

    Returns the maximum deviation of points of spot from a reference point. The reference point can be set as the centroid of spot, as the chief ray, or as a place that corresponding lack of distortion (W/o distorsion).
    The current reference point mode is assigned in the field "Reference" or by operator REFERENCE from forms.
    Here:
    a - angle, degrees.
    w - wave (1 .. 7). If w is 0, the maximum deviation is calculated for all waves selected in the "Select Wavelengths".
    Result in microns.

    [cp_maxr a,w]

    Same as [maxr a,w] but it will be computed using the optimized accel.dll; twice more faster than [maxr a,w].

    [cp_2_maxr a1,a2,w]

    This is equvivalent to [cp_maxr a1,w]+[cp_maxr a2,w]. If the computer has two processors it will be computed twice more faster.

    [nv_maxr a,w]

    Same as [maxr a,w] but it will be computed using NVIDIA CUDA or AMD Stream.

    [nv_2_maxr a1,a2,w]

    This is equivalent to [nv_maxr a1,w]+[nv_maxr a2,w] but will be computed twice more faster (if number of GPU processors is enough).

    [nv_3_maxr a1,a2,a3,w]

    This is equivalent to [nv_maxr a1,w]+[nv_maxr a2,w]+[nv_maxr a3,w] but will be computed thrice more faster (if number of GPU processors is enough).

    [vig a, w]

    Returns a percent of vignetting. Here:
    a - angle, degrees.
    w - wave (1 .. 7). If the wave is 0 the vignetting will calculated for all waves, selected in the "Select Wavelengths".

    [cp_vig a,w]

    This is equivalent to [vig a,w] but it will be computed using the optimized accel.dll; twice more faster than [vig a,w].

    [nv_vig a,w]

    Same as [vig ..] but it will be computed using NVIDIA CUDA or AMD Stream.

    [__vig]

    Quickly evals vignetting without ray tracing using data left in the cache by functions [cp_srms ..], [cp_maxr], [nv_srms], [nv_maxr].

    Example. If the "Goal:" contains "[cp_srms [angle], 0] + [cp_srms 0,0]" the expression "[cp_srms 0,0]" will be calculated last. Then, if the "Cond:" contains "[vig 0,0]" (vignetting for the center, this is the case by default), it may be replaced at [__vig], because optimizer calculates "Goal:" before "Cond:".

    [ef]

    The effective focal length in millimetres.

    [fr]

    The focal ratio.

    [opath a, w, y, z]

    Returns length of the optical path for angle a, wave w; y and z are coordinates of the point located on the surface 2. Result in mm.

    [opd a, w, y, z]

    Returns the difference in optical path lengths as:

          
    ([opath a, w, y, z] - [opath a, w, 0, 0]) / L 
    Here: a - angle, degrees, w - wave (1 .. 7), y,z - coordinates of points located on the surface 2, L - length of wave w.

    [zcentroid a, w]

    Returns the coordinate z of centroid of spot.
    Here:
    a - angle, degrees.
    w - waver (1 .. 7). If w is 0, the coordinates of centroid will be calculated for all waves selected in the "Select Wavelengths".
    Result in mm.

    [ycentroid a, w]

    Returns the coordinate y of centroid of spot.
    Here:
    a - angle, degrees.
    w - waver (1 .. 7). If w is 0, the coordinates of centroid will be calculated for all waves selected in the "Select Wavelengths".
    Result in mm.

    [lsa w, y]

    Returns the longitudinal spherical aberration for wave w (1..7) and point with coordinates (y,0) located on the surface 2.
    Result in mm.

    [rz a, w, y, z]

    Returns the coordinate z of the point of spot (point in the plane "Image") for angle a (degrees), wave w (1 .. 7) for ray passing through point with coordinates (y,z) located on the surface 2.
    Result in mm.

    [ry a, w, y, z]

    Returns the coordinate y of the point of spot (point in the plane "Image") for angle a (degrees), wave w (1 .. 7) for ray passing through point with coordinates (y, z) located on the surface 2.
    Result in mm.

    [wz a, w, y, z]

    Returns the coordinate z of the point of Exit Pupil for angle a (degrees), wave w (1 .. 7) for ray passing through point with coordinates (y, z) located on the surface 2.
    Result in mm.

    [wy a, w, y, z]

    Returns the coordinate y of the point of Exit Pupil for angle a (degrees), wave w (1 .. 7) for ray passing through point with coordinates (y, z) located on the surface 2.
    Result in mm.

    Functions for optimization

    [goal]

    Returns value of expression in the field "Goal ". This function is used as a criterion of optimality (merit function) by optimizer. The example of this function by default ( when you click on "Cond & Goal by default"):

         
    [srms 0,0] + [srms [angle], 0]
    Here is sum of root mean squares of deviations of points of spots in the center of view field and at its edge for all wavelengths.

    [cond]

    Returns value of expression in the field "Cond ". This function is used by optimizer as a condition for the correctness of the system. The example of this function by default ( when you click on "Cond & Goal by default"):

         
    ([Aedge]> 0) & ([Gedge]> 3) & ([Athick]> 0) & ([Vig 0.0] <0.0001)
    It requires to have positive thick of air edges ([Aedge]> 0), glass edge at least 3 mm thick ([Gedge]> 3), positive thick of air elements in the axis ([Athick]> 0), and zero vignetting in the center of the view field for all waves ([Vig 0.0] <0.0001).

    Mathematical Functions

    [sin x]

    Sine of angle x, rad.

    [cos x]

    Cosine of angle x, rad.

    [arctan x]

    Arctangent of angle x, rad.

    [sqrt x]

    Square root of x.

    [abs x]

    The absolute value of x.

    [ln x]

    Natural logarithm of x.

    [p2 x]

    Square of x.

    [rad x]

    Converts degrees to radians.

    [dgr x]

    Converts radians to degrees.

    [ro x]

    Rounds to the nearest integer number.

    [tr x]

    Truncates to integer number.

    [rnd]

    Random numbers in the range 0 .. 1.

    [ere x]

    Returns real part of raising number e to power i * 2 * pi * x. Used in the calculation of PSF and MTF. Here pi = 3.14159265358 ..., e = 2.718281828 .., i - imaginary 1.

    [eim x]

    Returns imaginary part of raising number e to power i * 2 * pi * x. Used in the calculation of PSF and MTF. Here pi = 3.14159265358 ..., e = 2.718281828 .., i - imaginary 1.

    Miscellaneous

    [ver]

    Returns version of the program.

    [lx]

    Horizontal coordinates of the upper left corner of the main window. Result in pixels.

    [ly]

    Vertical coordinates of the upper left corner of the main window. Result in pixels.

    [mem i]

    Returns value of element with number i of array MEM.

    [rindex w, g]

    Returns index of refraction for wave with number w and glass with number g. If the number of wave is 7 (wave length determined by the user), it performs an interpolation of six fixed-length waves using the Schott's formula.

    [tick]

    Returns number of milliseconds after the Windows start. Can be used for profiling.

    [rdtsc]

    Returns value of time stamp counter on CPU divided by 65536. Can be used for profiling.

    [nv_rays]

    Returns number of rays that simultaneously were traced using NVIDIA CUDA or AMD Stream. The result is correct only after call of [nv_srms] or [nv_maxr].


    User-defined functions

    Operator RETURN can return a value of expression in round brackets. In this case the subroutine is a user defined function. Calling such functions has syntax: [:label] or [:label parameters] where parameters are expression(s) which delimited by comas.

    Example 1:

                                                                                                                                                                                                                                                                                     
          x = [:max 3,5] 
          -^^^^^x
          stop
          *
    
         :max (x, y) 
         if x > y return (x); else return (y); endif
    
    Result: 5

    The recursive calls are allowed. Example 2 (recursive calculation of factorial N! = N*(N-1)*(N-2)...*1 ):

    
          x=[:factorial 5]
          -^^^^^^^x
          stop
    
          :factorial(n)
          if n=0 return (1); else return (n*[:factorial n-1]); endif 
    
    Result: 120


    Versions History

    Version 0.1 - March 3, 2008

    Version 0.2 - March 9, 2008:
    Added functions [ln ..] [p2 ..] [ro ..] [tr ..] [rnd], [wz ..] [wy ..].
    Added operators METHOD, FFT.
    Optimizer can use different methods.
    Library.lib: in this file can be defined functions, which can be called from the "Goal", "Cond", "Calc."

    Version 0.3 - March 17, 2008:
    Added functions [nsurfaces], [wlength ..] [ere ..] [eim ..].
    Added operators: INITVAR, INITMEM, .. SHIFT.
    Added forms: fft_PSF, fft_MTF - Point Spread Function and Modulation Transfer Function respectively.

    Version 0.4 - March 26, 2008:
    In addition to the six fixed waves can be entered the seventh wave with the required length.
    Added functions [nglasses], [rindex ..] [glassn ..]
    Added operators: LOADGLASSES, PRINTGLASS, GLASSN .., USERWAVE.
    Added forms WAVEFRONT, FOCAL_SHIFT, GLASSES - wavefront errors, chromatic curves, partial dispersion diagram.

    Version 0.5 - April 5, 2008:
    Added functions [nplates], [variable ..].
    Added operators: LOADPLATES,? ...
    Added forms: VIGNETTING - vignetting diagram, _SCALE_SYSTEM - scaling system _TEST_PLATES - selecting the standart curvature radii from file plates.txt with optimization.
    Menu "Analysis" expanded as "Analysis & Tools."
    Accelerated functions for working with the glass catalog.
    Increased the maximum number of surfaces: from 22 to 126.

    Version 0.6 - April 10, 2008:
    In the menu "File" added items: "New Analyse / Tool", "Edit Analyse / Tool Source", "Edit Library.lib" - for editing forms and libraries.
    Added highlighting of the LINZIK language syntax.
    Added form SPOTS - Expanded spot diagram.

    Version 0.7 - April 30, 2008:
    Added support for multiprocessor GPGPU computing on video card compatible with the NVIDIA CUDA. New functions [nv_srms ..] and [nv_maxr ..] calculate characteristics of spot tracing all rays simultaneously on video card processors. For example, using NVIDIA GeForce 8800GT (112 processors) gives acceleration as 2 - 10 times or more compared with functions [srms ..] and [maxr ..] on the central processor Intel Pentium E2180 2 GHz. The gain from using CUDA will grow with more optical surfaces in the scheme.
    Added forms DISTORTION - calculation of distortion, fft_PMTF - polychromatic modualation transfer function.
    Added functions [tick] and [nv_rays].

    Version 0.8 - May 7, 2008:
    Improved interaction with CUDA: functions [nv_srms ..] and [nv_maxr ..] are 30% faster than in version 0.7.
    New functions for computing on CUDA: [nv_2_srms ..], [nv_2_maxr ..], [nv_3_srms ..], [nv_3_maxr ..] allows for one call to them to calculate the characteristics of spots for the entire field: for 2 or 3 angles, respectively. For example, the function [nv_2_srms ..] runs almost the same time as [nv_srms ..], and are equivalent of [nv_srms ..]+[ nv_srms ..].
    Optimized ray-tracing code for central processor. New functions [cp_srms ..] and [cp_maxr ..] are twice faster than [srms ..] and [maxr ..] respectively. New functions [cp_2_srms ..] and [cp_2_maxr ..] are equivalents of the sum of two [cp_srms ..] or [cp_maxr ..], but if the system has two central processors it will be calculated almost twice faster.
    New function [rdtsc].

    Version 0.81 - May 18, 2008:
    Corrected the bug - versions 0.7 and 0.8 were not working in Windows x64. The [nv_ ...] functions use not CUDA 1.1 but CUDA 2.0 BETA for compatibility with Vista. If you intend to use these functions then download a new version of a suitable driver.

    Version 1.1 - June 18, 2008:
    Added operators: HINT.., HINTGLASS..
    Added form: GLASSES_nd_Vd - the Abbe's diagram.

    The form GLASSES (partial dispersion) was renamed to GLASSES_partial_dispersion, and (same as GLASSES_nd_Vd) it now has the mouse sensitivity: when the mouse cursor contacts the glass-point on the diagram the balloon appears near cursor with glass info. On right-click the popup menu (with single position) opens that contains the selected glass name; on click to this menu the glass name will be copied to the clipboard and can be used in "Glass" fields of the scheme editor (Ctrl-V or Shift-Ins). Thus, now this diagrams are more comfortable for navigation and selection in the glass catalog.

    An indication was added to FFT_PSF and WAVEFRONT: the balloon with function value in the mouse cursor point.
    All the plots that drawed using operator PLOT are also mouse sensitive now.

    Added the syntax highlighting of optimizer'z fields: "Cond", "Goal", "Calc".
    Added the indication of wrong conditions in optimizer: the compare operation ("<", ">", "<=", ">=", "<>") will be highlighted when returns 0 (FALSE).

    Attention! Functions [athick] and [gthick] now return the minimal thickness of air and glass only for those cells that selected as variables for optimizer (in column "Thickness").
    Functions [aedge] and [gedge] now return the true sign of the minimal edge nevertheless on signs of thicknesses (in column "Thickness")
    Functions [gthick] and [gedge] will not consider now that MIRROR is a glass.

    Version 0.91 - June 22, 2008:
    Corrected the bug: versions 0.5 .. 0.9 can crash when "Save Glass" pressed.
    Improved form _SCALE_SYSTEM.
    These functions were undocumented: [cp_vig..], [nv_vig..], [__vig].

    Version 1.1 - July 11 2008:
    The optimizer can use the new method: Global-random.
    Added button AntiLoop for exit from local minimums.
    Added indicator of current GPU.
    Function [cp...] has more precision.

    Version 1.1d - October 30 2008:
    Functions [nv...] here has the double precision - as CUDA 2 support for NVIDIA GeForce 280 GTX, 260 GTX, and Tesla C1060. Version 1.1d cannot work with single precision and it is not compatible with previous GeForces (8-th and 9-th).

    Functions [nv...] here can be computed using AMD Radeon HD 3850, 3870, 4850, 4870, or FireStream 9170 or 9250. To do this, should set the appropriate Add-On for LINZIK:

    for version 1.1 (single precision [nv...]) - AMD_GPU_forLINZIK_1_1_XP_Setup
    or AMD_GPU_forLINZIK_1_1_Vista_Setup for Vista

    for version 1.1d (double precision [nv...]) - AMD_GPU_forLINZIK_1_1d_XP_Setup
    or AMD_GPU_forLINZIK_1_1d_Vista_Setup for Vista

    These Add-Ons replace the runcuda.dll library at the same corresponding analog which uses the AMD Stream technology. Attention! Use driver Catalyst 8.9 or higher.