Skip to main content

So my problem is roughly that I want to do my own tolerance analysis and retrieve the RMS Spot Radius value as my criterion. But after changing certain values, as the Thickness and Tilt X, the programme does not seem to register this. The Value is not changing and i just get the same value over and over again. Can someone explain how to effectively change these parameters in Optic Studio, so I can retrieve the actual RMS Spot Radius Value?

I’m just assigning these parameters to my own values (f.e. from -10 to 10 with step 0.2) in a loop. Here a snippet of it:

surf36 = TheSystem.LDE.GetSurfaceAt(36)
mir1_thickness = surf36.ThicknessCell.DoubleValue
mir1_tiltX = surf36.GetCellAt(14).DoubleValue

for indexTilt, stepTilt in enumerate(np.arange(-10, 10, 5)):
mir1_tiltX = round(stepTilt, 2)
spotdata_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.StandardSpot)
spot_settings = spotdata_analysis.GetSettings()
spot_settings.Wavelength.SetWavelengthNumber(0)
spotdata_analysis.ApplyAndWaitForCompletion()
spot_results = spotdata_analysis.GetResults()
rmsSpotRadius_mir1tilt = spot_results.SpotData.GetRMSSpotSizeFor(1, 1)

Also, I would like to know if there is another way to determine the RMS spot radius than using my approach:

spotdata_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.StandardSpot)
spot_settings = spotdata_analysis.GetSettings() spot_settings.Wavelength.SetWavelengthNumber(0) spotdata_analysis.ApplyAndWaitForCompletion()
spot_results = spotdata_analysis.GetResults()
rmsSpotRadius = spot_results.SpotData.GetRMSSpotSizeFor(1, 1)

Because I’d love to avoid to open so many windows just to retrieve the value. I’m using that in a loop.

 

Thanks in advance for all answers!

Hi Mo.,

 

First, to change the surface Thickness, you simply need to write:

MySurfaceNumber = 1
MySurface = TheSystem.LDE.GetSurafceAt(MySurfaceNumber)

# This is where you change the thickness
MySurface.Thickness = 12.3

I understand why you tried to use the ThicknessCell, but this is only to setup a solve on the thickness. The way you accessed the Tilt About X is correct though.

Second, I’m not an expert in Python, but unless you work with list or arrays, the variables don’t work as pointers. When you type:

mir1_tiltX = surf36.GetCellAt(14).DoubleValue

Then mir1_tiltX will be a Double variable containing a Double value that corresponds to the actual Tilt About X at that point in time. Python doesn’t associate your surface with mir1_tiltX. I hope that makes sense. What you could do instead is have the Tilt About X cell as a programming variable, and update this one in the loop like so:

# This is your Tilt About X cell
mir1_tiltX = surf36.GetCellAt(14)

for indextilt, stepTilt in enumerate(np.arrange(-10, 10, 5)):
mir1_tiltX.DoubleValue = round(stepTilt, 2)

Third, there are several Merit Function operand to retrieve the spot size: RSCERSCHRSRE, and RSRH:

RSCE

RMS spot radius with respect to the centroid in lens units. This operand uses a Gaussian quadrature method that is accurate for systems with unvignetted circular pupils. Ring is used to specify the number of rings of rays traced. If Wave is zero; then a wavelength weighted polychromatic calculation is performed; otherwise, the specified wavelength number will be used. See “Hx, Hy, Px, and Py”.

RSCH

RMS spot radius with respect to the chief ray in lens units. This operand uses a Gaussian quadrature method that is accurate for systems with unvignetted circular pupils. Ring is used to specify the number of  rings of  rays traced. If  Wave is  zero; then a  wavelength weighted polychromatic calculation is performed; otherwise, the specified wavelength number will be used. See “Hx, Hy, Px, and Py”.

RSRE

RMS spot radius with respect to the centroid in lens units. This operand uses a rectangular grid of rays to estimate the RMS. This operand considers vignetting. A Samp value of n will trace an n x n grid per pupil quadrant. If Wave is zero; then a wavelength weighted polychromatic calculation is performed; otherwise, the specified wavelength number will be used. See “Hx, Hy, Px, and Py”.

RSRH

RMS spot radius with respect to the chief ray in lens units. This operand uses a rectangular grid of rays to estimate the RMS. This operand considers vignetting. A Samp value of n will trace an n x n grid per pupil quadrant. If Wave is zero; then a wavelength weighted polychromatic calculation is performed; otherwise, the specified wavelength number will be used. See “Hx, Hy, Px, and Py”.

 

In the ZOS-API, you can use the GetOperandValue method from the Merit Function Editor interface to calculate the value of a single operand. Here is an example with RSCE:

# RSCE parameters
Sampling = 5 # this is in number of rings
Wave = 1
Hx = 0.0
Hy = 0.0

# RSCE operand type
RSCE = ZOSAPI.Editors.MFE.MeritOperandType.RSCE

# Print RSCE value
print(TheSystem.MFE.GetOperandValue(RSCE, Sampling, Wave, Hx, Hy, 0, 0, 0, 0))

By doing it this way, it shouldn’t open any window. Also note that all the analyses have a method CloseAnalysis that you can call to close them.

Here is how the RSCE operand compares with the Spot Diagram in the Double Gauss sample file:

In the Spot Diagram you need to increase the sampling quite a bit to get down to a similar value as calculated by RSCE, and this is because the RSCE is using the same sampling as for the Gaussian quadrature in the Merit Function optimization.

This is the result with Python:

0.3598208788233937

I hope this helps, and good luck on your tolerancing journey (let us know how it goes 🙂,

 

David


Hey @David.Nguyen,

First of all sorry for my late response and thank you very much! Your reply was a great help for me and my tolerance analysis. The only thing i recognized, that was not going really well, were when i tilted my components (e.g. the first mirror) so far that the rays no longer occur on the detector. I expected to get a really low or zero value for the RMS Radius, but instead it were just decreased a little. It seemed to me as it just decreases it by a certain value. Anyway it does not correlate with the RMS Radius shown in the Spot Diagram. Do you, by any chance know why that is?

 

And also i would love to get the result of my Physical Optics Propagation without opening and closing windows. Is there a way to achieve that, too?

Best regards,

Mo


Reply