SimObject#
- class ansys.lumerical.core.SimObject(parent, id)#
Represents a simulation object in the Objects Tree.
Warning
Don’t initialize this class directly. Other functions and methods return this class.
Note
In addition to the default attributes listed below, SimObjects also have attributes that match the properties of the simulation object. See the “Notes” section below for more information.
- Parameters:
- Don’t initialize this class directly.
- Attributes:
- results
ansys.lumerical.core.SimObjectResults An object containing the results of the simulation object.
- properties
dict A dictionary that can be used to assign properties to the simulation object.
- results
Notes
All SimObjects also have attributes that match the properties of the simulation object in the Lumerical environment.
The attribute names are the same as the property names in the Lumerical application, except that spaces are replaced with underscore characters. You can also read and set attributes like a Python dict using the subscripting operator []. When you access it this way, attributes retain their original name including spaces. Setting an attribute immediately updates the object in the Lumerical application. For further information, see the Working with simulation objects page in the User guide.
Example
>>> fdtd = lumapi.FDTD() >>> #Initialize position and x span using keyword arguments >>> rect_obj = fdtd.addrect(x=0,y=0,z=0, x_span = 2e-6) >>> #Set y span as an attribute >>> rect_obj.y_span = 2e-6 >>> #Set z span like a dict, note that there is now a space since the original Lumerical attribute has a space >>> rect_obj["z span"] = 0.5e-6 >>> #Read and print out the x-span of the rectangle set earlier >>> print(f"{rect_obj.x_span =} \n")
Returns
>>> Attribute Access: rect_obj.x_span =2e-06 >>> Dict Access: rect_obj['x span']=2e-06
Warning
When two simulation objects have the same name in the Lumerical product, operations on them can generate unexpected results. Assign unique names to all simulation objects when using PyLumerical to avoid this problem.
Example
>>> fdtd = lumapi.FDTD() >>> rect_bot =fdtd.addrect(name = "Rect",x_span = 1e-6, z_span = 0.25e-6, z=0) #Create a bottom rectangle, Rect1 >>> rect_top = fdtd.addrect(name = "Rect", x_span = 1e-6, z_span = 0.25e-6, z=0.5e-6) #Create a top rectangle, Rect 2 >>> #The following code will change the x_span of the BOTTOM rectangle! >>> rect_top.x_span = 2e-6
For more information, see Working with simulation objects in the User guide.
Methods
Returns the children of the currently selected object in the Lumerical session.
Return the parent of the currently selected object in the Lumerical session.