dxtb.integrals.types.OverlapIntegral#

class dxtb.integrals.types.OverlapIntegral(device=None, dtype=None, uplo='l', cutoff=50.0)[source]#

Bases: BaseIntegral

Base overlap class.

Methods

build

Create the integral matrix.

checks

Check if the driver is setup.

clear

Clear the integral matrix and gradient.

cpu

Returns a copy of the TensorLike instance on the CPU.

get_gradient

Calculate the full nuclear gradient matrix of the integral.

normalize

Normalize the integral (changes self.matrix).

normalize_gradient

Normalize the gradient (changes self.gradient).

override_device

Override the device of the class object.

override_dtype

Override the dtype of the class object.

to

Returns a copy of the integral on the specified device "device".

to_pt

Save the integral matrix to a file.

type

Returns a copy of the TensorLike instance with specified floating point type.

Attributes

family

Family of the integral implementation (PyTorch or libcint).

cutoff

Real-space cutoff for integral calculation in Bohr.

uplo

Whether the matrix of unique shell pairs should be create as a triangular matrix (l: lower, u: upper) or full matrix (n).

allowed_dtypes

Specification of dtypes that the TensorLike object can take.

dd

Shortcut for device and dtype.

device

The device on which the class object resides.

dtype

Floating point dtype used by class object.

gradient

matrix

Matrix of the integral.

norm

requires_grad

Check if any field of the integral class is requires gradient.

Parameters:
abstract build(driver, **kwargs)#

Create the integral matrix.

Parameters:
  • driver (IntDriver) – Integral driver for the calculation.

  • kwargs (Any)

Returns:

Integral matrix.

Return type:

Tensor

checks(driver)#

Check if the driver is setup.

Parameters:

driver (IntDriver) – Integral driver for the calculation.

Return type:

None

clear()#

Clear the integral matrix and gradient.

Return type:

None

cpu()#

Returns a copy of the TensorLike instance on the CPU.

This method creates and returns a new copy of the TensorLike instance on the CPU.

Returns:

A copy of the TensorLike instance placed on the CPU.

Return type:

TensorLike

abstract get_gradient(driver, **kwargs)#

Calculate the full nuclear gradient matrix of the integral.

Parameters:
  • driver (IntDriver) – Integral driver for the calculation.

  • kwargs (Any)

Returns:

Nuclear integral derivative matrix.

Return type:

Tensor

normalize(norm=None, **_)#

Normalize the integral (changes self.matrix).

Parameters:
  • norm (Tensor | None, optional) – Overlap norm to normalize the integral.

  • _ (Any)

Return type:

None

normalize_gradient(norm=None)#

Normalize the gradient (changes self.gradient).

Parameters:

norm (Tensor) – Overlap norm to normalize the integral.

Return type:

None

override_device(device)#

Override the device of the class object.

Warning

This does not change the device of the underlying tensors. It only changes the device of the class object. Use with caution.

Parameters:

device (torch.device) – Device to override the current device.

Return type:

None

override_dtype(dtype)#

Override the dtype of the class object.

Warning

This does not change the dtype of the underlying tensors. It only changes the dtype of the class object. Use with caution.

Parameters:

dtype (torch.dtype) – Floating point dtype to override the current dtype.

Return type:

None

to(device=None, dtype=None)#

Returns a copy of the integral on the specified device “device”. This is essentially a wrapper around the to() method of the TensorLike class, but explicitly also moves the integral matrix.

Parameters:
  • device (torch.device | None) – Device to which all associated tensors should be moved.

  • dtype (dtype | None)

Returns:

A copy of the integral placed on the specified device.

Return type:

Self

to_pt(path=None)#

Save the integral matrix to a file.

Parameters:

path (PathLike | None) – Path to the file where the integral matrix should be saved. If None, the matrix is saved to the default location.

Return type:

None

type(dtype)#

Returns a copy of the TensorLike instance with specified floating point type. This method creates and returns a new copy of the TensorLike instance with the specified dtype.

Parameters:

dtype (torch.dtype) – Floating point type.

Returns:

A copy of the TensorLike instance with the specified dtype.

Return type:

TensorLike

Notes

If the TensorLike instance has already the desired dtype Self will be returned.

property allowed_dtypes: tuple[dtype, ...]#

Specification of dtypes that the TensorLike object can take. Defaults to float types and must be overridden by subclass if float are not allowed. The IndexHelper is an example that should only allow integers.

Returns:

Collection of allowed dtypes the TensorLike object can take.

Return type:

tuple[torch.dtype, …]

cutoff: Tensor | float | int | None#

Real-space cutoff for integral calculation in Bohr. Defaults to constants.defaults.INTCUTOFF.

property dd: DD#

Shortcut for device and dtype.

property device: device#

The device on which the class object resides.

property dtype: dtype#

Floating point dtype used by class object.

family: str | None#

Family of the integral implementation (PyTorch or libcint).

property gradient: Tensor#
property matrix: Tensor#

Matrix of the integral.

property norm: Tensor | None#
property requires_grad: bool#

Check if any field of the integral class is requires gradient.

Returns:

Flag for gradient requirement.

Return type:

bool

uplo: Literal['n', 'u', 'l']#

Whether the matrix of unique shell pairs should be create as a triangular matrix (l: lower, u: upper) or full matrix (n). Defaults to l (lower triangular matrix).