I have a simple system of a source and an object (CAD object checked with “object is a detector”). The CAD object has a coating defined with 80 % reflectance and 20 % absorbtance.
I´m trying to get the absorbed energy via ZPL macro with the operand NSDD. However, with the macro shown below, I always get the fully incident energy and not only the absorbed one.
In the help file (Non-sequential Ray Tracing and Detector Operands) it says:
For Object Is A Detector: There are two additional options for data. Data is 4 for absorbed flux and 5 for absorbed flux/area.
What am I doing wrong?
Greetings
Julian
Page 1 / 1
Hi Julian,
When things like this happen, I tend to check if I can reproduce the problem with the user interface only. If you create a Merit Function like so:
Then, you can’t set the Data column of the second NSDD operand to 4 (OpticStudio puts it back to zero automatically). Therefore, I’m not expecting this to work in your ZPL macro either. If you specify a valid pixel number (say 1 for example), then you can have Data = 4 for this particular pixel.
However, you want to know the total abosrption of your object and not for a single pixel.
I’m not sure how you should cannonically go about this problem, but here’s what I’ve done. First, I created a 1 x 1 x 1 mm^3 STEP file and uploaded it to OpticStudio as a Detector. I’ve assigned all its faces to Face 0 and used a coating like so:
FOR pixel_id, 1, pixel_number, 1 total_absorbed = total_absorbed + NSDD(1, 2, pixel_id, 4) NEXT
PRINT "Total flux absorbed = ", total_absorbed
As a last sanity check, I changed the Source Ray to a Source Ellipse (1E5 rays) with a 0.2 by 0.2 size and checked that I would still get the 0.2 W absorption. I’ve uploaded my file for you to check:
Executing C:\Users\David Nguyen\Documents\Zemax\MACROS\Total_absorbance.ZPL. Total flux absorbed = 0.2000
The draw back is that you need to figure out the total pixel number (by going to the Detector text tab) by hand (I couldn’t find an automatic way to get this number, perhaps @Csilla Timar-Fulep, @Berta.Bernad, or @Sandrine Auriol can further comment on this last issue). EDIT: I guess you could also parse the text file of the detector created by GETTEXTFILE for example.