Skip to content

Feature: Enable correct Laplacian-dependent meta-GGA calculations - #7820

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:fix/scanl-stress
Aug 14, 2026
Merged

Feature: Enable correct Laplacian-dependent meta-GGA calculations#7820
mohanchen merged 2 commits into
deepmodeling:developfrom
AsTonyshment:fix/scanl-stress

Conversation

@AsTonyshment

Copy link
Copy Markdown
Collaborator

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_LAPLACIAN can 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 nrxx real-space values, but then cleared the range from npw to nmaxgr as if the same array already contained reciprocal-space coefficients. Since npw is normally smaller than nrxx, this erased valid real-space data before the forward FFT. The resulting ∇²v_lapl contribution 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, and yz.

  • System: Si-2
  • Basis types: PW and LCAO
  • Functionals: PBE, r²SCAN, and SCAN-L before and after this fix
  • Wave-function cutoff: 50 Ry
  • Strain magnitude: ±0.005
image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cpp by 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.

Comment thread source/source_hamilt/module_xc/test/xc3_mock.h Outdated
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Aug 14, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

This is an important fix!

@mohanchen
mohanchen merged commit 65a5039 into deepmodeling:develop Aug 14, 2026
17 checks passed
@AsTonyshment
AsTonyshment deleted the fix/scanl-stress branch August 14, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate large SCAN-L shear-stress residuals in finite-difference validation

3 participants