diff --git a/src/gui/configurationTab.cpp b/src/gui/configurationTab.cpp index afea32383f..3533fe2660 100644 --- a/src/gui/configurationTab.cpp +++ b/src/gui/configurationTab.cpp @@ -220,6 +220,9 @@ void ConfigurationTab::on_GenerateButton_clicked(bool checked) // Clear the messages dissolveWindow_->clearMessages(); + // Check pair potential range against box geometries + dissolveWindow_->checkPairPotentialRange(); + // Make sure the potential map is up to date dissolve_.updatePairPotentials(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index fa7479dd77..f1f4063468 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -458,3 +458,33 @@ void DissolveWindow::statusLabelLinkClicked(const QString &link) if (DissolveSys::sameString(link.toStdString(), "Messages")) ui_.MainTabs->setCurrentIndex(0); } + +/* + * Check functions + */ + +// Checks pair potential range against all present box geometries +void DissolveWindow::checkPairPotentialRange(QWidget *parent) +{ + std::optional radius; + + // 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())) + { + radius = config->box()->inscribedSphereRadius(); + } + } + + // Prompt to auto-adjust + if (radius.has_value()) + { + if (QMessageBox::question(parent, "Warning!", + QString("Maximum pair potential range exceeds smallest allowed by current Configurations! " + "Adjust pair potential range to %1?") + .arg(radius.value()), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) + dissolve_.setPairPotentialRange(radius.value()); + } +} \ No newline at end of file diff --git a/src/gui/gui.h b/src/gui/gui.h index 017ab2adf1..9de7061f37 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -254,4 +254,11 @@ class DissolveWindow : public QMainWindow Q_SIGNALS: void iterate(int); void stopIterating(); + + /* + * Checks + */ + public: + // Checks pair potential range against all present box geometries + void checkPairPotentialRange(QWidget *parent = nullptr); }; diff --git a/src/gui/gui_simulation.cpp b/src/gui/gui_simulation.cpp index 63b8e8fe06..c4d113c1d1 100644 --- a/src/gui/gui_simulation.cpp +++ b/src/gui/gui_simulation.cpp @@ -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 + checkPairPotentialRange(); + // Prepare the simulation if (!dissolve_.prepare()) { diff --git a/src/gui/menu_configuration.cpp b/src/gui/menu_configuration.cpp index a3c5598381..3734f7411b 100644 --- a/src/gui/menu_configuration.cpp +++ b/src/gui/menu_configuration.cpp @@ -80,6 +80,9 @@ void DissolveWindow::on_ConfigurationCreateAction_triggered(bool checked) fullUpdate(); ui_.MainTabs->setCurrentTab(newConfig); + + // Check pair potential range against box geometry + checkPairPotentialRange(); } }