Skip to content

fxc contraction: Laplacian-dependent meta-GGAs (RKS and UKS) - #231

Open
susilehtola wants to merge 3 commits into
wavefunction91:masterfrom
susilehtola:fxc-laplacian
Open

susilehtola wants to merge 3 commits into
wavefunction91:masterfrom
susilehtola:fxc-laplacian

Conversation

@susilehtola

Copy link
Copy Markdown
Contributor

Depends on #226 (same file); until that merges, this diff also shows
its two commits.

eval_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
take the unchanged path.

The host work-driver signature of eval_tmat_mgga_vxc_{rks,uks} gains
tlapl and D; 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:

functional RKS UKS
BR89 (tau + lapl) 1.1e-6 -> 2.8e-7 -> 7.0e-8 7.2e-6 -> 1.8e-6 -> 4.5e-7
B94 correlation (all cross-spin lapl blocks nonzero) 2.0e-6 -> 4.9e-7 -> 1.2e-7 7.7e-6 -> 1.9e-6 -> 4.8e-7
Colle-Salvetti 9.7e-7 1.3e-6

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

susilehtola and others added 3 commits September 15, 2026 10:20
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant