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
3 changes: 3 additions & 0 deletions src/gui/configurationTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ void ConfigurationTab::on_GenerateButton_clicked(bool checked)
// Clear the messages
dissolveWindow_->clearMessages();

// Check maximum potential range against box geometries
dissolveWindow_->checkPairPotential();

// Make sure the potential map is up to date
dissolve_.updatePairPotentials();

Expand Down
30 changes: 30 additions & 0 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,33 @@ void DissolveWindow::statusLabelLinkClicked(const QString &link)
if (DissolveSys::sameString(link.toStdString(), "Messages"))
ui_.MainTabs->setCurrentIndex(0);
}

/*
* Check functions
*/

// Returns maximum pair potential range given all present box geometries
aboswel marked this conversation as resolved.
Show resolved Hide resolved
void DissolveWindow::checkPairPotential(QWidget *parent) {
aboswel marked this conversation as resolved.
Show resolved Hide resolved

aboswel marked this conversation as resolved.
Show resolved Hide resolved
std::optional<double> radius;
QMessageBox::StandardButton reply;
aboswel marked this conversation as resolved.
Show resolved Hide resolved

// Return smallest inscribed sphere radius if less than current pair potential range
for (const auto& config : dissolve_.coreData().configurations()) {

if (config->box()->inscribedSphereRadius() < radius.value_or(dissolve_.pairPotentialRange())) {

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

// Prompt to auto-adjust
if (radius.has_value()) {

aboswel marked this conversation as resolved.
Show resolved Hide resolved
reply = QMessageBox::question(parent, "Warning!", QString("Maximum pair potential range exceeds smallest box inradius! Adjust pair potential range to %1?").arg(radius.value()),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);

if (reply == QMessageBox::Yes)
dissolve_.setPairPotentialRange(radius.value());
aboswel marked this conversation as resolved.
Show resolved Hide resolved
}
}
7 changes: 7 additions & 0 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,11 @@ class DissolveWindow : public QMainWindow
Q_SIGNALS:
void iterate(int);
void stopIterating();

/*
* Checks
*/
public:
// Returns maximum pair potential range given all present box geometries
aboswel marked this conversation as resolved.
Show resolved Hide resolved
void checkPairPotential(QWidget *parent = nullptr);
};
3 changes: 3 additions & 0 deletions src/gui/gui_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ 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
checkPairPotential();

// Prepare the simulation
if (!dissolve_.prepare())
{
Expand Down
3 changes: 3 additions & 0 deletions src/gui/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ void DissolveWindow::on_ConfigurationCreateAction_triggered(bool checked)

ui_.MainTabs->setCurrentTab(newConfig);
}

// Check pair potential range against box geometry
checkPairPotential();
aboswel marked this conversation as resolved.
Show resolved Hide resolved
}

void DissolveWindow::on_ConfigurationCreateEmptyAction_triggered(bool checked)
Expand Down
Loading