Hey Max,
I just tested the IBatchRayTrace
in non-sequential and everything looks to be working as expected. I’m using a simple Source Ray, Standard Lens, and Detector Rectangle. The code to create the system is below:
ZOSAPI = zos.ZOSAPI
TheApplication = zos.TheApplication
TheSystem = zos.TheSystem
zos.TheSystem.New(False)
zos.TheSystem.MakeNonSequential()
o1 = TheSystem.NCE.GetObjectAt(1)
o1.ChangeType(o1.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.SourceRay))
o1.YPosition = 0.9
o1.ZPosition = -1
o1.ObjectData.__implementation__.NumberOfLayoutRays = 1
o1.ObjectData.__implementation__.NumberOfAnalysisRays = 1
o1.ObjectData.__implementation__.ZCosine = 1
o2 = TheSystem.NCE.InsertNewObjectAt(2)
o2.ChangeType(o2.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.StandardLens))
o2.Material = 'N-BK7'
o2.ObjectData.__implementation__.Radius1 = 12.5
o3 = TheSystem.NCE.InsertNewObjectAt(3)
o3.ChangeType(o3.GetObjectTypeSettings(ZOSAPI.Editors.NCE.ObjectType.DetectorRectangle))
o3.ZPosition = 24.6
o3.ObjectData.__implementation__.NumberOfXPixels = 100
o3.ObjectData.__implementation__.NumberOfYPixels = 100
Then, to perform the ray trace, I wanted to add the same values as the Source Ray above, namely (x, y, z) = (0, 0.9, -1.0) and (l, m, n) = (0, 0, 1):
from System import Enum
tool = TheSystem.Tools.OpenBatchRayTrace()
nsc_raytrace = tool.CreateNSC(1, 10, 0)
nsc_raytrace.AddRay(1, 1, Enum.Parse(zos.ZOSAPI.Tools.RayTrace.NSCTraceOptions, 'None'), 0, 0.9, -1, 0, 0, 1, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
tool.RunAndWaitForCompletion()
nsc_raytrace.StartReadingResults()
sr, rn, _, _, ns = nsc_raytrace.ReadNextResult(1, 1, 1, 1)
while sr:
ss, seglevel, segpar, hit, _, x, y, z, l, m, n, _, _, _, _, _, _, intensity, opl = nsc_raytrace.ReadNextSegment(1, 1, 1, 1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
while ss:
ss, seglevel, segpar, hit, _, x, y, z, l, m, n, _, _, _, _, _, _, intensity, opl = nsc_raytrace.ReadNextSegment(1, 1, 1, 1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
print(f'(x, y, z) : ({x:8.5f}, {y:8.5f}, {z:8.5f})')
sr, rn, _, _, ns = nsc_raytrace.ReadNextResult(1, 1, 1, 1)
tool.Close()
The output is shown below and this matches the new Single Ray Trace feature with the same initial inputs:
(x, y, z) : ( 0.00000, 0.90000, 0.03244)
(x, y, z) : ( 0.00000, 0.87616, 1.00000)
(x, y, z) : ( 0.00000, -0.00703, 24.60000)
(x, y, z) : ( 0.00000, -0.10277, 27.15821)
(x, y, z) : ( 0.00000, 0.00000, 0.00000)
The one thing I’ll note is if you’re using NSCTraceOptions that uses any Polarization (only None and UseScattering don’t use Polarization) and your e-field is not normalized to 1.0, then you’ll get incorrect data.
If this still isn’t working for you, please post your code so the community can help out.