Skip to content

Commit 7d14803

Browse files
authored
Fix: instable nonlocal pp in uspp (#5798)
1 parent cecf36a commit 7d14803

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
255255

256256
if (ucell.cell_parameter_updated)
257257
{
258-
this->ppcell.init_vnl(ucell, this->pw_rhod);
258+
this->ppcell.rescale_vnl(ucell.omega);
259259
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL");
260260

261261
this->pw_wfc->initgrids(ucell.lat0, ucell.latvec, this->pw_wfc->nx, this->pw_wfc->ny, this->pw_wfc->nz);

source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ void pseudopot_cell_vnl::init_vnl(UnitCell& cell, const ModulePW::PW_Basis* rho_
550550
ModuleBase::TITLE("pseudopot_cell_vnl", "init_vnl");
551551
ModuleBase::timer::tick("ppcell_vnl", "init_vnl");
552552

553+
this->omega_old = cell.omega;
554+
553555
// from init_us_1
554556
// a) For each non vanderbilt pseudopotential it computes the D and
555557
// the betar in the same form of the Vanderbilt pseudopotential.
@@ -1733,6 +1735,27 @@ void pseudopot_cell_vnl::newd_nc(const int& iat, UnitCell& cell)
17331735
}
17341736
}
17351737

1738+
// scale the non-local pseudopotential tables
1739+
void pseudopot_cell_vnl::rescale_vnl(const double& omega_in)
1740+
{
1741+
const double ratio = this->omega_old / omega_in;
1742+
const double sqrt_ratio = std::sqrt(ratio);
1743+
this->omega_old = omega_in;
1744+
1745+
for (int i = 0; i < this->tab.getSize(); i++)
1746+
{
1747+
this->tab.ptr[i] *= sqrt_ratio;
1748+
}
1749+
for (int i = 0; i < this->tab_at.getSize(); i++)
1750+
{
1751+
this->tab_at.ptr[i] *= sqrt_ratio;
1752+
}
1753+
for (int i = 0; i < this->qrad.getSize(); i++)
1754+
{
1755+
this->qrad.ptr[i] *= ratio;
1756+
}
1757+
}
1758+
17361759
template <>
17371760
float* pseudopot_cell_vnl::get_nhtol_data() const
17381761
{

source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class pseudopot_cell_vnl
3636

3737
void init_vnl(UnitCell& cell, const ModulePW::PW_Basis* rho_basis);
3838

39+
void rescale_vnl(const double& omega_in);
40+
3941
template <typename FPTYPE, typename Device>
4042
void getvnl(Device* ctx, const UnitCell& ucell, const int& ik, std::complex<FPTYPE>* vkb_in) const;
4143

@@ -200,6 +202,8 @@ class pseudopot_cell_vnl
200202

201203
Soc soc;
202204

205+
double omega_old = 0;
206+
203207
/**
204208
* @brief Compute interpolation table qrad
205209
*

0 commit comments

Comments
 (0)