Skip to content

Commit 362fee1

Browse files
authored
Fix: support lmax of orbital 5, 6, 7 (#5519)
1 parent 7a87079 commit 362fee1

File tree

1 file changed

+18
-50
lines changed

1 file changed

+18
-50
lines changed

source/module_cell/read_atoms.cpp

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,9 @@ void UnitCell::check_dtau() {
11251125

11261126
void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_running, Atom* atom)
11271127
{
1128+
// the maximum L is 7, according to the basissetexchange https://www.basissetexchange.org/
1129+
// there is no orbitals with L>7 presently
1130+
const std::string spectrum = "SPDFGHIK";
11281131
std::ifstream ifs(orb_file.c_str(), std::ios::in); // pengfei 2014-10-13
11291132
// mohan add return 2021-04-26
11301133
if (!ifs)
@@ -1133,71 +1136,36 @@ void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_r
11331136
std::cout << " orbital file: " << orb_file << std::endl;
11341137
ModuleBase::WARNING_QUIT("read_orb_file","ABACUS Cannot find the ORBITAL file (basis sets)");
11351138
}
1136-
char word[80];
1139+
std::string word;
11371140
atom->nw = 0;
1138-
int L =0;
11391141
while (ifs.good())
11401142
{
11411143
ifs >> word;
1142-
if (strcmp("Element", word) == 0) // pengfei Li 16-2-29
1144+
if (word == "Element") // pengfei Li 16-2-29
11431145
{
11441146
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->label_orb);
11451147
}
1146-
if (strcmp("Lmax", word) == 0)
1148+
if (word == "Lmax")
11471149
{
11481150
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->nwl);
11491151
delete[] atom->l_nchi;
1150-
atom->l_nchi = new int[ atom->nwl+1];
1152+
atom->l_nchi = new int[atom->nwl+1];
11511153
}
1152-
assert(atom->nwl<10);
1153-
if (strcmp("Cutoff(a.u.)", word) == 0) // pengfei Li 16-2-29
1154+
// assert(atom->nwl<10); // cannot understand why restrict the maximum value of atom->nwl
1155+
if (word == "Cutoff(a.u.)") // pengfei Li 16-2-29
11541156
{
11551157
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->Rcut);
11561158
}
1157-
if (strcmp("Sorbital-->", word) == 0)
1158-
{
1159-
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[L]);
1160-
atom->nw += (2*L + 1) * atom->l_nchi[L];
1161-
std::stringstream ss;
1162-
ss << "L=" << L << ", number of zeta";
1163-
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[L]);
1164-
L++;
1165-
}
1166-
if (strcmp("Porbital-->", word) == 0)
1167-
{
1168-
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[L]);
1169-
atom->nw += (2*L + 1) * atom->l_nchi[L];
1170-
std::stringstream ss;
1171-
ss << "L=" << L << ", number of zeta";
1172-
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[L]);
1173-
L++;
1174-
}
1175-
if (strcmp("Dorbital-->", word) == 0)
1176-
{
1177-
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[L]);
1178-
atom->nw += (2*L + 1) * atom->l_nchi[L];
1179-
std::stringstream ss;
1180-
ss << "L=" << L << ", number of zeta";
1181-
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[L]);
1182-
L++;
1183-
}
1184-
if (strcmp("Forbital-->", word) == 0)
1185-
{
1186-
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[L]);
1187-
atom->nw += (2*L + 1) * atom->l_nchi[L];
1188-
std::stringstream ss;
1189-
ss << "L=" << L << ", number of zeta";
1190-
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[L]);
1191-
L++;
1192-
}
1193-
if (strcmp("Gorbital-->", word) == 0)
1159+
for (int i = 0; i < spectrum.size(); i++)
11941160
{
1195-
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[L]);
1196-
atom->nw += (2*L + 1) * atom->l_nchi[L];
1197-
std::stringstream ss;
1198-
ss << "L=" << L << ", number of zeta";
1199-
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[L]);
1200-
L++;
1161+
if (word == spectrum.substr(i, 1) + "orbital-->")
1162+
{
1163+
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[i]);
1164+
atom->nw += (2*i + 1) * atom->l_nchi[i];
1165+
std::stringstream ss;
1166+
ss << "L=" << i << ", number of zeta";
1167+
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[i]);
1168+
}
12011169
}
12021170
}
12031171
ifs.close();

0 commit comments

Comments
 (0)