Skip to content

Commit 41985fe

Browse files
committed
fix(xc): restore func_type check in gradcorr stress path for mGGA
The previous commit (XC_FLAGS_NEEDS_LAPLACIAN) incorrectly replaced 'func_type == 3 || func_type == 5' with 'need_laplacian' in the stress path of gradcorr(). This caused SCAN (func_type=3, need_laplacian=false) to call gcxc_libxc instead of tau_xc, losing the tau-dependent v2xc and making the GGA stress contribution zero. Fix: use func_type check for selecting tau_xc vs gcxc_libxc (all mGGA functionals need tau_xc), and need_laplacian only for Laplacian computation and vlapl stress contribution. SCAN PW stress FD: error reduced from 41.3% to 0.45%.
1 parent c6f0d57 commit 41985fe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

source/source_hamilt/module_xc/xc_grad.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void XC_Functional::gradcorr(
475475
if (use_libxc && is_stress)
476476
{
477477
#ifdef USE_LIBXC
478-
if(need_laplacian)
478+
if(func_type == 3 || func_type == 5)
479479
{
480480
double v3xc = 0.0;
481481
double vlapl = 0.0;
@@ -540,7 +540,7 @@ void XC_Functional::gradcorr(
540540
double v2xcup = 0.0;
541541
double v2xcdw = 0.0;
542542
double v2xcud = 0.0;
543-
if(need_laplacian)
543+
if(func_type == 3 || func_type == 5)
544544
{
545545
double v3xcup = 0.0;
546546
double v3xcdw = 0.0;

0 commit comments

Comments
 (0)