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 pair potential range against box geometries
dissolveWindow_->checkPairPotentialRange();

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

Expand Down
34 changes: 34 additions & 0 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,37 @@ 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)
{

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

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

aboswel marked this conversation as resolved.
Show resolved Hide resolved
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
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());
}
}
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:
// Checks pair potential range against all present box geometries
void checkPairPotentialRange(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
checkPairPotentialRange();

// 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 @@ -80,6 +80,9 @@ void DissolveWindow::on_ConfigurationCreateAction_triggered(bool checked)
fullUpdate();

ui_.MainTabs->setCurrentTab(newConfig);

// Check pair potential range against box geometry
checkPairPotentialRange();
}
}

Expand Down