tidy3d.PolySlab#

class PolySlab[source]#

Bases: Planar

Polygon extruded with optional sidewall angle along axis direction.

Parameters:
  • axis (Literal[0, 1, 2] = 2) – Specifies dimension of the planar axis (0,1,2) -> (x,y,z).

  • sidewall_angle (ConstrainedFloatValue = 0.0) – [units = rad]. Angle of the sidewall. sidewall_angle=0 (default) specifies a vertical wall; 0<sidewall_angle<np.pi/2 specifies a shrinking cross section along the axis direction; and -np.pi/2<sidewall_angle<0 specifies an expanding cross section along the axis direction.

  • reference_plane (Literal['bottom', 'middle', 'top'] = middle) – The position of the plane where the supplied cross section are defined. The plane is perpendicular to the axis. The plane is located at the bottom, middle, or top of the geometry with respect to the axis. E.g. if axis=1, bottom refers to the negative side of the y-axis, and top refers to the positive side of the y-axis.

  • slab_bounds (Tuple[float, float]) – [units = um]. Minimum and maximum positions of the slab along axis dimension.

  • dilation (float = 0.0) – [units = um]. Dilation of the supplied polygon by shifting each edge along its normal outwards direction by a distance; a negative value corresponds to erosion.

  • vertices (ArrayLike[dtype=float, ndim=2]) – [units = um]. List of (d1, d2) defining the 2 dimensional positions of the polygon face vertices at the reference_plane. The index of dimension should be in the ascending order: e.g. if the slab normal axis is axis=y, the coordinate of the vertices will be in (x, z)

Example

>>> vertices = np.array([(0,0), (1,0), (1,1)])
>>> p = PolySlab(vertices=vertices, axis=2, slab_bounds=(-1, 1))

Attributes

base_polygon

The polygon at the base, derived from the middle_polygon.

bounds

Returns bounding box min and max coordinates.

center_axis

Gets the position of the center of the geometry in the out of plane dimension.

is_ccw

Is this PolySlab CCW-oriented?

length_axis

Gets the length of the geometry along the out of plane dimension.

middle_polygon

The polygon at the middle.

reference_polygon

The polygon at the reference plane.

top_polygon

The polygon at the top, derived from the middle_polygon.

Methods

array_to_vertices(arr_vertices)

Converts a numpy array of vertices to a list of tuples.

correct_shape(val)

Makes sure vertices size is correct.

from_gds(gds_cell, axis, slab_bounds, gds_layer)

Import PolySlab from a gdstk.Cell or a gdspy.Cell.

inside(x, y, z)

For input arrays x, y, z of arbitrary but identical shape, return an array with the same shape which is True for every point in zip(x, y, z) that is inside the volume of the Geometry, and False otherwise.

intersections_tilted_plane(normal, origin, to_2D)

Return a list of shapely geometries at the plane specified by normal and origin.

no_complex_self_intersecting_polygon_at_reference_plane(...)

At the reference plane, check if the polygon is self-intersecting.

no_self_intersecting_polygon_during_extrusion(...)

In this simple polyslab, we don't support self-intersecting polygons yet, meaning that any normal cross section of the PolySlab cannot be self-intersecting.

slab_bounds_order(val)

Maximum position of the slab should be no smaller than its minimal position.

vertices_to_array(vertices_tuple)

Converts a list of tuples (vertices) to a numpy array.

slab_bounds#
dilation#
vertices#
classmethod slab_bounds_order(val)[source]#

Maximum position of the slab should be no smaller than its minimal position.

classmethod correct_shape(val)[source]#

Makes sure vertices size is correct. Make sure no intersecting edges.

classmethod no_complex_self_intersecting_polygon_at_reference_plane(val, values)[source]#

At the reference plane, check if the polygon is self-intersecting.

There are two types of self-intersection that can occur during dilation: 1) the one that creates holes/islands, or splits polygons, or removes everything; 2) the one that does not.

For 1), we issue an error since it is yet to be supported; For 2), we heal the polygon, and warn that the polygon has been cleaned up.

classmethod no_self_intersecting_polygon_during_extrusion(val, values)[source]#

In this simple polyslab, we don’t support self-intersecting polygons yet, meaning that any normal cross section of the PolySlab cannot be self-intersecting. This part checks if any self-interction will occur during extrusion with non-zero sidewall angle.

There are two types of self-intersection, known as edge events, that can occur during dilation: 1) neighboring vertex-vertex crossing. This type of edge event can be treated with ComplexPolySlab which divides the polyslab into a list of simple polyslabs.

