How to scale a section of a lens system from within ZPL?

  • 26 April 2021
  • 2 replies
  • 251 views

Userlevel 5
Badge +3

I need to be able to scale a section of a lens system from surface Sj to Sn from within a ZPL macro during optimization.  Surface 3 in this system is in collimated light and initially set to 1.0, and can be changed in optimization to scale S7-S9 without affecting the system.  The thing being optimized is the S7-S9 EFL.  I tried using this macro with no luck.  I found no SETSCALE or similar ZPL keyword.  How to do this?  Thanks, Mike


# ZPL20.ZPL

# USE T3 IN LENS FILE AS SCALING FACTOR FOR L1/L2 DOUBLET

T3 = THIC(3)  #  Varies from unity during op

R7 = RADI(7) * T3

R8 = RADI(8) * T3

R9 = RADI(9) * T3

T7 = THIC(7) * T3

T8 = THIC(8) * T3


OPTRETURN 0, T3

OPTRETURN 1, R7

OPTRETURN 2, R8

OPTRETURN 3, R9

OPTRETURN 4, T7

OPTRETURN 5, T8

 


2 replies

Userlevel 5
Badge +3

And the general solution if more parameters are involved:


Use SPRO to get the surface data and scale them, then use SETSURFACEPROPERTY to set up the scaled data.


Since not all parameters are needed to modify, you can build a vector and put the type codes to be scaled into this vector and call it every time.


Here is an example


!put the data into a vector


vec1(1)=2


vec1(2)=3


vec1(3)=5


vec1(4)=6


vec1(5)=10


for i=1,5,1


!call data out of the vector


k=vec1(i)


next


Here is an example of SETSURFACEPROPERTY


Set the thickness of surface 2 to the thickness of surface 1


SETSURFACEPROPERTY 2, THIC, THIC(1)


! Set the value of parameter 4 on surface 11 to 7.3


SURP 11, PARM, 7.3, 4


For more information, please refer to:


The Programming Tab > About the ZPL > Numeric Functions


The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > SETSURFACEPROPERTY, SURP

Userlevel 5
Badge +3

Hi Mike,


With help of Allie, I found your forum poste. Sorry I did not find your poste yesterday and sent you a general solution in case you have lots of parameters to modify.


The modified macro can be:


!parameter calcualtion


T3 = THIC(3) # Varies from unity during op

R7 = RADI(7) * T3

R8 = RADI(8) * T3

R9 = RADI(9) * T3

T7 = THIC(7) * T3

T8 = THIC(8) * T3


! set parameter


SETSURFACEPROPERTY 7, THIC, T7


SETSURFACEPROPERTY 8, THIC, T8


SETSURFACEPROPERTY 7, CURV, 1/R7


SETSURFACEPROPERTY 8, CURV, 1/R8


SETSURFACEPROPERTY 7, CURV, 1/R9


UPDATE


Do you intend to use this as a ZPLM? I am worried as everytime you run it, it scales the related parameters. Please pay attention to this when use.


Best regards,


 


Yuan Chen


Optical Engineer


yuan.chen@zemax.com

Reply