Evaluates the input string as Lumerical Scripting Language. This function is useful when you want to reduce the number of API calls for performance. For example, if you want to execute many commands in a loop, writing commands in Lumerical Scripting Language and executing it in a single call can improve performance.
Syntax
lumapi.eval(code)
Parameters
Field |
Type |
Description |
---|---|---|
code |
str |
Evaluates the argument code as Lumerical Scripting Language. The input code must be a string, and should follow syntaxes of the Lumerical Scripting Language. Escape characters in the string is ignored. |
Returns
None
Examples
Adds a rectangle to the current simulation.
fdtd = lumapi.FDTD()
fdtd.eval(f"addrect;")
Adds a rectangle to the current simulation using f-strings.
fdtd = lumapi.FDTD()
code = "addrect;addcircle;"
fdtd.eval(f"{code}\n")
Adds a rectangle to the current simulation using a text file, “code.txt” from the current working directory containing the commands. This text file can be in .lsf format or any other format that can be read by Python and turned into a string.
Contents of code.txt
addrect;
addcircle;
Python Driver Code
fdtd = lumapi.FDTD()
code = open("code.txt", "r").read()
fdtd.eval(code)
See Also
Python API overview – Ansys Optics, Lumerical Python API Reference