CalculatorDipole

class torchpme.CalculatorDipole(potential: PotentialDipole, full_neighbor_list: bool = False, prefactor: float = 1.0, lr_wavelength: float | None = None)[source]

Base calculator for interacting dipoles in the torch interface.

Parameters:
  • potential (PotentialDipole) – a PotentialDipole class object containing the functions that are necessary to compute the various components of the potential, as well as the parameters that determine the behavior of the potential itself.

  • full_neighbor_list (bool) – parameter indicating whether the neighbor information will come from a full (True) or half (False, default) neighbor list.

  • prefactor (float) – electrostatics prefactor; see Prefactors for details and common values.

  • lr_wavelength (float | None) – the wavelength of the long-range part of the potential.

forward(dipoles: Tensor, cell: Tensor, positions: Tensor, neighbor_indices: Tensor, neighbor_vectors: Tensor)[source]

Compute the potential “energy”.

It is calculated as:

\[V_i = \frac{1}{2} \sum_{j} \boldsymbol{\mu_j} \, \mathbf{v}(\mathbf{r_{ij}})\]

where \(\mathbf{v}(\mathbf{r})\) is the pair potential defined by the potential parameter, and \(\boldsymbol{\mu_j}\) are atomic “dipoles”.

If the smearing of the potential is not set, the calculator evaluates only the real-space part of the potential. Otherwise, provided that the calculator implements a _compute_kspace method, it will also evaluate the long-range part using a Fourier-domain method.

Parameters:
  • dipoles (Tensor) – torch.tensor of shape (len(positions), 3) containaing the atomic dipoles.

  • cell (Tensor) – torch.tensor of shape (3, 3), where cell[i] is the i-th basis vector of the unit cell

  • positions (Tensor) – torch.tensor of shape (N, 3) containing the Cartesian coordinates of the N particles within the supercell.

  • neighbor_indices (Tensor) – torch.tensor with the i,j indices of neighbors for which the potential should be computed in real space.

  • neighbor_vectors (Tensor) – torch.tensor with the pair vectors of the neighbors for which the potential should be computed in real space.