Skip to content

Commit

Permalink
fix single precision md bug (#3481)
Browse files Browse the repository at this point in the history
Co-authored-by: Qianrui Liu <[email protected]>
  • Loading branch information
denghuilu and Qianruipku authored Jan 13, 2024
1 parent 781e533 commit e135c71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/module_hsolver/hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,12 @@ typename HSolverPW<T, Device>::Real HSolverPW<T, Device>::reset_diagethr(std::of
ofs_running << " hsover_error=" << hsover_error << " > DRHO=" << drho << std::endl;
ofs_running << " Origin diag_ethr = " << this->diag_ethr << std::endl;
this->diag_ethr = 0.1 * drho / GlobalV::nelec;
// It is essential for single precision implementation to keep the diag_ethr value
// less or equal to the single-precision limit of convergence(0.5e-4).
// modified by denghuilu at 2023-05-15
if (GlobalV::precision_flag == "single") {
this->diag_ethr = std::max(this->diag_ethr, static_cast<Real>(0.5e-4));
}
ofs_running << " New diag_ethr = " << this->diag_ethr << std::endl;
return this->diag_ethr;
}
Expand Down

0 comments on commit e135c71

Please sign in to comment.