"csrc/vscode:/vscode.git/clone" did not exist on "7949f854f4029d242c7bc72525de31ab050a8c0d"
Unverified Commit 7af565ed authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Use more efficient version of updateContextState() (#4054)

parent 86f07082
......@@ -55,7 +55,7 @@ public:
const GayBerneForce& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context) {
void updateContextState(ContextImpl& context, bool& forcesInvalid) {
// This force field doesn't update the state directly.
}
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups);
......
......@@ -50,7 +50,7 @@ public:
const MonteCarloAnisotropicBarostat& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context);
void updateContextState(ContextImpl& context, bool& forcesInvalid);
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
// This force doesn't apply forces to particles.
return 0.0;
......
......@@ -50,7 +50,7 @@ public:
const MonteCarloMembraneBarostat& getOwner() const {
return owner;
}
void updateContextState(ContextImpl& context);
void updateContextState(ContextImpl& context, bool& forcesInvalid);
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
// This force doesn't apply forces to particles.
return 0.0;
......
......@@ -62,7 +62,7 @@ void MonteCarloAnisotropicBarostatImpl::initialize(ContextImpl& context) {
SimTKOpenMMUtilities::setRandomNumberSeed(owner.getRandomNumberSeed());
}
void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context) {
void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context, bool& forcesInvalid) {
if (++step < owner.getFrequency() || owner.getFrequency() == 0)
return;
if (!owner.getScaleX() && !owner.getScaleY() && !owner.getScaleZ())
......@@ -123,8 +123,10 @@ void MonteCarloAnisotropicBarostatImpl::updateContextState(ContextImpl& context)
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else
else {
numAccepted[axis]++;
forcesInvalid = true;
}
numAttempted[axis]++;
if (numAttempted[axis] >= 10) {
if (numAccepted[axis] < 0.25*numAttempted[axis]) {
......
......@@ -62,7 +62,7 @@ void MonteCarloMembraneBarostatImpl::initialize(ContextImpl& context) {
SimTKOpenMMUtilities::setRandomNumberSeed(owner.getRandomNumberSeed());
}
void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context, bool& forcesInvalid) {
if (++step < owner.getFrequency() || owner.getFrequency() == 0)
return;
step = 0;
......@@ -124,8 +124,10 @@ void MonteCarloMembraneBarostatImpl::updateContextState(ContextImpl& context) {
context.getOwner().setPeriodicBoxVectors(box[0], box[1], box[2]);
kernel.getAs<ApplyMonteCarloBarostatKernel>().restoreCoordinates(context);
}
else
else {
numAccepted[axis]++;
forcesInvalid = true;
}
numAttempted[axis]++;
if (numAttempted[axis] >= 10) {
if (numAccepted[axis] < 0.25*numAttempted[axis]) {
......
......@@ -54,7 +54,7 @@ public:
return owner;
}
void updateRPMDState(ContextImpl& context);
void updateContextState(ContextImpl& context) {
void updateContextState(ContextImpl& context, bool& forcesInvalid) {
// This is unused, since the updating is done in updateRPMDState().
}
double calcForcesAndEnergy(ContextImpl& context, bool includeForces, bool includeEnergy, int groups) {
......
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