Skip to content

Commit 7b8d46f

Browse files
author
dyzheng
committed
Fix: UnitTest HSolver_PW
1 parent a11d1fe commit 7b8d46f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

source/module_hsolver/hsolver_pw.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ void HSolverPW<T, Device>::cal_ethr_band(const double& wk, const double* wg, con
214214
{
215215
if(wk > 0.0)
216216
{
217+
// Note: the idea of threshold for unoccupied bands (1e-5) comes from QE
218+
// In ABACUS, We applied a smoothing process to this truncation to avoid abrupt changes in energy errors between different bands.
217219
const double ethr_unocc = std::max(1e-5, ethr);
218220
for (int i = 0; i < ethrs.size(); i++)
219221
{
@@ -223,7 +225,7 @@ void HSolverPW<T, Device>::cal_ethr_band(const double& wk, const double* wg, con
223225
ethrs[i] = ethr;
224226
}
225227
else if(band_weight > 1e-5)
226-
{// similar energy difference for difsferent bands
228+
{// similar energy difference for different bands when band_weight in range [1e-5, 1e-2]
227229
ethrs[i] = std::min(ethr_unocc, ethr / band_weight);
228230
}
229231
else
@@ -282,10 +284,16 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
282284

283285
// template add precondition calculating here
284286
update_precondition(precondition, ik, this->wfc_basis->npwk[ik]);
285-
this->cal_ethr_band(pes->klist->wk[ik],
287+
288+
// only dav_subspace method used smooth threshold for all bands now,
289+
// for other methods, this trick can be added in the future to accelerate calculation without accuracy loss.
290+
if (this->method == "dav_subspace")
291+
{
292+
this->cal_ethr_band(pes->klist->wk[ik],
286293
&pes->wg(ik, 0),
287294
DiagoIterAssist<T, Device>::PW_DIAG_THR,
288295
ethr_band);
296+
}
289297

290298
#ifdef USE_PAW
291299
this->call_paw_cell_set_currentk(ik);

0 commit comments

Comments
 (0)