CODE V Enewsletter

October 2020

Quick Tip: Relational Tests within Expressions

Our recent tech talk webinars cover CODE V Macro-PLUS. Macro-PLUS is the programming language for interacting with and scripting for CODE V. As part of the Macro-PLUS language, you can use relational tests between two statements, within expressions. Relational expressions include equal to (=), not equal to (<>), greater than (>), and less than (<). You might want to use this capability when for example, one part of the expression is conditional, as described in the following examples.  Instead of an IF ELSE code block, the relational test can be part of the expression, so relational tests can potentially simplify your macro. In this e-news, we’ll discuss how you can use these tests in Ceil() and Floor() functions, as well as with user-defined constraints in optimization.

Ceil and Floor Functions

A straight-forward example of how a relational test can be used within an expression, is to look at how to return the ceiling and floor of a number. The output of a Ceil(ing) function is the smallest integer that is greater than or equal to the argument. For instance, the ceiling of 1.123 is 2. Similarly, Floor function results in the largest integer that is less than or equal to the argument. The floor of 1.123 is 1. Here is how we can realize these two functions using just the Macro-PLUS inbuilt function ROUNDF (), a function that will round a number to the closest integer, followed by CODE V output.

Notice that the second part of the above expressions, (ROUNDF(^n) > ^n) and (ROUNDF(^n) < ^n), is a relational test. If this condition is true, it returns 1, and unity is either subtracted or added. Otherwise if the condition is false, it returns 0 and nothing is added or subtracted. 

Within User-Defined Constraints for Optimization

You can use these relational expressions within optimization sequences as user-defined constraints. One such case is if you are using Glass Expert to choose glasses from glass catalogs. Normally, Glass Expert will use the defined catalog of glasses for every permitted element in the system. You could exclude a glass catalog from being considered for certain elements with a relational expression. The concept is to use a relational expression to check the glass catalog for a specific surface and use this in a user constraint with the (GLA CAT Sn) database item. Then define the user defined constraint’s target in such a way that it increases the error function significantly if the catalog isn’t one of the desired catalogs. This will effectively reject any solutions where the undesired glass catalog is used for that surface. For example, we can define a user defined constraint to avoid Schott glasses for S1 as follows:

The above trick is also described in the 2017 User Group presentation on “Tips and Tricks."

For more about using the CODE V Macro-PLUS programing language, watch the Macro-PLUS tech talks on the Customer Support Portal. The latest CODE V Macro-PLUS tech talk discusses how to use worksheet buffers.

Chebyshev Polynomial Surfaces Offer Flexibility for Optical Design

The challenges of today’s optical designs require sophisticated and precise non-spherical surface shapes. A new surface formulation based on flexible geometry creation and Chebyshev polynomials is now available for use in CODE V as a User-Defined Surface. You can download the "Chebyshev Polynomial Freeform" from the Customer Support Portal.

The Chebyshev Polynomial User-Defined Surface applies well to square or rectangular pupils in compact folded geometries. To provide efficiency for designers, the surface formulation makes use of a unique, built in off-axis angle parameter to set the used portion of the base conic surface.  Designers can then apply polynomial deformation centered at the used portion of the conic. These modeling attributes further improve design efficiency and facilitate fabrication.

New on YouTube

Design Considerations for a High-Resolution Lens for Large Format Sensors

Watch a recording of our recent partner tech talk with Eduardo Gonzalez from Edmund Optics and Synopsys’ Matt Novak.

What's New on the Portal

CODE V Online Tech Talks

Recordings of recent CODE V Online Tech Talks, along with other product trainings and presentations, are available to watch on our Customer Support Portal. Watch now

CODE V 11.4 New User Orientation

The latest CODE V New User Orientation is available. Watch now

Check out our Blog!

Are You Up for the IODC Challenge?

An Interview with Brandon Hellman, Michael Kidger Memorial Scholarship Recipient for 2020

CODE V Global Synthesis – A Powerful Tool in Expert Optical Design Workflows
Matt Novak, Senior Staff Customer Applications Engineer, CODE V


CODE V Training and Online Tech Talks

Our Introduction to CODE V for Image Forming Systems course is scheduled to take place November 9-11 and 16-18, 2020. This is a 6 day paid online short course for technical professionals. The training covers the basics of modeling, analyzing, optimizing, and tolerancing image-forming optical systems using CODE V, including hands-on workshops. 

We also have a free CODE V Online Tech Talk taking place November 18, 2020 "Best Practices with CODE V Macro-PLUS." Check our software training schedule for regular updates on our latest upcoming training opportunities. Learn more

Introduction to CODE V

November 9-11 and 16-18, 2020


Paid Training

Best Practices with CODE V Macro-PLUS

November 18, 2020



Calendar of Events

For the latest event calendar, please go to our Events page.