-
Notifications
You must be signed in to change notification settings - Fork 64
05. Examples of array ray tracing
The array ray tracing module pyzdde.arraytrace
provides useful functions for performing bulk ray tracing as described in the Zemax manual.
Please refer to the wiki article Array ray tracing using Zemax and Python for a better understanding of the array ray tracing module in PyZDDE.
Please note that if the example is present in the PyZDDE/Examples directory, only a link to the source code is provided here.
Description: A simple example that demonstrates the use the functions getRayDataArray()
and zArrayTrace()
in the module pyzdde.arraytrace -- the former function helps in creating a ray data structure array, and the later function sends the ray data to Zemax (through c) for tracing. This example emulates the "ArrayDemo.c" example provided by Zemax/OpticStudio.
The traced data is put into text file named "arrayTraceOutput.txt". A partial output from the text file is shown below:
Listing of Array trace data
px py error xout yout l m n opd Exr Exi Eyr Eyi Ezr Ezi trans
-0.500 -0.500 0 -2.985686E-03 -2.985686E-03 0.05014 0.05014 0.99748 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
-0.500 -0.490 0 -3.097035E-03 -3.035095E-03 0.05013 0.04913 0.99753 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
-0.500 -0.480 0 -3.207192E-03 -3.078905E-03 0.05013 0.04813 0.99758 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
-0.500 -0.470 0 -3.316087E-03 -3.117121E-03 0.05013 0.04712 0.99763 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
-0.500 -0.460 0 -3.423649E-03 -3.149757E-03 0.05013 0.04612 0.99768 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
-0.500 -0.450 0 -3.529811E-03 -3.176830E-03 0.05013 0.04511 0.99772 64.711 0.000 0.000 0.000 0.000 -1.000 0.000 1.0000
...
Description: This example demonstrates the function zGetNSCTraceArray()
in the module pyzdde.arraytrace
for performing NSC ray tracing. It emulates the "NSCTraceDemo.c" external program that is shipped with Zemax/OpticStudio.
The program assumes that an appropriate lens design file is already loaded into the LDE. The following output shows the traced data for the sample lens file "Example 3 Grating Splits up Color.zmx" that is provided by Zemax.
Listing of NSC Trace data:
seg# Prnt Levl In Hit X Y Z Intensity
1 0 1 0 2 0.000000E+00 0.000000E+00 5.000000E+00 1.0000
2 1 2 2 2 1.819730E-01 0.000000E+00 5.500000E+00 0.3300
3 2 3 0 3 5.459189E+00 0.000000E+00 2.000000E+01 0.3300
4 1 2 2 2 0.000000E+00 0.000000E+00 5.500000E+00 0.3300
5 4 3 0 3 0.000000E+00 0.000000E+00 2.000000E+01 0.3300
6 1 2 2 2 -1.819730E-01 0.000000E+00 5.500000E+00 0.3300
7 6 3 0 3 -5.459189E+00 0.000000E+00 2.000000E+01 0.3300
8 1 2 0 0 6.840000E-01 0.000000E+00 3.120600E+00 0.3300
9 1 2 0 0 0.000000E+00 0.000000E+00 3.000000E+00 0.3300
10 1 2 0 0 -6.840000E-01 0.000000E+00 3.120600E+00 0.3300
Description: Demonstrate array tracing function by plotting spiral spot diagram. The function also prints out the execution times required to generate the spot diagram for the three different functions -- 1. using zGetTrace()
that trace one ray per DDE call, 2. using zArray()Trace()
that is a core function in the arraytrace
module, and 3. using zGetTraceArray()
that is a helper function in the arraytrace
module.
Execution time (zSpiralSpot) = 80454.14 ms
Execution time (zArrayTrace) = 1299.11 ms
Execution time (zGetTraceArray) = 1570.88 ms
This work by PyZDDE contributors is licensed under a Creative Commons Attribution 4.0 International License.
Based on a work at https://github.com/indranilsinharoy/PyZDDE.