Repository navigation
Description
Severity. Low: no measurable effect on energies at the default threshold (1e-15). This is a correctness and
documentation point, with a modest speed gain.
Where. src/ao_two_e_ints/two_e_integrals.irp.f:
ao_two_e_integral_schwartz(i,k) = sqrt(ao_two_e_integral(i,i,k,k)), used in ao_two_e_integral_zero
(screening.irp.f) and in the direct Fock build. The _erf version uses the standard (ik|ik).
Why. Since (ik|ik) <= (ii|kk), the test is valid, but (ii|kk) is a Coulomb integral (~1/R_ik for distant AOs):
it never screens anything in the tests below. All the screening comes from the overlap test
ao_overlap_abs(i,k) ao_overlap_abs(j,l) < thr, which is not a bound on (ik|jl): roughly
(ik|jl) ~ S_ik S_jl <1/r12>, and <1/r12> can exceed 1. The standard Cauchy-Schwarz factor sqrt((ik|ik)) is a
rigorous bound and decays like the overlap.
Measurement 1: Kr2, 4.0 Å. Temporary test program: for every unique quartet it evaluates the three tests; for
every quartet dropped by the overlap test but kept by the rigorous bound it computes the exact integral (all
primitive quartets).
cc-pVTZ (98 AOs, 11 768 526 unique quartets):
| thr | dropped: overlap | sqrt((ii|kk)) | sqrt((ik|ik)) | overlap-dropped with abs(v) >= thr | largest dropped | largest/thr |
|---|---|---|---|---|---|---|
| 1e-15 | 585 190 | 0 | 714 847 (+22 %) | 12 | 6.6e-15 | 6.6 |
| 1e-12 | 1 492 042 | 0 | 1 781 172 (+19 %) | 52 | 4.7e-12 | 4.7 |
| 1e-10 | 2 648 588 | 0 | 3 124 231 (+18 %) | 86 | 5.9e-10 | 5.9 |
| 1e-8 | 4 298 131 | 0 | 4 846 958 (+13 %) | 146 | 1.0e-7 | 10.1 |
| 1e-6 | 6 012 100 | 0 | 6 588 217 (+10 %) | 104 | 7.6e-6 | 7.6 |
cc-pVDZ (58 AOs, 1 464 616 quartets): same picture, smaller: sqrt((ii|kk)) drops 0, sqrt((ik|ik)) drops
14–17 % more than the overlap test, and the overlap test drops at most 18 integrals above thr, the largest
2.5 x thr. Over all quartets tested, abs(v)/(S_ik S_jl) reaches 5.8 (DZ) and 13 (TZ).
Measurement 2: (H2O)4 chain, cc-pVDZ, thr 1e-15 (map path, screening switched by a temporary patch):
| test | quartets skipped | skipped with abs(v) >= 1e-15 | largest skipped | integrals kept | CPU | energy |
|---|---|---|---|---|---|---|
| overlap + sqrt((ii|kk)) (now) | 70.2 % | 0 | 5.9e-16 | 2 831 197 | 35.6 s | reference |
| sqrt((ik|ik)) only | 71.0 % | 0 | 1.0e-15 | 2 831 197 | 34.0 s | identical |
Here both tests keep exactly the same integrals (every integral >= thr is computed with either test), so the energy
is identical; only the number of sub-threshold quartets skipped differs.
Remarks.
- The diagonal integrals (ik|ik) must be computed without the primitive Schwarz acceleration (
do_schwartz_accel),
whose absolute threshold sets small diagonals to exactly 0. The Cholesky path already does this
(do_schwartz_accelis false whendo_ao_cholesky). - That primitive acceleration is a larger error source than the screening: on the Kr2 quartets above, the values of
the default path differ from the full primitive sums by up to 3.9e-14 (DZ) and 6.9e-14 (TZ), i.e. up to ~70 x
the default threshold.
Proposal. Replace both the overlap test and sqrt((ii|kk)) by sqrt((ik|ik)) (diagonals without the primitive
acceleration) for real GTOs: rigorous, and 10–22 % more quartets skipped in the tests above. At minimum, the doc of
ao_two_e_integral_schwartz and ao_two_e_integral_zero should not call sqrt((ii|kk)) a Schwarz bound.
Activity
scemama commentedon Nov 18, 2026
Verified, and fixed in #422 (one line). Summary of the check:
The bound as written is not a proven bound on the screened integral.
ao_two_e_integral_zero(i,j,k,l)screens the integral whose electron pairs are(i,k)and(j,l), i.e.(ik|jl)— every call site (Fock loops, Choleskyon-the-fly, map lookups) interleaves the pairs that way. The issue's proposed
inequality
(ik|ik) ≤ (ii|kk)(repeated k, Cauchy–Schwarz between the AOsand the product AO
ik) does hold, but the factor used in the code is thecross-pairing
sqrt((ii|kk))·sqrt((jj|ll)), which is not a bound on(ik|jl).The direct Cauchy–Schwarz bound is
i.e. the self-energy of each product AO. That is the one-line fix:
sqrt(ao_two_e_integral(i,k,i,k))— the same factor the erf matrix alreadyuses (
providers_ao_erf.irp.f), so the two providers now agree.What this buys, measured on B2 @ 3.0 Å (6-31G, 18 AO):
geometries, so at the default threshold 1e-15 it effectively never
triggers there — that is why the impact is low, consistent with the
"severity: low" label;
verified numerically (3-D Gauss–Legendre) on a 4-distinct-primitive grid,
tight within ~1.1×; the old factor is a looser bound in that geometry
(up to ~4000× looser where it does fire);
local_threshold = schwartz(k,l)*schwartz(i,j)is now exactly the CSbound of the quartet's base integral
(kl|ij);threshold_ao = 1e-4(same build, only the provider line flipped):identical SCF energy to all digits (-49.0123445289287) — no observable
change on this system, so the risk of the change is minimal;
B-B_screeninginsrc/hartree_fock/10.hf.bats: SCFat
threshold_ao = 1e-8converges to -48.9950589230371, within 3.8e-7 a.u.of the unscreened reference -48.9950585434279; passes with the default
configuration (Cholesky on).
Two follow-ups noted in #422's description:
ao_two_e_integral_zerodocstring documents(ij|kl); the actualconvention is
(ik|jl). Fixed in ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419) #422.ao_overlap_abs(i,k)*ao_overlap_abs(j,l) < thresholdinthe same function is also not a bound (e.g. two 1s on atoms 5–8 bohr
apart: S² ≈ 1e-15 while the integral is 1.1e-15, at the threshold).
It is a pre-existing heuristic, left untouched in ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419) #422 to keep that PR
one-line; happy to discuss a principled replacement (or its removal,
since the CS bound covers it) in a separate issue.
Merge pull request #422 from QuantumPackage/issue419-schwartz-sameside
ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix #419)
AbdAmmar commentedon Nov 18, 2026
Thanks for the quick fix. One problem remains with #422 on the map path (
do_ao_cholesky = F), the point of thefirst remark in the issue:
ao_two_e_integral(i,k,i,k)goes throughao_two_e_integral_schwartz_accelwhen theproduct of the primitive numbers exceeds 1024. That shortcut skips primitive quartets with an absolute threshold
(
ao_integrals_threshold**2), so small diagonals (ik|ik) come out as exactly 0 (or too small), and the Schwartz testthen drops integrals far above the threshold. With the old factor sqrt((ii|kk)) this could not happen, since (ii|kk)
is never small.
Measured on current
dev-stable(66de718), threshold 1e-15,do_ao_cholesky = F; temporary test program comparingthe provider with the exact sqrt((ik|ik)) (all primitive quartets), and, for every quartet that passes the overlap
test but is dropped by the Schwartz test while its exact bound is >= thr, the exact integral:
(H2O)4, one SCF iteration from the same MOs: 2 796 731 integrals stored with #422 vs 2 831 197 with the previous
line, energy -303.9355174989487 vs -303.9355174993626 (4.1e-10 Ha). Before #422 the stored integrals were exactly
those of the unscreened calculation.
The Cholesky path is not affected (
do_schwartz_accelis false whendo_ao_cholesky), which is why the newB-B_screeningtest (default configuration, Cholesky on, 6-31G) passes.Possible fix: compute the diagonals without the primitive shortcut, e.g. by moving the full primitive sum of
ao_two_e_integralinto its own function and calling it in the provider. This is what the Cholesky diagonal alreadydoes for real GTOs and what #421 does for cGTOs (
ao_two_e_integral_cgtos_prim). A map-path test(
do_ao_cholesky = F) with a basis having more than 1024 primitive quartets, e.g. cc-pVDZ water, would catch it.Minor: sqrt((ii|kk)(jj|ll)) is a valid bound on (ik|jl) (since (ik|ik) <= (ii|kk), exchange <= Coulomb for the
positive-definite 1/r12); it is only useless, as it decays like 1/R.
On the overlap test: the Kr2 numbers in the issue show it drops integrals up to ~10 x thr, and the rigorous test
skips 10–22 % more quartets, so removing it (once the diagonals are exact) seems the cleanest choice.
ao_two_e_ints: same-side Schwartz bound sqrt((ik|ik)) (fix QuantumPac…
AbdAmmar commentedon Nov 19, 2026
Sorry, I closed this by mistake. Reopening: the map-path problem in my previous comment (exact diagonals needed when do_ao_cholesky = F) is still present in dev-stable after #422.
ao_two_e_integral_zero: drop the overlap product test
tests: (H2O)4 chain regression test for the map-path Schwartz fix
Merge pull request #423 from scemama/issue419-map-diagonals
scemama commentedon Nov 19, 2026
Done!
scemama commentedon Nov 19, 2026
Fixed in #423 (merged into dev-stable, 264d3e7). The two remaining points:
Map path (do_ao_cholesky = F). The (ik|ik) diagonals of the Schwartz factors are now summed over all primitive quartets: a new ao_two_e_integral_full (the full-primitive branch of the ao_two_e_integral dispatcher, moved verbatim) is used by the ao_two_e_integral_schwartz provider, so the primitive accelerator's absolute threshold (ao_integrals_threshold**2) can no longer zero the small diagonals. The same fix is applied to the long-range (erf) path, which had the identical defect (ao_two_e_integral_erf_full + the ao_two_e_integral_erf_schwartz provider). The Cholesky path is untouched and bit-identical (do_schwartz_accel is already off there); cGTO was already correct via #421.
Overlap test. Removed from ao_two_e_integral_zero per the issue's proposal: the rigorous CS bound subsumes it at zero cost (the factors are already provided). The (ik|jl) convention and the rigorous CS bound are now documented in ao_two_e_integral_zero (the doc fix that the merge of #422 dropped is restored).
Measured on a new (H2O)4 chain fixture (cc-pVDZ, 100 AOs, threshold 1e-15, map path), same setup as the measurements above: