ZOS-API- How to use sequential ray tracing tools?

  • 30 September 2019
  • 0 replies
  • 314 views

Userlevel 4
Badge +2


to_surf = TheSystem.LDE.NumberOfSurfaces-1;
Ex=0;Ey=1;phaX=0;phaY=90;waveNumber=2;Hx=0;Hy=0;Px=0;Py=1;
raytrace = TheSystem.Tools.OpenBatchRayTrace();
[success,errCode,exro,exio,eyro,eyio,ezro,ezio,intensity]=raytrace.SingleRayNormPol(ZOSAPI.Tools.RayTrace.RaysType.Real,Ex,Ey,phaX,phaY, to_surf, waveNumber,Hx,Hy,Px,Py,0,0,0,0,0,0);


  • Open the batch ray trace tool

  • Create polarized real raytracing in which a single ray with normalized pupil coordinates will be added



waveNumber=2;Hx=0;Hy=0.5;Px=0;Py=0.5;
raytrace = TheSystem.Tools.OpenBatchRayTrace();
[success,X,Y,Z,L,M,N]=raytrace.GetDirectFieldCoordinates(2,ZOSAPI.Tools.RayTrace.RaysType.Real,Hx,Hy,Px,Py)


  • Open the batch ray trace tool

  • Get direct field coordinates with input normalized field and pupil coordinates




raytrace = TheSystem.Tools.OpenBatchRayTrace();
max_rays = 4;
pwav = 0;
for a = 1:TheSystem.SystemData.Wavelengths.NumberOfWavelengths
if TheSystem.SystemData.Wavelengths.GetWavelength(a).IsPrimary == 1; pwav = a; end;
end
to_surf = TheSystem.LDE.NumberOfSurfaces;
normUnPolData = raytrace.CreateNormUnpol(11,ZOSAPI.Tools.RayTrace.RaysType.Real, (to_surf)-1);
hx=0;
px=0;
hy_ary = [0, 0.707, 1];
fprintf('%6s %8s %8s %8s %8s %12s %12s%12s %12s%12s %12s\n','ray#','hx','hy','px','py','X','Y','L','M','l2','m2')
for i=1: length(hy_ary)
normUnPolData.ClearData();

for j=0:max_rays
py(j+1)=-1+j/2;
normUnPolData.AddRay(pwav, hx, hy_ary(i), px, py(j+1), ZOSAPI. Tools.RayTrace.OPDMode.None);

end

raytrace.RunAndWaitForCompletion();
normUnPolData.StartReadingResults();
[success, rayNumber, errCode, vigCode, x, y, ~, L, M, ~, l2, m2, ~, ~, ~] = normUnPolData.ReadNextResult();
while success
if ((errCode == 0 ) && (vigCode == 0)) fprintf('%6d %8.2f %8.2f %8.2f %8.2f %12.6f %12.6f%12.6f %12.6f%12.6f %12.6f\n',rayNumber,hx, hy_ary(i), px,py(rayNumber),x,y,L,M,l2,m2)
end
[success, rayNumber, errCode, vigCode, x, y, ~, L, M, ~,l2, m2, ~, ~, ~] = normUnPolData.ReadNextResult();
end
end


In the above code:



  • Open the batch ray trace tool

  • Get primary wave number and number of surfaces

  • Create unpolarized real raytracing in which rays with normalized pupil coordinates will be added

  • Use for loop to add a batch of rays from different fields

  • Run the tool until it finished

  • Read results ray by ray if data is valid

  • Print data in command window





0 replies

Be the first to reply!

Reply