Skip to content

Commit 1e6fe92

Browse files
authored
Fix: Bug when kpar > 1, nspin=2, and cell-relax (#3957)
* Fix: bug when kpar>1, nspin=2, and cell-relax * update results
1 parent c04b8c9 commit 1e6fe92

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

source/module_cell/klist.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,9 +1347,10 @@ void K_Vectors::set_after_vc(
13471347
this->set_both_kvec_after_vc(reciprocal_vec, latvec);
13481348
//this->set_both_kvec(reciprocal_vec, latvec);
13491349

1350-
this->mpi_k_after_vc();
1350+
//Since the number of kpoints is not changed, we do not need to do the following.
1351+
// this->mpi_k_after_vc();
13511352

1352-
this->set_kup_and_kdw_after_vc();
1353+
// this->set_kup_and_kdw_after_vc();
13531354

13541355
this->print_klists(GlobalV::ofs_running);
13551356

@@ -1358,6 +1359,7 @@ void K_Vectors::set_after_vc(
13581359

13591360
//LiuXh add a new function here,
13601361
//20180515
1362+
//Useless now, it has bugs in it.
13611363
void K_Vectors::mpi_k_after_vc(void)
13621364
{
13631365
#ifdef __MPI
@@ -1395,6 +1397,7 @@ void K_Vectors::mpi_k_after_vc(void)
13951397

13961398
if (GlobalV::MY_RANK == 0)
13971399
{
1400+
// It is wrong! kvec_c and kvec_d are local variables.
13981401
for (int ik = 0;ik < nkstot;ik++)
13991402
{
14001403
isk_aux[ik] = isk[ik];
@@ -1503,6 +1506,7 @@ void K_Vectors::set_both_kvec_after_vc(const ModuleBase::Matrix3 &G, const Modul
15031506
return;
15041507
}
15051508

1509+
//Useless now
15061510
void K_Vectors::set_kup_and_kdw_after_vc(void)
15071511
{
15081512
ModuleBase::TITLE("K_Vectors", "setup_kup_and_kdw_after_vc");
@@ -1535,7 +1539,7 @@ void K_Vectors::set_kup_and_kdw_after_vc(void)
15351539
}
15361540

15371541
this->nks *= 2;
1538-
//this->nkstot *= 2;
1542+
//this->nkstot *= 2; //This makes the code difficult to read.
15391543

15401544
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nks(nspin=2)",nks);
15411545
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"nkstot(nspin=2)",nkstot);

source/module_cell/klist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class K_Vectors
8787
void print_klists(std::ofstream &fn);
8888
//bool read_kpoints_after_vc(const std::string &fn); //LiuXh add 20180515
8989
//void Monkhorst_Pack_after_vc(const int *nmp_in,const double *koffset_in,const int tipo); //LiuXh add 20180515
90-
void mpi_k_after_vc(); //LiuXh add 20180515
91-
void set_both_kvec_after_vc(const ModuleBase::Matrix3 &G,const ModuleBase::Matrix3 &R);
90+
void mpi_k_after_vc(); //LiuXh add 20180515 //Useless now, it should be removed after several versions' testing.
91+
void set_both_kvec_after_vc(const ModuleBase::Matrix3 &G,const ModuleBase::Matrix3 &R); //Useless now, it should be removed after several versions' testing.
9292
void set_kup_and_kdw_after_vc();
9393
};
9494

tests/integrate/109_PW_CR/INPUT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ calculation cell-relax
88
#Parameters (Accuracy)
99
ecutwfc 20
1010
scf_nmax 20
11+
kpar 2
12+
nspin 2
1113

1214
basis_type pw
1315
relax_nmax 2

tests/integrate/109_PW_CR/result.ref

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -211.8220727412902988
2-
etotperatomref -105.9110363706
3-
totalforceref 0.000018
4-
totalstressref 348.867117
5-
totaltimeref +0.31629
1+
etotref -211.8247254821208969
2+
etotperatomref -105.9123627411
3+
totalforceref 0.000000
4+
totalstressref 342.188349
5+
totaltimeref 1.87

0 commit comments

Comments
 (0)