Skip to content

Commit 94a52d5

Browse files
authored
Fix: large smearing_sigma would lead to occupations of band less than 0, the cutoff should be careful (#1835)
1 parent ad34732 commit 94a52d5

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

source/module_elecstate/elecstate_pw.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ void ElecStatePW<FPTYPE, Device>::rhoBandK(const psi::Psi<std::complex<FPTYPE>,
151151
{
152152
///
153153
/// only occupied band should be calculated.
154+
/// be care of when smearing_sigma is large, wg would less than 0
154155
///
155-
if (this->wg(ik, ibnd) < threshold) {
156+
if (std::fabs(this->wg(ik, ibnd)) < threshold) {
156157
continue;
157158
}
158159

source/module_hamilt_pw/hamilt_pwdft/forces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ void Forces<FPTYPE, Device>::cal_force_nl(ModuleBase::matrix& forcenl, const Mod
978978
///
979979
int nbands_occ = GlobalV::NBANDS;
980980
const double threshold = ModuleBase::threshold_wg * wg(ik, 0);
981-
while (wg(ik, nbands_occ - 1) < threshold)
981+
while (std::fabs(wg(ik, nbands_occ - 1)) < threshold)
982982
{
983983
nbands_occ--;
984984
if(nbands_occ == 0)

source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ void Stress_Func<FPTYPE, Device>::stress_kin(ModuleBase::matrix& sigma, const Mo
5050
{
5151
for(int ibnd=0;ibnd<GlobalV::NBANDS;ibnd++)
5252
{
53+
if( std::fabs(wg(ik, ibnd)) < ModuleBase::threshold_wg * wg(ik, 0) ) continue;
5354
const std::complex<FPTYPE>* ppsi=nullptr;
5455
if(psi_in!=nullptr)
5556
{

source/module_hamilt_pw/hamilt_pwdft/stress_func_nl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void Stress_Func<FPTYPE, Device>::stress_nl(ModuleBase::matrix& sigma, const Mod
120120
///
121121
int nbands_occ = GlobalV::NBANDS;
122122
const double threshold = ModuleBase::threshold_wg * wg(ik, 0);
123-
while(wg(ik, nbands_occ - 1) < threshold)
123+
while(std::fabs(wg(ik, nbands_occ - 1)) < threshold)
124124
{
125125
nbands_occ--;
126126
if(nbands_occ == 0)

0 commit comments

Comments
 (0)