tidy3d.PolySlab#
- class PolySlab[source]#
Bases:
Planar
Polygon extruded with optional sidewall angle along axis direction.
- 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()
.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 theaxis
direction; and-np.pi/2<sidewall_angle<0
specifies an expanding cross section along theaxis
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 thebottom
,middle
, ortop
of the geometry with respect to the axis. E.g. ifaxis=1
,bottom
refers to the negative side of the y-axis, andtop
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 (Union[ArrayLike[dtype=float, ndim=2], Box]) – [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 isaxis=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
The polygon at the base, derived from the
middle_polygon
.Returns bounding box min and max coordinates.
Gets the position of the center of the geometry in the out of plane dimension.
Is this
PolySlab
CCW-oriented?Gets the length of the geometry along the out of plane dimension.
The polygon at the middle.
The polygon at the reference plane.
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.
compute_derivative_vertices
(derivative_info)compute_derivatives
(derivative_info)Compute the adjoint derivatives for this object.
correct_shape
(val)Makes sure vertices size is correct.
edge_basis_vectors
(edges)Normalized basis vectors for 'normal' direction, 'slab' tangent direction and 'edge'.
from_gds
(gds_cell, axis, slab_bounds, gds_layer)Import
PolySlab
from agdstk.Cell
or agdspy.Cell
.inside
(x, y, z)For input arrays
x
,y
,z
of arbitrary but identical shape, return an array with the same shape which isTrue
for every point in zip(x, y, z) that is inside the volume of theGeometry
, andFalse
otherwise.make_shapely_polygon
(vertices)Make a shapely polygon from some vertices, first ensures they are untraced.
no_complex_self_intersecting_polygon_at_reference_plane
(...)At the reference plane, check if the polygon is self-intersecting.
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.
normalize_vect
(arr)normalize an array shaped (N, d) along the d axis and return (N, 1).
pop_axis_vect
(coord)Combine coordinate along axis with coordinates on the plane tangent to the axis.
slab_bounds_order
(val)Maximum position of the slab should be no smaller than its minimal position.
unpop_axis_vect
(ax_coords, plane_coords)Combine coordinate along axis with coordinates on the plane tangent to the axis.
vertices_to_array
(vertices_tuple)Converts a list of tuples (vertices) to a numpy array.
Inherited Common Usage
- slab_bounds#
- dilation#
- vertices#
- static make_shapely_polygon(vertices)[source]#
Make a shapely polygon from some vertices, first ensures they are untraced.
- 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 agdstk.Cell
or agdspy.Cell
.- Parameters:
gds_cell (Union[gdstk.Cell, gdspy.Cell]) –
gdstk.Cell
orgdspy.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
. IfNone
, 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, while0<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
, ortop
of the PolySlab. E.g. ifaxis=1
,bottom
refers to the negative side of y-axis, andtop
refers to the positive side of y-axis.
- Returns:
List of
PolySlab
objects sharingaxis
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 isTrue
for every point in zip(x, y, z) that is inside the volume of theGeometry
, andFalse
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]
- 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.
- edge_basis_vectors(edges)[source]#
Normalized basis vectors for ‘normal’ direction, ‘slab’ tangent direction and ‘edge’.
- unpop_axis_vect(ax_coords, plane_coords)[source]#
Combine coordinate along axis with coordinates on the plane tangent to the axis.
ax_coords.shape == [N] plane_coords.shape == [N, 2] return shape == [N, 3]
- pop_axis_vect(coord)[source]#
Combine coordinate along axis with coordinates on the plane tangent to the axis.
coord.shape == [N, 3] return shape == ([N], [N, 2]
- static normalize_vect(arr)[source]#
normalize an array shaped (N, d) along the d axis and return (N, 1).
- __hash__()#
Hash method.