forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_orb.cpp
More file actions
74 lines (72 loc) · 2.59 KB
/
read_orb.cpp
File metadata and controls
74 lines (72 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "read_orb.h"
#include "source_base/formatter.h"
namespace elecstate {
bool read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_running, Atom* atom)
{
// the maximum L is 9 like cc-pV9Z, according to the
// basissetexchange https://www.basissetexchange.org/
// there is no orbitals with L>9 presently
const std::string spectrum = "SPDFGHIKLM";
std::ifstream ifs(orb_file.c_str(), std::ios::in); // pengfei 2014-10-13
// mohan add return 2021-04-26
if (!ifs)
{
std::cout << " Element index " << it+1 << std::endl;
std::cout << " orbital file: " << orb_file << std::endl;
ModuleBase::WARNING("elecstate::read_orb_file",
"cannot open the ORBITAL file (NAO basis sets)");
return false;
}
std::string word;
atom->nw = 0;
while (ifs.good())
{
ifs >> word;
if (word == "Element") // pengfei Li 16-2-29
{
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->label_orb);
}
if (word == "Lmax")
{
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->nwl);
atom->l_nchi.resize(atom->nwl+1, 0);
}
// assert(atom->nwl<10); // cannot understand why restrict the maximum value of atom->nwl
if (word == "Cutoff(a.u.)") // pengfei Li 16-2-29
{
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->Rcut);
}
if (FmtCore::endswith(word, "orbital-->"))
{
bool valid = false;
for (int i = 0; i < spectrum.size(); i++)
{
if (word == spectrum.substr(i, 1) + "orbital-->")
{
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[i]);
atom->nw += (2*i + 1) * atom->l_nchi[i];
std::stringstream ss;
ss << "L=" << i << ", number of zeta";
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[i]);
valid = true;
break;
}
}
if (!valid)
{
ModuleBase::WARNING("elecstate::read_orb_file",
"ABACUS does not support NAO with L > 9, "
"or an invalid orbital label is found in the ORBITAL file.");
return false;
}
}
}
ifs.close();
if(!atom->nw)
{
ModuleBase::WARNING("elecstate::read_orb_file","get nw = 0, check the ORBITAL file");
return false;
}
return true;
}
}