eval#

INTERCONNECT.eval(code)#

Low level script workspace method that evaluates the input string as Lumerical Scripting Language.

This method is a low level method that interacts directly with the script workspace in Lumerical. It is not recommended to use this unless a specific function needs to be achieved.

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.

Parameters:
codestr

Evaluates the argument code as Lumerical Scripting Language. The input code must be a string, and should follow syntaxes of the Lumerical Scripting Language. The method ignores characters in the string.

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)