Skip to content

Commit

Permalink
Merge branch 'develop' into blas_gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
Critsium-xy authored Jan 3, 2025
2 parents d03b7b6 + 7d14803 commit 9ff2ce5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
38 changes: 9 additions & 29 deletions source/module_cell/update_cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,41 +384,21 @@ void periodic_boundary_adjustment(Atom* atoms,
// first adjust direct coordinates,
// then update them into cartesian coordinates,
//----------------------------------------------
for (int i=0;i<ntype;i++) {
Atom* atom = &atoms[i];
for (int j=0;j<atom->na;j++) {
printf("the taud is %f %f %f\n",atom->taud[j].x,atom->taud[j].y,atom->taud[j].z);
}
}
for (int it = 0; it < ntype; it++) {
Atom* atom = &atoms[it];
for (int ia = 0; ia < atom->na; ia++) {
// mohan update 2011-03-21
if (atom->taud[ia].x < 0)
for (int ik = 0; ik < 3; ik++)
{
atom->taud[ia].x += 1.0;
}
if (atom->taud[ia].y < 0)
{
atom->taud[ia].y += 1.0;
}
if (atom->taud[ia].z < 0)
{
atom->taud[ia].z += 1.0;
}
if (atom->taud[ia].x >= 1.0)
{
atom->taud[ia].x -= 1.0;
}
if (atom->taud[ia].y >= 1.0)
{
atom->taud[ia].y -= 1.0;
}
if (atom->taud[ia].z >= 1.0)
{
atom->taud[ia].z -= 1.0;
if (atom->taud[ia][ik] < 0)
{
atom->taud[ia][ik] += 1.0;
}
if (atom->taud[ia][ik] >= 1.0)
{
atom->taud[ia][ik] -= 1.0;
}
}

if (atom->taud[ia].x < 0
|| atom->taud[ia].y < 0
|| atom->taud[ia].z < 0
Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)

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

this->pw_wfc->initgrids(ucell.lat0, ucell.latvec, this->pw_wfc->nx, this->pw_wfc->ny, this->pw_wfc->nz);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,

if (PARAM.inp.deepks_bandgap)
{
const int nocc = PARAM.inp.nelec / 2;
const int nocc = (PARAM.inp.nelec+1) / 2;
std::vector<double> o_tot(nks);
for (int iks = 0; iks < nks; ++iks)
{
Expand Down
23 changes: 23 additions & 0 deletions source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ void pseudopot_cell_vnl::init_vnl(UnitCell& cell, const ModulePW::PW_Basis* rho_
ModuleBase::TITLE("pseudopot_cell_vnl", "init_vnl");
ModuleBase::timer::tick("ppcell_vnl", "init_vnl");

this->omega_old = cell.omega;

// from init_us_1
// a) For each non vanderbilt pseudopotential it computes the D and
// the betar in the same form of the Vanderbilt pseudopotential.
Expand Down Expand Up @@ -1733,6 +1735,27 @@ void pseudopot_cell_vnl::newd_nc(const int& iat, UnitCell& cell)
}
}

// scale the non-local pseudopotential tables
void pseudopot_cell_vnl::rescale_vnl(const double& omega_in)
{
const double ratio = this->omega_old / omega_in;
const double sqrt_ratio = std::sqrt(ratio);
this->omega_old = omega_in;

for (int i = 0; i < this->tab.getSize(); i++)
{
this->tab.ptr[i] *= sqrt_ratio;
}
for (int i = 0; i < this->tab_at.getSize(); i++)
{
this->tab_at.ptr[i] *= sqrt_ratio;
}
for (int i = 0; i < this->qrad.getSize(); i++)
{
this->qrad.ptr[i] *= ratio;
}
}

template <>
float* pseudopot_cell_vnl::get_nhtol_data() const
{
Expand Down
4 changes: 4 additions & 0 deletions source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class pseudopot_cell_vnl

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

void rescale_vnl(const double& omega_in);

template <typename FPTYPE, typename Device>
void getvnl(Device* ctx, const UnitCell& ucell, const int& ik, std::complex<FPTYPE>* vkb_in) const;

Expand Down Expand Up @@ -200,6 +202,8 @@ class pseudopot_cell_vnl

Soc soc;

double omega_old = 0;

/**
* @brief Compute interpolation table qrad
*
Expand Down

0 comments on commit 9ff2ce5

Please sign in to comment.