xnn.common.models.electrostatics.coulomb_direct#

xnn.common.models.electrostatics.coulomb_direct(charges, pos, batch, k_e=14.39964547846902, num_graphs=0, damping_midpoint=0.0, damping_steepness=0.0, dense=False)[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. With a positive damping_steepness b every pair term is multiplied by the Fermi function 1 / (1 + exp(b (a - r_ij))) of midpoint a, which attenuates the short-range pairs.

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.

  • num_graphs (int, optional) – Number of structures, when the caller knows it: one structure sums its pair matrix directly (no host synchronization for the pair list), by default 0 (unknown).

  • damping_midpoint (float, optional) – Distance a where the damping is one half, by default 0.0.

  • damping_steepness (float, optional) – Steepness b of the damping in inverse length, by default 0.0 (no damping).

  • dense (bool, optional) – Sum several structures over a masked (N, N) pair matrix (dense_pairs()) instead of a pair list, which reads no count back from the device (a captured evaluation), by default False.

Returns:

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

Return type:

Tensor