We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Photonics

Photonics

Topics related to Lumerical and more.

Code gives different result when run as a script compared to analysis

    • williamfraser3
      Subscriber

      I am designing a grating coupler in Lumerical FDTD. I have some code in the Analysis tab of the "model" object that calculates the overlap between the field radiated by the grating and a Gaussian fiber mode. If I copy this code and run it as a script instead of inside the "model" object, it gives a different result, i.e., calculates an overlap of 72% instead of 77%. It is the EXACT same code (copy and pasted). What is going on?

    • Kirill
      Ansys Employee

      Dear Subscriber,

      My guess is that some variables under Model > Analysis > Variables may have different values in your Script Workspace. So, while the "exact same code" is being used, it might not be processing exactly the same data.

      Best regards,
      Kirill

      • williamfraser3
        Subscriber

        Hi Kirill,

        Yes, I discovered what the problem was. In the Model variables I have a length parameter called 'wav' that I use to set the wavelength for the sources. Inside the analysis, I have an if statement that checks the wavelength to set the appropriate fiber MFD. Even though 'wav' was set to 1.55 um, the condition 'wav == 1.55e-6' was returning false, so the wrong fiber MFD was being used. Changing the 'wav' parameter to be a number instead of a length fixes this problem. Not sure if that is a bug or intentional. 

    • Kirill
      Ansys Employee

      Hi @williamfraser3,

      Using um unit should give exactly 1e-6 factor... Anyway, I'm glad that you have resolve the issue. Thanks for confirming!

      Best regards,
      Kirill

      • williamfraser3
        Subscriber

        Hi Kirill,

        Yes, that's what I figured. But for some reason 1.55e-6 == 1.55e-6 is not true according to Lumerical when the left side is a "length" but 1.55 == 1.55 is true if the left side is a "number". Weird, but glad I noticed and found a workaround.

        Best,

        William

Viewing 2 reply threads
  • You must be logged in to reply to this topic.