2) other types of edge events that can create holes/islands or split polygons. To detect this, we sample _N_SAMPLE_POLYGON_INTERSECT cross sections to see if any creation of polygons/holes, and changes in vertices number.

classmethod from_gds(gds_cell, axis, slab_bounds, gds_layer, gds_dtype=None, gds_scale=1.0, dilation=0.0, sidewall_angle=0, reference_plane='middle')[source]#

Import PolySlab from a gdstk.Cell or a gdspy.Cell.

Parameters:
  • gds_cell (Union[gdstk.Cell, gdspy.Cell]) – gdstk.Cell or gdspy.Cell containing 2D geometric data.

  • axis (int) – Integer index into the polygon’s slab axis. (0,1,2) -> (x,y,z).

  • slab_bounds (Tuple[float, float]) – Minimum and maximum positions of the slab along axis.

  • gds_layer (int) – Layer index in the gds_cell.

  • gds_dtype (int = None) – Data-type index in the gds_cell. If None, imports all data for this layer into the returned list.

  • gds_scale (float = 1.0) – Length scale used in GDS file in units of MICROMETER. For example, if gds file uses nanometers, set gds_scale=1e-3. Must be positive.

  • dilation (float = 0.0) – Dilation of the polygon in the base by shifting each edge along its normal outwards direction by a distance; a negative value corresponds to erosion.

  • sidewall_angle (float = 0) – Angle of the sidewall. sidewall_angle=0 (default) specifies vertical wall, while 0<sidewall_angle<np.pi/2 for the base to be larger than the top.

  • reference_plane (PlanePosition = "middle") – The position of the GDS layer. It can be at the bottom, middle, or top of the PolySlab. E.g. if axis=1, bottom refers to the negative side of y-axis, and top refers to the positive side of y-axis.

Returns:

List of PolySlab objects sharing axis and slab bound properties.

Return type:

List[PolySlab]

property center_axis#

Gets the position of the center of the geometry in the out of plane dimension.

property length_axis#

Gets the length of the geometry along the out of plane dimension.

property reference_polygon#

The polygon at the reference plane.

Returns:

The vertices of the polygon at the reference plane.

Return type:

ArrayLike[float, float]

property middle_polygon#

The polygon at the middle.

Returns:

The vertices of the polygon at the middle.

Return type:

ArrayLike[float, float]

property base_polygon#

The polygon at the base, derived from the middle_polygon.

Returns:

The vertices of the polygon at the base.

Return type:

ArrayLike[float, float]

property top_polygon#

The polygon at the top, derived from the middle_polygon.

Returns:

The vertices of the polygon at the top.

Return type:

ArrayLike[float, float]

property is_ccw#

Is this PolySlab CCW-oriented?

inside(x, y, z)[source]#

For input arrays x, y, z of arbitrary but identical shape, return an array with the same shape which is True for every point in zip(x, y, z) that is inside the volume of the Geometry, and False otherwise.

Parameters:
  • x (np.ndarray[float]) – Array of point positions in x direction.

  • y (np.ndarray[float]) – Array of point positions in y direction.

  • z (np.ndarray[float]) – Array of point positions in z direction.

Returns:

True for every point that is inside the geometry.

Return type:

np.ndarray[bool]

intersections_tilted_plane(normal, origin, to_2D)[source]#

Return a list of shapely geometries at the plane specified by normal and origin.

Parameters:
  • normal (Coordinate) – Vector defining the normal direction to the plane.

  • origin (Coordinate) – Vector defining the plane origin.

  • to_2D (MatrixReal4x4) – Transformation matrix to apply to resulting shapes.

Returns:

List of 2D shapes that intersect plane. For more details refer to Shapely’s Documentation.

Return type:

List[shapely.geometry.base.BaseGeometry]

property bounds#

Returns bounding box min and max coordinates. The dilation and slant angle are not taken into account exactly for speed. Instead, the polygon may be slightly smaller than the returned bounds, but it should always be fully contained.

Returns:

Min and max bounds packaged as (minx, miny, minz), (maxx, maxy, maxz).

Return type:

Tuple[float, float, float], Tuple[float, float float]

static array_to_vertices(arr_vertices)[source]#

Converts a numpy array of vertices to a list of tuples.

static vertices_to_array(vertices_tuple)[source]#

Converts a list of tuples (vertices) to a numpy array.

__hash__()#

Hash method.