Repository navigation
ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419) - #422
Merged
Merged
Conversation
ao_two_e_integral_zero(i,j,k,l) tests the integral with electron pairs (i,k) and (j,l), i.e. (ik|jl). By Cauchy-Schwarz, |(ik|jl)| <= sqrt((ik|ik)(jl|jl)), so the per-pair factor must be sqrt((ik|ik)) - the self-energy of the product AO ik - not the old cross-pairing sqrt((ii|kk)), which is not a proven bound on (ik|jl) and decays only as 1/R in stretched two-center geometries. Same factor as the erf matrix (providers_ao_erf.irp.f:104). Also fixes the (ij|kl)/(ik|jl) convention slip in the ao_two_e_integral_zero docstring, and adds the B-B_screening regression test (SCF at ao_integrals_threshold=1e-8 stays within 1e-5 a.u. of the unscreened reference on stretched B2).
scemama
added a commit
that referenced
this pull request
Nov 19, 2026
On the map path (do_ao_cholesky = False) the dispatcher ao_two_e_integral routes to ao_two_e_integral_schwartz_accel whenever the product of the primitive counts exceeds 1024, and that accelerator skips primitive quartets with the absolute threshold ao_integrals_threshold**2. The Schwartz screening factors ao_two_e_integral_schwartz(i,k) = sqrt((ik|ik)) were therefore computed from zeroed (or under-summed) diagonals, and the AO-level CS test then dropped integrals far above the threshold: on the (H2O)4 chain, cc-pVDZ, threshold 1e-15, 43/5050 factors came out exactly 0 and 34 482 integrals >= 1e-15 were dropped (largest 3.9e-9). The Cholesky path was unaffected (do_schwartz_accel is false when do_ao_cholesky), which is why the defect survived the sqrt((ik|ik)) fix of #422. The full primitive sum (the dispatcher's final branch, moved verbatim) is now ao_two_e_integral_full, and the provider ao_two_e_integral_schwartz uses dsqrt(dabs(ao_two_e_integral_full(i,k,i,k))) - the same pattern the cGTO providers use since #421 (dabs: a vanishing diagonal can be negative by rounding). Dispatcher behaviour is unchanged: its last branch is now a single call. The same defect existed on the long-range (erf) path, which routes to ao_two_e_integral_schwartz_accel_erf unconditionally above 1024 primitives; ao_two_e_integral_erf_full and ao_two_e_integral_erf_schwartz get the same treatment.
scemama
added a commit
that referenced
this pull request
Nov 19, 2026
Per the proposal in issue #419: the test ao_overlap_abs(j,l)*ao_overlap_abs(i,k) < ao_integrals_threshold is not a bound on (ik|jl) - it dropped integrals up to ~10x the threshold (5-8 bohr 1s example: S_ik*S_jl ~ 1e-15 while (ik|jl) = 1.1e-15). The rigorous CS bound sqrt((ik|ik)(jl|jl)) with exact diagonals (previous commit) subsumes it at zero cost: the factors are already provided. The BEGIN_DOC is rewritten: the integral tested is (ik|jl) (1st+3rd arguments = pair 1, 2nd+4th = pair 2), the real-GTO test is the rigorous Cauchy-Schwarz bound, and no integral above ao_integrals_threshold is screened. This also restores the doc fix that the merge 66de718 of #422 dropped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #419.
One-line change in the
ao_two_e_integral_schwartzprovider:ao_two_e_integral_zero(i,j,k,l)tests the integral whose electron pairs are(i,k)and(j,l), i.e.(ik|jl)(the same reading asao_two_e_integral(i,k,j,l)). By the direct Cauchy-Schwarz inequality,the self-energy of each product AO, so the per-pair factor must be
sqrt((ik|ik)). The old cross-pairingsqrt((ii|kk)(jj|ll))is not aproven bound on
(ik|jl), and in stretched two-center geometries itdecays only as 1/R, so at the default
ao_integrals_thresholdof 1e-15it effectively never triggers. This also aligns the matrix with the erf
provider, which already uses the same-side factor
(
providers_ao_erf.irp.f:104).Call sites audited (1st+3rd / 2nd+4th arguments form the electron pairs):
cholesky.irp.f:420), the default SCF path:zero(L1,D1,L2,D2)— the bound is now rigorous for the(L1L2|D1D2)integral actually computed;
fock_matrix_hf.irp.f:61,fock_matrix_ks.irp.f:58):local_threshold = schwartz(k,l)*schwartz(i,j)becomes the exactCauchy-Schwarz bound on the quartet's base integral
(kl|ij)(it was across-pairing that is not a bound), tightening the per-quartet
primitive down-screening;
map_integrals.irp.f); the 1/r12 map uses its own erfmatrix, unchanged.
Also fixes a convention slip in the
ao_two_e_integral_zerodocstring(it documented
(ij|kl); the convention is(ik|jl)).Verification (B2 @ 3.0 A, 6-31G, 18 AO; full build, gfortran 13.4):
sqrt((ik|ik)(jl|jl)) >= |(ik|jl)|on a 4-distinct-primitive grid, tight (within ~1.1x in theFock convention); the old factor is a looser bound there (up to ~4000x);
threshold_ao = 1e-4(only the provider line flipped, samebuild): identical SCF energy, -49.0123445289287 — no observable change
in this system, consistent with the "severity: low" assessment;
B-B_screeningin10.hf.bats: SCF atthreshold_ao = 1e-8converges to -48.9950589230371, within 3.8e-7 a.u.of the unscreened reference -48.9950585434279 (bats tolerance 1e-5);
passes with the default configuration (Cholesky on). The existing
B-Btest is unaffected.
CI compiles the PR as usual.