The joint energy-force Gaussian process

A surrogate that fits energies and forces separately can predict a force field that is not the gradient of any energy. An oracle call in GPRidge never returns an energy alone: every call to the wrapped potential returns \(E(x)\) and the Cartesian gradient \(\nabla E(x)\) together (see the surrogate loop). The model that consumes those observations does not fit three independent models for the force components and a fourth for the energy. It fits one latent scalar function and treats every observed force component as a linear (differential) functional of that same function. This page derives the consequence of that choice: the energy-force covariance is fixed once the scalar kernel is fixed, and the resulting force field is conservative by construction, not by penalty.

Status: implemented. This is the default model of gprn and gprd (class gpr::GaussianProcessRegression with the covariance gpr::SexpatCF). The block identities are checked by a SymPy script under scripts/, and the kernel convention by a scikit-learn comparison test; the last section lists both.

One latent function, four covariance blocks

Let \(f\) be the latent scalar process, \(f \sim \mathcal{GP}(0, k)\), and identify \(f(x) = E(x)\). Because differentiation is linear, \(f(x)\) and \(-\partial_{x_a} f(x)\) are jointly Gaussian for a differentiable kernel \(k\), and every covariance between an energy observation and a force component reduces to a covariance between \(f\) and a partial derivative of \(f\). Writing \(K_{EE}\) for the energy-energy block, \(K_{EF}\) for energy-force, \(K_{FE}\) for force-energy, and \(K_{FF}\) for force-force,

\[K_{EE}(x,y) = k(x,y), \qquad K_{EF}(x,y) = -\nabla_y k(x,y),\]
\[K_{FE}(x,y) = -\nabla_x k(x,y), \qquad K_{FF}(x,y) = \nabla_x \nabla_y^\top k(x,y).\]

Every block is a derivative of the same scalar function \(k(x,y)\); nothing about the force blocks introduces a new covariance structure. scripts/derive_symmetry_adapted_joint_gp.py checks this symbolically (function joint_energy_force_blocks, theorem theorem_joint_blocks_are_invariant_and_equivariant): differentiating one scalar kernel produces an energy block that is invariant under a relabeling of identical atoms and force blocks that transform equivariantly under the same relabeling, because both are literally partial derivatives of the one invariant scalar.

The script goes one step further (theorem theorem_joint_tensor_is_one_feature_gram) and shows the full block tensor is itself a Gram matrix. For a feature-map kernel \(k(x,y)=\phi(x)^\top\phi(y)\), stack the feature and its negated Jacobian into one factor,

\[\begin{split}\Phi(x) = \begin{pmatrix} \phi(x) \\ -J_\phi(x)^\top \end{pmatrix},\end{split}\]

and the joint block tensor equals \(\Phi(x)\Phi(y)^\top\) exactly. A Gram matrix is PSD for any feature map, so the joint energy-force covariance is PSD without any separate argument about differentiability or block symmetry: it is a Gram matrix because the construction is a Gram matrix. That is the sense in which derive_soft_geodesic_energy_force_gp.py and derive_symmetry_adapted_joint_gp.py both build every additive term as an explicit feature map rather than patching a differentiated kernel after the fact (see the soft geodesic heat-kernel prior).

Curl-free by construction

A GP posterior draw over \(f\) is, for a smooth kernel, almost surely a smooth scalar function. If the model reports the force as \(F(x) = -\nabla f(x)\) for that same \(f\), then

\[\nabla \times F = \nabla \times (-\nabla f) \equiv 0\]

identically, for every draw and for the posterior mean alike. The posterior mean energy \(\mu(x)\) is a finite linear combination of the kernel \(k(x, x_i)\) and of its derivatives with respect to the training geometries, and the posterior mean force is \(-\nabla\mu(x)\). That field has zero curl everywhere the kernel is twice differentiable, with no extra term added to enforce it.

Contrast this with training three independent scalar GPs, one per Cartesian force component. Nothing in that construction ties \(F_x\), \(F_y\), \(F_z\) back to a common potential; three independently-fitted, independently-noisy models will not generally satisfy \(\nabla \times F = 0\), so the resulting surrogate would not correspond to any potential energy surface. The joint energy-force GP avoids that failure mode structurally: differentiating one scalar function makes the zero-curl property automatic. No constraint gets imposed, checked, or projected out afterward.

The production kernel: SexpatCF over inverse distances

The scalar kernel used in practice is gpr::SexpatCF, a squared exponential evaluated not on raw Cartesian coordinates but on the inverse-distance descriptor \(\phi(x)\) built by gpr::InverseDistanceDescriptor. Each feature \(\phi_f(x)=1/r_{ab}(x)\) belongs to one atom pair \(f=(a,b)\) (moving-moving pairs first, then moving-frozen pairs), with \(r_{ab}\) in Angstrom. Each pair carries a pairtype \(\mathrm{pt}(f)\): a C-H pair and a C-C pair are different pairtypes with independently fitted length scales \(\ell_{\mathrm{pt}}\) (an ARD length scale per pairtype). With a positive --gp-pair-cutoff the feature is the inverse distance multiplied by a quintic switch that reaches zero at the cutoff (gpr/auxiliary/PairCutoff.h); the formulas below hold for either choice of \(\phi_f\).

The kernel is

