The switched ZBL residual prior mean¶
A Gaussian-process surrogate that has no data near a query geometry
returns its prior mean there. With a zero mean, a compressed geometry
that no observation covers looks as low in energy as a bonded one, and a
band can step into it. This page fixes what the surrogate reverts to when
a query geometry leaves every training point behind. It sits beside
the joint energy-force Gaussian process (what the surrogate models),
the soft geodesic heat-kernel prior (where it carries support) and
the Riemannian tangent projection (what the optimizer may do with the
result). gpr::priors::ZBLPriorMean
answers the question with a residual-learning prior mean built from the ZBL
screened-Coulomb pair potential, switched off everywhere except a
short compression-only window near each pair’s covalent-radii sum.
scripts/derive_switched_zbl_prior_mean.py checks every derivative
and cutoff identity that follows symbolically; the divergence argument
for a mean without a switch gets checked separately in
scripts/derive_zbl_prior_mean_divergence.py.
Status: implemented and off by default. --gp-zbl-prior-mean true enables it
in gprn and gprd. The page proves properties of the switch and of the
gradient. It does not report a benchmark of the switched mean against the
bare one: the repository holds no recorded run that compares them.
Residual learning: the GP fits what the prior mean does not explain¶
A Gaussian process with a nonzero prior mean \(m(x)\) does not fit the raw energy and force targets directly. It fits the residual,
training on \(y(x) - m(x)\) and adding \(m(x)\) back at prediction time. Because \(m\) is a fixed closed-form function of atomic positions rather than a fitted degree of freedom, differentiating the decomposition carries through unchanged to the gradient channel: the energy row of the training target is \(E_{\text{obs}} - m(x)\) and the gradient row is \(G_{\text{obs}} - \nabla m(x)\), and the posterior mean reported back to the caller is
for the energy row and the Cartesian gradient rows respectively.
ZBLPriorMean::subtractFromTargets performs the first step: energy
rows are offset at index row, gradient rows at index
energy_count + row + component * positions.rows(), which is the
same energy-block-then-component-major-gradient-block target layout
energy_count parameterizes throughout GaussianProcessRegression.
ZBLPriorMean::addToObservation performs the inverse for a freshly
observed point, so both directions of the split use the same pairwise
visitPairs evaluation and never drift out of sync with each other.
Why bare ZBL is too rough a mean for the bonding manifold¶
A first attempt sets \(m\) to the bare ZBL pair sum with no switch.
Theorem theorem_bare_pair_energy_scale_at_bonded_distances reproduces
the bare pair energy at two representative bonded distances using the
production screening weights and exponents: 2.9 eV for an H-C pair at
1.1 A, and 3.4 eV for a C-C pair at 1.5 A. Both distances sit well
inside the normal single-bond region, nowhere near a Pauli-repulsion
wall, so a mean built from the bare potential carries eV-scale
curvature across the entire bonding manifold the GP is meant to model
smoothly. Two problems follow directly. First, every training target gets
offset by a different, sharply varying amount depending on which
bonds happen to be present in that configuration, which roughens
what would otherwise be a smooth residual and makes the covariance
structure harder to fit. Second, at extrapolation, where the learned
correction is smallest and the posterior mean leans most heavily on
\(m\) itself, that eV-scale bias pulls predicted energies and forces
away from the true surface even on ordinary bonded geometries. The ZBL
term itself stays:
its divergence at bond collapse is exactly the signal that keeps a
GP-NEB band from stepping into an unphysical compressed geometry, as
scripts/derive_zbl_prior_mean_divergence.py establishes. The switch
confines that signal to the region where it is actually informative.
The quintic switch¶
ZBLPriorMean multiplies every pair’s bare potential \(V(r)\) by a
switch \(S(r)\) built from the covalent-radii sum \(r_{\text{cov}} =
R_i + R_j\) (Cordero et al. 2008 single-bond radii), with
Theorem theorem_switch_matches_endpoints_to_second_order checks
\(S(0)=1\), \(S(1)=0\), and that both \(S'\) and \(S''\) vanish at
\(t=0\) and \(t=1\): the switch matches the constant-one and
constant-zero pieces on either side of the window in value, slope,
and curvature simultaneously, which is the exact sense in which it is
C:math:^2 at both breakpoints. Theorem
theorem_switch_is_bounded_and_monotone checks the factored form
\(S(t) = (1-t)^3(1+3t+6t^2)\) (two positive-definite factors on
\([0,1]\), confirmed via a negative-discriminant argument on the
quadratic part rather than by sampling), so \(S\) stays inside
\([0,1]\) with no overshoot, and that its derivative
\(S'(t) = -30t^2(1-t)^2\) never changes sign: the switch is a smooth,
monotone ramp with no oscillation anywhere in the transition window.
The gradient carries the product-rule term¶
The pair energy the code adds is \(m_{\text{pair}}(r) = S(r)\,V(r)\), so its derivative is a product rule, not \(S(r)\,V'(r)\) alone:
ZBLPriorMean::visitPairs evaluates exactly this: dsw_dr is
\(S'(r)\) via the chain rule from \(S'(t)\) and \(dt/dr = 1/(r_{off} -
r_{on})\), pair_energy before the switch is applied is the bare
\(V(r)\), and the assembled Cartesian gradient scale is (sw * dV_dr + dsw_dr * pair_energy) / r, i.e. \(\big(S(r)V'(r) + S'(r)V(r)\big)/r\)
projected onto the pair separation vector. Theorem
theorem_chain_rule_matches_code checks the chain-rule form of
\(dS/dr\) against the code’s closed-form dsw_dr exactly, and theorem
theorem_product_rule_matches_code differentiates \(S(r)V(r)\)
directly (with \(V\) left as a symbolic function) and checks the
result against the sw * dV_dr + dsw_dr * pair_energy assembly. Both
match with zero residual. Multiplying the bare gradient by \(S(r)\)
alone, omitting the \(S'(r)V(r)\) term, breaks energy conservation
inside the switch window with no diagnostic to catch it: the reported
force would no longer be the negative gradient of the reported energy.
The cutoff is calibrated against real bond distances, including triples¶
\(r_{\text{off}} = 0.75\, r_{\text{cov}}\) is not a free knob; it has
to clear every real bonded distance so the mean stays exactly zero
across the whole bonding manifold and active only in the compression
region beyond it. The tightest case is a triple bond, the shortest
bond order commonly seen relative to its single-bond covalent-radii
sum. Theorem theorem_cutoff_clears_the_tightest_real_bond checks
this for C-N: the Cordero single-bond sum is 1.47 A, so
\(r_{\text{off}} = 1.1025\) A, while a C:math:equiv`N triple bond (as in
a nitrile) sits at about 1.16 A, a ratio of 0.789 to the single-bond
sum that matches the 0.78 figure used to size the cutoff. Because
:math:`1.1025 < 1.16, the switch is already fully off (\(S=0\), and by
the endpoint theorem above, \(S'=0\) too) at this triple bond, which the
theorem takes as the tightest case; the script checks no other element pair.
Double and single bonds of the same pair are longer than its triple bond, so they clear the cutoff by a larger margin. The window \((r_{\text{on}}, r_{\text{off}})\) therefore sits entirely
inside the region shorter than any real equilibrium bond: compressed,
Pauli-repulsion geometries that a GP-NEB band should never treat as
low energy, and nothing else.
Consequence for the GP-OIE loop¶
The posterior mean is \(m(x_*)\) plus a bounded data correction, so at extrapolation, far from any training point, where the learned correction shrinks toward its prior value, the posterior reverts toward \(m(x_*)\) itself. With the bare, switch-free mean, that reversion carried an eV-scale bias across all of ordinary bonding, the roughening problem described above. With the switched mean, reversion away from prior observations is inert everywhere except the compression region: a compressed geometry the band has not yet sampled still sees \(m(x_*)\) rising sharply toward the ZBL divergence, while a bonded or stretched geometry the band has not yet sampled sees a flat, zero mean, exactly matching the smooth residual the GP fit. The inner band relaxation used by the GP-OIE loop therefore cannot mistake an unsampled compressed configuration for a low-energy one: the compression wall is a structural property of the mean itself, present before any variance certificate is evaluated, rather than a boundary a restricted-variance gate has to enforce on every single step.
Checks¶
The pixi task derive-switched-zbl-prior-mean (environment symbolic)
runs scripts/derive_switched_zbl_prior_mean.py, which calls the six
theorems above and prints ALL_CHECKS_PASS. The
divergence argument that motivates keeping the ZBL term at all is
checked separately by scripts/derive_zbl_prior_mean_divergence.py, an
inline-metadata script that needs only SymPy: that the bare pair potential
diverges at bond collapse, that the posterior mean inherits that divergence
through a bounded data correction, and that the divergence location is
scale-free under a change of energy units.