Skip to content

Commit

Permalink
Reduce max volume adjustment to avoid negative box dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
LSchwiebert committed May 18, 2024
1 parent ff3f67a commit c913717
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/BoxDimensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ uint BoxDimensions::ShiftVolume(BoxDimensions &newDim, XYZ &scale, const uint b,
// automatically reject to prevent errors.
if ((newDim.halfAx.x[b] < rCut[b] || newDim.halfAx.y[b] < rCut[b] ||
newDim.halfAx.z[b] < rCut[b] || newVolume < minVol[b])) {
std::cout << "WARNING!!! box shrunk below 2*Rcut! Auto-rejecting!\n";
std::cout << "AxisDimensions: " << newDim.GetAxis(b) << std::endl;
std::cout << "Exiting!\n";
std::cout << "WARNING!!! Box " << b
<< " shrunk below 2*Rcut! Auto-rejecting!" << std::endl;
std::cout << "Volume was reduced from " << volume[b] << " to " << newVolume
<< std::endl;
std::cout << "Old Axis Dimensions: " << axis.Get(b) << std::endl;
std::cout << "New Axis Dimensions: " << newDim.GetAxis(b) << std::endl;
std::cout << "Exiting!" << std::endl;
exit(EXIT_FAILURE);
}
scale = newDim.axis.Get(b) / axis.Get(b);
Expand Down
10 changes: 7 additions & 3 deletions src/BoxDimensionsNonOrth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,13 @@ uint BoxDimensionsNonOrth::ShiftVolume(BoxDimensionsNonOrth &newDim, XYZ &scale,
// automatically reject to prevent errors.
if ((newDim.halfAx.x[b] < rCut[b] || newDim.halfAx.y[b] < rCut[b] ||
newDim.halfAx.z[b] < rCut[b] || newVolume < minVol[b])) {
std::cout << "WARNING!!! box shrunk below 2*Rcut! Auto-rejecting!\n";
std::cout << "AxisDimensions: " << newDim.GetAxis(b) << std::endl;
std::cout << "Exiting!\n";
std::cout << "WARNING!!! Box " << b
<< " shrunk below 2*Rcut! Auto-rejecting!" << std::endl;
std::cout << "Volume was reduced from " << volume[b] << " to " << newVolume
<< std::endl;
std::cout << "Old Axis Dimensions: " << axis.Get(b) << std::endl;
std::cout << "New Axis Dimensions: " << newDim.GetAxis(b) << std::endl;
std::cout << "Exiting!" << std::endl;
exit(EXIT_FAILURE);
}
scale = newDim.axis.Get(b) / axis.Get(b);
Expand Down
5 changes: 3 additions & 2 deletions src/MoveSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,9 @@ void MoveSettings::Adjust(const uint box, const uint move, const uint kind) {
scale[box][move][kind] *= 0.5;
}
}
// Warning: This will lead to have acceptance > 50%
double maxVolExchange = boxDimRef.volume[box] - boxDimRef.minVol[box];
// Warning: This could lead to an acceptance of > 50%
double maxVolExchange =
boxDimRef.volume[box] * 0.34 - boxDimRef.minVol[box];
num::Bound<double>(scale[box][move][kind], 0.001, maxVolExchange - 0.001);
}
#endif
Expand Down

0 comments on commit c913717

Please sign in to comment.