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

fix: potential range check not handling empty configs or size factors #2078

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gui/configurationTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ 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();

// Initialise the content
configuration_->initialiseContent({dissolve_.worldPool(), dissolve_});

// Check pair potential range against box geometries
dissolveWindow_->checkPairPotentialRange();

// Update
updateControls();
dissolveWindow_->updateStatusBar();
Expand Down
11 changes: 7 additions & 4 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,10 @@ void DissolveWindow::checkPairPotentialRange(QWidget *parent)
// 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()) && config->nAtoms() > 0)
{
radius = config->box()->inscribedSphereRadius();
}
// Accounting for size factors
double reducedRadius = config->box()->inscribedSphereRadius() / config->requestedSizeFactor().value_or(1.0);
if (reducedRadius < radius.value_or(dissolve_.pairPotentialRange()) && config->nAtoms() > 0)
radius = reducedRadius;
}

// Prompt to auto-adjust
Expand All @@ -485,6 +485,9 @@ void DissolveWindow::checkPairPotentialRange(QWidget *parent)
"Adjust pair potential range to %1?")
.arg(radius.value()),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
{
dissolve_.setPairPotentialRange(radius.value());
dissolve_.updatePairPotentials();
}
}
}
Loading