Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adjust potential range against box geometry dialog #1992

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ add_library(
intramolecularTermsDialog.ui
modifyChargesDialog.cpp
modifyChargesDialog.h
pairPotentialCheckDialog.cpp
pairPotentialCheckDialog.h
aboswel marked this conversation as resolved.
Show resolved Hide resolved
selectAtomTypeDialog.cpp
selectAtomTypeDialog.h
selectAtomTypeDialog.ui
Expand Down
11 changes: 11 additions & 0 deletions src/gui/gui_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "gui/gui.h"
#include "main/dissolve.h"
#include "gui/pairPotentialCheckDialog.h"
#include <QMessageBox>

// Clear all module data
Expand Down Expand Up @@ -51,6 +52,16 @@ void DissolveWindow::setupIteration(int count)
// Clear the messages tab
clearMessages();

// Check if pair potential range is too large for configuration box, ask to auto adjust if so
if (PairPotentialCheck::checkPairPotential(dissolve_.coreData().configurations(), dissolve_.pairPotentialRange())) {

if (PairPotentialCheck::displayPairPotentialWarning()) {

dissolve_.setPairPotentialRange(PairPotentialCheck::radius);
Messenger::print("Pair potential range updated to {}", PairPotentialCheck::radius);
}
}
aboswel marked this conversation as resolved.
Show resolved Hide resolved

// Prepare the simulation
if (!dissolve_.prepare())
{
Expand Down
43 changes: 43 additions & 0 deletions src/gui/pairPotentialCheckDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors

#include "pairPotentialCheckDialog.h"

double PairPotentialCheck::radius = 0.0;
QMessageBox::StandardButton PairPotentialCheck::reply;

// Retrieve the inscribed sphere radius for all configuration boxes find the smallest
// Compare smallest radius to pair potential range, return radius if smaller

aboswel marked this conversation as resolved.
Show resolved Hide resolved
double PairPotentialCheck::checkPairPotential(std::vector<std::unique_ptr<Configuration>>& currentConfigs, double pairPotentialRange) {

radius = pairPotentialRange;

for (const auto& config : currentConfigs) {

if (config->box()->inscribedSphereRadius() < radius) {

radius = config->box()->inscribedSphereRadius();
}
}
aboswel marked this conversation as resolved.
Show resolved Hide resolved

if (radius == pairPotentialRange)
return 0;
else
return radius;
aboswel marked this conversation as resolved.
Show resolved Hide resolved

}

// Prompt the user for automatic adjustment, return the choice as true/false

bool PairPotentialCheck::displayPairPotentialWarning(QWidget *parent) {

reply = QMessageBox::question(parent, "Warning!", QString("Maximum pair potential range exceeds smallest box inradius! Adjust pair potential range to %1? and run?").arg(radius),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);

if (reply == QMessageBox::Yes)
return true;
else
return false;

}
aboswel marked this conversation as resolved.
Show resolved Hide resolved
25 changes: 25 additions & 0 deletions src/gui/pairPotentialCheckDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2024 Team Dissolve and contributors

#pragma once

#include "classes/coreData.h"
#include "classes/configuration.h"
#include "classes/box.h"
#include <QMessageBox>

aboswel marked this conversation as resolved.
Show resolved Hide resolved
class PairPotentialCheck {

public:

static double checkPairPotential(std::vector<std::unique_ptr<Configuration>>& currentConfigs, double pairPotentialRange);
static bool displayPairPotentialWarning(QWidget *parent = nullptr);

static double radius;

private:

static QMessageBox::StandardButton reply;


};
Loading