Photonics

Photonics

Topics related to Lumerical and more.

getindex is not a valid function or variable name

    • Rabeeya Hamid
      Subscriber

      I am getting this error in my optimization figure of merit script, however the same function (getindex) works fine when used in normal script. I got the same error for getfdtdindex. Why is this happening and how can I fix it?

    • Amrita Pati
      Ansys Employee

      Hi Rabeeya,

      The user-defined scripting option in the Optimization Utility has limited capabilities similar to the scripting options within model, analysis, and structure groups. Some functions won't work from within these environments. 

      I believe there is a workaround, but I haven't tested it fully myself. You can try and let me know if there are any issues. The getindex script works within "model", the root class in the objects tree. 

      1. You can edit "model".
      2. Go to "Analysis" and then "Variables".
      3. In the Results section, define a varaible called "n".
      4. Copy and paste the getindex commands in the Analysis-->Script of "model".
      5. Now model should return "n" as a result after FDTD is run:
      6. Moving on to the optimization task, in the "Figures of merit", you can select "n" as shown below, in addition to any other result you might have:
      7. Next, you can use this "n" in the user defined fom section directly. A random code is shown as an example below:

      Please feel free to let me know if you have any questions.

      Regards,
      Amrita

Viewing 1 reply thread
  • The topic ‘getindex is not a valid function or variable name’ is closed to new replies.