Skip to content

Commit

Permalink
Merge pull request #2653 from ghutchis/fix-xtb-gaussian-vibrations
Browse files Browse the repository at this point in the history
Fix parsing "Gaussian" vibration output from xtb program
  • Loading branch information
ghutchis committed Dec 6, 2023
2 parents 283cc84 + 0ad3717 commit f67d6bc
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/formats/gaussformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ namespace OpenBabel

//Vibrational data
std::vector< std::vector< vector3 > > Lx;
std::vector<double> Frequencies, Intensities;
std::vector<double> Frequencies, Intensities, RamanActivities;
//Rotational data
std::vector<double> RotConsts(3);
int RotSymNum=1;
Expand Down Expand Up @@ -978,9 +978,13 @@ namespace OpenBabel

ifs.getline(buffer, BUFF_SIZE); // column labels or Raman intensity
if(strstr(buffer, "Raman Activ")) {
tokenize(vs, buffer);
for(unsigned int i=3; i<vs.size(); ++i)
RamanActivities.push_back(atof(vs[i].c_str()));
ifs.getline(buffer, BUFF_SIZE); // Depolar (P)
ifs.getline(buffer, BUFF_SIZE); // Depolar (U)
ifs.getline(buffer, BUFF_SIZE); // column labels

while (strstr(buffer, "Atom") == nullptr)
ifs.getline(buffer, BUFF_SIZE); // eventually column labels
}
ifs.getline(buffer, BUFF_SIZE); // actual displacement data
tokenize(vs, buffer);
Expand Down Expand Up @@ -1325,7 +1329,22 @@ namespace OpenBabel
if(Frequencies.size()>0)
{
OBVibrationData* vd = new OBVibrationData;
vd->SetData(Lx, Frequencies, Intensities);
if (RamanActivities.size() != 0) {
// check to see if they're all zero
bool allZero = true;
for (auto &i : RamanActivities) {
if (i != 0.0) {
allZero = false;
break;
}
}
if (!allZero) {
vd->SetData(Lx, Frequencies, Intensities, RamanActivities);
} else { // zero Raman
vd->SetData(Lx, Frequencies, Intensities);
}
} else // no Raman
vd->SetData(Lx, Frequencies, Intensities);
vd->SetOrigin(fileformatInput);
mol.SetData(vd);
}
Expand Down

0 comments on commit f67d6bc

Please sign in to comment.