TAGGED: api, eigenmode, lumapi, python, python-scripting, python-scripts
-
-
April 12, 2023 at 7:19 pm
minusunny
SubscriberCan i use python API feature to run EME simulation or it is applicable only for FDTD?
import numpy as np
import matplotlib.pyplot as plt
import os
import implumapi = imp.load_source("lumapi","C:\\Program Files\\Lumerical\\v231\\api\\python\\lumapi.py")
os.add_dll_directory("C:\\Program Files\\Lumerical\\v231\\api\\python")mode = lumapi.MODE()
mode.addeme()
{
PARAMETERS
}
mode.addemeport();
{PARAMETERS
}
mode.addemeprofile();
{
parameters
}
mode.runeme()
mode.emepropagate();Is this the right way to implement?
-
April 13, 2023 at 12:40 am
Lito
Ansys Employee@minusunny,
The Python API applies to all Ansys Lumerical solvers. On windows, simply set the Python integration to use the bundled Python 3 and add the "import lumapi" into your script. Run the Python script.py script from the Script File Editor window as shown in the image below.
Note: On Linux, it requires the Gnome or Mate terminal when running from the Lumerical CAD/GUI. Otherwise, to run directly from Terminal, see this KB > How to run Lumerical API (Python) scripts in Linux – Ansys Optics.
-
April 13, 2023 at 2:51 pm
minusunny
SubscriberHi, Thank you for your response, i understand that. I am running the software in windows and using spyder notebook to code in python. When i use mode.addeme() command , it is not allowing me to run. So I want to know if mode.addeme() is the right command to call EME solver using python, using the setup:
import numpy as np
import matplotlib.pyplot as plt
import os
import implumapi = imp.load_source("lumapi","C:\\Program Files\\Lumerical\\v231\\api\\python\\lumapi.py")
os.add_dll_directory("C:\\Program Files\\Lumerical\\v231\\api\\python")mode = lumapi.MODE()
mode.addeme()
{
PARAMETERS
}
mode.addemeport();
{PARAMETERS
}
mode.addemeprofile();
{
parameters
}
mode.runeme()
mode.emepropagate();I have searched for some examples with EME solver , but i could only find one with FDE,varFDTD, FDTD.
-
April 13, 2023 at 3:57 pm
Lito
Ansys EmployeeAre you able to run the following commands from Spyder Notebook on windows? Does it create and save the FDTD simulation file?
import numpy as np
import matplotlib.pyplot as plt
import os
import imp
lumapi = imp.load_source("lumapi","C:\\Program Files\\Lumerical\\v231\\api\\python\\lumapi.py")
os.add_dll_directory("C:\\Program Files\\Lumerical\\v231\\api\\python")
fdtd = lumapi.FDTD()
fdtd.addfdtd()
fdtd.addring()
fdtd.addmesh()
fdtd.save("lumtestpy.fsp")
-
-
April 13, 2023 at 3:59 pm
minusunny
SubscriberYes, I was able to run and is working fine.
-
April 13, 2023 at 11:45 pm
Lito
Ansys EmployeeTry the script below on Spyder notebook. I ran this from the script file editor window in the CAD with Python integration using our bundled Python3. The script should create a new EME simulation file, “eme_test.lms” on your current working directory.
import numpy as np
import matplotlib.pyplot as plt
import os
import imp
lumapi = imp.load_source("lumapi","C:\\Program Files\\Lumerical\\v231\\api\\python\\lumapi.py")
os.add_dll_directory("C:\\Program Files\\Lumerical\\v231\\api\\python")mode = lumapi.MODE()
mode.addeme()
mode.addring()
mode.addmesh()
mode.save("eme_test.lms")
-
-
April 14, 2023 at 3:04 pm
minusunny
SubscriberThank you, it worked. Apparently , the notebook was showing error at wrong place. Now I am able to run the code.
-
April 14, 2023 at 4:02 pm
minusunny
SubscriberAnother question how do i delcare EME simulation properties, group spans , as well as modes in python-format ?
-
April 14, 2023 at 4:17 pm
Lito
Ansys Employee@minusunny,
Please check out the scripting or API sections in our Knowledge Base (KB).
> Python API overview – Ansys Optics
> Lumerical scripting language – By category – Ansys Optics
Our FAQ section might come handy for other common issues.
-
-
- The topic ‘Lumerical Python API’ is closed to new replies.
-
3587
-
1193
-
1086
-
1068
-
952
© 2025 Copyright ANSYS, Inc. All rights reserved.