fxc contraction: Laplacian-dependent meta-GGAs (RKS and UKS) - #231
Open
susilehtola wants to merge 3 commits into
Open
susilehtola wants to merge 3 commits into
susilehtola wants to merge 3 commits into
Conversation
Address review feedback on wavefunction91#226. Tests: the stored trial densities in the reference data are exactly symmetric, so the existing FXC reference comparison cannot detect how a non-symmetric trial density is handled -- which is why it passed throughout wavefunction91#225. For every functional, spin case and backend exercised by test_fxc_contractioin, build a non-symmetric trial matrix M whose symmetric part is bitwise the stored trial density (strict upper triangle doubled, lower zeroed), and check that * F[M] reproduces the stored FXC reference, and * F[(M - M^T)/2] vanishes. Without the symmetrization fix, all 12 new checks for PBE0, SCAN (RKS) and BLYP, SCAN (UKS) fail by 4e-4..3e-3 against a 1e-10 tolerance, while the LDA sections and all pre-existing checks still pass. With the fix, all 44 assertions pass (host build). Docs: state at the public C++ and C API entry points that the kernel is contracted with the symmetric part of the trial density, and that a linear-response caller must pass P1 = T + T^T; a one-sided transition density yields half that response. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sk6Km8XjNxNU8wyRDQ8sxx
The host fxc contraction threw for functionals that need the density
Laplacian. eval_tmat_mgga_vxc_{rks,uks} now take the trial Laplacian and
return a fourth channel D = delta v_lapl; the trial Laplacian also enters
A, B and C through v2rholapl, v2gammalapl and v2lapltau. D is assembled
exactly where the ground-state potential puts v_lapl: D lapl(chi) in the
Z matrix and D grad(chi) in the M matrices. Functionals without a
Laplacian pass null second-derivative pointers and are unchanged.
Checked against central differences of the potential,
F[X] = d/dh VXC(P + hX), on benzene/cc-pVDZ (UltraFine), RKS and UKS
(spin-polarized reference, independent s/z trial matrices):
BR89 (tau + lapl) RKS 1.1e-6 -> 2.8e-7 -> 7.0e-8 UKS 7.2e-6 -> 1.8e-6 -> 4.5e-7
B94 corr. (tau + lapl, RKS 2.0e-6 -> 4.9e-7 -> 1.2e-7 UKS 7.7e-6 -> 1.9e-6 -> 4.8e-7
all cross-spin blocks)
Colle-Salvetti RKS 9.7e-7 UKS 1.3e-6
as the step halves -- the h^2 truncation of the reference -- and
Tr(X F[Y]) = Tr(Y F[X]) to 3e-15. TPSS and PBE are unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0135evJ9zgNL1y8U6T9bQ3UT
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.
Depends on #226 (same file); until that merges, this diff also shows
its two commits.
eval_fxc_contractionthrew for functionals that need the densityLaplacian.
eval_tmat_mgga_vxc_{rks,uks}now take the trial Laplacianand return a fourth channel D = delta v_lapl; the trial Laplacian also
enters A, B and C through
v2rholapl,v2gammalaplandv2lapltau.D is assembled exactly where the ground-state potential puts
v_lapl:D lapl(chi) in the Z matrix and D grad(chi) in the M matrices.
Functionals without a Laplacian pass null second-derivative pointers and
take the unchanged path.
The host work-driver signature of
eval_tmat_mgga_vxc_{rks,uks}gainstlaplandD; the fxc contraction is its only caller.Validation
Benzene / cc-pVDZ, UltraFine, against central differences of the
potential, F[X] = d/dh VXC(P + hX); UKS uses a spin-polarized reference
and independent s/z trial matrices. Relative max error as the step halves:
The clean factor-4 decrease is the h^2 truncation of the reference.
Tr(X F[Y]) = Tr(Y F[X]) to 3e-15; TPSS and PBE results are unchanged.
Two functionals are poor references and were not used: BR89_EXPLICIT
(a piecewise fit whose second derivatives jump, so its error grows as
the step shrinks) and r2SCAN-L (converges, then reaches FD noise at
5e-5 RKS / 8e-4 UKS).
🤖 Generated with Claude Code
https://claude.ai/code/session_0135evJ9zgNL1y8U6T9bQ3UT