tidy3d.LayerRefinementSpec#
- class LayerRefinementSpec[source]#
- Bases: - Box- Specification for automatic mesh refinement and snapping in layered structures. Structure corners on the cross section perpendicular to layer thickness direction can be automatically identified. Subsequently, mesh is snapped and refined around the corners. Mesh can also be refined and snapped around the bounds along the layer thickness 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, - attrsare mutable. For example, the following is allowed for setting an- attr- obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a- TypeErrorif- attrscontain objects that can not be serialized. One can check if- attrsare serializable by calling- obj.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. 
- axis (Literal[0, 1, 2]) β Specifies dimension of the layer normal axis (0,1,2) -> (x,y,z). 
- min_steps_along_axis (Optional[PositiveFloat] = None) β If not - Noneand the thickness of the layer is nonzero, set minimal number of steps discretizing the layer thickness.
- bounds_refinement (Optional[GridRefinement] = None) β If not - None, refine mesh around minimum and maximum positions of the layer along normal axis dimension. If min_steps_along_axis is also specified, refinement here is only applied if it sets a smaller grid size.
- bounds_snapping (Optional[Literal['bounds', 'lower', 'upper', 'center']] = lower) β If not - None, enforcing grid boundaries to pass through- lower,- center, or- upperposition of the layer; or both- lowerand- upperwith- bounds.
- corner_finder (Optional[CornerFinderSpec] = CornerFinderSpec(attrs={}, medium='metal', angle_threshold=0.3141592653589793, distance_threshold=None, type='CornerFinderSpec')) β Specification for inplane corner detection. Inplane mesh refinement is based on the coordinates of those corners. 
- corner_snapping (bool = True) β If - Trueand- corner_finderis not- None, enforcing inplane grid boundaries to pass through corners of geometries specified by- corner_finder.
- corner_refinement (Optional[GridRefinement] = GridRefinement(attrs={}, refinement_factor=None, dl=None, num_cells=3, type='GridRefinement')) β If not - Noneand- corner_finderis not- None, refine mesh around corners of geometries specified by- corner_finder.
- refinement_inside_sim_only (bool = True) β If - True, only apply mesh refinement to features such as corners inside the simulation domain; If- False, features outside the domain can take effect along the dimensions where the projection of the feature and the projection of the simulation domain overlaps.
 
 - Note - Corner detection is performed on a 2D plane sitting in the middle of the layer. If the layer is finite along inplane axes, corners outside the bounds are discarded. - Note - This class only takes effect when - AutoGridis applied.- Example - >>> layer_spec = LayerRefinementSpec(axis=2, center=(0,0,0), size=(2, 3, 1)) - Attributes - Gets the position of the center of the layer along the layer dimension. - Gets the thickness of the layer. - Methods - from_bounds(rmin,Β rmax[,Β axis,Β ...])- Constructs a - LayerRefiementSpecfrom minimum and maximum coordinate bounds.- from_layer_bounds(axis,Β bounds[,Β ...])- Constructs a - LayerRefiementSpecthat is unbounded in inplane dimensions from bounds along layer thickness dimension.- from_structures(structures[,Β axis,Β ...])- Constructs a - LayerRefiementSpecfrom the bounding box of a list of structures.- Generate mesh override structures for mesh refinement. - generate_snapping_points(structure_list)- generate snapping points for mesh refinement. - suggested_dl_min(grid_size_in_vacuum)- Suggested lower bound of grid step size for this layer. - Inherited Common Usage - axis#
 - min_steps_along_axis#
 - bounds_refinement#
 - bounds_snapping#
 - corner_finder#
 - corner_snapping#
 - corner_refinement#
 - refinement_inside_sim_only#
 - classmethod from_layer_bounds(axis, bounds, min_steps_along_axis=None, bounds_refinement=None, bounds_snapping='lower', corner_finder=CornerFinderSpec(attrs={}, medium='metal', angle_threshold=0.3141592653589793, distance_threshold=None, type='CornerFinderSpec'), corner_snapping=True, corner_refinement=GridRefinement(attrs={}, refinement_factor=None, dl=None, num_cells=3, type='GridRefinement'), refinement_inside_sim_only=True)[source]#
- Constructs a - LayerRefiementSpecthat is unbounded in inplane dimensions from bounds along layer thickness dimension.- Parameters:
- axis (Axis) β Specifies dimension of the layer normal axis (0,1,2) -> (x,y,z). 
- bounds (Tuple[float, float]) β Minimum and maximum positions of the layer along axis dimension. 
- min_steps_along_axis (np.PositiveFloat = None) β Minimal number of steps along axis. 
- bounds_refinement (GridRefinement = None) β Mesh refinement factor around layer bounds. 
- bounds_snapping (Literal["bounds", "lower", "upper", "center"] = "lower") β Placing grid snapping point along axis: - lower,- center, or- upperposition of the layer; or both- lowerand- upperwith- bounds.
- corner_finder (CornerFinderSpec = CornerFinderSpec()) β Inplane corner detection specification. 
- corner_snapping (bool = True) β Placing grid snapping point at corners. 
- corner_refinement (GridRefinement = GridRefinement()) β Inplane mesh refinement factor around corners. 
- refinement_inside_sim_only (bool = True) β Apply refinement only to features inside simulation domain. 
 
 - Example - >>> layer = LayerRefinementSpec.from_layer_bounds(axis=2, bounds=(0,1)) 
 - classmethod from_bounds(rmin, rmax, axis=None, min_steps_along_axis=None, bounds_refinement=None, bounds_snapping='lower', corner_finder=CornerFinderSpec(attrs={}, medium='metal', angle_threshold=0.3141592653589793, distance_threshold=None, type='CornerFinderSpec'), corner_snapping=True, corner_refinement=GridRefinement(attrs={}, refinement_factor=None, dl=None, num_cells=3, type='GridRefinement'), refinement_inside_sim_only=True)[source]#
- Constructs a - LayerRefiementSpecfrom minimum and maximum coordinate bounds.- Parameters:
- rmin (Tuple[float, float, float]) β (x, y, z) coordinate of the minimum values. 
- rmax (Tuple[float, float, float]) β (x, y, z) coordinate of the maximum values. 
- axis (Axis) β Specifies dimension of the layer normal axis (0,1,2) -> (x,y,z). If - None, apply the dimension along which the layer thas smallest thickness.
- min_steps_along_axis (np.PositiveFloat = None) β Minimal number of steps along axis. 
- bounds_refinement (GridRefinement = None) β Mesh refinement factor around layer bounds. 
- bounds_snapping (Literal["bounds", "lower", "upper", "center"] = "lower") β Placing grid snapping point along axis: - lower,- center, or- upperposition of the layer; or both- lowerand- upperwith- bounds.
- corner_finder (CornerFinderSpec = CornerFinderSpec()) β Inplane corner detection specification. 
- corner_snapping (bool = True) β Placing grid snapping point at corners. 
- corner_refinement (GridRefinement = GridRefinement()) β Inplane mesh refinement factor around corners. 
- refinement_inside_sim_only (bool = True) β Apply refinement only to features inside simulation domain. 
 
 - Example - >>> layer = LayerRefinementSpec.from_bounds(axis=2, rmin=(0,0,0), rmax=(1,1,1)) 
 - classmethod from_structures(structures, axis=None, min_steps_along_axis=None, bounds_refinement=None, bounds_snapping='lower', corner_finder=CornerFinderSpec(attrs={}, medium='metal', angle_threshold=0.3141592653589793, distance_threshold=None, type='CornerFinderSpec'), corner_snapping=True, corner_refinement=GridRefinement(attrs={}, refinement_factor=None, dl=None, num_cells=3, type='GridRefinement'), refinement_inside_sim_only=True)[source]#
- Constructs a - LayerRefiementSpecfrom the bounding box of a list of structures.- Parameters:
- structures (List[Structure]) β A list of structures whose overall bounding box is used to define mesh refinement 
- axis (Axis) β Specifies dimension of the layer normal axis (0,1,2) -> (x,y,z). If - None, apply the dimension along which the bounding box of the structures thas smallest thickness.
- min_steps_along_axis (np.PositiveFloat = None) β Minimal number of steps along axis. 
- bounds_refinement (GridRefinement = None) β Mesh refinement factor around layer bounds. 
- bounds_snapping (Literal["bounds", "lower", "upper", "center"] = "lower") β Placing grid snapping point along axis: - lower,- center, or- upperposition of the layer; or both- lowerand- upperwith- bounds.
- corner_finder (CornerFinderSpec = CornerFinderSpec()) β Inplane corner detection specification. 
- corner_snapping (bool = True) β Placing grid snapping point at corners. 
- corner_refinement (GridRefinement = GridRefinement()) β Inplane mesh refinement factor around corners. 
- refinement_inside_sim_only (bool = True) β Apply refinement only to features inside simulation domain. 
 
 
 - property length_axis#
- Gets the thickness of the layer. 
 - property center_axis#
- Gets the position of the center of the layer along the layer dimension. 
 - suggested_dl_min(grid_size_in_vacuum)[source]#
- Suggested lower bound of grid step size for this layer. - Parameters:
- grid_size_in_vaccum (float) β Grid step size in vaccum. 
- Returns:
- Suggested lower bound of grid size to resolve most snapping points and mesh refinement structures. 
- Return type:
- float 
 
 - generate_override_structures(grid_size_in_vacuum, structure_list)[source]#
- Generate mesh override structures for mesh refinement. 
 - __hash__()#
- Hash method.