diff --git a/tests/test_components/test_grid_spec.py b/tests/test_components/test_grid_spec.py index 3a01134dc7..6c340b8134 100644 --- a/tests/test_components/test_grid_spec.py +++ b/tests/test_components/test_grid_spec.py @@ -30,7 +30,7 @@ def test_make_coords(): periodic=(True, False, False), wavelength=1.0, num_pml_layers=(10, 4), - fixpoints=(), + snapping_points=(), ) @@ -46,7 +46,7 @@ def test_make_coords_2d(): periodic=(True, True, False), wavelength=1.0, num_pml_layers=(10, 4), - fixpoints=(), + snapping_points=(), ) diff --git a/tidy3d/components/grid/grid_spec.py b/tidy3d/components/grid/grid_spec.py index ee968668c1..c326bf3d35 100644 --- a/tidy3d/components/grid/grid_spec.py +++ b/tidy3d/components/grid/grid_spec.py @@ -86,7 +86,7 @@ def make_coords( periodic: bool, wavelength: pd.PositiveFloat, num_pml_layers: Tuple[pd.NonNegativeInt, pd.NonNegativeInt], - fixpoints: Tuple[Coordinate, ...], + snapping_points: Tuple[Coordinate, ...], ) -> Coords1D: """Generate 1D coords to be used as grid boundaries, based on simulation parameters. Symmetry, and PML layers will be treated here. @@ -104,7 +104,7 @@ def make_coords( Free-space wavelength. num_pml_layers : Tuple[int, int] number of layers in the absorber + and - direction along one dimension. - fixpoints : Tuple[Coordinate, ...] + snapping_points : Tuple[Coordinate, ...] A set of points that enforce grid boundaries to pass through them. Returns @@ -124,7 +124,7 @@ def make_coords( wavelength=wavelength, symmetry=symmetry, is_periodic=is_periodic, - fixpoints=fixpoints, + snapping_points=snapping_points, ) # incorporate symmetries @@ -427,7 +427,7 @@ def _make_coords_initial( wavelength: float, symmetry: Symmetry, is_periodic: bool, - fixpoints: Tuple[Coordinate, ...], + snapping_points: Tuple[Coordinate, ...], ) -> Coords1D: """Customized 1D coords to be used as grid boundaries. @@ -444,7 +444,7 @@ def _make_coords_initial( normal to each of the three axes. is_periodic : bool Apply periodic boundary condition or not. - fixpoints : Tuple[Coordinate, ...] + snapping_points : Tuple[Coordinate, ...] A set of points that enforce grid boundaries to pass through them. Returns @@ -475,9 +475,9 @@ def _make_coords_initial( self.min_steps_per_wvl, self.dl_min, ) - # insert fixpoints - interval_coords, max_dl_list = self.mesher.insert_fixpoints( - axis, interval_coords, max_dl_list, fixpoints + # insert snapping_points + interval_coords, max_dl_list = self.mesher.insert_snapping_points( + axis, interval_coords, max_dl_list, snapping_points ) # Put just a single pixel if 2D-like simulation @@ -584,11 +584,11 @@ class GridSpec(Tidy3dBaseModel): "uses :class:`.AutoGrid`.", ) - fixpoints: Tuple[Coordinate, ...] = pd.Field( + snapping_points: Tuple[Coordinate, ...] = pd.Field( (), - title="Grid specification fixpoints", + title="Grid specification snapping_points", description="A set of points that enforce grid boundaries to pass through them. " - "However, some fixpoints might be skipped if they are too close. " + "However, some points might be skipped if they are too close. " "Note: it only takes effect when at least one of the three dimensions " "uses :class:`.AutoGrid`.", ) @@ -709,7 +709,7 @@ def make_grid( periodic=periodic[idim], wavelength=wavelength, num_pml_layers=num_pml_layers[idim], - fixpoints=self.fixpoints, + snapping_points=self.snapping_points, ) coords = Coords(**coords_dict) @@ -722,7 +722,7 @@ def auto( min_steps_per_wvl: pd.PositiveFloat = 10.0, max_scale: pd.PositiveFloat = 1.4, override_structures: List[StructureType] = (), - fixpoints: Tuple[Coordinate, ...] = (), + snapping_points: Tuple[Coordinate, ...] = (), dl_min: pd.NonNegativeFloat = 0.0, mesher: MesherType = GradedMesher(), ) -> GridSpec: @@ -742,7 +742,7 @@ def auto( A list of structures that is added on top of the simulation structures in the process of generating the grid. This can be used to refine the grid or make it coarser depending than the expected need for higher/lower resolution regions. - fixpoints : Tuple[Coordinate, ...] + snapping_points : Tuple[Coordinate, ...] A set of points that enforce grid boundaries to pass through them. dl_min: pd.NonNegativeFloat Lower bound of grid size. @@ -767,7 +767,7 @@ def auto( grid_y=grid_1d, grid_z=grid_1d, override_structures=override_structures, - fixpoints=fixpoints, + snapping_points=snapping_points, ) @classmethod diff --git a/tidy3d/components/grid/mesher.py b/tidy3d/components/grid/mesher.py index ab010c2cc7..be6f16f749 100644 --- a/tidy3d/components/grid/mesher.py +++ b/tidy3d/components/grid/mesher.py @@ -44,14 +44,14 @@ def parse_structures( """Calculate the positions of all bounding box interfaces along a given axis.""" @abstractmethod - def insert_fixpoints( + def insert_snapping_points( self, axis: Axis, interval_coords: ArrayFloat1D, max_dl_list: ArrayFloat1D, - fixpoints: List[Coordinate], + snapping_points: List[Coordinate], ) -> Tuple[ArrayFloat1D, ArrayFloat1D]: - """Insert fixpoints to the intervals.""" + """Insert snapping_points to the intervals.""" @abstractmethod def make_grid_multiple_intervals( @@ -68,14 +68,14 @@ class GradedMesher(Mesher): """Implements automatic nonuniform meshing with a set minimum steps per wavelength and a graded mesh expanding from higher- to lower-resolution regions.""" - def insert_fixpoints( + def insert_snapping_points( self, axis: Axis, interval_coords: ArrayFloat1D, max_dl_list: ArrayFloat1D, - fixpoints: List[Coordinate], + snapping_points: List[Coordinate], ) -> Tuple[ArrayFloat1D, ArrayFloat1D]: - """Insert fixpoints to the intervals. + """Insert snapping_points to the intervals. Parameters ---------- @@ -85,7 +85,7 @@ def insert_fixpoints( Coordinate of interval boundaries. max_dl_list : ArrayFloat1D Maximal allowed step size of each interval generated from `parse_structures`. - fixpoints : List[Coordinate] + snapping_points : List[Coordinate] A set of points that enforce grid boundaries to pass through them. Returns @@ -103,18 +103,18 @@ def insert_fixpoints( """ # Don't do anything for a 2D-like simulation, or no fix points - if interval_coords.size == 1 or len(fixpoints) < 1: + if interval_coords.size == 1 or len(snapping_points) < 1: return interval_coords, max_dl_list min_step = np.amin(max_dl_list) * 0.5 - for point in fixpoints: + for point in snapping_points: new_coord = point[axis] # Skip if the point is outside the domain if new_coord >= interval_coords[-1] or new_coord <= interval_coords[0]: continue # search insertion location ind = np.searchsorted(interval_coords, new_coord, side="left") - # Skip fixpoints if the distance to the existing interval boundarires are + # Skip snapping_points if the distance to the existing interval boundarires are # smaller than half of the minimal maximal step size if abs(new_coord - interval_coords[ind]) < min_step: continue diff --git a/tidy3d/components/simulation.py b/tidy3d/components/simulation.py index 5507c0e30c..e027715e0a 100644 --- a/tidy3d/components/simulation.py +++ b/tidy3d/components/simulation.py @@ -712,8 +712,8 @@ def plot_grid( ) ax.add_patch(rect) - # Plot fixpoints - for point in self.grid_spec.fixpoints: + # Plot snapping points + for point in self.grid_spec.snapping_points: _, (x_point, y_point) = Geometry.pop_axis(point, axis=axis) x_point, y_point = (self._evaluate_inf(v) for v in (x_point, y_point)) ax.scatter(x_point, y_point, color=plot_params.edgecolor)