Almost all script commands in the Lumerical script language can be used as methods on your session object in Python. The lumapi methods and the Lumerical script commands share the same name and can be called directly on the session once it's been created. For example,
fdtd.addrect() # Note the added brackets since this is a method in Python.
For more information on Lumerical scripting language please see:
- Scripting Learning Track on Ansys Innovation Courses (AIC)
- Lumerical scripting language - Alphabetical list
- Lumerical scripting language - By category
Documentation Docstrings
For information on the lumapi methods from within the environment we support Python docstrings for Lumerical session objects. This is the simplest way to determine the available script commands, and syntax. This contains information that is similar to the Alphabetical List of Script Commands . You can view the docstring by using the Python built-in function "help" or most ways rich interactive Python shells display docstrings (e.g. IPython, Jupyter Notebook):
>>> help(f.addfdtd)
Help on method addfdtd in module lumapi:
addfdtd(self, *args) method of lumapi.FDTD instance
Adds an FDTD solver region to the simulation environment. The extent of
the solver region determines the simulated volume/area in FDTD
Solutions.
+-----------------------------------+-----------------------------------+
| Syntax | Description |
+-----------------------------------+-----------------------------------+
| o.addfdtd() | Adds an FDTD solver region to the |
| | simulation environment. |
| | |
| | This function does not return any |
| | data. |
+-----------------------------------+-----------------------------------+
See Also
set(), run()
https://kb.lumerical.com/en/ref_scripts_addfdtd.html
Note: We still support previous version of the Python API, yet we strongly recommend to use the newer Python API. |
Missing Methods
Since the list of methods available through the API is nearly complete it is more illuminating to look at the syntax which is not acceptable in Python to understand the subtle variations. Special characters, and reserved keywords in lsf cannot be arbitrarily overloaded in Python; thus, the variations can be reduced to differing methods to access data, script operators. If you require the use of lsf characters it is recommended to use lumapi.eval() method, but one should be mindful that variables that exist in the Python are not necessarily available in Lumerical script environment and vice-versa. See Passing Data - Python API for more information.
Operators
The Script operators that are used in lsf cannot be overloaded in Python, so Algebraic: * , / , + , - , ^,... and Logical: >= , < , > , & , and , | , or , ! , ~ cannot be accessed. One should use the native Python operators to manipulate variables although some slight variations may exist.
A very helpful operator in Lumerical is ? (print, display) - Script operator, which allows you to print to screen and query available results. In Python your should use the print function to display and querynamed method, queryanalysisprop method, etc to access simulation object properties in Lumerical.
Datatypes
Lumerical and Python datatypes will differ in the associated operations, methods, and access style. For a summary of how datatypes are passed between environments see getv(), and putv(). Information on Lumerical datatypes and access is available in Introduction to Lumerical datasets. A reference on built-in Python types documentation is available from the Python Software Foundation.