diff --git a/avogadro/core/molecule.cpp b/avogadro/core/molecule.cpp index f2f814cb8a..da19638982 100644 --- a/avogadro/core/molecule.cpp +++ b/avogadro/core/molecule.cpp @@ -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; } } diff --git a/avogadro/qtplugins/openbabel/obcharges.cpp b/avogadro/qtplugins/openbabel/obcharges.cpp index 68641ea344..b2c2c9d405 100644 --- a/avogadro/qtplugins/openbabel/obcharges.cpp +++ b/avogadro/qtplugins/openbabel/obcharges.cpp @@ -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;