Skip to content

Commit 6ed6af9

Browse files
wenfei-liwenfei-li
andauthored
Perf : include time reversal symmetry for multi-k when symmetry is not analyzed (#1044)
* gint : remove old code in src_lcao * fixed some memory leaks * replace new XXX[1] by nullptr * include time reversal symmetry in klist * kpoint : check time reversal only for mp, as in qe * fix bug in pp_blps * removed some unnecessary output Co-authored-by: wenfei-li <[email protected]>
1 parent c3caafa commit 6ed6af9

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

source/src_pw/klist.cpp

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ void K_Vectors::set(
8080
}
8181

8282
// (2)
83-
if(ModuleSymmetry::Symmetry::symm_flag)
83+
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag);
84+
if(ModuleSymmetry::Symmetry::symm_flag)
8485
{
85-
this->ibz_kpoint(symm);
8686
this->update_use_ibz();
8787
this->nks = this->nkstot = this->nkstot_ibz;
8888
}
@@ -236,11 +236,13 @@ bool K_Vectors::read_kpoints(const std::string &fn)
236236
{
237237
if (kword == "Gamma")
238238
{
239+
is_mp = true;
239240
k_type = 0;
240241
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Input type of k points","Monkhorst-Pack(Gamma)");
241242
}
242243
else if (kword == "Monkhorst-Pack" || kword == "MP" || kword == "mp")
243244
{
245+
is_mp = true;
244246
k_type = 1;
245247
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Input type of k points","Monkhorst-Pack");
246248
}
@@ -250,6 +252,8 @@ bool K_Vectors::read_kpoints(const std::string &fn)
250252
return 0;
251253
}
252254

255+
GlobalV::ofs_running << "is_mp : " << is_mp << std::endl;
256+
253257
ifk >> nmp[0] >> nmp[1] >> nmp[2];
254258

255259
ifk >> koffset[0] >> koffset[1] >> koffset[2];
@@ -526,7 +530,7 @@ void K_Vectors::update_use_ibz( void )
526530
return;
527531
}
528532

529-
void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry &symm)
533+
void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry &symm, bool use_symm)
530534
{
531535
if (GlobalV::MY_RANK!=0) return;
532536
ModuleBase::TITLE("K_Vectors", "ibz_kpoint");
@@ -538,24 +542,39 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry &symm)
538542
bool include_inv = false;
539543
std::vector<ModuleBase::Matrix3> kgmatrix(48 * 2);
540544
ModuleBase::Matrix3 inv(-1, 0, 0, 0, -1, 0, 0, 0, -1);
545+
ModuleBase::Matrix3 ind(1, 0, 0, 0, 1, 0, 0, 0, 1);
541546

542-
int nrotkm = symm.nrotk;// change if inv not included
543-
for (int i = 0; i < nrotkm; ++i)
547+
int nrotkm;
548+
if(use_symm)
544549
{
545-
if (symm.gmatrix[i] == inv)
550+
nrotkm = symm.nrotk;// change if inv not included
551+
for (int i = 0; i < nrotkm; ++i)
546552
{
547-
include_inv = true;
553+
if (symm.gmatrix[i] == inv)
554+
{
555+
include_inv = true;
556+
}
557+
kgmatrix[i] = symm.gmatrix[i];
548558
}
549-
kgmatrix[i] = symm.gmatrix[i];
550-
}
551559

552-
if (!include_inv)
553-
{
554-
for (int i = 0; i<symm.nrotk; ++i)
560+
if (!include_inv)
555561
{
556-
kgmatrix[i + symm.nrotk] = inv * symm.gmatrix[i];
562+
for (int i = 0; i<symm.nrotk; ++i)
563+
{
564+
kgmatrix[i + symm.nrotk] = inv * symm.gmatrix[i];
565+
}
566+
nrotkm = 2 * symm.nrotk;
557567
}
558-
nrotkm = 2 * symm.nrotk;
568+
}
569+
else if(is_mp) // only include for mp grid
570+
{
571+
nrotkm = 2;
572+
kgmatrix[0] = ind;
573+
kgmatrix[1] = inv;
574+
}
575+
else
576+
{
577+
return;
559578
}
560579

561580
// use operation : kgmatrix to find
@@ -599,12 +618,12 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry &symm)
599618
// fix the bug like kvec_d * G; is wrong
600619
//kvec_rot = kvec_d[i] * kgmatrix[j]; //wrong for total energy, but correct for nonlocal force.
601620
kvec_rot = kgmatrix[j] * kvec_d[i]; //correct for total energy, but wrong for nonlocal force.
602-
603621

604622
kvec_rot.x = fmod(kvec_rot.x + 100, 1);
605623
kvec_rot.y = fmod(kvec_rot.y + 100, 1);
606624
kvec_rot.z = fmod(kvec_rot.z + 100, 1);
607625

626+
608627
// std::cout << "\n kvec_rot = " << kvec_rot.x << " " << kvec_rot.y << " " << kvec_rot.z;
609628

610629
for (int k=0; k< this->nkstot_ibz; ++k)

source/src_pw/klist.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class K_Vectors
3838
const ModuleBase::Matrix3 &reciprocal_vec,
3939
const ModuleBase::Matrix3 &latvec);
4040

41-
void ibz_kpoint( const ModuleSymmetry::Symmetry &symm);
41+
void ibz_kpoint( const ModuleSymmetry::Symmetry &symm, bool use_symm);
4242
//LiuXh add 20180515
4343
void set_after_vc(
4444
const ModuleSymmetry::Symmetry &symm,
@@ -54,7 +54,8 @@ class K_Vectors
5454
double koffset[3]; // used only in automatic k-points.
5555
std::string k_kword; //LiuXh add 20180619
5656
int k_nkstot; //LiuXh add 20180619
57-
57+
bool is_mp = false; //Monkhorst-Pack
58+
5859
void renew( const int &kpoint_number );
5960

6061
// step 1 : generate kpoints

0 commit comments

Comments
 (0)