tidy3d.Grid#
- class Grid[source]#
Bases:
Tidy3dBaseModel
Contains all information about the spatial positions of the FDTD grid.
- Parameters:
boundaries (Attribute:
boundaries
) βType
Coords
Default
Description
x,y,z coordinates of the boundaries between cells, defining the FDTD grid.
Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z) >>> grid = Grid(boundaries=coords) >>> centers = grid.centers >>> sizes = grid.sizes >>> yee_grid = grid.yee
Attributes
Return centers of the cells in the
Grid
.Return sizes of the cells in the
Grid
.Return sizes of the cells in the
Grid
.Return the
YeeGrid
defining the yee cell locations for thisGrid
.Methods
discretize_inds
(box[,Β extend])Start and stopping indexes for the cells that intersect with a
Box
.extended_subspace
(axis[,Β ind_beg,Β ind_end,Β ...])Pick a subspace of 1D boundaries within
range(ind_beg, ind_end)
.snap_to_box_zero_dim
(box)Snap a grid to an exact box position for dimensions for which the box is size 0.
- boundaries#
- property centers#
Return centers of the cells in the
Grid
.Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z) >>> grid = Grid(boundaries=coords) >>> centers = grid.centers
- property sizes#
Return sizes of the cells in the
Grid
.Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z) >>> grid = Grid(boundaries=coords) >>> sizes = grid.sizes
- property num_cells#
Return sizes of the cells in the
Grid
.- Returns:
Number of cells in the grid in the x, y, z direction.
- Return type:
tuple[int, int, int]
Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z) >>> grid = Grid(boundaries=coords) >>> Nx, Ny, Nz = grid.num_cells
- property yee#
Return the
YeeGrid
defining the yee cell locations for thisGrid
.- Returns:
Stores coordinates of all of the components on the yee lattice.
- Return type:
Example
>>> x = np.linspace(-1, 1, 10) >>> y = np.linspace(-1, 1, 11) >>> z = np.linspace(-1, 1, 12) >>> coords = Coords(x=x, y=y, z=z) >>> grid = Grid(boundaries=coords) >>> yee_cells = grid.yee >>> Ex_positions = yee_cells.E.x
- discretize_inds(box, extend=False)[source]#
Start and stopping indexes for the cells that intersect with a
Box
.- Parameters:
box (
Box
) β Rectangular geometry within simulation to discretize.extend (bool = False) β If
True
, ensure that the returned indexes extend sufficiently in every direction to be able to interpolate any field component at any point within thebox
, for field components sampled on the Yee grid.
- Returns:
The (start, stop) indexes of the cells that intersect with
box
in each of the three dimensions.- Return type:
List[Tuple[int, int]]
- extended_subspace(axis, ind_beg=0, ind_end=0, periodic=True)[source]#
Pick a subspace of 1D boundaries within
range(ind_beg, ind_end)
. If any indexes lie outside of the grid boundaries array, padding is used based on the boundary conditions. For periodic BCs, the zeroth and last element of the grid boundaries are identified. For other BCs, the zeroth and last element of the boundaries are a reflection plane.- Parameters:
axis (Axis) β Axis index along which to pick the subspace.
ind_beg (int = 0) β Starting index for the subspace.
ind_end (int = 0) β Ending index for the subspace.
periodic (bool = True) β Whether to pad out of bounds indexes with a periodic or reflected pattern.
- Returns:
The subspace of the grid along
axis
.- Return type:
Coords1D
- snap_to_box_zero_dim(box)[source]#
Snap a grid to an exact box position for dimensions for which the box is size 0. If the box location is outside of the grid, an error is raised.
- Parameters:
box (
Box
) β Box to use for the zero dim check.- Returns:
class β Snapped copy of the grid.
- Return type:
Grid
- __hash__()#
Hash method.