Feature: Enable correct Laplacian-dependent meta-GGA calculations - #7820
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes corruption in the Laplacian-dependent meta-GGA (e.g., SCAN-L) XC potential path by separating real-space and reciprocal-space buffers during the ∇²(v_lapl) FFT workflow, enabling correct use of Libxc functionals flagged with XC_FLAGS_NEEDS_LAPLACIAN.
Changes:
- Fix Laplacian-potential FFT workflow in
libxc_pot.cppby using distinct real-space (lapl_r) and reciprocal-space (lapl_g) arrays. - Update SCAN-L PW integration test reference outputs to reflect corrected physics.
- Relax/adjust SCAN-L test thresholds to cover numerical differences across supported Libxc versions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
source/source_hamilt/module_xc/libxc_pot.cpp |
Fixes the Laplacian-dependent potential FFT path to avoid overwriting real-space data before the forward FFT. |
source/source_hamilt/module_xc/test/xc3_mock.h |
Extends the FFT mock to support complex→real recip2real needed by the updated Laplacian-potential path. |
tests/01_PW/207_PW_SCANL/result.ref |
Updates SCAN-L integration test reference values consistent with the corrected Laplacian potential contribution. |
tests/01_PW/207_PW_SCANL/threshold |
Adjusts thresholds to tolerate Libxc-version-dependent numerical differences for SCAN-L. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mohanchen
approved these changes
Aug 14, 2026
Collaborator
|
This is an important fix! |
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.
Linked Issue
This PR is a follow-up to #7457, which introduced the energy, potential, and stress paths required by Laplacian-dependent meta-GGA functionals.
Fixes #7813.
What's changed?
Summary
This PR fixes the remaining corruption in the Laplacian-potential FFT path. With this correction, SCAN-L and other Libxc meta-GGA functionals marked with
XC_FLAGS_NEEDS_LAPLACIANcan use the shared Laplacian-dependent implementation correctly.Root cause
The code added in #7457 reused one complex array for both the real-space and reciprocal-space representations of the Laplacian potential. It first filled
nrxxreal-space values, but then cleared the range fromnpwtonmaxgras if the same array already contained reciprocal-space coefficients. Sincenpwis normally smaller thannrxx, this erased valid real-space data before the forward FFT. The resulting∇²v_laplcontribution to the self-consistent XC potential was therefore corrupted.Finite-difference validation at 50 Ry
The correction was validated by comparing analytic stress with central finite differences of the total energy for all six independent stress components:
xx,yy,zz,xy,xz, andyz.