From 2793650b4a62e77c81df43282f96438fbf6e3ae2 Mon Sep 17 00:00:00 2001 From: Peter Spackman Date: Fri, 15 Nov 2024 14:36:52 +0530 Subject: [PATCH] Adjust reading of occ json output for pair energies, bump occ version number --- CMakeLists.txt | 2 +- src/core/pair_energy_parameters.h | 2 +- src/core/pair_energy_results.cpp | 6 +++--- src/core/pair_energy_results.h | 2 +- src/crystal/crystalstructure.cpp | 5 +---- src/graphics/frameworkrenderer.cpp | 13 ++++++++++--- src/graphics/scene.cpp | 2 +- src/io/crystalclear.cpp | 9 +++++++++ 8 files changed, 27 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b308fb..433205f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ endif() message(STATUS "Using CPACK_SYSTEM_NAME=${CPACK_SYSTEM_NAME}") option(ENABLE_CX_TESTS "Enable testing" OFF) -set(OCC_VERSION "0.6.4" CACHE STRING "OCC version number for download") +set(OCC_VERSION "0.6.6" CACHE STRING "OCC version number for download") set(OCC_PLATFORM "${CPACK_SYSTEM_NAME}" CACHE STRING "OCC platform string for download") include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake") diff --git a/src/core/pair_energy_parameters.h b/src/core/pair_energy_parameters.h index 059ad56..7caebed 100644 --- a/src/core/pair_energy_parameters.h +++ b/src/core/pair_energy_parameters.h @@ -43,7 +43,7 @@ struct Parameters { int charge() const; bool operator==(const Parameters &rhs) const; bool isXtbModel() const; - bool hasInversionSymmetry{true}; + bool hasPermutationSymmetry{true}; }; struct Result { diff --git a/src/core/pair_energy_results.cpp b/src/core/pair_energy_results.cpp index 7081a02..004b463 100644 --- a/src/core/pair_energy_results.cpp +++ b/src/core/pair_energy_results.cpp @@ -217,18 +217,18 @@ bool PairInteractions::haveInteractions(const QString &model) const { } -bool PairInteractions::hasInversionSymmetry(const QString &model) const { +bool PairInteractions::hasPermutationSymmetry(const QString &model) const { if (model.isEmpty()) { for (const auto &[k, v] : m_pairInteractions) { for(const auto &[interaction_key, interaction]: v) { - if(!interaction->parameters().hasInversionSymmetry) return false; + if(!interaction->parameters().hasPermutationSymmetry) return false; } } } else { const auto kv = m_pairInteractions.find(model); if (kv != m_pairInteractions.end()) { for(const auto &[interaction_key, interaction]: kv->second) { - if(!interaction->parameters().hasInversionSymmetry) return false; + if(!interaction->parameters().hasPermutationSymmetry) return false; } } } diff --git a/src/core/pair_energy_results.h b/src/core/pair_energy_results.h index 8e51fb6..0d1d15c 100644 --- a/src/core/pair_energy_results.h +++ b/src/core/pair_energy_results.h @@ -91,7 +91,7 @@ class PairInteractions : public QObject { int getCount(const QString &model = "") const; bool haveInteractions(const QString &model = "") const; - bool hasInversionSymmetry(const QString &model = "") const; + bool hasPermutationSymmetry(const QString &model = "") const; signals: void interactionAdded(); diff --git a/src/crystal/crystalstructure.cpp b/src/crystal/crystalstructure.cpp index 42a5593..b568231 100644 --- a/src/crystal/crystalstructure.cpp +++ b/src/crystal/crystalstructure.cpp @@ -1339,13 +1339,10 @@ void CrystalStructure::setPairInteractionsFromDimerAtoms( added.insert(unique); - pair_energy::Parameters params; + pair_energy::Parameters params = pair->parameters(); params.fragmentDimer = ud; params.nearestAtomDistance = d.nearestAtomDistance; params.centroidDistance = d.centroidDistance; - // TODO better handling of inversion symmetry - QString modelName = pair->interactionModel(); - params.hasInversionSymmetry = !(modelName == "cg" || modelName.startsWith("crystalclear")); pair->setParameters(params); p->add(pair); } diff --git a/src/graphics/frameworkrenderer.cpp b/src/graphics/frameworkrenderer.cpp index f3f7a49..04cdcec 100644 --- a/src/graphics/frameworkrenderer.cpp +++ b/src/graphics/frameworkrenderer.cpp @@ -106,7 +106,7 @@ void FrameworkRenderer::handleInteractionsUpdate() { pairSettings.allowInversion = m_options.allowInversion & - m_interactions->hasInversionSymmetry(m_options.model); + m_interactions->hasPermutationSymmetry(m_options.model); auto fragmentPairs = m_structure->findFragmentPairs(pairSettings); std::vector uniquePairs = fragmentPairs.uniquePairs; @@ -150,12 +150,19 @@ void FrameworkRenderer::handleInteractionsUpdate() { break; case FrameworkOptions::LabelDisplay::Interaction: { const auto ¶ms = interaction->parameters(); - label = interaction->label() + QString("%1").arg(m_structure->getFragmentLabel(params.fragmentDimer.a.asymmetricFragmentIndex)); + label = interaction->label() + + QString("%1") + .arg(m_structure->getFragmentLabel( + params.fragmentDimer.a.asymmetricFragmentIndex)); break; } case FrameworkOptions::LabelDisplay::Fragments: { const auto ¶ms = interaction->parameters(); - label = m_structure->getFragmentLabel(params.fragmentDimer.a.asymmetricFragmentIndex) + ":" + m_structure->getFragmentLabel(params.fragmentDimer.b.asymmetricFragmentIndex); + label = m_structure->getFragmentLabel( + params.fragmentDimer.a.asymmetricFragmentIndex) + + ":" + + m_structure->getFragmentLabel( + params.fragmentDimer.b.asymmetricFragmentIndex); break; } default: diff --git a/src/graphics/scene.cpp b/src/graphics/scene.cpp index 06a5abe..3f9760f 100644 --- a/src/graphics/scene.cpp +++ b/src/graphics/scene.cpp @@ -1386,7 +1386,7 @@ void Scene::togglePairHighlighting(bool show) { // TODO fix this to be more robust auto *interactions = m_structure->pairInteractions(); FragmentPairSettings settings; - settings.allowInversion = interactions->hasInversionSymmetry(); + settings.allowInversion = interactions->hasPermutationSymmetry(); colorFragmentsByEnergyPair(settings); _disorderCycleIndex = 0; // Turn off disorder highlighting } else { diff --git a/src/io/crystalclear.cpp b/src/io/crystalclear.cpp index abbcba4..ba59fc3 100644 --- a/src/io/crystalclear.cpp +++ b/src/io/crystalclear.cpp @@ -65,6 +65,11 @@ CrystalStructure *loadCrystalClearJson(const QString &filename) { if(json.contains("model")) { modelName = QString::fromStdString(json["model"]); } + bool hasPermutationSymmetry{true}; + if(json.contains("has_permutation_symmetry")) { + hasPermutationSymmetry = json["has_permutation_symmetry"]; + } + // Parse neighbor energies auto pairsArray = json["pairs"]; interactions.resize(pairsArray.size()); @@ -75,6 +80,10 @@ CrystalStructure *loadCrystalClearJson(const QString &filename) { auto &offsets = atomIndices[i]; for (int j = 0; j < siteEnergies.size(); ++j) { auto *pair = new PairInteraction(modelName); + pair_energy::Parameters params; + params.hasPermutationSymmetry = hasPermutationSymmetry; + pair->setParameters(params); + auto dimerObj = siteEnergies[j]; auto energiesObj = dimerObj["energies"]; pair->setLabel(QString::number(j + 1));