chemtools.utils.cube.UniformGrid

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

Class for generating a cubic grid and writing cube files.

Initialize UniformGrid 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(molecule, spacing=0.2, extension=5.0, rotate=True)[source]

Initialize UniformGrid class from Molecule object.

Parameters:
  • molecule (instance of Molecule) – Instance of Molecule class.
  • spacing (float, optional) – Increment between grid points along x, y and z direction.
  • extension (float, optional) – The extension of the cube on each side of the molecule.
  • rotate (bool, optional) – 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(fname)[source]

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

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

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

Parameters:
  • fname (str) – Path to molecule’s file.
  • spacing (float, optional) – Increment between grid points along x, y and z direction.
  • extension (float, optional) – The extension of the cube on each side of the molecule.
  • rotate (bool, optional) – 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.

centers

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.

generate_cube(fname, data)[source]

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

Parameters:
  • fname (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, optional) –

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.