Skip to content

Commit ae10873

Browse files
Refactor
1 parent f48ea9b commit ae10873

File tree

2 files changed

+7
-85
lines changed

2 files changed

+7
-85
lines changed

source/module_cell/klist.cpp

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,68 +1017,8 @@ void K_Vectors::ibz_kpoint(const ModuleSymmetry::Symmetry& symm,
10171017
// if direct coordinates are given, then cartesian coordinates are calculated
10181018
void K_Vectors::set_both_kvec(const ModuleBase::Matrix3& G, const ModuleBase::Matrix3& R, std::string& skpt)
10191019
{
1020+
KVectorUtils::set_both_kvec(*this, G, R, skpt);
10201021

1021-
if (PARAM.inp.final_scf) // LiuXh add 20180606
1022-
{
1023-
if (k_nkstot == 0)
1024-
{
1025-
kd_done = true;
1026-
kc_done = false;
1027-
}
1028-
else
1029-
{
1030-
if (k_kword == "Cartesian" || k_kword == "C")
1031-
{
1032-
kc_done = true;
1033-
kd_done = false;
1034-
}
1035-
else if (k_kword == "Direct" || k_kword == "D")
1036-
{
1037-
kd_done = true;
1038-
kc_done = false;
1039-
}
1040-
else
1041-
{
1042-
GlobalV::ofs_warning << " Error : neither Cartesian nor Direct kpoint." << std::endl;
1043-
}
1044-
}
1045-
}
1046-
1047-
// set cartesian k vectors.
1048-
if (!kc_done && kd_done)
1049-
{
1050-
KVectorUtils::k_vec_d2c(*this, G);
1051-
kc_done = true;
1052-
}
1053-
1054-
// set direct k vectors
1055-
else if (kc_done && !kd_done)
1056-
{
1057-
KVectorUtils::k_vec_c2d(*this, R);
1058-
kd_done = true;
1059-
}
1060-
std::string table;
1061-
table += " K-POINTS DIRECT COORDINATES\n";
1062-
table += FmtCore::format("%8s%12s%12s%12s%8s\n", "KPOINTS", "DIRECT_X", "DIRECT_Y", "DIRECT_Z", "WEIGHT");
1063-
for (int i = 0; i < nkstot; i++)
1064-
{
1065-
table += FmtCore::format("%8d%12.8f%12.8f%12.8f%8.4f\n",
1066-
i + 1,
1067-
this->kvec_d[i].x,
1068-
this->kvec_d[i].y,
1069-
this->kvec_d[i].z,
1070-
this->wk[i]);
1071-
}
1072-
GlobalV::ofs_running << table << std::endl;
1073-
if (GlobalV::MY_RANK == 0)
1074-
{
1075-
std::stringstream ss;
1076-
ss << " " << std::setw(40) << "nkstot now"
1077-
<< " = " << nkstot << std::endl;
1078-
ss << table << std::endl;
1079-
skpt = ss.str();
1080-
}
1081-
return;
10821022
}
10831023

10841024
void K_Vectors::normalize_wk(const int& degspin)
@@ -1332,29 +1272,7 @@ void K_Vectors::set_after_vc(const int& nspin_in,
13321272
{
13331273
ModuleBase::TITLE("K_Vectors", "set_after_vc");
13341274

1335-
GlobalV::ofs_running << "\n SETUP K-POINTS" << std::endl;
1336-
this->nspin = nspin_in;
1337-
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "nspin", nspin);
1338-
1339-
// set cartesian k vectors.
1340-
KVectorUtils::k_vec_d2c(*this, reciprocal_vec);
1341-
1342-
std::string table;
1343-
table += "K-POINTS DIRECT COORDINATES\n";
1344-
table += FmtCore::format("%8s%12s%12s%12s%8s\n", "KPOINTS", "DIRECT_X", "DIRECT_Y", "DIRECT_Z", "WEIGHT");
1345-
for (int i = 0; i < nks; i++)
1346-
{
1347-
table += FmtCore::format("%8d%12.8f%12.8f%12.8f%8.4f\n",
1348-
i + 1,
1349-
this->kvec_d[i].x,
1350-
this->kvec_d[i].y,
1351-
this->kvec_d[i].z,
1352-
this->wk[i]);
1353-
}
1354-
GlobalV::ofs_running << table << std::endl;
1355-
// this->set_both_kvec(reciprocal_vec, latvec);
1356-
1357-
this->print_klists(GlobalV::ofs_running);
1275+
KVectorUtils::set_after_vc(*this, nspin_in, reciprocal_vec);
13581276

13591277
return;
13601278
}

source/module_cell/klist.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "module_base/matrix3.h"
77
#include "module_cell/unitcell.h"
88
#include "parallel_kpoints.h"
9+
#include "k_vector_utils.h"
910
#include <vector>
1011

1112
class K_Vectors
@@ -158,7 +159,7 @@ class K_Vectors
158159
bool kd_done = false;
159160
double koffset[3] = {0.0}; // used only in automatic k-points.
160161
std::string k_kword; // LiuXh add 20180619
161-
int k_nkstot = 0; // LiuXh add 20180619
162+
int k_nkstot = 0; // LiuXh add 20180619 // WHAT IS THIS?????
162163
bool is_mp = false; // Monkhorst-Pack
163164

164165
/**
@@ -390,5 +391,8 @@ class K_Vectors
390391
* @return this->ik2iktot[ik]
391392
*/
392393
void cal_ik_global();
394+
395+
friend void KVectorUtils::set_both_kvec(K_Vectors& kv, const ModuleBase::Matrix3& G, const ModuleBase::Matrix3& R, std::string& skpt);
396+
friend void KVectorUtils::set_after_vc(K_Vectors& kv, const int& nspin_in, const ModuleBase::Matrix3& reciprocal_vec);
393397
};
394398
#endif // KVECT_H

0 commit comments

Comments
 (0)