Skip to main content

Hey everyone!

[All necessary files are attached]

I am coding a User-Defined Surface (.dll) to simulate the behaviour of a Diffractive Optical Element (DOE), which in this case will have a phase profile given by the following equation:

  • phase  = (X0Y1 * y) + (X2Y0 * x^2)
  • where X0Y1, and X2Y0 will be coefficients that the user can input in the LDE to later use it for optimization.

So far, the code I wrote for compiling the DLL was based on the code written by  @Michael Cheng : “us_binary_mix12.c”, where I adapted it according to my needs. 

To check whether or not the code is working correctly, I am comparing the rays/beams behaviour when this User-Defined surface is used and when the equivalent “Binary 1” surface is used. If the coefficients X0Y1, and X2Y0 are the same, then I expect the same results, regardless of the surface I use. (Of course, assuming that the units for these coefficients are consistent with each other).

Problem

  • In the front pass of the system, i.e. no mirror space, the results of both approaches match exactly, whether we’re talking about centroids, rays, or beams, with GBSS operands.
  • However, if my system includes a mirror, i.e. the rays will then propagate in the mirror space, then only the results that involve rays are correctly matching with the case when I use the “Binary 1” surface. The GBSS results are quite different. This is what my problem is.

Any suggestions to help me overcome this problem and find the bug in my code? (I am assuming that the problem comes from the way the mirror space case is handled in the code).

Thanks again!

 

Be the first to reply!

Reply