tidy3d.Grid#
- class Grid[source]#
- Bases: - Tidy3dBaseModel- Contains all information about the spatial positions of the FDTD grid. - 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().
- boundaries (Coords) โ 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 - YeeGriddefining the yee cell locations for this- Grid.- 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. - Inherited Common Usage - 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 - YeeGriddefining the yee cell locations for this- Grid.- 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 the- box, for field components sampled on the Yee grid.
 
- Returns:
- The (start, stop) indexes of the cells that intersect with - boxin 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.