Repository navigation
Implement UKS nuclear gradients for Laplacian-dependent meta-GGAs - #229
Merged
wavefunction91 merged 1 commit intoNov 25, 2026
Merged
wavefunction91 merged 1 commit into
wavefunction91 merged 1 commit into
Conversation
exc_grad refused the spin-polarized case outright: "UKS Gradients + Laplacian Dependent MGGAs is Not Yet Implemented" Everything below the assembly was already in place -- eval_uvvar_mgga_uks computes lapl for both spins, and lapl/vlapl are allocated per spin -- so only the gradient assembly and the guard were missing. The spin transformation mirrors the LDA, GGA and tau blocks around it: rho_alpha = (rho_s + rho_z)/2, hence the 0.5 (v+ + v-) N + 0.5 (v+ - v-) Z combination, with fac P lapl(B) built for both the scalar and the spin density. One trap: the tau branch immediately above reassigns d2_term_* to the Z hessian term when polarized, and the laplacian block consumed it. Reusing it here would have paired the Z hessian term with the N laplacian contribution. This block now rebuilds hN_* and hZ_* explicitly instead. Verified against a central difference of eval_exc over a displaced molecule and displaced basis, cytosine (doublet) / cc-pVDZ / UltraFine, MGGA_X_R2SCANL+MGGA_C_R2SCANL, atom 0: d/dx analytic -1.5224974586e-01 FD -1.5224974458e-01 rel 8.4e-09 d/dy analytic 3.3558979268e-01 FD 3.3558978846e-01 rel 1.3e-08 d/dz both zero to 1e-10 (planar) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
wavefunction91
force-pushed
the
uks-laplacian-mgga-exc-grad
branch
from
November 25, 2026 19:03
3e035f8 to
0ee264b
Compare
wavefunction91
added a commit
to susilehtola/GauXC
that referenced
this pull request
Nov 25, 2026
Adds artifacts for wavefunction91#174, wavefunction91#224, wavefunction91#230, wavefunction91#210 and wavefunction91#229, and cross-cutting findings (the wavefunction91#218 root cause in wavefunction91#224, the gau2grid l>=4 third-derivative bug, and eval_exc_grad heap corruption for off-atom shells). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wavefunction91
added a commit
to susilehtola/GauXC
that referenced
this pull request
Nov 25, 2026
… merged; wavefunction91#229 needs rebase, revise C1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wavefunction91
added a commit
to susilehtola/GauXC
that referenced
this pull request
Nov 25, 2026
… bitwise-identical) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wavefunction91
force-pushed
the
uks-laplacian-mgga-exc-grad
branch
from
November 25, 2026 19:34
0ee264b to
e305e2b
Compare
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.
Builds on #228 (the Laplacian gradient fix); review that first, or this diff will
look like it contains both.
What
eval_exc_gradrefused the spin-polarized case outright:Everything below the assembly was already in place —
eval_uvvar_mgga_ukscomputes
laplfor both spins (lapls,laplz, split intolapl[2i]/lapl[2i+1]), andlapl/vlaplare allocated per spin — so only the gradientassembly and the guard were missing.
How
The spin transformation mirrors the LDA, GGA and tau blocks around it:
rho_alpha = (rho_s + rho_z)/2, hence0.5 (v+ + v-) N + 0.5 (v+ - v-) Z, withfac P lapl(B)built for both thescalar and the spin density (
xLmat,xZLmat; the extra blocks already fit inhost_data.zmat, which is sized5 * spin_dim_scalwhenneeds_laplacian).One trap worth flagging for review: the tau branch immediately above
reassigns
d2_term_*to the Z hessian term when polarized, and thelaplacian block consumed it directly. Reusing it would have paired the Z hessian
term with the N laplacian contribution — a wrong-index bug of exactly the kind
#228 fixes, sitting behind the exception. This block rebuilds
hN_*andhZ_*explicitly instead.
Verification
eval_exc_gradagainst a central difference ofeval_excover a displacedmolecule and displaced basis, so the grid and its partition weights ride on
the atoms and the comparison shares no algebra with the gradient code.
Cytosine (doublet) / cc-pVDZ / UltraFine,
MGGA_X_R2SCANL+MGGA_C_R2SCANL,atom 0, h = 1e-4:
RKS is unchanged and still verifies at 1.6e-09 (BR89) / 9.4e-08 (r2SCANL).
gauxc_test: all 3640979 assertions in 56 test cases pass.Not covered
The device path keeps its own, separate restriction
(
"Device EXC Gradients + Laplacian Dependent MGGAs Not Yet Implemented"),which this does not touch.
🤖 Generated with Claude Code