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, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are 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 None and 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 upper position of the layer; or both lower and upper with 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 True and corner_finder is 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 None and corner_finder is 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 AutoGrid is applied.

Example

>>> layer_spec = LayerRefinementSpec(axis=2, center=(0,0,0), size=(2, 3, 1))

Attributes

center_axis

Gets the position of the center of the layer along the layer dimension.

length_axis

Gets the thickness of the layer.

attrs

Methods

from_bounds(rmin,Β rmax[,Β axis,Β ...])

Constructs a LayerRefiementSpec from minimum and maximum coordinate bounds.

from_layer_bounds(axis,Β bounds[,Β ...])

Constructs a LayerRefiementSpec that is unbounded in inplane dimensions from bounds along layer thickness dimension.

from_structures(structures[,Β axis,Β ...])

Constructs a LayerRefiementSpec from the bounding box of a list of structures.

generate_override_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 LayerRefiementSpec that 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 upper position of the layer; or both lower and upper with 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 LayerRefiementSpec from 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 upper position of the layer; or both lower and upper with 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 LayerRefiementSpec from 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 upper position of the layer; or both lower and upper with 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_snapping_points(structure_list)[source]#

generate snapping points for mesh refinement.

generate_override_structures(grid_size_in_vacuum, structure_list)[source]#

Generate mesh override structures for mesh refinement.

__hash__()#

Hash method.