Please enable JavaScript to view this site.

Knowledge Base

A Python function that opens a session of selected Lumerical tool via the Python interoperability API. Once the session is opened, Lumerical can be called from Python to execute Lumerical script command(s). Opened Lumerical session also allows Python to get variables from Lumerical workspace.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

Supported OS: Windows, Linux

 

Syntax

Description

h = lumapi.open("tool_name")

When executed in Python, this function will open a session of FDTD via the interoperability API.

 

Accepted parameters:

"fdtd"

"mode"

"interconnect"

 

Example

The following Python script example opens an FDTD session, passes some variables and strings to FDTD. Then it executes an FDTD script command and retrieves some variable to Python.

 

import sys, numpy

 

sys.path.append("/opt/lumerical/fdtd/api/python") # lumapi path

import lumapi

 

h=lumapi.open("fdtd")

 

# passing arguments to Lumerical

lumapi.putDouble(h,"x",2)

lumapi.putString(h,"string_name", "text")

lumapi.putMatrix(h, "M", [[1,2,3],[4,5,6]])

lumapi.evalScript(h, "A=x*M;")

 

# getting variables from Lumerical

A=lumapi.getVar(h,"A")

B=lumapi.getVar(h,"string_name")

 

lumapi.close(h)

 

print A

print B

 

 

# results on Terminal

#4 # this is the number of string characters returned by the lumapi.putSting function

#[[2. 4. 6.]

# [8, 10. 12.]]

#text

 

See Also

lumapi.close

Copyright Lumerical Inc. | Privacy | Site Map