From ba0cb21164faeeee17ecf526ff6668dee8d02604 Mon Sep 17 00:00:00 2001 From: kirk0830 <67682086+kirk0830@users.noreply.github.com> Date: Thu, 26 Sep 2024 13:39:07 +0800 Subject: [PATCH] Fix: recover the wannier90 interface for lcao_in_pw case (#5177) --- source/module_psi/psi_initializer.cpp | 7 +++---- source/module_psi/psi_initializer.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/module_psi/psi_initializer.cpp b/source/module_psi/psi_initializer.cpp index 6e6879e92e..22a64104d7 100644 --- a/source/module_psi/psi_initializer.cpp +++ b/source/module_psi/psi_initializer.cpp @@ -82,10 +82,9 @@ psi::Psi>* psi_initializer::allocate(const bool // std::cout << " MEMORY FOR PSI PER PROCESSOR (MB) : " << double(memory_cost_psi)/1024.0/1024.0 << std::endl; ModuleBase::Memory::record("Psi_PW", memory_cost_psi); } - // for memory saving, the psig can always only hold one k-point data. But for lcao_in_pw, the psig - // is actcually a transformation matrix. During the SCF, the projection might be quite time- - // consuming. - const int nks_psig = (this->mem_saver_ == 1 && PARAM.inp.basis_type != "lcao_in_pw")? 1 : nks_psi; + // psi_initializer also works for basis transformation tasks. In this case, psig needs to allocate memory for + // each kpoint, otherwise, for initializing pw wavefunction, only one kpoint's space is enough. + const int nks_psig = (PARAM.inp.basis_type == "pw")? 1 : nks_psi; this->psig_ = std::make_shared>(nks_psig, nbands_actual, nbasis_actual, diff --git a/source/module_psi/psi_initializer.h b/source/module_psi/psi_initializer.h index 059a8b258b..ec1efd605e 100644 --- a/source/module_psi/psi_initializer.h +++ b/source/module_psi/psi_initializer.h @@ -175,7 +175,7 @@ class psi_initializer // avoid memory leak std::shared_ptr> psig_; private: - int mem_saver_ = 1; + int mem_saver_ = 0; std::string method_ = "none"; int nbands_complem_ = 0; double random_mix_ = 0;