From 66f230b0295b62141c111043613dc10d318ff27e Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Mon, 4 Dec 2023 21:18:16 -0500 Subject: [PATCH] If no partial charges are assigned, set them Signed-off-by: Geoff Hutchison --- .../qtplugins/propertytables/CMakeLists.txt | 2 ++ .../propertytables/propertymodel.cpp | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/avogadro/qtplugins/propertytables/CMakeLists.txt b/avogadro/qtplugins/propertytables/CMakeLists.txt index 18170b789a..8a73d2bc98 100644 --- a/avogadro/qtplugins/propertytables/CMakeLists.txt +++ b/avogadro/qtplugins/propertytables/CMakeLists.txt @@ -5,3 +5,5 @@ avogadro_plugin(PropertyTables PropertyTables "propertytables.cpp;propertymodel.cpp;propertyview.cpp" ) + +target_link_libraries(PropertyTables PRIVATE Avogadro::Calc) \ No newline at end of file diff --git a/avogadro/qtplugins/propertytables/propertymodel.cpp b/avogadro/qtplugins/propertytables/propertymodel.cpp index 9793106ca4..e1d2a79cc5 100644 --- a/avogadro/qtplugins/propertytables/propertymodel.cpp +++ b/avogadro/qtplugins/propertytables/propertymodel.cpp @@ -5,6 +5,7 @@ #include "propertymodel.h" +#include #include #include #include @@ -135,6 +136,28 @@ QString partialCharge(Molecule* molecule, int atom) auto first = types.cbegin(); MatrixX charges = molecule->partialCharges((*first)); charge = charges(atom, 0); + } else { + // find something + const auto options = + Calc::ChargeManager::instance().identifiersForMolecule(*molecule); + if (options.size() > 0) { + // look for GFN2 or AM1BCC, then MMFF94 then Gasteiger + std::string type; + if (options.find("GFN2") != options.end()) + type = "GFN2"; + else if (options.find("am1bcc") != options.end()) + type = "am1bcc"; + else if (options.find("mmff94") != options.end()) + type = "mmff94"; + else if (options.find("gasteiger") != options.end()) + type = "gasteiger"; + else + type = *options.begin(); + + MatrixX charges = + Calc::ChargeManager::instance().partialCharges(type, *molecule); + charge = charges(atom, 0); + } } return QString("%L1").arg(charge, 0, 'f', 3); }