-
-
August 13, 2021 at 3:25 am
d08941008
SubscriberHi, 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?
August 13, 2021 at 4:09 pmKyle
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.
August 25, 2021 at 4:37 amd08941008
SubscriberThanks for the reply. But can it be done in the "fom script" zone of optimization?
August 27, 2021 at 9:13 pmKyle
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.
Ansys Innovation SpaceTrending discussionsTop Contributors-
3492
-
1057
-
1051
-
965
-
942
Top Rated Tags© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-

Ansys Assistant

Welcome to Ansys Assistant!
An AI-based virtual assistant for active Ansys Academic Customers. Please login using your university issued email address.

Hey there, you are quite inquisitive! You have hit your hourly question limit. Please retry after '10' minutes. For questions, please reach out to ansyslearn@ansys.com.
RETRY