Skip to content

Commit 884c789

Browse files
committed
Merge branch 'develop' into deepks_unittest
2 parents d589690 + 7d14803 commit 884c789

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

source/module_cell/update_cell.cpp

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -384,41 +384,21 @@ void periodic_boundary_adjustment(Atom* atoms,
384384
// first adjust direct coordinates,
385385
// then update them into cartesian coordinates,
386386
//----------------------------------------------
387-
for (int i=0;i<ntype;i++) {
388-
Atom* atom = &atoms[i];
389-
for (int j=0;j<atom->na;j++) {
390-
printf("the taud is %f %f %f\n",atom->taud[j].x,atom->taud[j].y,atom->taud[j].z);
391-
}
392-
}
393387
for (int it = 0; it < ntype; it++) {
394388
Atom* atom = &atoms[it];
395389
for (int ia = 0; ia < atom->na; ia++) {
396390
// mohan update 2011-03-21
397-
if (atom->taud[ia].x < 0)
391+
for (int ik = 0; ik < 3; ik++)
398392
{
399-
atom->taud[ia].x += 1.0;
400-
}
401-
if (atom->taud[ia].y < 0)
402-
{
403-
atom->taud[ia].y += 1.0;
404-
}
405-
if (atom->taud[ia].z < 0)
406-
{
407-
atom->taud[ia].z += 1.0;
408-
}
409-
if (atom->taud[ia].x >= 1.0)
410-
{
411-
atom->taud[ia].x -= 1.0;
412-
}
413-
if (atom->taud[ia].y >= 1.0)
414-
{
415-
atom->taud[ia].y -= 1.0;
416-
}
417-
if (atom->taud[ia].z >= 1.0)
418-
{
419-
atom->taud[ia].z -= 1.0;
393+
if (atom->taud[ia][ik] < 0)
394+
{
395+
atom->taud[ia][ik] += 1.0;
396+
}
397+
if (atom->taud[ia][ik] >= 1.0)
398+
{
399+
atom->taud[ia][ik] -= 1.0;
400+
}
420401
}
421-
422402
if (atom->taud[ia].x < 0
423403
|| atom->taud[ia].y < 0
424404
|| atom->taud[ia].z < 0

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_lcao/module_deepks/LCAO_deepks_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
6969

7070
if (PARAM.inp.deepks_bandgap)
7171
{
72-
const int nocc = PARAM.inp.nelec / 2;
72+
const int nocc = (PARAM.inp.nelec+1) / 2;
7373
std::vector<double> o_tot(nks);
7474
for (int iks = 0; iks < nks; ++iks)
7575
{

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)