xnn.common.models.electrostatics.coulomb_direct#

xnn.common.models.electrostatics.coulomb_direct(charges, pos, batch, k_e=14.39964547846902)[source]#

Per-atom share of the all-pairs Coulomb energy of molecular structures.

E_i = (k_e / 2) sum_{j != i} q_i q_j / r_ij over the atoms of the same structure, summing to k_e sum_{i<j} q_i q_j / r_ij. The pair terms are accumulated in float64 whatever their dtype.

Parameters:
  • charges (Tensor) – Partial charges (N,).

  • pos (Tensor) – Positions (N, 3); the pair distances are formed in the charges’ dtype.

  • batch (Tensor) – Structure index per atom (N,).

  • k_e (float, optional) – The Coulomb constant (an argument so the function compiles under TorchScript), by default COULOMB_CONSTANT.

Returns:

Per-atom energies (N,) in eV, float64.

Return type:

Tensor