tidy3d.Structure#
- class Structure[source]#
- Bases: - AbstractStructure- Defines a physical object that interacts with the electromagnetic fields. A - Structureis a combination of a material property (- AbstractMedium) and a- Geometry.- Parameters:
- attrs (dict = {}) – Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, - attrsare mutable. For example, the following is allowed for setting an- attr- obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a- TypeErrorif- attrscontain objects that can not be serialized. One can check if- attrsare serializable by calling- obj.json().
- geometry (Union[Box, Transformed, ClipOperation, GeometryGroup, Sphere, Cylinder, PolySlab, ComplexPolySlabBase, TriangleMesh]) – Defines geometric properties of the structure. 
- name (Optional[str] = None) – Optional name for the structure. 
- background_permittivity (Optional[ConstrainedFloatValue] = None) – Relative permittivity used for the background of this structure when performing shape optimization with autograd. 
- medium (Union[Medium, AnisotropicMedium, PECMedium, PoleResidue, Sellmeier, Lorentz, Debye, Drude, FullyAnisotropicMedium, CustomMedium, CustomPoleResidue, CustomSellmeier, CustomLorentz, CustomDebye, CustomDrude, CustomAnisotropicMedium, PerturbationMedium, PerturbationPoleResidue, Medium2D, AnisotropicMediumFromMedium2D]) – Defines the electromagnetic properties of the structure’s medium. 
 
 - Notes - Structures can indeed be larger than the simulation domain in - tidy3d. In such cases,- tidy3dwill automatically truncate the geometry that goes beyond the domain boundaries. For best results, structures that intersect with absorbing boundaries or simulation edges should extend all the way through. In many such cases, an “infinite” size- td.infcan be used to define the size along that dimension.- Example - >>> from tidy3d import Box, Medium >>> box = Box(center=(0,0,1), size=(2, 2, 2)) >>> glass = Medium(permittivity=3.9) >>> struct = Structure(geometry=box, medium=glass, name='glass_box') - See also - Notebooks: - Quickstart: Usage in a basic simulation flow. 
- First walkthrough: Usage in a basic simulation flow. 
 - Lectures: - GUI: - Attributes - Methods - compute_derivatives(derivative_info)- Compute adjoint gradients given the forward and adjoint fields - eps_comp(row, col, frequency, coords)- Single component of the complex-valued permittivity tensor as a function of frequency. - eps_diagonal(frequency, coords)- Main diagonal of the complex-valued permittivity tensor as a function of frequency. - from_permittivity_array(geometry, eps_data, ...)- Create - Structurewith- geometryand- CustomMediumcontaining- eps_datafor The- permittivityfield.- get_monitor_name(index, data_type)- Get the monitor name for either a field or permittivity monitor at given index. - make_adjoint_monitors(freqs, index)- Generate the field and permittivity monitor for this structure. - to_gds(cell[, x, y, z, ...])- Append a structure's planar slice to a .gds cell. - to_gds_file(fname[, x, y, z, ...])- Export a structure's planar slice to a .gds file. - to_gdspy([x, y, z, gds_layer, gds_dtype])- Convert a structure's planar slice to a .gds type polygon. - to_gdstk([x, y, z, permittivity_threshold, ...])- Convert a structure's planar slice to a .gds type polygon. - Inherited Common Usage - medium#
 - eps_diagonal(frequency, coords)[source]#
- Main diagonal of the complex-valued permittivity tensor as a function of frequency. - Parameters:
- frequency (float) – Frequency to evaluate permittivity at (Hz). 
- Returns:
- The diagonal elements of the relative permittivity tensor evaluated at - frequency.
- Return type:
- complex 
 
 - static get_monitor_name(index, data_type)[source]#
- Get the monitor name for either a field or permittivity monitor at given index. 
 - make_adjoint_monitors(freqs, index)[source]#
- Generate the field and permittivity monitor for this structure. 
 - compute_derivatives(derivative_info)[source]#
- Compute adjoint gradients given the forward and adjoint fields 
 - eps_comp(row, col, frequency, coords)[source]#
- Single component of the complex-valued permittivity tensor as a function of frequency. - Parameters:
- row (int) – Component’s row in the permittivity tensor (0, 1, or 2 for x, y, or z respectively). 
- col (int) – Component’s column in the permittivity tensor (0, 1, or 2 for x, y, or z respectively). 
- frequency (float) – Frequency to evaluate permittivity at (Hz). 
 
