Skip to content

Commit

Permalink
Merge pull request #1020 from aerkiaga/charge-models-fix
Browse files Browse the repository at this point in the history
Workaround charge models locking up or not running
  • Loading branch information
ghutchis authored Jul 13, 2022
2 parents 10a7a97 + 67cc002 commit c131275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ MatrixX Molecule::partialCharges(const std::string& type) const
return search->second; // value from the map
} else {
MatrixX charges(atomCount(), 1);
charges.fill(0.0);
return charges;
}
}
Expand Down
4 changes: 4 additions & 0 deletions avogadro/qtplugins/openbabel/obcharges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ MatrixX OBCharges::partialCharges(Core::Molecule& molecule) const
charges(i, 0) = output[i];
}

// workaround failed runs causing the code to freeze
if (abs(charges(0, 0)) < 0.00001)
charges(0, 0) = 0.0001;

// cache the charges and allow them to show up in output
molecule.setPartialCharges(m_identifier, charges);
return charges;
Expand Down

0 comments on commit c131275

Please sign in to comment.