xnn.common.models.pme#

Smooth particle-mesh Ewald reciprocal sums (Essmann and co-workers, 1995).

J. Chem. Phys. 103, 8577 (1995).

The reciprocal-space part of an Ewald sum through a charge mesh: the point charges are spread onto a regular grid of the unit cell with cardinal B-splines of order p (eq 4.1 of the paper, the weights M_p(u - k) of the scaled fractional coordinate u), the grid is Fourier transformed, and the structure factor is recovered from the transform through the Euler exponential spline coefficients b_i(m_i) (eq 4.4), so that

E_rec = 1 / (2 pi V) sum_{m != 0} exp(-pi^2 m^2 / alpha^2) / m^2 B(m) |F(Q)(m)|^2

with B(m) = prod_i |b_i(m_i)|^2 (eq 4.7). The per-atom energies come from the reciprocal potential interpolated back onto the atoms with the same splines, E_i = q_i phi(r_i) / 2, which sum to E_rec. Everything is written in differentiable tensor operations, so forces (through the spline weights and the charges) and the stress (through the cell) follow from autograd, and the functions compile under TorchScript.

The mesh size follows the production heuristic K_i = 2 alpha L_i / (3 eps^(1/5)) rounded up to a power of two (the same choice as the reference AIMNet2 calculator), which covers both the Gaussian truncation and the spline aliasing error at the target relative accuracy eps. The B-spline coefficients are the exact ones of the paper (the discrete Euler spline), not the continuous sinc^p approximation some codes use; the two agree to the aliasing error the mesh heuristic controls.

Functions

bspline_moduli(size, order, dtype, device)

|b(m)|^2 of the Euler exponential spline along one mesh axis (paper eq 4.4).

bspline_weights(t, order)

Cardinal B-spline weights M_p(t + j) for j from 0 to p - 1.

mesh_wavevectors(cell, mesh)

The wave vectors of a mesh in FFT order: 2 pi times the Miller indices dotted with the reciprocal vectors.

pme_mesh(cell, alpha, accuracy)

Mesh dimensions for a target accuracy: 2 alpha L_i / (3 eps^(1/5)), up to a power of two.

pme_reciprocal(charges, pos, cell, alpha, ...)

Per-atom reciprocal-space energies of one periodic structure, q_i phi(r_i) / 2.

pme_weighted_sum(charges, pos, cell, mesh, ...)

sum_c sum_m w(m) |S_c(m)|^2 with the structure factors from the mesh.

spline_moduli(mesh, order, dtype, device)

B(m) = prod_i |b_i(m_i)|^2 over the mesh (paper eq 4.7), (K_1, K_2, K_3).

spread_charges(charges, pos, cell, mesh, order)

Charges on the mesh by B-spline assignment (paper eq 4.6).