Find out how you can save time and energy using the Zemax Programming Language!
- 136 Topics
- 369 Replies
2D-Vignetting for off-axis optics
Dear support team, I am working with a complex off-axis optics with several stray-light baffles. I need to determine the vignetting as a function of the two field coordinates. The first surface of my afocal system is the aperture stop. With vignetting I mean a geometrical quantity defined as the number of rays from one field that reach the image divided by the number of rays that pass my aperture stop. I think this is basically what the Zemax 'Vignetting Plot' does. But: 'This feature is appropriate for rotationally symmetric lenses and fields' only. The Footprint Diagram determines the 'percentage of rays through', which should be the same. Is this correct? Is there an Operand available, that calculates the vignetting according to what these two plots do and which I can calculate over a 2D-field with ZPL? I found the IMAE Operand: 'The IMAE operand estimates the efficiency of an optical system by launching many rays into the entrance pupil; computing the fraction of rays t
ZPL commands for sensitivity analysis
I’m interested in automating a couple of simple steps using ZPL. I don’t find a reference table of the names of different parameters in ZPL in the Help. How do I print a particular merit function result e.g. CENX at a particular station, and how do I change the value of a Coordinate Break’s “Decenter X” or “Tilt X” etc.?
Suppress Zemax Message during macro execution
Hi, I'm running Zemax Optic Studio Professional, version 20.2.2. Whenever I'm working with large pixel arrays, or high (> 1024 x 1024) sampling in physical optics propagation, and my detector viewer/beam file viewer is set to text view, I get a message box saying 'Text is too long to display. Use Copy All or Save As' to retrieve the entire file'. This message box doesn't cause a problem as I'm exporting the data in a macro anyway, but it means that during a long macro where I'm running POP multiple times, I have to constantly watch OpticStudio as it pauses the macro until I dismiss the message box, which is obviously impractical. Is there a way to either a) Increase the maximum allowed text file to be displayed within OpticStudio, or b) Suppress the message box, as the data export is absolutely fine Thank you!
I am using a ZPL script to determine COM positions of many spots with the CENX,Y operant. To set the field positions, I need the 'SETSYSTEMPROPERTY' command followed by an 'update'. Now it turns out that the 'update' requires by far more time than all the ray-tracing. This causes huge runtime issues. My script is running for weeks. Is there a more efficient way to set the field positions in ZPL w/o an 'update'command?
Unable to save file
Hi, I've recently experienced an issue when using ZPL/Zrdplayback command for optimizing a non sequential system. The local optimizer/orthogonal descent, worked fine, but the two global optimizers (Global search & Hammer) stopped at the start of the optimization process with the following error message 'Unable to save file...'. I've found a design file in this forum showing the same behavior (please check the attached file). I suspect that the problem arises when several variations of the initial model are generated and attempt to create and/or read the rayfile from the ZPL macro. Could you please comment and propose a fix that would ideally, preserve the call to zrdplayback? Thank you
FFT PSF: "Computation aborted, invalid results!"
Hello! When calculating the FFT PSF, I sometimes get the error message 'Computation aborted, invalid results'. When I change the PSF sampling, the error disappears. It is probably linked to a user defined surface (based on the multizone asphere surface example) combined with specific values of decentrations of the optical elements. Do you have any ideas about the meaning of the error-message and how to debug it / get rid of it? I am saving the FFT PSF window within a ZPL macro. Is there a way to do error-handling in the ZPL macro? (E.g. if the error occurs, the sampling of the FFT PSF calculation will be decreased and the calculation repeated...) Thank you!
Surface Property Updating, but results not changing without manual refresh
Hello, I am doing a polarizaiton analysis and am running into an issue when it comes to updating my surfaces. I have a short macro that updates the tilt about x for a coordinate break before a mirror, and the tilt about x for a coordinate break after a mirror. Then, I am using the OPEV function to get the transmission of a surface further in the system. The problem is, when I use the macro to udpate the tilts, the results don't show in the OPEV function unless I manually refresh the results. This will not work for me as I am working with a very large data set and thus need to be able to do it without manually refreshing. Just a simple example of the setup is given below. SETSURFACEPROPERTY 8, 10, 3, 3 # sets the tilt about x before the mirror (surface 9) SETSURFACEPROPERTY 10, 10, -3, 3 # resents the tilt about x for the whole system, esentially just tilting the mirror in the whole system code_coda = OCOD('CODA') # defining the merit function code used to get th
POLDEFINE use case in ZPL
Hello, I am trying to run a polarization analysis on a system and am using different polarization states as input. I have created a macro that does this by first using 'POLDEFINE' to define a polarization state, and then using the CODA function to get the information I need. I then use the 'POLDEFINE' function again to describe a new polarization state, and the use the CODA function again. Though, this is unfortunately not working. For some reason, all data sets are the exact same. I am curious how the POLDEFINE is actually working. Are the CODA and POLDEFINE functions possibly decoupled? And if so how do I go about changing the system input polarization using the zpl?
Exporting to .txt file when running a macro from the command line
I am currently tyring to run a macro from the command line of my computer. The macro includes the command : >>> OUTPUT 'exampleFile', APPEND This is used to create an output txt file by the name of 'exampleFile.' Now, when I run this macro through the command line, no file is generated. But, when this macro is run through optic studio, there is a file that is generated named exampleFile. I don't understand why this step is ignored when the macro is used through the command line?
Input surface map (Surface Sag) to ZEMAX
Hi all, I am currently doing an optics project with some mechanical simulations. We are trying to simulate the surface deformation with mechanical design software. Then input the data to ZEMAX. If I have a sag data like the attached, could I input these data to get the surface in ZEMAX? Including radius of curvature and aspherical coefficients. Thank you, Raymond
Macro Solves in parent objects for Compound Lens
I am trying to generate a compound lens with front and back surfaces made up of two Biconic Zernike surfaces. One of the aspheric parameters on the front biconic surface is generated by a ZPL macro. When building this model, the compound lens ignores the value provided by the ZPL solve, treating it as it were zero. Is there any way to pass the surface generated by the macro solve to the compound lens without having it be ignored?
Calculate the "field Type" "Angle" from the "field Type" "Real Image Height" with a ZPL
Is it possible to calculate the 'field Type' 'Angle' (Code 0) from the 'field Type' 'Real Image Height' (Code 3) with a ZPL script? It is basically what the Zemax 'Field data editor' offers with the 'Convert to' option. However, I do not need to *convert* the field type, but just have to determine the value. With 'Single Ray Trace' as well as with the operand 'RAID', I only get one angle. But I need the two angles as defined for the 'field Type' 'Angle' Thank you and best regards, Christof.
Can I create a new text file for output inside of ZPL macro
I would like to create a new text file from inside of a ZPL macro for saving data while the macro runs. I see the OPEN command, but it requires the file to already be created. I do not see any keyword for creating the new file. Is there a way to create new files from inside of a running Macro? Thanks Chris Buchholz
Hello. I guess my question is fairly straight forward. However, I am not very used to any optimization procedures, so any help will be appreciated. Assuming I have a source and a detector, and some surfaces inbetween in a non-sequential setting. I need to write a merit funtion that maximizes flux on the detector - but only for rays hitting a specific surface in between source and detector. While this is easily done by filter strings in a simple detector view, I was unsure on how to implement this in the optimization. Therefore Zemax provided some help a while ago in form of this ZPLM operand detector = PVHX() clear = NSDD(1,0,0,0) NSTR 1, 0, 0, 0, 0, 0, 0, 1, 'Test.ZRD', 'H4' ZRDPLAYBACK 'Test.ZRD', 1, detector, 1 X = NSDD(1, detector, -3, 0) OPTRETURN 0, X So I specify my detector in H(x) and then clear all detectors, run a raytrace with the filter string applied (in this case hit surface 4) and point it back to the detector. So now this returns the rays hitting the detector under con
Legend problem-macro plots
Dear Zemax team, Could you please help me put the legends showing the color of each line right next to the regarding legend or is there a way to do this with labels? As you can see, the labels do not show the colored line near them. So, it is hard to distinguish which one belongs to which data line. Next graph below is from an article on your webpage about diffractive optics macro and it does not have this problem. Attached in my macro. At the end of my macro , you can see how I call all the plots in a SUB routine. Your urgent help on this would be appreciated! No problem with legends or labels in the knowledge base article plot about diffractive optics below;
"GetNSCPosition" is not recoganize in ZPL
I applied a solve on position z by 'SOLVETYPE'. Then I need to refer to the result of solve, i.e. the position os z. I am trying to using 'GETNSCPOSITION'. According to the EXTENSION DATA ITEMS, this should return the object position and angle and material. However, the viewer shows 'Unknown symbol GETNSCPOSITION.' The similar command 'SETNSCPOSITION' works fine. But not the GETNSCPOSITION. It seems in the editor, it does not recoganize it as a legal command Can anyone help something is wrong? Thanks.
GETTEXTFILE writes empty file randomly
I am running Zemax OpticStudio 19.4 SP2 on Windows 10. When I run the following line in a loop in a macro, randomly, some of the files are empty. The non-empty files are correct. GETTEXTFILE OUTPUT_PSF_FILE$, Hps, CFG_FILENAME$, 1 Please help! Thanks, Qiang
how to force an analysis window to read a changed/modified config file
I have a lens file open, with some analysis windows open. Using ZPL, I want to loop through and change the .CFG file (this is for a detector window in non-sequential.). I haven't done it yet, but I think this will change the settings: ModifySettings (filename,DVW_FILTER, ‘new_filter_string”, ‘DVR’) , or something like that, once I get the quotes straightened out. However, my question is: How do I force the open analysis window to update with the new .cfg file? In ZPL Macro, there does not seem to be any command like: LoadNewConfig(Filename, WindowNumber). I know I might be able to open a new analysis window, but for reasons of being able to see what is going on, I'll save that for Option B. thanks for your time. John
ZPL: GETTEXTFILE with and w/o settingsfile
Dear support team, I have problems understanding the behaviour of the PDL statement GETTEXTFILE in combination with the settingsfile: I am using GETTEXTFILE for Huygens PSF simulations. My questions: 1. Which settings are used if no settingsfile is given at all? It seems that in this case the settings that are saved with the 'save' button in the 'Huygns PSF' window are used. Is this correct and always the case? Does it additionaly depend on the 'flag' setting? 2. With flag=2 the settings box for the requested feature should be displayed. This doesn't seem to happen. No setting box appears. Or is this only the case in combination with an explicit settingsfile? I tryed w/o settingsfile. 3. How can I make sure that the current settings in the 'Huygns PSF' window are used for the simulation? Thank you and best regards, Christof. -- DR. CHRISTOF BODENDORF Max-Planck-Institute for Extraterrestrial Physics Division:
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.