Skip to main content

I would like to write the Macro script of ZPL about how to optimize the POP by merit function like as “POPD” optimized operand

1.Set the one surface of Thickness or parameter 1,2,3… as the value of  0.5mm, 0.6mm , 0.7mm to run a loop

2.Set the someone surface “Thickness or parameter 1,2,3…..” as variable factor. 

3.Execute to optimize the MF as POPD to run 10,15 circles as you want 

4.In the end, shows the final optimized value to 1st step different cases you set

Ex. Surface 3 thickness as 0.5mm, 0.6mm, 0.7mm

Optimized the surface 7 of thickness as variable factor by using POPD MF

to get value under surface 3 as 0.5mm, 0.6mm, 0.7mm respectively.

 

 

Hi Vincent,

 

Before I get to answer your questions. I’d like to mention that depending how complex you want the macro to be, it might be worth considering the ZOS-API, which should give you more flexibility.

These are my answers to your questions:

  1. Changing a surface Thickness and Parameter 1 in a loop. You can use the SETSURFACEPROPERTY or SURP keyword to modify the Thickness and Parameter 1 of a surface. I’m showing how to do so in a loop below:

# Surface to be modified

surface_number = 1



# Codes for the SURP keyword (check Help File for more details)

thickness_code = 3

parameter_code = 10 # This is the code for the parameters

parameter_number_code = 1 # This is the code for Parameter 1



# Loop

FOR index, 0, 10, 1

    # Calculate new thickness and Parameter 1

    new_thickness = index

    new_parameter = index

    

    # Update the lens data with the new values

    SURP surface_number, thickness_code, new_thickness

    SURP surface_number, parameter_code, new_parameter, parameter_number_code

NEXT

  1. Setting a variable surface parameter. This is doen with the SOLVETYPE keyword. I let you read the Help File (F1) to understand what codes you need. For Thickness and Parameter 1 you need the following lines (assuming surface_number has been defined like above):

SOLVETYPE surface_number, TV

SOLVETYPE surface_number, PV_1

  1. If you need to remove the variable solve for the Thickness and Parameter 1 you need the following lines:

SOLVETYPE surface_number, TF

SOLVETYPE surface_number, PF_1

  1. Running an optimization. To run an optimization, you need the OPTIMIZE keyword and you can specify the number of cycles like so:

OPTIMIZE number_of_cylces

  1. Adding an operand. In case you’d want to setup POPD through ZPL (assuming your POP analysis settings have been saved properly, check the Help File about POPD). I would do it like so:

# Row at which the operand is inserted

row_number = 1



# New operand

INSERTMFO row_number



# New operand settings

popd_surface = 1

popd_wave = 1

popd_field = 1

popd_data = 0

popd_target = 0.5

popd_weight = 1.0



# Set new operand

SETOPERAND row_number, 11, "POPD"

SETOPERAND row_number, 2, popd_surface

SETOPERAND row_number, 3, popd_wave

SETOPERAND row_number, 4, popd_field

SETOPERAND row_number, 5, popd_data

SETOPERAND row_number, 8, popd_target

SETOPERAND row_number, 9, popd_weight

 

I believe you have everything to get started with your macro, let me know if you have any other question and if everything makes sense.

Take care,

 

David

 


Reply