cube_files

class DataCube(mol: Mole, box: ndarray, origin: ndarray, data: ndarray)[source]

A data cube, containing a field on a cartesian grid, spanning a molecule.

__init__(mol: Mole, box: ndarray, origin: ndarray, data: ndarray)[source]

Initialize a DataCube.

Parameters:
  • mol – The pyscf molecule.

  • box – The vectors spanning the box, defining x y and z directions.

  • origin – The origin of the box.

  • data – The data, shape (nx, ny, nz).

__str__()[source]

Return str(self).

classmethod from_file(filename: str | IO, is_tiling_unit_cell=False) DataCube[source]

Read a cube file. Adapted from pyscf.tools.cubegen.Cube.read. For details on the format see https://h5cube-spec.readthedocs.io/en/latest/cubeformat.html#cubeformat-dset-ids

Parameters:
  • filename – The filename.

  • is_tiling_unit_cell – Whether to use an asymmetric mesh for tiling unit cells.

Returns:

A DataCube object.

classmethod from_fileobject(f: IO, is_tiling_unit_cell=False)[source]

Read a cube file. Adapted from pyscf.tools.cubegen.Cube.read. For details on the format see https://h5cube-spec.readthedocs.io/en/latest/cubeformat.html#cubeformat-dset-ids

Parameters:
  • f – The file object.

  • is_tiling_unit_cell – Whether to use an asymmetric mesh for tiling unit cells.

Returns:

A DataCube object.

classmethod from_function(mol: Mole, func: callable, resolution: float = None, margin: float = 3.0, block_size: int = 16384)[source]

Create a DataCube by evaluating a given function on a cartesian grid spanning a molecule.

Parameters:
  • mol – The pyscf molecule.

  • func – The function to evaluate on the grid. Must take an array of positions of shape (n, 3) as input.

  • resolution – The resolution of the grid in Bohr.

  • margin – The margin of the box.

  • block_size – The blocksize for the evaluation. Defaults to 16384.

to_pyvista()[source]

Convert to a pyvista grid.

Parameters:

self – The DataCube.

Returns:

The pyvista grid.