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 Yap
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 Yap
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 Yap
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 Yap
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.
-
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Why am I getting “process exited without calling finalize”, and how do I fix it?
- “Import optical generation” or “delta generation rate”?
- Error: addfdtd is not a valid function or a variable name
- Error on Lumerical device
- Using a license file on a new license server
- Ansys Insight: Transmission results greater than one
- Ansys Insight: Diverging Simulations
- Finding your Ansys (or Lumerical) account number
- Is there a Lumerical script command to output the Simulation and Memory requirements?
- Ansys Insight: Why my simulation result is different from published paper or experiment?
-
5162
-
3275
-
2447
-
1308
-
956
© 2023 Copyright ANSYS, Inc. All rights reserved.