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

Parse NMR spectra from Orca #1799

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
44 changes: 41 additions & 3 deletions avogadro/quantumio/orca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,26 @@ bool ORCAOutput::read(std::istream& in, Core::Molecule& molecule)
electronicData(i, 1) = m_electronicIntensities[i];
}
molecule.setSpectra("Electronic", electronicData);
std::cout << "UV/Vis data found." << electronicData.rows() << std::endl;
if (m_electronicRotations.size() == m_electronicTransitions.size()) {
MatrixX electronicRotations(m_electronicTransitions.size(), 2);
for (size_t i = 0; i < m_electronicTransitions.size(); ++i) {
electronicRotations(i, 0) = m_electronicTransitions[i];
electronicRotations(i, 1) = m_electronicRotations[i];
}
molecule.setSpectra("CircularDichroism", electronicRotations);
std::cout << "CircularDichroism data found." << electronicRotations.rows()
<< std::endl;
}
}

if (m_nmrShifts.size() > 0) {
MatrixX nmrData(m_nmrShifts.size(), 2);
// nmr_shifts has an entry for every atom even if not computed
for (size_t i = 0; i < m_nmrShifts.size(); ++i) {
nmrData(i, 0) = m_nmrShifts[i];
nmrData(i, 1) = 1.0;
}
molecule.setSpectra("NMR", nmrData);
}

// guess bonds and bond orders
molecule.perceiveBondsSimple();
molecule.perceiveBondOrders();
Expand Down Expand Up @@ -281,6 +288,11 @@ void ORCAOutput::processLine(std::istream& in, GaussianSet* basis)
getline(in, key); // skip blank line
getline(in, key); // skip column titles
getline(in, key); // skip ------------
} else if (Core::contains(key, "CHEMICAL SHIELDING SUMMARY (ppm)")) {
m_currentMode = NMR;
for (int i = 0; i < 4; ++i) {
getline(in, key); // skip header
}
} else {

vector<vector<double>> columns;
Expand Down Expand Up @@ -618,6 +630,32 @@ void ORCAOutput::processLine(std::istream& in, GaussianSet* basis)
}
m_currentMode = NotParsing;
}
case NMR: {
if (key.empty())
break;
list = Core::split(key, ' ');
// default to filling m_nmrShifts with zeros
m_nmrShifts.resize(m_atomNums.size(), 0.0);
while (!key.empty()) {
// should have 4 columns
if (list.size() != 4) {
break;
}

// e.g. 1 C 0.0000 0.0000 0.0000 0.0000
int atomIndex = Core::lexicalCast<int>(list[0]);
double shift = Core::lexicalCast<double>(list[2]);
// ignore the anisotropy for now
m_nmrShifts[atomIndex] = shift;

getline(in, key);
key = Core::trimmed(key);
list = Core::split(key, ' ');
}

m_currentMode = NotParsing;
break;
}
case GTO: {
// // should start at the first newGTO
if (key.empty())
Expand Down
2 changes: 2 additions & 0 deletions avogadro/quantumio/orca.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class AVOGADROQUANTUMIO_EXPORT ORCAOutput : public Io::FileFormat
Core::Array<double> m_electronicTransitions; // in eV
Core::Array<double> m_electronicIntensities;
Core::Array<double> m_electronicRotations; // for CD

Core::Array<double> m_nmrShifts; // for NMR (in ppm)
};

} // namespace QuantumIO
Expand Down
Loading