From 93498002da38c59cb75e060035e2df0448bbe464 Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Wed, 12 Jun 2024 07:35:23 +0800 Subject: [PATCH 1/2] Fix: report error when fr-uspp used in linear calculations --- source/module_cell/read_pp.cpp | 39 ++++++++++++------- source/module_cell/test/read_pp_test.cpp | 4 ++ .../hamilt_pwdft/hamilt_pw.cpp | 2 - 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/source/module_cell/read_pp.cpp b/source/module_cell/read_pp.cpp index 72e5c12048..a7508af948 100644 --- a/source/module_cell/read_pp.cpp +++ b/source/module_cell/read_pp.cpp @@ -143,23 +143,32 @@ std::string Pseudopot_upf::trimend(std::string &in_str) int Pseudopot_upf::average_p(const double& lambda) { - int error = 0; - double lambda_ = lambda; - if(!GlobalV::LSPINORB) lambda_ = 0.0; - if(!this->has_so && GlobalV::LSPINORB) - { - error++; - std::cout<<"warning_quit! no soc upf used for lspinorb calculation, error!"<has_so && this->tvanp) + { + error++; + std::cout << "------------------------------------------------------" << std::endl; + std::cout << " FR-USPP please use lspinorb=.true." << std::endl; + std::cout << "------------------------------------------------------" << std::endl; + return error; + } + if (!this->has_so && GlobalV::LSPINORB) + { + error++; + std::cout << "warning_quit! no soc upf used for lspinorb calculation, error!" << std::endl; + return error; + } + // ModuleBase::WARNING_QUIT("average_p", "no soc upf used for lspinorb calculation, error!"); - if(!this->has_so || (GlobalV::LSPINORB && std::abs(lambda_ - 1.0) < 1.0e-8) ) - { - return error; - } + if (!this->has_so || (GlobalV::LSPINORB && std::abs(lambda_ - 1.0) < 1.0e-8)) + { + return error; + } - //if(std::abs(lambda_)<1.0e-8) + //if(std::abs(lambda_)<1.0e-8) if(!GlobalV::LSPINORB) { int new_nbeta = 0; //calculate the new nbeta diff --git a/source/module_cell/test/read_pp_test.cpp b/source/module_cell/test/read_pp_test.cpp index d5db05f7ee..e1d58fee41 100644 --- a/source/module_cell/test/read_pp_test.cpp +++ b/source/module_cell/test/read_pp_test.cpp @@ -746,6 +746,10 @@ TEST_F(ReadPPTest, AverageSimpleReturns) upf->has_so = 1; ierr = upf->average_p(lambda); EXPECT_EQ(ierr,0); + upf->has_so = 1; + upf->tvanp = 1; + ierr = upf->average_p(lambda); + EXPECT_EQ(ierr, 1); } TEST_F(ReadPPTest, AverageErrReturns) diff --git a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp index 965a8628db..96dc305547 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp @@ -362,8 +362,6 @@ void HamiltPW::sPsi(const T* psi_in, // psi delmem_complex_op()(this->ctx, ps); delmem_complex_op()(this->ctx, becp); } - - ModuleBase::TITLE("HamiltPW", "sPsi"); } template class HamiltPW, base_device::DEVICE_CPU>; From 9c8f71e76a22f6f57f794f9c8c492b6d69d9595a Mon Sep 17 00:00:00 2001 From: Mohan Chen Date: Wed, 12 Jun 2024 09:46:58 +0800 Subject: [PATCH 2/2] Update source/module_cell/read_pp.cpp Co-authored-by: kirk0830 <67682086+kirk0830@users.noreply.github.com> --- source/module_cell/read_pp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/module_cell/read_pp.cpp b/source/module_cell/read_pp.cpp index a7508af948..153c7dae71 100644 --- a/source/module_cell/read_pp.cpp +++ b/source/module_cell/read_pp.cpp @@ -145,8 +145,7 @@ int Pseudopot_upf::average_p(const double& lambda) { int error = 0; double lambda_ = lambda; - if (!GlobalV::LSPINORB) - lambda_ = 0.0; + if(!GlobalV::LSPINORB) { lambda_ = 0.0; } if (this->has_so && this->tvanp) { error++;