You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix(module_xc): compute real density laplacian for meta-GGA functionals via reciprocal space
SCANL, R2SCANL, and REVSCAN require the density laplacian (∇²ρ) but
v_xc_meta was passing |∇ρ|² (sigma) instead. This caused ~150 kbar
stress error for Na with SCANL vs SCAN.
Laplacian computation method:
∇²ρ(r) = -∑_G |G|² ρ(G) e^{iGr}
- ρ(r) is Fourier-transformed to ρ(G) via real2recip()
- Each G-component is multiplied by -|G|² (i.e. -gg[ig] * tpiba²)
- Inverse FFT via recip2real() yields ∇²ρ(r) on the real-space grid
- Only the real part is retained (imaginary part should be ~0 for real ρ)
This is exact within the plane-wave basis, not numerical differentiation.
Spin handling:
- cal_lapl(nspin, nrxx, rho, tpiba2, chr) computes ∇²ρ for each spin
channel: rho is interleaved [rho_up[0], rho_dw[0], rho_up[1], ...]
and output lapl is [lapl_up[0], lapl_dw[0], lapl_up[1], ...]
- nspin=1: single channel (spin-unpolarized), loop runs once for is=0
- nspin=2: separate laplacian for spin-up and spin-down channels,
each computed independently from its own real-space density
- nspin=4 (noncollinear): effective up/down densities are constructed
via noncolin_rho() diagonalization of the spin density matrix,
then ∇²ρ is computed for each effective channel
Changes:
- Add cal_lapl() in xc_functional_libxc_tools.cpp as reusable function
for reciprocal-space Laplacian computation per spin channel
- Fix v_xc_meta to call cal_lapl() and pass real laplacian to LibXC;
handle vlapl output by computing ∇²(vlapl) via same G-space method
- Fix tau_xc wrapper — added lapl_rho parameter, removed grho hack
- Fix tau_xc_spin wrapper — initialize lapl array to zero instead of
leaving uninitialized
- Fix gradcorr stress/force paths — replace ~50 lines of duplicated
inline Laplacian code with cal_lapl() calls; handles nspin=1/2/4
spin channel selection consistently with existing grad_rho pattern
- Update test_xc4.cpp and test CMakeLists for new tau_xc signature
0 commit comments