Skip to content

Commit

Permalink
Fix: enable force and stress in uspp nscf
Browse files Browse the repository at this point in the history
  • Loading branch information
YuLiu98 committed Dec 23, 2024
1 parent 178c24c commit 9c46b77
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion source/module_elecstate/elecstate_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
}

template <typename T, typename Device>
void ElecStatePW<T, Device>::add_usrho(const psi::Psi<T, Device>& psi)
void ElecStatePW<T, Device>::cal_becsum(const psi::Psi<T, Device>& psi)
{
const T one{1, 0};
const T zero{0, 0};
Expand Down Expand Up @@ -392,6 +392,12 @@ void ElecStatePW<T, Device>::add_usrho(const psi::Psi<T, Device>& psi)
}
}
delmem_complex_op()(this->ctx, becp);
}

template <typename T, typename Device>
void ElecStatePW<T, Device>::add_usrho(const psi::Psi<T, Device>& psi)
{
this->cal_becsum(psi);

// transform soft charge to recip space using smooth grids
T* rhog = nullptr;
Expand Down
5 changes: 4 additions & 1 deletion source/module_elecstate/elecstate_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ElecStatePW : public ElecState

virtual void cal_tau(const psi::Psi<T, Device>& psi);

//! calculate becsum for uspp
void cal_becsum(const psi::Psi<T, Device>& psi);

Real* becsum = nullptr;

//! init rho_data and kin_r_data
Expand All @@ -61,7 +64,7 @@ class ElecStatePW : public ElecState

//! calcualte rho for each k
void rhoBandK(const psi::Psi<T, Device>& psi);

//! add to the charge density in reciprocal space the part which is due to the US augmentation.
void add_usrho(const psi::Psi<T, Device>& psi);

Expand Down
4 changes: 4 additions & 0 deletions source/module_hsolver/hsolver_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ void HSolverLIP<T>::solve(hamilt::Hamilt<T>* pHamilt, // ESolver_KS_PW::p_hamilt
reinterpret_cast<elecstate::ElecStatePW<T>*>(pes)->calEBand();
if (skip_charge)
{
if (PARAM.globalv.use_uspp)
{
reinterpret_cast<elecstate::ElecStatePW<T>*>(pes)->cal_becsum(psi);
}
ModuleBase::timer::tick("HSolverLIP", "solve");
return;
}
Expand Down
4 changes: 4 additions & 0 deletions source/module_hsolver/hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
reinterpret_cast<elecstate::ElecStatePW<T>*>(pes)->calEBand();
if (skip_charge)
{
if (PARAM.globalv.use_uspp)
{
reinterpret_cast<elecstate::ElecStatePW<T, Device>*>(pes)->cal_becsum(psi);
}
ModuleBase::timer::tick("HSolverPW", "solve");
return;
}
Expand Down

0 comments on commit 9c46b77

Please sign in to comment.