使用ZEMAX的Marcro进行优化操作

If the ZPL macro language (see “OPTICSTUDIO PROGRAMMING LANGUAGE”) is sufficient to perform the required computations, then the operand ZPLM may be used to call a ZPL macro from within the merit function.

如果ZPL的宏编程语言能够满足必要的计算,则操作数ZPLM可以在优化函数编辑器中进行Marco的调用。

The macro performs the required computations, then returns the result using the ZPL OPTRETURN keyword.

Marco中存在ZPL OPTRETURN这个关键字的时候,返回结果。

ZPLM is simple to use.

ZPLM 用起来很简单方便。

The Mac# and Data values are used to specify the macro number and data field number, respectively.

Mac#和数据值是分别用来表征Marco的数量和数据。

The macro number is used to indicate which ZPL macro should be executed, while the data field number indicates which value computed by the macro should be optimized.

Macro的数值表示使用哪一个ZPL的宏编程,而返回的数值表示宏编程计算的数值结果。

The macro number must be an integer between 0 and 99. If the Mac# value is 17, for example, then the macro to be executed must be named ZPL17.ZPL. The macro name must always use a two digit representation of the macro number. If the macro number was 6, then the macro to be executed would be ZPL06.ZPL. The ZPL macro file must reside in the folder for ZPL macros; see “Folders”.

Marco的数值编号必须是0-99的整数。如果Mac#数值编号是17,则Marco要被执行的化,必须命名为ZPL17.ZPL。如果Marco的数值编号是6,则Macro的想要被执行,则必须命名为ZPL06.ZPL。ZPL编辑的Marco必须放在ZPL marco的文件夹下才能有效被执行。

The data field number may be any number between 0 and 50, inclusive. This number refers to a position in a global array associated with the lens in memory. During execution of the macro, the macro keyword OPTRETURN specifies which data field number stores the results of the macro calculation. There are 51 different data fields, so that a single macro call can be used to optimize up to 51 different values simultaneously.

数据场必须是被包括在0-50的整数之间。这个数值关系到了在内存中的镜片的全局存储位置。在执行Marco的时候,在Marco中的OPTRETURN函数是Marco计算结果存储到的位置。如果有51个不同的数据,则Marco需要同时对51个不同的数据进行优化。

For example, suppose you needed a macro which computed the total length of the lens from surface 1 to the image surface (this is in effect a user-defined version of the TOTR operand). The macro might look like this:

n = NSUR()
x = 0
FOR i = 1, n, 1
x = x + THIC(i)
NEXT
OPTRETURN 0, x

比如,假设你需要使用一个Marco来计算镜片系统中从第一个面到像面的总长(在用户自定义的操作数TOTR也能实现)。这个宏编程内容如下所示:

n = NSUR()
x = 0
FOR i = 1, n, 1
x = x + THIC(i)
NEXT
OPTRETURN 0, x

你可能感兴趣的:(使用ZEMAX的Marcro进行优化操作)