\[k(x,y) = \sigma^2 \exp\!\left( -\sum_{f} \frac{\big(\phi_f(x) - \phi_f(y)\big)^2} {\ell_{\mathrm{pt}(f)}^2} \right),\]

where the sum runs over the atom-pair features \(f\), \(\sigma^2\) is the signal variance (magnSigma2) and \(\ell_{\mathrm{pt}}\) is the length scale of pairtype \(\mathrm{pt}\) (SexpatCF::lengthScale, one entry per pairtype, or one shared entry). The features are in 1/Angstrom, so each \(\ell_{\mathrm{pt}}\) is in 1/Angstrom. \(\sigma^2\) has the units of the training targets squared: eV squared with --gp-no-output-norm true, dimensionless in the default case, where the targets are standardized before the fit.

The factor in the exponent follows the code. The squared distance accumulated in gpr/auxiliary/Distance.cpp is \(d^2(x,y)=2\sum_f(\phi_f(x)-\phi_f(y))^2/\ell_{\mathrm{pt}(f)}^2\), and SexpatCF::calculateCovarianceMatrix returns \(\sigma^2\exp(-d^2/2)\). Equivalently \(k\) is the ordinary squared-exponential kernel \(\sigma^2\exp(-\tfrac12\sum_f(z_f(x)-z_f(y))^2/\ell^2)\) on the scaled features \(z_f=\sqrt2\,\phi_f\). The test python/tests/test_sklearn_reference_gp.py checks this convention against an RBF kernel of scikit-learn on a diatomic.

The hyperparameters are stored as logarithms, \(\theta_0=\log\sigma^2\) and \(\theta_{1+\mathrm{pt}}=\log\ell_{\mathrm{pt}}\) (a single \(\theta_1\) when the length scale is shared). SexpatCF::buildSharedKernel takes the per-pairtype squared distance \(d_{\mathrm{pt}}=2\sum_{f\in\mathrm{pt}}(\phi_f(x)-\phi_f(y))^2\) at unit length and evaluates \(\exp(\theta_0)\cdot\exp(-\tfrac12\sum_{\mathrm{pt}} \exp(-2\theta_{1+\mathrm{pt}})\,d_{\mathrm{pt}})\).

A shorter \(\ell_{\mathrm{pt}}\) lets the model resolve sharper curvature along the bond coordinate of one pairtype without over-smoothing the rest; that is the practical reason SexpatCF carries one length scale per pairtype rather than one global length scale.

Because energy and force observations are always expressed in Cartesian coordinates, the code applies the derivative-block theorem above through the Jacobian of the descriptor map (InverseDistanceDescriptor::computeWithJacobian). For the feature built from the pair \((a,b)\),

\[J(f, 3a+d) = -\frac{(x_a-x_b)_d}{r_{ab}^3}, \qquad J(f, 3b+d) = +\frac{(x_a-x_b)_d}{r_{ab}^3},\]

the derivative of \(1/r_{ab}\) with respect to Cartesian component \(d\) of atom \(a\) or \(b\). For a moving-frozen pair only the column of the moving atom is nonzero. (The comment above computeWithJacobian in gpr/auxiliary/InverseDistanceDescriptor.h states the opposite signs; the implementation in InverseDistanceDescriptor.cpp and the derivative above agree with each other.) Composing a smooth Jacobian with a Gram-factor kernel preserves the Gram structure by the ordinary chain rule, so the block tensor built by ginput2=/=ginput3=/=ginput4 and the calculateGradOfCovMatrixWithDerivatives* family is exactly \(K_{EE}, K_{EF}, K_{FE}, K_{FF}\) as derived above, with \(x\) replaced by \(\phi(x)\) throughout.

The inverse-distance choice also keeps the descriptor finite through linear (collinear) geometries, where a bond-angle chart would have a coordinate singularity. The features \(1/r_{ab}\) and the entries of \(J\) are finite whenever every pair distance is positive, and collinear geometries of distinct atoms satisfy that. The SymPy check theorem_linear_geometry_descriptor_is_regular in the soft geodesic heat-kernel prior verifies the same statement for log pair distances, the descriptor of that page’s regularity argument, not for \(1/r\).

What the page does not establish

The identities are algebraic. They do not show that this kernel makes a search converge faster than another kernel, and they do not choose the hyperparameters; see the surrogate loop for the limits of a convergence claim and Choose GP settings for the settings that change the kernel.

Checks

The covariance-block identities of the first sections are checked without finite differences in scripts/derive_symmetry_adapted_joint_gp.py. The pixi task derive-symmetry-adapted-joint-gp runs it in the symbolic environment; any Python with SymPy runs it directly. The script prints ALL_CHECKS_PASS when every theorem holds and stops with an AssertionError naming the first check that fails.

The kernel convention of the SexpatCF section is checked separately by python/tests/test_sklearn_reference_gp.py.

The script also checks that a molecular permutation-symmetry group layers on top of this construction (Reynolds-projecting the base kernel keeps every block PSD and the correct invariant/equivariant symmetry), and that projecting only an additive extra term without also projecting the base kernel is not sufficient to restore permutation symmetry of the composite (theorem_partial_projection_leaves_composite_wrong). That result matters directly for the additive geodesic term introduced in the soft geodesic heat-kernel prior.