Readout OPD from Arraytrace

  • 14 July 2021
  • 0 replies
  • 59 views

Hello,


we're currently working on parallelizing a raytracing program in Python that uses the ZOS-API for a connection to Zemax. We didn't write the code, we're tasked with bugfixing and optimisation, so we don't fully understand the code. The problem we identified is that the code needs to do a 2nd Trace. By default, the OPD gets normed to a centroid of some sort, because of this we need to retrace every ray to get rid of this norm as the purpose of the code is to simulate interferometry, which is why we need the OPD values unnormed.


Is there any way to stop Zemax from norming these values (perhap some get merit function?)?


A different approach might be do incorporate Python multiprocessing, whoever we are unsure how to incorporate the bellow OPD function into Python multiprocessing.




Below is the snippet of the code that creates the major slowdown, the OpdItr=... part takes up approx. 80%+ of the Runtime (which is bad, total code runtime for a full detector simulation is at about 2 weeks).



LoopIds = np.fromiter(range(0, NbrRaysToTrace), np.int)
FieldIds = np.floor(LoopIds / NbrValidRaysPerField).astype(int)
Func = TheSystem.MFE.GetOperandValue
Operand = [constants.MeritOperandType_OPTH, ] * NbrRaysToTrace
NSurfs = [NSurf, ] * NbrRaysToTrace
Wave = [NbrWavelength, ] * NbrRaysToTrace
Modus = LoopIds % NbrValidRaysPerField
Pxs = Px_[Modus]
Pys = Py_[Modus]
Zeros = [0.0, ] * NbrRaysToTrace
OpdItr = map(Func, Operand, NSurfs, Wave, HxToTrace[FieldIds], HyToTrace[FieldIds], Pxs, Pys, Zeros, Zeros)
RayDataTraced[IndexConfig-1, 11, :, 🙂 = np.reshape(np.fromiter(OpdItr,
RayDataTraced[IndexConfig - 1].dtype),
newshape=(HxToTrace.size, NbrValidRaysPerField))

If you need further information for comprehension ask away.


Thank you for your time and help


Anton Rabanus


0 replies

Be the first to reply!

Reply