tidy3d.Box#
- class Box[source]#
Bases:
SimplePlaneIntersection,Centered- Rectangular prism.
Also base class for
Simulation,Monitor, andSource.
- Parameters:
center (Optional[tuple[Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box]]] = None) – [units = um]. Center of object in x, y, and z.
size (tuple[Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box], Union[NonNegativeFloat, autograd.tracer.Box]]) – [units = um]. Size in x, y, and z directions.
Example
>>> b = Box(center=(1,2,3), size=(2,2,2))
Attributes
Returns bounding box min and max coordinates.
Boxrepresentation of self (used for subclasses of Box).A list of axes along which the
Boxis zero-sized.centerMethods
from_bounds(rmin, rmax, **kwargs)Constructs a
Boxfrom minimum and maximum coordinate boundsinside(x, y, z)For input arrays
x,y,zof arbitrary but identical shape, return an array with the same shape which isTruefor every point in zip(x, y, z) that is inside the volume of theGeometry, andFalseotherwise.intersections_plane([x, y, z, cleanup, ...])Returns shapely geometry at plane specified by one non None value of x,y,z.
intersections_with(other[, cleanup, quad_segs])Returns list of shapely geometries representing the intersections of the geometry with this 2D box.
padded_copy([x, y, z])Created a padded copy of a
Boxinstance.Box size slightly enlarged around machine precision.
surfaces(size, center, **kwargs)Returns a list of 6
Boxinstances corresponding to each surface of a 3D volume.surfaces_with_exclusion(size, center, **kwargs)Returns a list of 6
Boxinstances corresponding to each surface of a 3D volume.- size#
- classmethod from_bounds(rmin, rmax, **kwargs)[source]#
Constructs a
Boxfrom minimum and maximum coordinate bounds- Parameters:
Example
>>> b = Box.from_bounds(rmin=(-1, -2, -3), rmax=(3, 2, 1))
- classmethod surfaces(size, center, **kwargs)[source]#
Returns a list of 6
Boxinstances corresponding to each surface of a 3D volume. The output surfaces are stored in the order [x-, x+, y-, y+, z-, z+], where x, y, and z denote which axis is perpendicular to that surface, while “-” and “+” denote the direction of the normal vector of that surface. If a name is provided, each output surface’s name will be that of the provided name appended with the above symbols. E.g., if the provided name is “box”, the x+ surfaces’s name will be “box_x+”.- Parameters:
Example
>>> b = Box.surfaces(size=(1, 2, 3), center=(3, 2, 1))
- classmethod surfaces_with_exclusion(size, center, **kwargs)[source]#
Returns a list of 6
Boxinstances corresponding to each surface of a 3D volume. The output surfaces are stored in the order [x-, x+, y-, y+, z-, z+], where x, y, and z denote which axis is perpendicular to that surface, while “-” and “+” denote the direction of the normal vector of that surface. If a name is provided, each output surface’s name will be that of the provided name appended with the above symbols. E.g., if the provided name is “box”, the x+ surfaces’s name will be “box_x+”. Ifkwargscontains anexclude_surfacesparameter, the returned list of surfaces will not include the excluded surfaces. Otherwise, the behavior is identical to that ofsurfaces().- Parameters:
Example
>>> b = Box.surfaces_with_exclusion( ... size=(1, 2, 3), center=(3, 2, 1), exclude_surfaces=["x-"] ... )
- intersections_plane(x=None, y=None, z=None, cleanup=True, quad_segs=None)[source]#
Returns shapely geometry at plane specified by one non None value of x,y,z.
- 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.
cleanup (bool = True) – If True, removes extremely small features from each polygon’s boundary.
quad_segs (Optional[int] = None) – Number of segments used to discretize circular shapes. Not used for Box geometry.
- Returns:
List of 2D shapes that intersect plane. For more details refer to Shapely’s Documentation.
- Return type:
list[shapely.geometry.base.BaseGeometry]
- inside(x, y, z)[source]#
For input arrays
x,y,zof arbitrary but identical shape, return an array with the same shape which isTruefor every point in zip(x, y, z) that is inside the volume of theGeometry, andFalseotherwise.
- intersections_with(other, cleanup=True, quad_segs=None)[source]#
Returns list of shapely geometries representing the intersections of the geometry with this 2D box.
- Parameters:
other (Shapely) – Geometry to intersect with.
cleanup (bool = True) – If True, removes extremely small features from each polygon’s boundary.
quad_segs (Optional[int] = None) – Number of segments used to discretize circular shapes. If
None, uses high-quality visualization settings.
- Returns:
List of 2D shapes that intersect this 2D box. For more details refer to Shapely’s Documentation.
- Return type:
list[shapely.geometry.base.BaseGeometry]
- padded_copy(x=None, y=None, z=None)[source]#
Created a padded copy of a
Boxinstance.- Parameters:
x (Optional[tuple[pydantic.NonNegativeFloat, pydantic.NonNegativeFloat]] = None) – Padding sizes at the left and right boundaries of the box along x-axis.
y (Optional[tuple[pydantic.NonNegativeFloat, pydantic.NonNegativeFloat]] = None) – Padding sizes at the left and right boundaries of the box along y-axis.
z (Optional[tuple[pydantic.NonNegativeFloat, pydantic.NonNegativeFloat]] = None) – Padding sizes at the left and right boundaries of the box along z-axis.
- Returns:
Padded instance of
Box.- Return type:
- property bounds#
Returns bounding box min and max coordinates.