Unverified Commit 86f07082 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed error in barostats (#4049)

parent 729c0990
......@@ -111,7 +111,7 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
context.getOwner().setPeriodicBoxVectors(Vec3(box[0][0]*lengthScale[0], box[0][1]*lengthScale[1], box[0][2]*lengthScale[2]),
Vec3(box[1][0]*lengthScale[0], box[1][1]*lengthScale[1], box[1][2]*lengthScale[2]),
Vec3(box[2][0]*lengthScale[0], box[2][1]*lengthScale[1], box[2][2]*lengthScale[2]));
// Compute the energy of the modified system.
double finalEnergy = context.getOwner().getState(State::Energy, false, groups).getPotentialEnergy();
......@@ -120,8 +120,8 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > exp(-w/kT)) {
// Reject the step.
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else
numAccepted[axis]++;
......
......@@ -90,8 +90,8 @@ void MonteCarloBarostatImpl::updateContextState(ContextImpl& context, bool& forc
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > exp(-w/kT)) {
// Reject the step.
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else {
numAccepted++;
......
......@@ -115,8 +115,8 @@ void MonteCarloFlexibleBarostatImpl::updateContextState(ContextImpl& context, bo
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > exp(-w/kT)) {
// Reject the step.
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else {
numAccepted++;
......
......@@ -121,8 +121,8 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
if (w > 0 && SimTKOpenMMUtilities::getUniformlyDistributedRandomNumber() > exp(-w/kT)) {
// Reject the step.
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else
numAccepted[axis]++;
......
......@@ -7217,7 +7217,7 @@ void CommonIntegrateCustomStepKernel::execute(ContextImpl& context, CustomIntegr
energy = savedEnergy[forceGroups];
if (needsGlobals[step] && !deviceGlobalsAreCurrent) {
// Upload the global values to the device.
globalValues.upload(localGlobalValues, true);
deviceGlobalsAreCurrent = true;
}
......@@ -7781,13 +7781,13 @@ void CommonApplyMonteCarloBarostatKernel::scaleCoordinates(ContextImpl& context,
cc.getLongForceBuffer().copyTo(savedLongForces);
if (savedFloatForces.isInitialized())
cc.getFloatForceBuffer().copyTo(savedFloatForces);
lastPosCellOffsets = cc.getPosCellOffsets();
kernel->setArg(0, (float) scaleX);
kernel->setArg(1, (float) scaleY);
kernel->setArg(2, (float) scaleZ);
setPeriodicBoxArgs(cc, kernel, 4);
kernel->execute(cc.getNumAtoms());
lastAtomOrder = cc.getAtomIndex();
lastPosCellOffsets = cc.getPosCellOffsets();
}
void CommonApplyMonteCarloBarostatKernel::restoreCoordinates(ContextImpl& context) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment