Photonics

Photonics

Topics related to Lumerical and more.

Call python method in lumerical script

    • d08941008
      Subscriber

      Hi, I was wondering that if it's possible to call the python method (or def) within the lumerical script, say fom script of optimization?

      Although the syntax 'system("");' works for just running the python file, it can't return values back to lumerical for fom. It seems that the python API could solve the problem, but I don't know what method of lumapi should be used here.

      Could you help me with this?

    • Kyle
      Ansys Employee

      The Python API can be used to call Lumerical script methods from a Python script. It can't be used in the reverse manner, to call Python methods from a Lumerical script. If there is a Python method you would like to use, it would probably be better to write a Python script that uses the API methods rather than writing a Lumerical script file. This way you can use the Python method directly in your script.
    • d08941008
      Subscriber
      Thanks for the reply. But can it be done in the "fom script" zone of optimization?
    • Kyle
      Ansys Employee

      No, it's not possible to call Python methods from the FOM script in the optimization utility. You will either have to rewrite the Python method in the Lumerical scripting language, or use another optimization method in a Python script. For example, the Scipy library has some optimization methods. However this will be much more complicated to set up than using Lumerical's built-in optimization utility. Unless the Python method is very complicated, or uses external libraries, I think it would probably be easier to rewrite the Python method in a Lumerical script.
Viewing 3 reply threads
  • The topic ‘Call python method in lumerical script’ is closed to new replies.