InversePowerLawPotential

class torchpme.InversePowerLawPotential(exponent: int, smearing: float | None = None, exclusion_radius: float | None = None)[source]

Inverse power-law potentials of the form \(1/r^p\).

Here \(r\) is a distance parameter and \(p\) an exponent.

It can be used to compute:

  1. the full \(1/r^p\) potential

  2. its short-range (SR) and long-range (LR) parts, the split being determined by a length-scale parameter (called “smearing” in the code)

  3. the Fourier transform of the LR part

Parameters:
  • exponent (int) – the exponent \(p\) in \(1/r^p\) potentials

  • smearing (float | None) – float or torch.Tensor containing the parameter often called “sigma” in publications, which determines the length-scale at which the short-range and long-range parts of the naive \(1/r^p\) potential are separated. For the Coulomb potential (\(p=1\)), this potential can be interpreted as the effective potential generated by a Gaussian charge density, in which case this smearing parameter corresponds to the “width” of the Gaussian.

  • exclusion_radius (float | None)

Param:

exclusion_radius: float or torch.Tensor containing the length scale corresponding to a local environment. See also Potential.

from_dist(dist: Tensor) Tensor[source]

Full \(1/r^p\) potential as a function of \(r\).

Parameters:

dist (Tensor) – torch.tensor containing the distances at which the potential is to be evaluated.

Return type:

Tensor

lr_from_dist(dist: Tensor) Tensor[source]

Long range of the range-separated \(1/r^p\) potential.

Used to subtract out the interior contributions after computing the LR part in reciprocal (Fourier) space.

For the Coulomb potential, this would return (note that the only change between the SR and LR parts is the fact that erfc changes to erf)

potential = erf(dist / sqrt(2) / smearing) / dist
Parameters:

dist (Tensor) – torch.tensor containing the distances at which the potential is to be evaluated.

Return type:

Tensor

lr_from_k_sq(k_sq: Tensor) Tensor[source]

Fourier transform of the LR part potential in terms of \(\mathbf{k^2}\).

Parameters:

k_sq (Tensor) – torch.tensor containing the squared lengths (2-norms) of the wave vectors k at which the Fourier-transformed potential is to be evaluated

Return type:

Tensor

self_contribution() Tensor[source]

A correction that depends exclusively on the “charge” on every particle and on the range splitting parameter. Foe example, in the case of a Coulomb potential, this is the potential generated at the origin by the fictituous Gaussian charge density in order to split the potential into a SR and LR part.

Return type:

Tensor

background_correction() Tensor[source]

A correction designed to compensate for the presence of divergent terms. For instance, the energy of a periodic electrostatic system is infinite when the cell is not charge-neutral. This term then implicitly assumes that a homogeneous background charge of the opposite sign is present to make the cell neutral.

Return type:

Tensor