Electronegativity equilibration charge model#

Implementation of the electronegativity equlibration model for obtaining atomic partial charges as well as atom-resolved electrostatic energies.

Example

>>> import torch
>>> from tad_multicharge import eeq
>>> numbers = torch.tensor([7, 7, 1, 1, 1, 1, 1, 1])
>>> positions = torch.tensor([
...     [-2.98334550857544, -0.08808205276728, +0.00000000000000],
...     [+2.98334550857544, +0.08808205276728, +0.00000000000000],
...     [-4.07920360565186, +0.25775116682053, +1.52985656261444],
...     [-1.60526800155640, +1.24380481243134, +0.00000000000000],
...     [-4.07920360565186, +0.25775116682053, -1.52985656261444],
...     [+4.07920360565186, -0.25775116682053, -1.52985656261444],
...     [+1.60526800155640, -1.24380481243134, +0.00000000000000],
...     [+4.07920360565186, -0.25775116682053, +1.52985656261444],
... ])
>>> total_charge = torch.tensor(0.0)
>>> cn = torch.tensor([3.0, 3.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
>>> eeq_model = eeq.EEQModel.param2019()
>>> qat, energy = eeq_model.solve(
...     numbers, positions, total_charge, cn, return_energy=True
... )
>>> print(torch.sum(energy, -1))
tensor(-0.1750)
>>> print(qat)
tensor([-0.8347, -0.8347,  0.2731,  0.2886,  0.2731,  0.2731,  0.2886,  0.2731])
class tad_multicharge.model.eeq.EEQModel(chi, kcn, eta, rad, device=None, dtype=None)[source]#

Electronegativity equilibration charge model published in

  • E. Caldeweyher, S. Ehlert, A. Hansen, H. Neugebauer, S. Spicher, C. Bannwarth and S. Grimme, J. Chem. Phys., 2019, 150, 154122. DOI: 10.1063/1.5090222

classmethod param2019(device=None, dtype=None)[source]#

Create the EEQ model from the standard (2019) parametrization.

Parameters:
  • device (torch.device | None, optional) – PyTorch device for the tensors. Defaults to None.

  • dtype (torch.dtype | None, optional) – PyTorch floating point type for the tensors. Defaults to None.

Returns:

Instance of the EEQ charge model class.

Return type:

EEQModel

solve(numbers, positions, total_charge, cn, return_energy=False, solve_mode='schur')[source]#

Solve the electronegativity equilibration for the partial charges minimizing the electrostatic energy.

Parameters:
  • numbers (Tensor) – Atomic numbers of all atoms in the system. (shape: (..., nat)).

  • positions (Tensor) – Cartesian coordinates of the atoms in system (shape: (..., nat, 3)).

  • total_charge (Tensor) – Total charge of the system.

  • cn (Tensor) – Coordination numbers for all atoms in the system.

  • return_energy (bool, optional) – Return the EEQ energy as well. Defaults to False.

  • solve_mode (Literal[“schur”, “linear”], optional) – Choose the solution method for the linear system. - "schur": Use Schur-complement based method with Cholesky

    factorization (default, recommended).

    • "linear": Solve the full bordered linear system directly. Less stable and slower for large systems.

    Defaults to "schur".

Returns:

Tensor of electrostatic charges or tuple of partial charges and electrostatic energies if return_energy=True.

Return type:

Tensor | (Tensor, Tensor)

Example

>>> import torch
>>> from tad_multicharge import eeq
>>> numbers = torch.tensor([7, 1, 1, 1])
>>> positions = torch.tensor([
...     [+0.00000000000000, +0.00000000000000, -0.54524837997150],
...     [-0.88451840382282, +1.53203081565085, +0.18174945999050],
...     [-0.88451840382282, -1.53203081565085, +0.18174945999050],
...     [+1.76903680764564, +0.00000000000000, +0.18174945999050],
... ], requires_grad=True)
>>> total_charge = torch.tensor(0.0, requires_grad=True)
>>> cn = torch.tensor([3.0, 1.0, 1.0, 1.0])
>>> eeq_model = eeq.EEQModel.param2019()
>>> e = eeq_model.solve(numbers, positions, total_charge, cn)[0]
>>> energy = torch.sum(e, -1)
>>> energy.backward()
>>> print(positions.grad)
tensor([[-9.3132e-09,  7.4506e-09, -4.8064e-02],
        [-1.2595e-02,  2.1816e-02,  1.6021e-02],
        [-1.2595e-02, -2.1816e-02,  1.6021e-02],
        [ 2.5191e-02, -6.9849e-10,  1.6021e-02]])
>>> print(total_charge.grad)
tensor(0.6312)
tad_multicharge.model.eeq.get_charges(numbers, positions, chrg, cutoff=None)[source]#

Calculate atomic EEQ charges.

Parameters:
  • numbers (Tensor) – Atomic numbers for all atoms in the system of shape (..., nat).

  • positions (Tensor) – Cartesian coordinates of all atoms (shape: (..., nat, 3)).

  • chrg (Tensor) – Total charge of system.

  • cutoff (Tensor | None, optional) – Real-space cutoff. Defaults to None.

Returns:

Atomic charges.

Return type:

Tensor