==================================== 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 :doc:`the joint energy-force Gaussian process ` (what the surrogate models), :doc:`the soft geodesic heat-kernel prior ` (where it carries support) and :doc:`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 :math:`m(x)` does not fit the raw energy and force targets directly. It fits the residual, .. math:: y(x) = m(x) + f(x), \qquad f \sim \mathcal{GP}(0, k), training on :math:`y(x) - m(x)` and adding :math:`m(x)` back at prediction time. Because :math:`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 :math:`E_{\text{obs}} - m(x)` and the gradient row is :math:`G_{\text{obs}} - \nabla m(x)`, and the posterior mean reported back to the caller is .. math:: \mu_E(x_*) = m(x_*) + k_*^\top (K + \sigma_n^2 I)^{-1}\big(y - m(X)\big), \qquad \mu_G(x_*) = \nabla m(x_*) + \mu_{f,\text{grad}}(x_*), 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 :math:`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 :math:`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 :math:`V(r)` by a switch :math:`S(r)` built from the covalent-radii sum :math:`r_{\text{cov}} = R_i + R_j` (Cordero et al. 2008 single-bond radii), with .. math:: r_{\text{on}} = 0.55\, r_{\text{cov}}, \qquad r_{\text{off}} = 0.75\, r_{\text{cov}}, \qquad t = \frac{r - r_{\text{on}}}{r_{\text{off}} - r_{\text{on}}}, .. math:: S(t) = 1 - t^3\,(10 - 15t + 6t^2), \qquad S(r) = \begin{cases} 1 & r \le r_{\text{on}} \\ S(t) & r_{\text{on}} < r < r_{\text{off}} \\ 0 & r \ge r_{\text{off}} \end{cases}. Theorem ``theorem_switch_matches_endpoints_to_second_order`` checks :math:`S(0)=1`, :math:`S(1)=0`, and that both :math:`S'` and :math:`S''` vanish at :math:`t=0` and :math:`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 :math:`S(t) = (1-t)^3(1+3t+6t^2)` (two positive-definite factors on :math:`[0,1]`, confirmed via a negative-discriminant argument on the quadratic part rather than by sampling), so :math:`S` stays inside :math:`[0,1]` with no overshoot, and that its derivative :math:`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 :math:`m_{\text{pair}}(r) = S(r)\,V(r)`, so its derivative is a product rule, not :math:`S(r)\,V'(r)` alone: .. math:: \frac{dm_{\text{pair}}}{dr} = S'(r)\,V(r) + S(r)\,V'(r). ``ZBLPriorMean::visitPairs`` evaluates exactly this: ``dsw_dr`` is :math:`S'(r)` via the chain rule from :math:`S'(t)` and :math:`dt/dr = 1/(r_{off} - r_{on})`, ``pair_energy`` before the switch is applied is the bare :math:`V(r)`, and the assembled Cartesian gradient scale is ``(sw * dV_dr + dsw_dr * pair_energy) / r``, i.e. :math:`\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 :math:`dS/dr` against the code's closed-form ``dsw_dr`` exactly, and theorem ``theorem_product_rule_matches_code`` differentiates :math:`S(r)V(r)` directly (with :math:`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 :math:`S(r)` alone, omitting the :math:`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 ----------------------------------------------------------------------- :math:`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 :math:`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 (:math:`S=0`, and by the endpoint theorem above, :math:`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 :math:`(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 :math:`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 :math:`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 :math:`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. Related ------- - Explanation: :doc:`the joint energy-force Gaussian process ` defines the data term this mean is added to; :doc:`How GPRidge finds a saddle <../method>` shows where the prior mean enters the loop; :doc:`the mathematics index ` lists the other theory pages. - How-to: :doc:`Choose GP settings <../../howto/gp_settings>` lists the prior-mean switches. - Reference: ``--gp-zbl-prior-mean`` in :doc:`the command-line reference <../../reference/cli_reference>`.