tidy3d.Grid
tidy3d.Grid#
- class tidy3d.Grid#
Contains all information about the spatial positions of the FDTD grid.
- Parameters
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
Show JSON schema
{ "title": "Grid", "description": "Contains all information about the spatial positions of the FDTD grid.\n\nParameters\n----------\nboundaries : Coords\n x,y,z coordinates of the boundaries between cells, defining the FDTD grid.\n\nExample\n-------\n>>> x = np.linspace(-1, 1, 10)\n>>> y = np.linspace(-1, 1, 11)\n>>> z = np.linspace(-1, 1, 12)\n>>> coords = Coords(x=x, y=y, z=z)\n>>> grid = Grid(boundaries=coords)\n>>> centers = grid.centers\n>>> sizes = grid.sizes\n>>> yee_grid = grid.yee", "type": "object", "properties": { "boundaries": { "title": "Boundary Coordinates", "description": "x,y,z coordinates of the boundaries between cells, defining the FDTD grid.", "allOf": [ { "$ref": "#/definitions/Coords" } ] }, "type": { "title": "Type", "default": "Grid", "enum": [ "Grid" ], "type": "string" } }, "required": [ "boundaries" ], "additionalProperties": false, "definitions": { "Coords": { "title": "Coords", "description": "Holds data about a set of x,y,z positions on a grid.\n\nParameters\n----------\nx : Array\n 1-dimensional array of x coordinates.\ny : Array\n 1-dimensional array of y coordinates.\nz : Array\n 1-dimensional array of z coordinates.\n\nExample\n-------\n>>> x = np.linspace(-1, 1, 10)\n>>> y = np.linspace(-1, 1, 11)\n>>> z = np.linspace(-1, 1, 12)\n>>> coords = Coords(x=x, y=y, z=z)", "type": "object", "properties": { "x": { "title": "Array Like", "description": "Accepts sequence (tuple, list, numpy array) and converts to tuple.", "type": "tuple", "properties": {}, "required": [] }, "y": { "title": "Array Like", "description": "Accepts sequence (tuple, list, numpy array) and converts to tuple.", "type": "tuple", "properties": {}, "required": [] }, "z": { "title": "Array Like", "description": "Accepts sequence (tuple, list, numpy array) and converts to tuple.", "type": "tuple", "properties": {}, "required": [] }, "type": { "title": "Type", "default": "Coords", "enum": [ "Coords" ], "type": "string" } }, "required": [ "x", "y", "z" ], "additionalProperties": false } } }
- attribute boundaries: tidy3d.components.grid.grid.Coords [Required]#
x,y,z coordinates of the boundaries between cells, defining the FDTD grid.
- discretize_inds(box: tidy3d.components.geometry.Box, extend: bool = False, extend_2d_normal: bool = False) List[Tuple[int, int]] #
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 very direction to be able to interpolate any field component at any point within thebox
.extend_2d_normal (bool = False) – If
True
, and the box is size zero along a single dimension, ensure that the returned indexes extend sufficiently along that dimension to be able to interpolate to the box center from data that lives on grid cell centers.
- Returns
The (start, stop) indexes of the cells that intersect with
box
in each of the three dimensions.- Return type
List[Tuple[int, int]]
- periodic_subspace(axis: Literal[0, 1, 2], ind_beg: int = 0, ind_end: int = 0) tidy3d.components.types.Array #
Pick a subspace of 1D boundaries within
range(ind_beg, ind_end)
. If any indexes lie outside of the grid boundaries array, periodic padding is used, where the zeroth and last element of the boundaries are identified.- 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.
- Returns
The subspace of the grid along
axis
.- Return type
Coords1D
- property centers: tidy3d.components.grid.grid.Coords#
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 num_cells: Tuple[int, int, int]#
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 sizes: tidy3d.components.grid.grid.Coords#
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 yee: tidy3d.components.grid.grid.YeeGrid#
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