chemtools.utils.cube.CubeGen

class chemtools.utils.cube.CubeGen(numbers, pseudo_numbers, coordinates, origin, axes, shape)[source]

Class for generating a cubic grid and writing cube files.

Initialize CubeGen class based on the origin, axes and shape of the cube.

Parameters:
  • numbers (np.ndarray, shape=(M,)) – Atomic number of M atoms in the molecule.
  • pseudo_numbers (np.ndarray, shape=(M,)) – Pseudo-number of M atoms in the molecule.
  • coordinates (np.ndarray, shape=(M, 3)) – Cartesian coordinates of M atoms in the molecule.
  • origin (np.ndarray, shape=(3,)) – Cartesian coordinates of the cubic grid origin.
  • axes (np.ndarray, shape=(3, 3)) – The three vectors, stored as rows of axes array, defining the Cartesian coordinate system used to build the cubic grid.
  • shape (np.ndarray, shape=(3,)) – Number of grid points along x, y, and z axis.
classmethod from_molecule(numbers, pseudo_numbers, coordinates, spacing=0.2, threshold=5.0, rotate=True)[source]

Initialize CubeGen class based on the Cartesian coordinates of the molecule.

Parameters:
  • numbers (np.ndarray, shape=(M,)) – Atomic number of M atoms in the molecule.
  • pseudo_numbers (np.ndarray, shape=(M,)) – Pseudo-number of M atoms in the molecule.
  • coordinates (np.ndarray, shape=(M, 3)) – Cartesian coordinates of M atoms in the molecule.
  • spacing (float, default=0.2) – Increment between grid points along x, y and z direction.
  • threshold (float, default=5.0) – The extension of the cube on each side of the molecule.
  • rotate (bool, default=True) – When True, the molecule is rotated so the axes of the cube file are aligned with the principle axes of rotation of the molecule.
classmethod from_cube(filename)[source]

Initialize CubeGen class based on the grid specifications of a cube file.

Parameters:filename (str) – Cube file name with *.cube extension.
classmethod from_file(filename, spacing=0.2, threshold=5.0, rotate=True)[source]

Initialize CubeGen class based on the grid specifications of a file.

Parameters:
  • filename (str) – file name with, readable with HORTON’s IOData.
  • spacing (float, default=0.2) – Increment between grid points along x, y and z direction.
  • threshold (float, default=5.0) – The extension of the cube on each side of the molecule.
  • rotate (bool, default=True) – When True, the molecule is rotated so the axes of the cube file are aligned with the principle axes of rotation of the molecule.
numbers

Atomic number of the atoms in the molecule.

pseudo_numbers

Pseudo-number of the atoms in the molecule.

coordinates

Cartesian coordinates of the atoms in the molecule.

origin

Cartesian coordinate of the cubic grid origin.

axes

Array with axes of the cube.

The three vectors, stored as rows of axes array, defining the Cartesian coordinate system used to build the cubic grid.

shape

Number of grid points along x, y, and z axis.

npoints

Total number of grid points.

points

Cartesian coordinates of the cubic grid points.

dump_cube(filename, data)[source]

Write the data evaluated on grid points into a cube file.

Parameters:
  • filename (str) – Cube file name with *.cube extension.
  • data (np.ndarray, shape=(npoints,)) – An array containing the evaluated scalar property on the grid points.
weights(method='R')[source]

Return integration weights at every point on the cubic grid.

Parameters:method (str, default='R0') –

The method for computing the integration weights at every point on the grid. Options:

  • ‘R’ method perfors rectangle/trapezoidal rule, without assuming that the function is close to zero at the edges of the grid.
  • ‘R0’ method performing rectangle/trapezoidal rule, assuming that the function is very close to zero at the edges of the grid.
integrate(data, method='R0')[source]

Integrate the data on a cubic grid.

Parameters:
  • data (np.ndarray, shape=(npoints, m)) – Data at every point on the grid given as an array. The size of axis=0 of this array should equal the number of grid points.
  • method (str, default='R0') –

    The method for computing the integration weights at every point on the grid. Options:

    • ‘R’ method perfors rectangle/trapezoidal rule, without assuming that the function is close to zero at the edges of the grid.
    • ‘R0’ method performing rectangle/trapezoidal rule, assuming that the function is very close to zero at the edges of the grid.