coeffs_to_grid

_assert_shapes(coeffs: ndarray | Tensor, ao: ndarray | Tensor) None[source]

Assert that coefficient vector and atomic orbitals have the correct shapes.

Parameters:
  • coeffs – Coefficient vector, sha[e (n_ao).

  • ao – Atomic orbitals on the grid. Shape: (n_grid, n_ao) or (n_deriv, n_grid, n_ao).

add_new_axis(tensor: ndarray | Tensor, axis=0) ndarray | Tensor[source]

Add a new axis to the tensor.

Parameters:
  • tensor – Input tensor.

  • axis – Axis to add.

Returns:

Tensor with new axis added.

Return type:

tensor

coeffs_to_grad_rho(coeffs: ndarray | Tensor, ao: ndarray | Tensor) ndarray | Tensor[source]

Compute the gradient of the electron density on the grid, using coeffs in the linear ansatz and (already evaluated) atomic orbitals.

Parameters:
  • coeffs – Coefficient vector.

  • ao – Atomic orbitals on the grid. Shape: (n_grid, n_ao) or (n_deriv, n_grid, n_ao).

Returns:

Gradient of the electron density on the grid.

Return type:

grad_rho

coeffs_to_laplace_rho(coeffs: ndarray | Tensor, ao: ndarray | Tensor) ndarray | Tensor[source]

Compute the laplacian of the electron density on the grid, using coeffs in the linear ansatz and (already evaluated) atomic orbitals.

Parameters:
  • coeffs – Coefficient vector.

  • ao – Atomic orbitals on the grid. Shape: (n_grid, n_ao) or (n_deriv, n_grid, n_ao).

Returns:

Laplacian of the electron density on the grid.

Return type:

grad_rho

coeffs_to_rho(coeffs: ndarray | Tensor, ao: ndarray | Tensor) ndarray | Tensor[source]

Compute the electron density on the grid, using coeffs in the linear ansatz and (already evaluated) atomic orbitals on the grid.

Parameters:
  • coeffs – Coefficient vector.

  • ao – Atomic orbitals on the grid. Shape: (n_grid, n_ao) or (n_deriv, n_ao, n_grid).

Returns:

Electron density on the grid.

Return type:

rho

coeffs_to_rho_and_derivatives(coeffs: ndarray | Tensor, ao: ndarray | Tensor, max_derivative_order: int) ndarray | Tensor[source]

Compute the electron density and its derivatives up to order max_derivative_order on the grid, using coeffs in the linear ansatz and (already evaluated) atomic orbitals.

Parameters:
  • coeffs – Coefficient vector.

  • ao – Atomic orbitals on the grid. Shape: (n_ao, n_grid) or (n_deriv, n_ao, n_grid).

  • max_derivative_order – Maximum derivative order to compute, if zero, only the electron density is computed. If one, the gradient is concatenated. If two, the laplacian is additionally concatenated.

Returns:

Electron density and its derivatives on the grid.
Shape depends on max_derivative:
  • if 0, shape is (1, n_grid)

  • if 1, shape is (4, n_grid)

  • if 2, shape is (5, n_grid)

Return type:

rho_and_derivatives

concatenate(arrays: ndarray | Tensor, axis: int = 0)[source]

Concatenate arrays along the given axis.

is_numpy(tensor: ndarray | Tensor) bool[source]

Check if tensor is a numpy array.

is_torch(tensor: ndarray | Tensor) bool[source]

Check if tensor is a torch tensor.