Skip to content

Commit 3c986a1

Browse files
Merge pull request #1 from kirk0830/lmax9-safe
Enhance: throw with information when there are unexpected spetrum symbol
2 parents 97e504d + d98090f commit 3c986a1

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

source/module_cell/read_atoms.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_r
11341134
{
11351135
std::cout << " Element index " << it+1 << std::endl;
11361136
std::cout << " orbital file: " << orb_file << std::endl;
1137-
ModuleBase::WARNING_QUIT("read_orb_file","ABACUS Cannot find the ORBITAL file (basis sets)");
1137+
ModuleBase::WARNING_QUIT("UnitCell::read_orb_file", "ABACUS Cannot find the ORBITAL file (basis sets)");
11381138
}
11391139
std::string word;
11401140
atom->nw = 0;
@@ -1156,21 +1156,33 @@ void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_r
11561156
{
11571157
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->Rcut);
11581158
}
1159-
for (int i = 0; i < spectrum.size(); i++)
1159+
if (FmtCore::endswith(word, "orbital-->"))
11601160
{
1161-
if (word == spectrum.substr(i, 1) + "orbital-->")
1161+
bool valid = false;
1162+
for (int i = 0; i < spectrum.size(); i++)
11621163
{
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]);
1164+
if (word == spectrum.substr(i, 1) + "orbital-->")
1165+
{
1166+
ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->l_nchi[i]);
1167+
atom->nw += (2*i + 1) * atom->l_nchi[i];
1168+
std::stringstream ss;
1169+
ss << "L=" << i << ", number of zeta";
1170+
ModuleBase::GlobalFunc::OUT(ofs_running,ss.str(),atom->l_nchi[i]);
1171+
valid = true;
1172+
break;
1173+
}
1174+
}
1175+
if (!valid)
1176+
{
1177+
ModuleBase::WARNING_QUIT("UnitCell::read_orb_file",
1178+
"ABACUS does not support numerical atomic orbital with L > 9, "
1179+
"or an invalid orbital label is found in the ORBITAL file.");
11681180
}
11691181
}
11701182
}
11711183
ifs.close();
11721184
if(!atom->nw)
11731185
{
1174-
ModuleBase::WARNING_QUIT("read_orb_file","get nw = 0");
1186+
ModuleBase::WARNING_QUIT("UnitCell::read_orb_file","get nw = 0");
11751187
}
11761188
}

0 commit comments

Comments
 (0)