Find out how you can save time and energy using the Zemax Programming Language!
- 130 Topics
- 348 Replies
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.
Hello all,I am a student in internship and I need to use ZPL to automate my system. I have a system with LED, which I am optimizing. After this optimization I have to measure the power received on the detector for different Z positions (34 positions).I do not know how to make a list of my different Z positions, how to change the value of the Z position for my detector and how to retrieve the value of the power received on my detector.Thank you in advance,Léo
Sometimes, we may design the system starting from the 'image' back to the 'object'. For example, this is often the case for those systems that are designed to be viewed by eye, like AR/VR, HUD. In this case, normally, if we want to check the relative illumination, we need to reverse the system to check because the tool 'Relative Illumination' only calculates that on last surface in the system.Here we will provide another way to calculate it using a macro so that you don't need to reverse the system.Note here we at the same time is also demoing how you can verify the calculation theory of the RI. RI is actually much easier to calculate if the system is reversely designed! First, by reading the following forum post, we know that relative illumination at each field is exactly linearly dependent to the area of the beam in cosine space in image space.So, here is the plan. We want to write a macro to calculate the beam area in cosine space for each field, normalize it, and then get the the R
Hi all,I want to save data and images of detectors automatically with ZPL. So I made the ZPL code as below. For n = 2, 6, 1 ####### get Detector viewer in img. winnum = n+1 OpenAnalysisWindow "Dvr", cfgpath$ ExportJPG winnum, imgfile$ ####### get Detector viewer in dat. #ModifySettings cfgtxt$, DVW_SHOW, 1 # extraction middle row data from 2d data GetTextFile datfile$, "Dvr", cfgtxt$ , 1 ConvertFileFormat datfile$, 1 #Unicode to ANSINext Once I open all detector viewer windows, I tried to save images and data in detector number order. However, I couldn’t save each detector data/image because it cannot recognize the number of detector in this code. What should I do? Or, are there better method to do it? Please help me. Thanks in advance.
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
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?
Dear support team, it seems that a 'Print' statement in ZPL is suppressed during the script is running. Then at the end of the script all print statements are executed at once. I guess, this is a kind of optimisation? However, I am running large scripts and I would like to see the progress in the command window . So I would like the print statement to react directly when it is called. Is this possible? Thank you, Christof.
Good afternoon! I am studying the ZPL macro language in order to simplify the analysis of data in the optimization process. In the macro being developed, I would like to implement the function of sorting optimization operands by their contribution. I know that such information is in the "" section, but I'm interested in the implementation in the ZPL language. There are no problems with the sort itself, I use the IF-THEN conditions in sequence, however, I cannot find a way to display the name of the operand by its ID code. Initially, I thought that the numerical function OPER(…,1) could give me the name of the operand in the string, however, as it turns out, this numeric function returns the ID code of the operand. Could you help me? Thanks
HiI am trying to calculate the RMS slope of a surface with the DSLP operand in a macro.The surface is Zernike Standard Sag (generated from tolerance analysis) and the rms slope of this surface computed in the MF editor is like below I wrote the following to calculate the same value in a macro:> print OPEV(OCOD("DSLP"),1,1,2,0,0,1)but this is obviously not correct as the output is 3.4456 (I was excpecting 4.913e-5).I can’t find the error, can you? :-)Thank you
Hi! I’m calculating the energy inside a surface with LEDS with different detectors: volume detector, sphere as detector, volume pipe as detector… but I can’t get the same values across them… I don’t know why if I hace the same system…From objects as a detector I get total power, but from volume detector total flux (all of them in mW); is this the same?When I take a value from the matrix in volume detector, what is this? flux, power¿?This is my file, I calculate the three detectors individuallyThanks in advance,Carmen
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?
Can you confirm the Data# field of NSDE is not working as expected, both in ZPL and MF? Help reference: The Optimize Tab (non-sequential ui mode) > Automatic Optimization Group (optimize tab, non-sequential) > Merit Function Editor (optimize tab, non-sequential) > NSC Operands I expect the following to work in fully non sequential mode: ! Detector color object reference det = 4 TotalFlux = NSDE(1,det,0,0,0,0) MaxIrradiance = NSDE(1,det,-1,0,1,0) But actually, the following work for me, i.e. return the correct quantity: TotalFlux = NSDE(1,det,0,0,1,0) MaxIrradiance = NSDE(1,det,-1,0,2,0) Therefore, if this is confirmed, the Data# reported in the table of the Help is wrong and should be incremented by 1. Thank you
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
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!
Good morning, I am designing a broadband spectrometer (currently in sequential mode). I think someone may answer the following questions way faster than I can. I am interested in measuring the spot size in the dispersion direction (therefore not as a general RMS parameter, as it is usually given). Is there a way in Zemax to automatically measure it through the merit function? I know that the optimization wizard allows to choose a X Weight and an Y Weight. Is there any reference I can read of the topic? Can you advice any specific reference on how to relate the calculated RMS spot size in Zemax to the spectrometer resolution? Thank you very much, Cinzia
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
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.