Skip to content

flex_rf.tidy3d.LayerRefinementSpec

Type: class Base(s): 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.

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.

This class only takes effect when AutoGrid is applied.

layer_spec = LayerRefinementSpec(axis=2, center=(0,0,0), size=(2, 3, 1))
size [TracedSize]

Size in x, y, and z directions.

axis [Axis]

Specifies dimension of the layer normal axis (0,1,2) -> (x,y,z).

center [TracedCoordinate] = (0.0, 0.0, 0.0)

Center of object in x, y, and z.

min_steps_along_axis [PositiveFloat | None] = None

If not None and the thickness of the layer is nonzero, set minimal number of steps discretizing the layer thickness.

bounds_refinement [GridRefinement | None] = 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 [Literal['bounds', 'lower', 'upper', 'center'] | None] = '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 [CornerFinderSpec | None] = factory: 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 [GridRefinement | None] = factory: 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.

gap_meshing_iters [NonNegativeInt] = 1

Number of recursive iterations for resolving thin gaps. The underlying algorithm detects gaps contained in a single cell and places a snapping plane at the gaps’s centers.

dl_min_from_gap_width [bool] = True

Take into account autodetected minimal PEC gap width when determining dl_min. This only applies if dl_min in AutoGrid specification is not set.

interior_disjoint_geometries [bool] = True

If True, geometries made of different materials on the plane must not be overlapping. This can speed up the performance of corner finder when there are many structures crossing the plane.

center_axis()

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

from_bounds(rmin: Coordinate, rmax: Coordinate, axis: Axis = None, min_steps_along_axis: PositiveFloat = None, bounds_refinement: GridRefinement = None, bounds_snapping: Literal['bounds', 'lower', 'upper', 'center'] = 'lower', corner_finder: CornerFinderSpec = Undefined, corner_snapping: bool = True, corner_refinement: GridRefinement = Undefined, refinement_inside_sim_only: bool = True, gap_meshing_iters: NonNegativeInt = 1, dl_min_from_gap_width: bool = True, **kwargs: Any)

Constructs a LayerRefinementSpec from minimum and maximum coordinate bounds.

from_layer_bounds(axis: Axis, bounds: tuple[float, float], min_steps_along_axis: PositiveFloat = None, bounds_refinement: GridRefinement = None, bounds_snapping: Literal['bounds', 'lower', 'upper', 'center'] = 'lower', corner_finder: CornerFinderSpec | None | object = Undefined, corner_snapping: bool = True, corner_refinement: GridRefinement | None | object = Undefined, refinement_inside_sim_only: bool = True, gap_meshing_iters: NonNegativeInt = 1, dl_min_from_gap_width: bool = True, **kwargs: Any)

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

from_structures(structures: list[Structure], axis: Axis = None, min_steps_along_axis: PositiveFloat = None, bounds_refinement: GridRefinement = None, bounds_snapping: Literal['bounds', 'lower', 'upper', 'center'] = 'lower', corner_finder: CornerFinderSpec = Undefined, corner_snapping: bool = True, corner_refinement: GridRefinement = Undefined, refinement_inside_sim_only: bool = True, gap_meshing_iters: NonNegativeInt = 1, dl_min_from_gap_width: bool = True, **kwargs: Any)

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

generate_override_structures(grid_size_in_vacuum: float, structure_list: list[Structure], sim_bounds: tuple, boundary_type: tuple, cached_corners_and_convexity: CornersAndConvexity | None = None, cached_merged_geos: list[tuple[Any, Shapely]] | None = None)

Generate mesh override structures for mesh refinement.

generate_snapping_points(structure_list: list[Structure], sim_bounds: tuple, boundary_type: tuple, cached_corners_and_convexity: CornersAndConvexity | None = None, cached_merged_geos: list[tuple[Any, Shapely]] | None = None)

generate snapping points for mesh refinement.

length_axis()

Gets the thickness of the layer.

suggested_dl_min(grid_size_in_vacuum: float, structures: list[Structure], sim_bounds: tuple, boundary_type: tuple, cached_merged_geos: list[tuple[Any, Shapely]] | None = None, cached_corners_and_convexity: CornersAndConvexity | None = None)

Suggested lower bound of grid step size for this layer.