Share your solutions or ask questions about the ZOS-API, ZPL, or DLLs. Code shared in these spaces is not reviewed by Zemax except for the Code Exchange.
I need to simulate a gaussian beam in non sequential mode, which has 850 nm wavelength, 15 degree diveregence angle (half angle) and the beam raduis of 2.563 mm at 10 mm which has the cross section of the beam profile shape as attached below, but when putting this values using the Gaussian source it doesnt give me the same results. By using the skewRaysCircular I cannot get the gaussain beam profile and it just shows me a ring, how can I get a gaussian beam profile in the output?
In this forum post, a sample C++ code to read value from a text file in DLL is shared. This is mainly a supplement to the follwoing knowledge base article. The only difference is we will do the similar thing with C++ code to how how to do this in C++ style. How to read a static data file into a user-defined surface In the attachments, a sample code is attached. This code does the same thing as shown in the following forum post. The difference is the diffraction efficiency data is read from a text file. Simulate 2D diffraction grating using customized diffractive DLL We will explain line by line in below. The first thing to do is to define a global variable, which is declared outside of all the functions. As discussed here, during ray-tracing in OpticStudio, the DLL will be called several times. For the global variable, the inside value is unchanged and the DLL can always see the same data in different thread. Our plan is to read data from text file and save it in this global va
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.
In OpticStudio, currently we only support one dimensional grating. However, it's not difficult to simulate 2D grating. Here we will show an example using diffractive DLL.You may compile it with the instructions or use the DLL file attached to this article. Before we start, here are some articles for required background knowledge that we will not repeat in this forum post. How diffractive surfaces are modeled in OpticStudio (KBA) How diffraction ray-tracing is calculated (forum post) Custom DLLs in OpticStudio: An overview of user-defined surfaces, objects, and other DLL types (KBA) How to compile a User-Defined DLL (KBA) Let's simply open the attached cpp file and observe how it works. This example is mainly modified from the built-in sample \Documents\Zemax\DLL\Diffractive\diff_samp_1.c To compile the program as C++ code. We package the functions with extern 'C'. In this example, we only want to return diffraction ray direction and its relative intensity. S
This forum post is a place to collect update history of diffractive tools beta functions, which includes all RCWA DLLs (and visualization API), polygon DLL, and Zemax Grating Data (ZGD) DLL. Content:1. Overview2. Resources3. Change history OverviewCurrently in OpticStudio, we are adding some useful DLLs to enhance the ability of fully simualting gratings. They allow OpticStudio to consider the efficiency when rays pass through diffractive optical elements (DOE), such like 1D/2D gratings, binary optics, or volume holograms. These extensions can be found in OpticStudio installations.These tools improve frequently based on users’ feedback. We decide to provide functions with DLL so it can be updaetd fast upon users' request. Between each OpticStudio public releases, there might be several minor updates and bug fixes. This forum post is a place for changes history.Note all tools provided here are only available with OpticStudio Premium Subscription. If users are interested in these functio
Hi, In the ZOSAPI, the settings for the Physical Optics Propagation analysis feature are now fully implemented: So as an example, we may set the settings in the 'General' and 'Beam Definition' tabs using the ZOSAPI in MATLAB: TheSystem = TheApplication.PrimarySystem; TheAnalyses = TheSystem.Analyses; newPOP = TheAnalyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PhysicalOpticsPropagation); newPOP.HasAnalysisSpecificSettings; newPOP_Settings = newPOP.Settings(); newPOP_Settings.Wavelength.SetWavelengthNumber(1); newPOP_Settings.Field.SetFieldNumber(1); newPOP_Settings.StartSurface.SetSurfaceNumber(1); newPOP_Settings.EndSurface.SetSurfaceNumber(4); newPOP_Settings.SurfaceToBeam = 0.0; newPOP_Settings.UsePolarization = true; newPOP_Settings.SeparateXY = false; newPOP_Settings.UseDiskStorage = false; newPOP_Settings.BeamType = ZOSAPI.Analysis.PhysicalOptics.POPBeamTypes.GaussianWaist; newPOP_Settings.XSampling = ZOSAPI.Analysis.SampleSizes.S_128x128; newPOP
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, I would like to save graphical plot in detector viewer into a picture file by ZOS-API.I looked at some similar questions in community but most of those tell that “get numerical data and draw a plot using the numerical data” or “that feature is in request” 1 year go.So, I am wondering if that feature is implemented already or not.To me, GUI already has that feature and hence it seems that if there is a function in ZOS-API to call that feature in GUI, it gets the job done. Does anybody know that? RegardsKazu
I use Detectorviewers in text mode to export the results of my simulations to disk.Futher processing is done via python, where the plain textfile gets parsed.I prefer to not using the ZOS API as this limits me in the python verison i use. Problem is: The Detector Viewer numbers are really error-prone as sometimes i close a window and open another one and the numbers i have to put into SAVEWINDOW keyword are just wrong by then.I would prefer using the detector number instead using SAVEDETECTOR keyword. But this saves in some binary format i did not find any specs upon for reading that in. Is there any description on the DDR/DDx file format?Is there any way to obtaining the detector data into python? Best regardsOlli
Hi, I would like to run a python script from a macro (could be a python executable), then get some of the outputed values in the macro. Then I would like to write this values in a merit function from the macro. Is there a simple way to do it or some starting code? Thanks, Jose
This Source DLL models an Astigmatic Gaussian Source. It is based on rays but the statistical distribution of rays gives a picture of a diffracting Gaussian beam. It is valid for small angles (paraxial approximation) and when propagating in free space. So clipping at apertures and aberrations will give incorrect results.w0x, w0y are the real beam waist radii (defined at the 1/e2 intensity point) in the XZ and YZ planes. They includes M^2. z0x, z0y are the positions of the beam waist in the XZ and YZ planes. z0<0: in propagation direction if the waist is located before source. M^2x, M^2y are the quality factors in the XZ and YZ planes.For more information, see "Representation of a Gaussian beam by rays" by P. P. Crooker, W. B. Colson, and J. Blau - Physics Department, Naval Postgraduate School, Monterey, California 93943Authors:Steffen Erhard and @Dirk Broemme Download
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 follwoing 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. FAQ about Relative Illumination So, here is the plan. We want to write a
Dear OpticStudio users, In the context of my research at the MRC - Laboratory of Molecular Biology, I am tolerencing a custom light-sheet microscope, which uses commercial immersion objective lenses. When tolerancing an optical system, which uses non-immersion objective lenses, I would often assume that this element can be replaced with a paraxial lens in a first approximation. However, when it comes to immersion objective lenses, this assumption breaks Abbe's sine condition . Consequently, it is usually not possible to satisfy the specifications, namely focal length, back-aperture diameter, and numerical aperture, of an immersion objective lens with a single paraxial lens. A direct solution to this problem involves patent search, and cumbersome reverse engineering to try and get your hands on the actual design of the commercial immersion objective lens. However, this is time-consuming, and requires a different kind of expertise. To address this issue, Hwang and L
Hi! Is there a way to run a macro from ZOS-API? I have a macro that does some calculation on the currently opened Zemax model and outputs some data. In a Python script I want to make some modifications to the Zemax model using the ZOS-API and then run my macro. Is that possible? Best, Erik
Within the API, we are able to quickly pull Peak Irradiance, Total Power, and Total Hits by using the property GetDetectorData as described in the forum post 'Methods for extracting detector data through the API.' However, this property will not take into account an applied ZRD file. We can apply a ZRD file to a Detector Viewer window, so is there a way to extract the same information from there?
I was pleased to see the new NSC Source DLL 'SkewRaysCircular.dll' added in the May 19 release (OpticStudio 20.2). We have immediate use for it in modeling our systems. It was inspired by the similar (sequential) User Defined Surface DLLs discussed in Paul Colbourne's webinar and KnowledgeBase Article KA-01772, which allows optimization of generally astigmatic Gaussian beams in Sequential mode. But I was disappointed to see that the new Non-Sequential Source DLL only models CIRCULAR Gaussian beams with no astigmatism, unlike the Sequential capabilities that were supplied by Dr. Colbourne, which accommodate general astigmatism! I suggest updating and replacing SkewRaysCircular.dll with a new, more general, Source DLL, renamed appropriately, e.g., SkewRaysGaussianXY.dll , that DOES support general astigmatism. This would seem simple enough to implement starting from the existing SkewRaysCircular.dll: add new pairs of parameters for WaistX, WaistY, (and/or SIzeX, Siz
Hello, I would like to retrieve current object number in Macro while I choose ZPL macro in solveing type of x position in pure NS editor. I check Manual and found there is a function that can get the object number. NPRO(surf, object, code,face), but the object parameter in this function is object number which is what I want to retrieve. How can I retrieve current object number in NS mode while I write ZPL code? Best regards Kevin
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
Hi, I found options to enable/disable GPU calculations in the ZOSAPI help (bool ZOSAPI.Preferences.IPreferencesGeneral.GetIsGPUEnabled() ), but I can’t find them in Project Preferences → General in OpticStudio nor in my standalone application.When I run a batch ray trace, I can see that the computation are done using the GPU.Thanks
In this post, it’s introduced how to simulate realistic grid wire polarizer with RCWA function that comes with OpticStudio 20.2. (Source: https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=5510) Note there are many different types of polarizer For polarizer based on birefringent crystal, check the following article: How to design birefringent polarizers For polarizer based on coating, there is no an article specific to introduction, but users can refer to the following article to know how to set up a coating and assign to object for beam splitting. How to model a dichroic beam splitter Then it’s also worth to note the existence of a build-in ideal coating “PASS_P”. This coating allows P polarization to pass and reflect light with S polarization. Note the coating method can only work for obliquely incident beam. Usually this kind of polarizer is made as a cube or a plate oblique placed in the system. More information can be found in this forum post: 'Pass_P' coating
I am trying to view/export the zernike data of my system using Matlab and the API. Currently my code reads: And I don't know what to do from here. The data comes to Matlab in an IAR file type, and I don't know how to extract it. Thanks, Stephen Chapman
Hi. I am using the ZOS-API for Python and try to switch to the new recommended method of using PythonNET instead of the COM interface. To do so, I created a new Python template using 'Programming>Python>Interactive Extension' (same problem occurs with 'Standalone Application'). Running this template fails when trying to add the NetHelper DLL: import clr, os, winreg from itertools import islice # determine the Zemax working directory aKey = winreg.OpenKey(winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER), r'Software\Zemax', 0, winreg.KEY_READ) zemaxData = winreg.QueryValueEx(aKey, 'ZemaxRoot') NetHelper = os.path.join(os.sep, zemaxData, r'ZOS-API\Libraries\ZOSAPI_NetHelper.dll') winreg.CloseKey(aKey) # add the NetHelper DLL for locating the OpticStudio install folder clr.AddReference(NetHelper) import ZOSAPI_NetHelper --------------------------------------------------------------------------- FileNotFoundException Traceback (most recent call
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.