tidy3d.Structure#
- class Structure[source]#
Bases:
AbstractStructure
Defines a physical object that interacts with the electromagnetic fields. A
Structure
is a combination of a material property (AbstractMedium
) and aGeometry
.- 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,
attrs
are mutable. For example, the following is allowed for setting anattr
obj.attrs['foo'] = bar
. Also note that Tidy3D` will raise aTypeError
ifattrs
contain objects that can not be serialized. One can check ifattrs
are serializable by callingobj.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.
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,tidy3d
will 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” sizetd.inf
can 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
Structure
withgeometry
andCustomMedium
containingeps_data
for Thepermittivity
field.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.Polygon
andgdspy.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.Cell
orgdspy.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
Structure
slice 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
Structure
withgeometry
andCustomMedium
containingeps_data
for Thepermittivity
field. Extra keyword arguments are passed totd.Structure()
.
- __hash__()#
Hash method.