Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug with parsing ORCA orbital coefficients #1910

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions avogadro/quantumio/orca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,11 @@
numColumns = list.size();
columns.resize(numColumns);
while (list.size() > 0) {
orcaOrbitals.push_back(list[1]);
// get the '2s' or '1dx2y2' piece from the line
// so we can re-order the orbitals later
std::vector<std::string> pieces = Core::split(key, ' ');
orcaOrbitals.push_back(pieces[1]);

for (unsigned int i = 0; i < numColumns; ++i) {
columns[i].push_back(Core::lexicalCast<double>(list[i]));
}
Expand Down Expand Up @@ -945,31 +949,34 @@
getline(in, key); // skip -----------
getline(in, key); // now we've got coefficients

regex rx("[.][0-9]{6}[0-9-]");
regex rx("[-]?[0-9]{1,2}[.][0-9]{6}");
auto key_begin = std::sregex_iterator(key.begin(), key.end(), rx);
auto key_end = std::sregex_iterator();
list.clear();
for (std::sregex_iterator i = key_begin; i != key_end; ++i) {
key += i->str() + " ";
list.push_back(i->str());
}

list = Core::split(key, ' ');
numColumns = list.size() - 2;
numColumns = list.size();
columns.resize(numColumns);
while (list.size() > 2) {
orcaOrbitals.push_back(list[1]);
while (list.size() > 0) {
// get the '2s' or '1dx2y2' piece from the line
// so we can re-order the orbitals later
std::vector<std::string> pieces = Core::split(key, ' ');
orcaOrbitals.push_back(pieces[1]);

// columns.resize(numColumns);
for (unsigned int i = 0; i < numColumns; ++i) {
columns[i].push_back(Core::lexicalCast<double>(list[i + 2]));
columns[i].push_back(Core::lexicalCast<double>(list[i]));
}

getline(in, key);
key_begin = std::sregex_iterator(key.begin(), key.end(), rx);
key_end = std::sregex_iterator();
auto key_begin = std::sregex_iterator(key.begin(), key.end(), rx);

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable key_begin hides another variable of the same name (on
line 953
).
auto key_end = std::sregex_iterator();

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable key_end hides another variable of the same name (on
line 954
).
list.clear();
for (std::sregex_iterator i = key_begin; i != key_end; ++i) {
key += i->str() + " ";
list.push_back(i->str());
}
list = Core::split(key, ' ');
if (list.size() != numColumns + 2)
if (list.size() != numColumns)
break;

} // ok, we've finished one batch of MO coeffs
Expand Down Expand Up @@ -1001,7 +1008,6 @@
for (unsigned int i = 0; i < numColumns; ++i) {
numRows = columns[i].size();
for (unsigned int j = 0; j < numRows; ++j) {

m_BetaMOcoeffs.push_back(columns[i][j]);
}
}
Expand Down
Loading