- Returns:
- Element of the relative permittivity tensor evaluated at - frequency.
- Return type:
- complex 
 
 - to_gdstk(x=None, y=None, z=None, permittivity_threshold=1, frequency=0, gds_layer=0, gds_dtype=0)[source]#
- Convert a structure’s planar slice to a .gds type polygon. - Parameters:
- x (float = None) – Position of plane in x direction, only one of x,y,z can be specified to define plane. 
- y (float = None) – Position of plane in y direction, only one of x,y,z can be specified to define plane. 
- z (float = None) – Position of plane in z direction, only one of x,y,z can be specified to define plane. 
- permittivity_threshold (float = 1.1) – Permitivitty value used to define the shape boundaries for structures with custom medim 
- frequency (float = 0) – Frequency for permittivity evaluaiton in case of custom medium (Hz). 
- gds_layer (int = 0) – Layer index to use for the shapes stored in the .gds file. 
- gds_dtype (int = 0) – Data-type index to use for the shapes stored in the .gds file. 
 
- Returns:
- List of - gdstk.Polygon
- Return type:
- List 
 
 - to_gdspy(x=None, y=None, z=None, gds_layer=0, gds_dtype=0)[source]#
- Convert a structure’s planar slice to a .gds type polygon. - Parameters:
- x (float = None) – Position of plane in x direction, only one of x,y,z can be specified to define plane. 
- y (float = None) – Position of plane in y direction, only one of x,y,z can be specified to define plane. 
- z (float = None) – Position of plane in z direction, only one of x,y,z can be specified to define plane. 
- gds_layer (int = 0) – Layer index to use for the shapes stored in the .gds file. 
- gds_dtype (int = 0) – Data-type index to use for the shapes stored in the .gds file. 
 
- Returns:
- List of - gdspy.Polygonand- gdspy.PolygonSet.
- Return type:
- List 
 
 - to_gds(cell, x=None, y=None, z=None, permittivity_threshold=1, frequency=0, gds_layer=0, gds_dtype=0)[source]#
- Append a structure’s planar slice to a .gds cell. - Parameters:
- cell ( - gdstk.Cellor- gdspy.Cell) – Cell object to which the generated polygons are added.
- x (float = None) – Position of plane in x direction, only one of x,y,z can be specified to define plane. 
- y (float = None) – Position of plane in y direction, only one of x,y,z can be specified to define plane. 
- z (float = None) – Position of plane in z direction, only one of x,y,z can be specified to define plane. 
- permittivity_threshold (float = 1.1) – Permitivitty value used to define the shape boundaries for structures with custom medim 
- frequency (float = 0) – Frequency for permittivity evaluaiton in case of custom medium (Hz). 
- gds_layer (int = 0) – Layer index to use for the shapes stored in the .gds file. 
- gds_dtype (int = 0) – Data-type index to use for the shapes stored in the .gds file. 
 
 
 - to_gds_file(fname, x=None, y=None, z=None, permittivity_threshold=1, frequency=0, gds_layer=0, gds_dtype=0, gds_cell_name='MAIN')[source]#
- Export a structure’s planar slice to a .gds file. - Parameters:
- fname (str) – Full path to the .gds file to save the - Structureslice to.
- x (float = None) – Position of plane in x direction, only one of x,y,z can be specified to define plane. 
- y (float = None) – Position of plane in y direction, only one of x,y,z can be specified to define plane. 
- z (float = None) – Position of plane in z direction, only one of x,y,z can be specified to define plane. 
- permittivity_threshold (float = 1.1) – Permitivitty value used to define the shape boundaries for structures with custom medim 
- frequency (float = 0) – Frequency for permittivity evaluaiton in case of custom medium (Hz). 
- gds_layer (int = 0) – Layer index to use for the shapes stored in the .gds file. 
- gds_dtype (int = 0) – Data-type index to use for the shapes stored in the .gds file. 
- gds_cell_name (str = 'MAIN') – Name of the cell created in the .gds file to store the geometry. 
 
 
 - classmethod from_permittivity_array(geometry, eps_data, **kwargs)[source]#
- Create - Structurewith- geometryand- CustomMediumcontaining- eps_datafor The- permittivityfield. Extra keyword arguments are passed to- td.Structure().
 - __hash__()#
- Hash method.