- Home
- User Articles
- How to Write User-Defined Surfaces with Waterloo Maple
- Home
- Programming ZEMAX
- User Defined Features
- How to Write User-Defined Surfaces with Waterloo Maple
How to Write User-Defined Surfaces with Waterloo Maple
- By Mikhail Levtonov
- Published 14 March 2006
- User Articles , User Defined Features
-
Rating:




Defining the Surface Sag
z = f(x, y)
In this article I will use Waterloo Maple to enter the required equations and produce the optimized C-code needed. In the following examples, red courier font represents data entered into Maple, blue font represents output from Maple, and text after the # symbol are comments.
In the following, the variable ka is the amplitude of a Gaussian function of fixed width, rr is the radial distance at which the amplitude has fallen to ka/100, and dx and dy are optional decentrations entered via the Lens Data Editor.

This function is then added to the normal Odd Asphere sag as defined in the ZEMAX manual. By using Maple this can be easily done with common math functions and procedures:

This equation must be converted to C code to implement adequate DLL for Zemax. Maple has very convenient tool for this action namely “Codegen”. Note, that array indexes are decreased by 1 when Maple performs C code generation – that’s why there is param[i+1] in the Maple code:

What's more, Maple can also optimize the C-code it produces:

This can then be copy-and-pasted into Case 5 of the DLL, with just a little hand editing.