Solved

Merit function to optimize spot size in spot diagram

• 7 replies
• 2300 views

• Monochrome
• 4 replies

Hello,

I have a built up system with lenses and mirrors and I want to build merit function which optimize the spot size in merit function. I am not sure which operands and how I could adjust them in merit function inorder to optimize my merit function where the target is spot size. Thank you

icon

Best answer by David.Nguyen 22 April 2021, 11:18

View original

7 replies

Userlevel 7
+2

Hi Saeedeh,

Usually, you don't need to do this yourself. You can use the Optimize...Optimization Wizard for this task.

This tool will populate the Merit Function for you with the required operands. It'll account for the different wavelengths, and fields you have setup.

Have a look at some of the introductory knowledgebase articles for sequential optimization, such as:

https://my.zemax.com/en-US/Knowledge-Base/kb-article/?ka=KA-01823

Good luck on your optical design journey, and take care,

David

What if I wanted to optimize to the spot size to a specific value, such as 10 mm in diameter? How would I be able to do that?

Userlevel 7
+2

Hi Sebastian,

It depends what you mean by spot size. Since you are talking about a 10-mm diameter spot size, I believe a ray-based approach is more suitable (as opposed to using the PSF tools). There’s an operand called RSCE, which gives you the RMS spot radius with respect to the centroid in lens units. Assuming your lens units are mm, then just type 5 in the Target column. Alternatively, if you want the geometrical radius, you could use REAY/REAX, which gives the X/Y landing coordinates of a ray at a particular surface, with a marginal ray.

Let me know if this makes sense. I’m also attaching this file to my reply.

Take care,

David

Hello,

I’m trying to optimize the max spot size radius (as calculated by the Spot diagram panel) to be 5mm. This is to be the outmost ray I believe. I do not want the RMS width, but the maximum diameter / radius. Additionally, I want to avoid looking at a particular ray as I would like to have my system aperture limited. I guess I could use REAX or REAY and set my entrance aperture to be the same as the lens (assuming I can figure out Hx, Hy, Px, and Py).

Thank you for your help on this.

Userlevel 7
+2

Hi Sebastian,

If you absolutely can’t use REAX/Y for some reason. You can program your own Merit Function operand to retrieve the Max Spot Radius from a Standard Spot. But this will be slower than using built-in operands.

Here’s how it looks like:

I’ve used Hx as the Field Number, Hy as the Wave number, and Px as the Ray Density and I’m reporting the Max Spot Radius as Data 0. As you can see the value matches exactly that of the Spot Diagram for the same Ray Density. The Prog# is 4 because I already have other custom operands, this number should match the syntax of the operand name (in this case UDOC04.exe).

The code I’ve used is as follow (I’m using the template Programming..C#..User Operand in OpticStudio):

``            // Add your custom code here...            // Open new Standard Spot            IA_ std_spot = TheSystem.Analyses.New_StandardSpot();            // Retrieve Standard Spot Settings            IAS_Spot std_spot_settings = std_spot.GetSettings() as IAS_Spot;            // Assign Hx to be the field number            std_spot_settings.Field.SetFieldNumber((int)Hx);            // Assign Hy to be the wave number            std_spot_settings.Wavelength.SetWavelengthNumber((int)Hy);            // Assign Px to be the ray density            std_spot_settings.RayDensity = (int)Px;            // You can use Py to do something else            // ...            // Run the analysis with the settings            std_spot.ApplyAndWaitForCompletion();            // Retrieve Standard Spot results            IAR_ std_spot_results = std_spot.GetResults();            // Return the maximum radius            operandResults[0] = std_spot_results.SpotData.MaxRadius;``

I’m attaching this example file to my reply. If you open it with OpticStudio, it should automatically copy the UDOC file (UDOC04.exe) at the correct location on your PC.

I hope this helps.

Take care,

David

Thank you very much,

I was able to use  REAX/Y  for what I wanted (with some tweaking of number of rays and aperture size). If I need a custom merit function, this information will be helpful in the future. Thanks again.

I was not able to open your attachment, but I think this was just due to a OpticsStudio version difference.

Userlevel 7
+2

Hi Sebastian,

Glad to hear you were able to use REAX/Y. Here is the operand alone, it needs to be copied to your {Documents}\Zemax\ZOS-API\Operands folder before it can be used through the UDOC operand. Not sure it works with previous version of OpticStudio though (I’m using 22.2.1).

Take care,

David