From 97e504d3f4777963ffa78bcf1439afdf94334403 Mon Sep 17 00:00:00 2001 From: JamesMisaka Date: Tue, 19 Nov 2024 15:51:25 +0800 Subject: [PATCH 1/2] Fix: support lmax of orbital 8,9 --- source/module_cell/read_atoms.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index 084679bb19..89181a4a2b 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -1125,9 +1125,9 @@ void UnitCell::check_dtau() { void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_running, Atom* atom) { - // the maximum L is 7, according to the basissetexchange https://www.basissetexchange.org/ - // there is no orbitals with L>7 presently - const std::string spectrum = "SPDFGHIK"; + // 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) From d98090f5767662fb4f419c362756dcb51aad3c02 Mon Sep 17 00:00:00 2001 From: kirk0830 Date: Wed, 20 Nov 2024 11:07:24 +0800 Subject: [PATCH 2/2] Enhance: throw with information when there are unexpected spetrum symbol --- source/module_cell/read_atoms.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index 89181a4a2b..a14c9bc5f5 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -1134,7 +1134,7 @@ void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_r { std::cout << " Element index " << it+1 << std::endl; std::cout << " orbital file: " << orb_file << std::endl; - ModuleBase::WARNING_QUIT("read_orb_file","ABACUS Cannot find the ORBITAL file (basis sets)"); + ModuleBase::WARNING_QUIT("UnitCell::read_orb_file", "ABACUS Cannot find the ORBITAL file (basis sets)"); } std::string word; atom->nw = 0; @@ -1156,21 +1156,33 @@ void UnitCell::read_orb_file(int it, std::string &orb_file, std::ofstream &ofs_r { ModuleBase::GlobalFunc::READ_VALUE(ifs, atom->Rcut); } - for (int i = 0; i < spectrum.size(); i++) + if (FmtCore::endswith(word, "orbital-->")) { - if (word == spectrum.substr(i, 1) + "orbital-->") + bool valid = false; + for (int i = 0; i < spectrum.size(); i++) { - 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]); + 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_QUIT("UnitCell::read_orb_file", + "ABACUS does not support numerical atomic orbital with L > 9, " + "or an invalid orbital label is found in the ORBITAL file."); } } } ifs.close(); if(!atom->nw) { - ModuleBase::WARNING_QUIT("read_orb_file","get nw = 0"); + ModuleBase::WARNING_QUIT("UnitCell::read_orb_file","get nw = 0"); } }