Skip to content

Commit b3287b2

Browse files
authored
Merge pull request #161 from PeizeLin/develop
1. fix bug in LCAO_Hamilt::calculate_HR_exx_sparse()
2 parents fb188b3 + e227fd1 commit b3287b2

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

source/Makefile.vars

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ CPLUSPLUS_MPI = mpiicpc
44

55
LAPACK_DIR = $(MKLROOT)
66

7-
FFTW_DIR = /home/qianrui/intelcompile/fftw_3.3.8
7+
FFTW_DIR = /public/software/fftw_3.3.8
88

9-
ELPA_DIR = /home/qianrui/intelcompile/elpa_21.05.002
9+
ELPA_DIR = /public/software/elpa_21.05.002
1010
ELPA_INCLUDE_DIR = ${ELPA_DIR}/include/elpa-2021.05.002
1111

12-
CEREAL_DIR = /home/qianrui/headfile/cereal
12+
CEREAL_DIR = /public/software/cereal
1313

1414
# LIBXC_DIR = /public/software/libxc-5.0.0
1515

source/src_external/src_test/print_tmp.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,20 @@ static void print_tmp(const T &S)
2323
}
2424
}
2525

26-
void print_matrixess(const std::map<size_t,std::map<size_t,std::map<Abfs::Vector3_Order<double>,std::weak_ptr<ModuleBase::matrix>>>> &ms, std::ofstream &ofs)
26+
template<typename T1,typename T2,typename T3>
27+
void print_matrixess(const std::map<T1,std::map<T2,std::map<Abfs::Vector3_Order<T3>,ModuleBase::matrix>>> &ms, std::ofstream &ofs)
28+
{
29+
for( const auto & c1 : ms )
30+
for( const auto & c2 : c1.second )
31+
for( const auto & c3 : c2.second )
32+
{
33+
ofs<<c1.first<<"\t"<<c2.first<<"\t"<<c3.first<<std::endl;
34+
c3.second.print(ofs, 1E-10)<<std::endl;
35+
}
36+
}
37+
38+
template<typename T1,typename T2,typename T3>
39+
void print_matrixess(const std::map<T1,std::map<T2,std::map<Abfs::Vector3_Order<T3>,std::weak_ptr<ModuleBase::matrix>>>> &ms, std::ofstream &ofs)
2740
{
2841
for( const auto & c1 : ms )
2942
for( const auto & c2 : c1.second )
@@ -34,7 +47,8 @@ void print_matrixess(const std::map<size_t,std::map<size_t,std::map<Abfs::Vector
3447
}
3548
}
3649

37-
void print_matrixess(const std::map<size_t,std::map<size_t,std::map<Abfs::Vector3_Order<int>,std::shared_ptr<ModuleBase::matrix>>>> &ms, std::ofstream &ofs)
50+
template<typename T1,typename T2,typename T3>
51+
void print_matrixess(const std::map<T1,std::map<T2,std::map<Abfs::Vector3_Order<T3>,std::shared_ptr<ModuleBase::matrix>>>> &ms, std::ofstream &ofs)
3852
{
3953
for( const auto & c1 : ms )
4054
for( const auto & c2 : c1.second )

source/src_lcao/LCAO_hamilt.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,8 @@ void LCAO_Hamilt::calculat_HR_dftu_soc_sparse(const int &current_spin, const dou
10271027

10281028
}
10291029

1030+
#include "src_external/src_test/src_global/matrix-test.h"
1031+
10301032
#ifdef __MPI
10311033
// Peize Lin add 2021.11.16
10321034
void LCAO_Hamilt::calculate_HR_exx_sparse(const int &current_spin, const double &sparse_threshold)
@@ -1040,9 +1042,10 @@ void LCAO_Hamilt::calculate_HR_exx_sparse(const int &current_spin, const double
10401042
+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__));
10411043
const std::vector<Abfs::Vector3_Order<int>> Rs = Abfs::get_Born_von_Karmen_boxes( Rs_period );
10421044

1043-
10441045
const int ik_begin = (GlobalV::NSPIN==2) ? (current_spin*GlobalC::kv.nks/2) : 0;
10451046
const int ik_end = (GlobalV::NSPIN==2) ? ((current_spin+1)*GlobalC::kv.nks/2) : GlobalC::kv.nks;
1047+
const double frac = (GlobalV::NSPIN==1) ? 0.5 : 1.0; // Peize Lin add 2022.07.09
1048+
10461049
for(const Abfs::Vector3_Order<int> &R : Rs)
10471050
{
10481051
ModuleBase::matrix HexxR;
@@ -1051,11 +1054,13 @@ void LCAO_Hamilt::calculate_HR_exx_sparse(const int &current_spin, const double
10511054
ModuleBase::matrix HexxR_tmp;
10521055
if(GlobalV::GAMMA_ONLY_LOCAL)
10531056
HexxR_tmp = GlobalC::exx_global.info.hybrid_alpha
1054-
* GlobalC::exx_lcao.Hexx_para.HK_Gamma_m2D[ik];
1057+
* GlobalC::exx_lcao.Hexx_para.HK_Gamma_m2D[ik]
1058+
* (GlobalC::kv.wk[ik] * frac);
10551059
else
10561060
HexxR_tmp = GlobalC::exx_global.info.hybrid_alpha
10571061
* (GlobalC::exx_lcao.Hexx_para.HK_K_m2D[ik]
1058-
* std::exp( ModuleBase::TWO_PI*ModuleBase::IMAG_UNIT * (GlobalC::kv.kvec_c[ik] * (R*GlobalC::ucell.latvec)) )).real();
1062+
* std::exp( ModuleBase::TWO_PI*ModuleBase::IMAG_UNIT * (GlobalC::kv.kvec_c[ik] * (R*GlobalC::ucell.latvec)) )).real()
1063+
* (GlobalC::kv.wk[ik] * frac);
10591064

10601065
if(HexxR.c)
10611066
HexxR += HexxR_tmp;

0 commit comments

Comments
 (0)