mlipops.ChargeEquilibration#

class mlipops.ChargeEquilibration(coulomb: CoulombNC | CoulombRF | CoulombEwald)#

Compute atomic partial charges with charge equilibration.

This class implements the charge equilibration method as described in http://dx.doi.org/10.1103/PhysRevB.92.045131. It models atoms as Gaussian charge distributions. You provide three parameters for each atom: electronegativity, which describes its innate affinity for electrons; hardness, which describes its resistance to changes in charge; and radius, which is the width of the Gaussian charge distribution. It solves for the charges that minimize an energy function subject to constraints on the total charge.

In the simplest version, you provide a single number for the total charge of the system, and it constrains the atomic partial charges to add up to the correct value. This works well for single isolated molecules, but cannot accurately describe systems of multiple molecules. In particular, it unrealistically predicts fractional charges for molecules. Instead you can provide a list of the atoms that make up each molecule and the total charge of each one. It then solves the equations subject to a separate constraint for each molecule. This produces more realistic results, but requires that you know in advance how the atoms are divided into molecules and how the charge is divided among them.

__init__(coulomb: CoulombNC | CoulombRF | CoulombEwald)#

Create an object for performing charge equilibration.

Parameters:

coulomb (CoulombNC | CoulombRF | CoulombEwald) – the object used to compute Coulomb interactions between atoms. This determines what method is used for handling long range interactions and the neighbor list used for identifying interacting pairs.

forward(positions: Tensor, electronegativity: Tensor, hardness: Tensor, radius: Tensor, total_charge: float | None = None, molecules: list | None = None, box_vectors: Tensor | None = None) Tensor#

Perform charge equilibration to compute atomic partial charges.

Parameters:
  • positions (torch.Tensor) – a Tensor of shape (n_particles, 3) containing the Cartesian coordinates of each particle

  • electronegativity (torch.Tensor) – a Tensor of shape (n_particles,) containing the electronegativity ($chi$) of each particle

  • hardness (torch.Tensor,) – a Tensor of shape (n_particles,) containing the hardness ($J_{ii}$) of each particle

  • radius (torch.Tensor) – a Tensor of shape (n_particles,) containing the radius ($lpha$) of each particle

  • total_charge (float | None) – the total charge of the system. You must specify either total_charge or molecules, but not both.

  • molecules (list | None) – the list of molecules. Each element should be a tuple with two elements. The first element is a Tensor containing the indices of the particles that belong to the molecule. The second element is a float with the total charge of the molecule. You must specify either total_charge or molecules, but not both.

  • box_vectors (torch.Tensor | None) – a Tensor of shape (3, 3) containing box vectors defining the periodic box. If None, periodic boundary conditions are not used.

Returns:

a Tensor of shape (n_particles,) containing the charge of each particle

Return type:

torch.Tensor