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 a Geometry.

Parameters:

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” size td.inf can be used to define the size along that dimension.

Practical Advice

For example, a waveguide extending along x should use td.inf to ensure it passes fully through PML regions:

waveguide = Structure(
    geometry=Box(center=(0, 0, 0), size=(td.inf, 0.5, 0.22)),
    medium=Medium(permittivity=3.48**2),
)

Structures that terminate inside PML can cause evanescent fields at the interface to be amplified by the absorber, potentially leading to simulation divergence.

For uniform pixelated design regions (e.g. topology optimization), use the convenience method Structure.from_permittivity_array(), which creates a Structure with a CustomMedium from a 3D numpy array of permittivity values and a geometry defining the region:

design_region = td.Box(center=(0, 0, 0), size=(2, 2, 0.22))
structure = Structure.from_permittivity_array(
    geometry=design_region, eps_data=eps_array
)

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:

Lectures:

GUI:

Attributes

viz_spec

medium

geometry

name

background_permittivity

background_medium

priority

Methods

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 with geometry and CustomMedium containing eps_data for The permittivity field.

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_gdstk([x, y, z, permittivity_threshold, ...])

Convert a structure's planar slice to a .gds type polygon.

medium#
property viz_spec#
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

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, pixel_exact=False)[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) – Permitivitty value used to define the shape boundaries for structures with custom medium

  • 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.

  • pixel_exact (bool = False) – If true export gds as pixel exact rectangles instead of gdstk contour if a custom medium is provided.

Returns:

List of gdstk.Polygon

Return type:

List

to_gds(cell, x=None, y=None, z=None, permittivity_threshold=1, frequency=0, gds_layer=0, gds_dtype=0, pixel_exact=False)[source]#

Append a structure’s planar slice to a .gds cell.

Parameters:
  • cell (gdstk.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.

  • pixel_exact (bool = False) – If true export gds as pixel exact rectangles instead of gdstk contour if a custom medium is provided.

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', pixel_exact=False)[source]#

Export a structure’s planar slice to a .gds file.

Parameters:
  • fname (PathLike) – 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.

  • pixel_exact (bool = False) – If true export gds as pixel exact rectangles instead of gdstk contour if a custom medium is provided.

classmethod from_permittivity_array(geometry, eps_data, **kwargs)[source]#

Create Structure with geometry and CustomMedium containing eps_data for The permittivity field. Extra keyword arguments are passed to td.Structure().