Skip to content

Commit e14b77d

Browse files
author
dyzheng
committed
Fix(xc): disable SF builtin dispatch for gga_grad=3
SF builtin (xc_functional_gga_noncol_sf_builtin.cpp) produces non-convergent results with varying ecutwfc due to numerical instability from independent FFT sequence divergence. gga_grad=3 - gga_grad=1: ecut=20: -0.071 eV ecut=35: -0.003 eV ecut=50: +0.291 eV (sign flip!) Remove dispatch from v_xc so gga_grad=3 falls through to the numerically stable gradcorr path. SF builtin implementation retained for future debugging. Also fix gcc_spin guard and zeta clipping in SF builtin to match gradcorr conventions (prep for future re-enablement).
1 parent 7b07f9f commit e14b77d

2 files changed

Lines changed: 2 additions & 21 deletions

File tree

source/source_hamilt/module_xc/xc_functional_gga_noncol_sf_builtin.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,8 @@ std::tuple<double, double, ModuleBase::matrix> v_xc_ncgga_sf_builtin(
135135
{
136136
double zeta = (rhotmp1[ir] - rhotmp2[ir]) / rh;
137137
zeta = std::fabs(zeta);
138-
if (zeta > 1.0 - epsr)
139-
zeta = 1.0 - epsr;
140138
const double grh2 = (gdr1[ir] + gdr2[ir]) * (gdr1[ir] + gdr2[ir]);
141-
if (std::sqrt(std::abs(grh2)) > 1e-10)
142-
{
143-
XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c);
144-
}
139+
XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c);
145140
}
146141

147142
vup_gga[ir] = e2 * (v1xup + v1cup);
@@ -287,13 +282,8 @@ void gradcorr_ncgga_sf_builtin(const Charge* const chr, ModulePW::PW_Basis* rhop
287282
{
288283
double zeta = (rhotmp1[ir] - rhotmp2[ir]) / rh;
289284
zeta = std::fabs(zeta);
290-
if (zeta > 1.0 - epsr)
291-
zeta = 1.0 - epsr;
292285
const double grh2 = (gdr1[ir] + gdr2[ir]) * (gdr1[ir] + gdr2[ir]);
293-
if (std::sqrt(std::abs(grh2)) > small)
294-
{
295-
XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c);
296-
}
286+
XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c);
297287
v2cup = v2c;
298288
v2cdw = v2c;
299289
v2cud = v2c;

source/source_hamilt/module_xc/xc_functional_vxc.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,6 @@ std::tuple<double, double, ModuleBase::matrix> XC_Functional::v_xc(const int& nr
2222
{
2323
ModuleBase::TITLE("XC_Functional", "v_xc");
2424

25-
if (PARAM.inp.nspin == 4 && (PARAM.globalv.domag || PARAM.globalv.domag_z) && PARAM.inp.gga_grad == 3)
26-
{
27-
const int ft = XC_Functional::get_func_type();
28-
if (ft == 2 || ft == 4)
29-
{
30-
return ModuleXC::NCGGA_SF_Builtin::v_xc_ncgga_sf_builtin(nrxx, ucell->omega, ucell->tpiba, chr);
31-
}
32-
}
33-
3425
if (use_libxc)
3526
{
3627
#ifdef USE_LIBXC

0 commit comments

Comments
 (0)