Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/module_hsolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ list(APPEND objects
diago_david.cpp
diago_dav_subspace.cpp
diago_bpcg.cpp
pawcode_in_hsolverpw.cpp
hsolver_pw.cpp
hsolver_lcaopw.cpp
hsolver_pw_sdft.cpp
Expand Down
70 changes: 5 additions & 65 deletions source/module_hsolver/hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,76 +21,16 @@
#ifdef USE_PAW
#include "module_cell/module_paw/paw_cell.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
// #include "module_base/parallel_global.h" // for MPI
// #include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h"
#endif

namespace hsolver
{

#ifdef USE_PAW
template <typename T, typename Device>
void HSolverPW<T, Device>::paw_func_in_kloop(const int ik)
{
if (this->use_paw)
{
const int npw = this->wfc_basis->npwk[ik];
ModuleBase::Vector3<double>* _gk = new ModuleBase::Vector3<double>[npw];
for (int ig = 0; ig < npw; ig++)
{
_gk[ig] = this->wfc_basis->getgpluskcar(ik, ig);
}

std::vector<double> kpt(3, 0);
kpt[0] = this->wfc_basis->kvec_c[ik].x;
kpt[1] = this->wfc_basis->kvec_c[ik].y;
kpt[2] = this->wfc_basis->kvec_c[ik].z;

double** kpg;
double** gcar;
kpg = new double*[npw];
gcar = new double*[npw];
for (int ipw = 0; ipw < npw; ipw++)
{
kpg[ipw] = new double[3];
kpg[ipw][0] = _gk[ipw].x;
kpg[ipw][1] = _gk[ipw].y;
kpg[ipw][2] = _gk[ipw].z;

gcar[ipw] = new double[3];
gcar[ipw][0] = this->wfc_basis->getgcar(ik, ipw).x;
gcar[ipw][1] = this->wfc_basis->getgcar(ik, ipw).y;
gcar[ipw][2] = this->wfc_basis->getgcar(ik, ipw).z;
}

GlobalC::paw_cell.set_paw_k(npw,
wfc_basis->npwk_max,
kpt.data(),
this->wfc_basis->get_ig2ix(ik).data(),
this->wfc_basis->get_ig2iy(ik).data(),
this->wfc_basis->get_ig2iz(ik).data(),
(const double**)kpg,
GlobalC::ucell.tpiba,
(const double**)gcar);

std::vector<double>().swap(kpt);
for (int ipw = 0; ipw < npw; ipw++)
{
delete[] kpg[ipw];
delete[] gcar[ipw];
}
delete[] kpg;
delete[] gcar;

GlobalC::paw_cell.get_vkb();

GlobalC::paw_cell.set_currentk(ik);
}
}

template <typename T, typename Device>
void HSolverPW<T, Device>::call_paw_cell_set_currentk(const int ik)
{
if (this->use_paw)
if (PARAM.inp.use_paw)
{
GlobalC::paw_cell.set_currentk(ik);
}
Expand All @@ -99,7 +39,7 @@ void HSolverPW<T, Device>::call_paw_cell_set_currentk(const int ik)
template <typename T, typename Device>
void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecstate::ElecState* pes)
{
if (this->use_paw)
if (PARAM.inp.use_paw)
{
if (typeid(Real) != typeid(double))
{
Expand Down Expand Up @@ -204,9 +144,9 @@ void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecst
GlobalC::paw_cell.get_nhat(pes->charge->nhat, nhatgr);
}
}

#endif


template <typename T, typename Device>
void HSolverPW<T, Device>::cal_ethr_band(const double& wk,
const double* wg,
Expand Down Expand Up @@ -283,7 +223,7 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
pHamilt->updateHk(ik);

#ifdef USE_PAW
this->paw_func_in_kloop(ik);
this->paw_func_in_kloop(ik, this->wfc_basis);
#endif

/// update psi pointer for each k point
Expand Down
2 changes: 1 addition & 1 deletion source/module_hsolver/hsolver_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class HSolverPW
std::vector<double> ethr_band;

#ifdef USE_PAW
void paw_func_in_kloop(const int ik);
void paw_func_in_kloop(const int ik, ModulePW::PW_Basis_K* wfc_basis);

void call_paw_cell_set_currentk(const int ik);

Expand Down
89 changes: 89 additions & 0 deletions source/module_hsolver/pawcode_in_hsolverpw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include "hsolver_pw.h"

// #include "pawcode_in_hsolverpw.h"

#include "module_base/global_variable.h"
#include "module_base/timer.h"
#include "module_base/tool_quit.h"
#include "module_elecstate/elecstate_pw.h"
#include "module_hamilt_general/hamilt.h"
#include "module_hamilt_pw/hamilt_pwdft/wavefunc.h"
#include "module_parameter/parameter.h"
#include "module_psi/psi.h"

#include <algorithm>
#include <vector>

#ifdef USE_PAW
#include "module_cell/module_paw/paw_cell.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#endif

#ifdef USE_PAW

namespace hsolver
{

template <typename T, typename Device>
void HSolverPW<T, Device>::paw_func_in_kloop(const int ik, ModulePW::PW_Basis_K* wfc_basis)
{
if (PARAM.inp.use_paw)
{
const int npw = this->wfc_basis->npwk[ik];
ModuleBase::Vector3<double>* _gk = new ModuleBase::Vector3<double>[npw];
for (int ig = 0; ig < npw; ig++)
{
_gk[ig] = this->wfc_basis->getgpluskcar(ik, ig);
}

std::vector<double> kpt(3, 0);
kpt[0] = this->wfc_basis->kvec_c[ik].x;
kpt[1] = this->wfc_basis->kvec_c[ik].y;
kpt[2] = this->wfc_basis->kvec_c[ik].z;

double** kpg;
double** gcar;
kpg = new double*[npw];
gcar = new double*[npw];
for (int ipw = 0; ipw < npw; ipw++)
{
kpg[ipw] = new double[3];
kpg[ipw][0] = _gk[ipw].x;
kpg[ipw][1] = _gk[ipw].y;
kpg[ipw][2] = _gk[ipw].z;

gcar[ipw] = new double[3];
gcar[ipw][0] = this->wfc_basis->getgcar(ik, ipw).x;
gcar[ipw][1] = this->wfc_basis->getgcar(ik, ipw).y;
gcar[ipw][2] = this->wfc_basis->getgcar(ik, ipw).z;
}

GlobalC::paw_cell.set_paw_k(npw,
wfc_basis->npwk_max,
kpt.data(),
this->wfc_basis->get_ig2ix(ik).data(),
this->wfc_basis->get_ig2iy(ik).data(),
this->wfc_basis->get_ig2iz(ik).data(),
(const double**)kpg,
GlobalC::ucell.tpiba,
(const double**)gcar);

std::vector<double>().swap(kpt);
for (int ipw = 0; ipw < npw; ipw++)
{
delete[] kpg[ipw];
delete[] gcar[ipw];
}
delete[] kpg;
delete[] gcar;

GlobalC::paw_cell.get_vkb();

GlobalC::paw_cell.set_currentk(ik);
}
}


} // namespace hsolver

#endif
27 changes: 27 additions & 0 deletions source/module_hsolver/pawcode_in_hsolverpw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// #ifndef PAW_CODE_IN_HSOLVER
// #define PAW_CODE_IN_HSOLVER

// #include "module_base/global_variable.h"
// #include "module_base/timer.h"
// #include "module_base/tool_quit.h"
// #include "module_elecstate/elecstate_pw.h"
// #include "module_hamilt_general/hamilt.h"
// #include "module_hamilt_pw/hamilt_pwdft/wavefunc.h"
// #include "module_parameter/parameter.h"
// #include "module_psi/psi.h"
// #include "module_base/macros.h"
// #include "module_basis/module_pw/pw_basis_k.h"
// #include "module_hamilt_pw/hamilt_pwdft/wavefunc.h"

// #ifdef USE_PAW

// namespace hsolver
// {

// void paw_func_in_kloop(const int ik, ModulePW::PW_Basis_K* wfc_basis);

// }

// #endif

// #endif
Loading