tidy3d.Box#
- class Box[source]#
Bases:
SimplePlaneIntersection,Centered- Rectangular prism.
Also base class for
Simulation,Monitor, andSource.
- 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,
attrsare mutable. For example, the following is allowed for setting anattrobj.attrs['foo'] = bar. Also note that Tidy3D` will raise aTypeErrorifattrscontain objects that can not be serialized. One can check ifattrsare serializable by callingobj.json().center (Union[tuple[Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box], Union[float, autograd.tracer.Box]], Box] = (0.0, 0.0, 0.0)) – [units = um]. Center of object in x, y, and z.
size (Union[tuple[Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box], Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box], Union[pydantic.v1.types.NonNegativeFloat, autograd.tracer.Box]], 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.Methods
compute_derivatives(derivative_info)Compute the adjoint derivatives for this object.
derivative_face(min_max_index, axis_normal, ...)Compute the derivative w.r.t.
derivative_faces(derivative_info)Derivative with respect to normal position of 6 faces of
Box.derivatives_center_size(vjps_faces)Derivatives with respect to the
centerandsizefields in theBox.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])Returns shapely geometry at plane specified by one non None value of x,y,z.
intersections_with(other)Returns list of shapely geometries representing the intersections of the geometry with this 2D box.
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.Inherited Common Usage
- 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)[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.
- 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)[source]#
Returns list of shapely geometries representing the intersections of the geometry with this 2D box.
- 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]
- property bounds#
Returns bounding box min and max coordinates.
- static derivatives_center_size(vjps_faces)[source]#
Derivatives with respect to the
centerandsizefields in theBox.