tidy3d.TetrahedralGridDataset#

class TetrahedralGridDataset[source]#

Bases: UnstructuredGridDataset

Dataset for storing tetrahedral grid data. Data values are associated with the nodes of the 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, attrs are mutable. For example, the following is allowed for setting an attr obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a TypeError if attrs contain objects that can not be serialized. One can check if attrs are serializable by calling obj.json().

  • points (PointDataArray) – Coordinates of points composing the unstructured grid.

  • values (IndexedDataArray) – Values stored at the grid points.

  • cells (CellDataArray) – Cells composing the unstructured grid specified as connections between grid points.

Note

To use full functionality of unstructured datasets one must install vtk package (pip install tidy3d[vtk] or pip install vtk). Otherwise the functionality of unstructured datasets is limited to creation, writing to/loading from a file, and arithmetic manipulations.

Example

>>> tet_grid_points = PointDataArray(
...     [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
...     coords=dict(index=np.arange(4), axis=np.arange(3)),
... )
>>>
>>> tet_grid_cells = CellDataArray(
...     [[0, 1, 2, 3]],
...     coords=dict(cell_index=np.arange(1), vertex_index=np.arange(4)),
... )
>>>
>>> tet_grid_values = IndexedDataArray(
...     [1.0, 2.0, 3.0, 4.0], coords=dict(index=np.arange(4)),
... )
>>>
>>> tet_grid = TetrahedralGridDataset(
...     points=tet_grid_points,
...     cells=tet_grid_cells,
...     values=tet_grid_values,
... )

Attributes

Methods

line_slice(axis,Β pos)

Slice data with a line and return the resulting :class:.`SpatialDataArray`.

plane_slice(axis,Β pos)

Slice data with a plane and return the resulting :class:.`TriangularGridDataset`.

sel([x,Β y,Β z])

Extract/interpolate data along one or more Cartesian directions.

Inherited Common Usage

plane_slice(axis, pos)[source]#

Slice data with a plane and return the resulting :class:.`TriangularGridDataset`.

Parameters:
  • axis (Axis) – The normal direction of the slicing plane.

  • pos (float) – Position of the slicing plane along its normal direction.

Returns:

The resulting slice.

Return type:

TriangularGridDataset

line_slice(axis, pos)[source]#

Slice data with a line and return the resulting :class:.`SpatialDataArray`.

Parameters:
  • axis (Axis) – The axis of the slicing line.

  • pos (Tuple[float, float, float]) – Position of the slicing line.

Returns:

The resulting slice.

Return type:

SpatialDataArray

sel(x=None, y=None, z=None)[source]#

Extract/interpolate data along one or more Cartesian directions. At least of x, y, and z must be provided.

Parameters:
  • x (Union[float, ArrayLike] = None) – x-coordinate of the slice.

  • y (Union[float, ArrayLike] = None) – y-coordinate of the slice.

  • z (Union[float, ArrayLike] = None) – z-coordinate of the slice.

Returns:

Extracted data.

Return type:

Union[TriangularGridDataset, SpatialDataArray]

__hash__()#

Hash method.