Skip to main content
Solved

Only positive values for Chief Ray Coordinates with Merit Function Operands

  • November 22, 2022
  • 2 replies
  • 384 views

Ineedhelpformy hesis

Hey Everyone!

 

I am currently trying to figure out a way to get the coordinates of the Chief Ray from a Monte Carlo Run so that I get a dataset of Chief Ray coordinates correlating to different lens displacements.  I am using the the Merit Function Criterion for the Monte Carlo Run in the Tolerancing tab. My Merit Funtion consists only of the Headers and one operand ( REAY or REAX).  The results only give out positive values for the Merit Function but I need it to also show me negative displacements.

I am new to ZOS so any help is very appreciated! 

Best answer by Ethan

Hi @Ineedhelpformy hesis,

The merit function will always be positive. The value of the merit function is computed based on how close the operand values are to their target. In other words, the calculation of the merit function is related to the value of your REAY or REAX operand, but it does not give those numbers directly. The merit function is defined by the following equation in OpticStudio:

where W is the weight, V is the value, and T is the target of each operand. Therefore, to get the value of REAX or REAY, you will need to view them in the Merit Function Editor directly and save the data from Values column.

With the ZOS-API, you can collect these values directly instead of retrieving the value of the Merit Function. Here is a snippet of MATLAB code that retrieves the REAX operand value:

MFE = TheSystem.MFE;

RayX = MFE.GetOperandValue(ZOSAPI.Editors.MFE.MeritOperandType.REAX, 

     surface

     wave,

     Hx,

     Hy,

     Px,

     Py,

     0, (not used)

     0, (not used)

     );

 

Best,
Ethan

View original
Did this topic help you find an answer to your question?

2 replies

Ethan
En-Lightened
Forum|alt.badge.img+2
  • En-Lightened
  • 107 replies
  • Answer
  • December 20, 2022

Hi @Ineedhelpformy hesis,

The merit function will always be positive. The value of the merit function is computed based on how close the operand values are to their target. In other words, the calculation of the merit function is related to the value of your REAY or REAX operand, but it does not give those numbers directly. The merit function is defined by the following equation in OpticStudio:

where W is the weight, V is the value, and T is the target of each operand. Therefore, to get the value of REAX or REAY, you will need to view them in the Merit Function Editor directly and save the data from Values column.

With the ZOS-API, you can collect these values directly instead of retrieving the value of the Merit Function. Here is a snippet of MATLAB code that retrieves the REAX operand value:

MFE = TheSystem.MFE;

RayX = MFE.GetOperandValue(ZOSAPI.Editors.MFE.MeritOperandType.REAX, 

     surface

     wave,

     Hx,

     Hy,

     Px,

     Py,

     0, (not used)

     0, (not used)

     );

 

Best,
Ethan


Forum|alt.badge.img+2

You can also use a Tolerance Script to get these values. Have a look at that article: https://support.zemax.com/hc/en-us/articles/1500005575382-How-to-get-any-optimization-operand-value-in-the-tolerance-report


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings