Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Fix catastrophic bugs reading Orca orbitals. #912

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
59 changes: 46 additions & 13 deletions libavogadro/src/extensions/surfaces/openqube/orca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,28 +288,61 @@ void ORCAOutput::processLine(GaussianSet *basis)
key = m_in->readLine(); // skip -----------
key = m_in->readLine(); // now we've got coefficients

QRegExp rx("[.][0-9]{6}[0-9-]");
while (rx.indexIn(key) != -1){ // avoid wrong splitting
key.insert(rx.indexIn(key)+1, " ");
}
QRegExp rx("[0-9-]+[.][0-9]{6}");
list = key.split(' ', QString::SkipEmptyParts);
if (list.size() < 2) {
m_orcaSuccess = false;
qDebug() << "Initial list line didn't match " << key;
break;
}
QString orbitalDesc = list[1];

int pos = rx.indexIn(key);
if (pos == -1) {
m_orcaSuccess = false;
qDebug() << "Initial regex didn't match " << key;
break;
}

list.clear();
while ((pos = rx.indexIn(key, pos)) != -1) {
list << rx.cap(0);
pos += rx.matchedLength();
}

numColumns = list.size() - 2;
numColumns = list.size();
columns.resize(numColumns);
while (list.size() > 2) {
orcaOrbitals += list[1];
while (true) {
orcaOrbitals += orbitalDesc;
for (unsigned int i = 0; i < numColumns; ++i) {
columns[i].push_back(list[i + 2].toDouble());
bool ok;
columns[i].push_back(list[i].toDouble(&ok));
if (!ok) {
m_orcaSuccess = false;
qDebug() << "Failed to parse double in line " << list;
break;
}
}

key = m_in->readLine();
while (rx.indexIn(key) != -1){ // avoid wrong splitting
key.insert(rx.indexIn(key)+1, " ");
list = key.split(' ', QString::SkipEmptyParts);
if (list.size() < 2) {
// We reached the end of molecular orbitals (hopefully)
break;
}
orbitalDesc = list[1];

list = key.split(' ', QString::SkipEmptyParts);
if (list.size() != numColumns+2)
pos = rx.indexIn(key);
if (pos == -1) {
// We reached a line the next set of orbital sequence numbers
break;
}

list.clear();
while ((pos = rx.indexIn(key, pos)) != -1) {
list << rx.cap(0);
pos += rx.matchedLength();
}

} // ok, we've finished one batch of MO coeffs
// now reorder the p orbitals from "orcaStyle" (pz, px,py) to expected (px,py,pz)
Expand Down Expand Up @@ -343,7 +376,7 @@ void ORCAOutput::processLine(GaussianSet *basis)
} // finished parsing MOs
if (m_MOcoeffs.size() != numRows*numRows) {
m_orcaSuccess = false;
qDebug() << "Something went wrong during read of MOs\n check columns!!!";
qDebug() << "Something went wrong during read of MOs. Expected " << numRows*numRows << " coeffs but got " << m_MOcoeffs.size() << "\n";
}
m_numBasisFunctions = numRows;
if (m_openShell && m_useBeta) {
Expand Down