OpticStudio Tolerancing : step size of compensator.

  • 10 June 2022
  • 2 replies

Hi there, In OpticStudio, during tolerancing, is there a way to request for the compensator to take specific step sizes within the designated range. For example for the comp range from -0.26mm to +0.26 mm, can we designate it to take 0.0125mm steps?

thanks in adv, 



Best answer by Allie 10 June 2022, 21:24

View original

2 replies

Userlevel 6
Badge +2

Hi Phil,

Compensators are treated as variables with boundaries designated by the TDE operand’s Min/Max values. During the tolerance, OpticStudio performs an optimization using these compensators as variables to drive towards the designated criterion. By default, OpticStudio considers variables to be continuous during an optimization; so we cannot designate a discrete change for these variables during the tolerance.

With this in mind, step-wise compensation must be performed after the tolerance is done. In the past, I have recommended users to run a tolerance and save a set of Monte Carlo files. Then, open each file and apply the step-wise compensator and check the Merit Function to obtain the new criterion value. This workflow is best handled programmatically, either through the API or ZPL. Luckily, I have already written a ZPL macro for this. You can find it within the Code Exchange here: 


If anyone else on the community has an idea for this please share! I’d love to hear it :). In the meantime, I hope this helps you. Let me know if you have any questions about it. 

Userlevel 6
Badge +2

I’m adding another comment to this post as I feel it can also help.

Another way to add a non-ideal compensator (or step compensator) is to round the compensators to a specific step by making a multi-configuration system. It may not be practical in all cases but well gives another option. The advantage being that the result will be in the tolerancing viewer.

Below I have used a singlet file.
I created two configurations: the 1st one will be optimized and the 2nd one will round the thickness of the 1st configuration using a ZPL solve.

Then when I run the tolerancing (if using a built-in criterion), I tick “Separate Fields/Configs”: 

If I am using a merit function as a criterion, I would need to create a user script to report the configurations separately.
The results of configuration 1 are the results of the optimized compensator.
The results of configuration 2 are the results of the rounded optimized compensator.