Skip to content

Commit

Permalink
Adjust reading of occ json output for pair energies, bump occ version…
Browse files Browse the repository at this point in the history
… number
  • Loading branch information
peterspackman committed Nov 15, 2024
1 parent 03a7b5a commit 2793650
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/core/pair_energy_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/core/pair_energy_results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/pair_energy_results.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/crystal/crystalstructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
13 changes: 10 additions & 3 deletions src/graphics/frameworkrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<FragmentDimer> uniquePairs = fragmentPairs.uniquePairs;
Expand Down Expand Up @@ -150,12 +150,19 @@ void FrameworkRenderer::handleInteractionsUpdate() {
break;
case FrameworkOptions::LabelDisplay::Interaction: {
const auto &params = interaction->parameters();
label = interaction->label() + QString("<sub>%1</sub>").arg(m_structure->getFragmentLabel(params.fragmentDimer.a.asymmetricFragmentIndex));
label = interaction->label() +
QString("<sub>%1</sub>")
.arg(m_structure->getFragmentLabel(
params.fragmentDimer.a.asymmetricFragmentIndex));
break;
}
case FrameworkOptions::LabelDisplay::Fragments: {
const auto &params = 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:
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/io/crystalclear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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));
Expand Down

0 comments on commit 2793650

Please sign in to comment.