From 3c33d42d3bdac47a5f765b7fcdf331385c153101 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Tue, 7 May 2013 17:06:44 +0200 Subject: [PATCH] Modified use of neighbor list in COORDINATION It solves a known problem with the calculation of acceptance in replica exchange with COORDINATION and NLIST. Notice that it changes the behavior of neighbor list in the first two steps of a simulation. Previously, during those steps full pair list was used. Now, first step is equivalent to any other step multiple of NL_STRIDE. Because of this, I updated a couple of regtests. --- regtest/multicolvar/rt20-mpi/colvar.reference | 4 ++-- regtest/multicolvar/rt20/colvar.reference | 4 ++-- src/colvar/CoordinationBase.cpp | 22 +++++++++---------- src/colvar/CoordinationBase.h | 3 ++- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/regtest/multicolvar/rt20-mpi/colvar.reference b/regtest/multicolvar/rt20-mpi/colvar.reference index 514344336..93677d871 100644 --- a/regtest/multicolvar/rt20-mpi/colvar.reference +++ b/regtest/multicolvar/rt20-mpi/colvar.reference @@ -1,6 +1,6 @@ #! FIELDS time d1.less_than d2.less_than c1 - 0.000000 3.71160 3.70528 3.71160 - 0.050000 3.65204 3.64568 3.65204 + 0.000000 3.71160 3.70528 3.63725 + 0.050000 3.65204 3.64568 3.57396 0.100000 3.68479 3.67845 3.61408 0.150000 3.74173 3.73336 3.66938 0.200000 3.80672 3.79754 3.73794 diff --git a/regtest/multicolvar/rt20/colvar.reference b/regtest/multicolvar/rt20/colvar.reference index 514344336..93677d871 100644 --- a/regtest/multicolvar/rt20/colvar.reference +++ b/regtest/multicolvar/rt20/colvar.reference @@ -1,6 +1,6 @@ #! FIELDS time d1.less_than d2.less_than c1 - 0.000000 3.71160 3.70528 3.71160 - 0.050000 3.65204 3.64568 3.65204 + 0.000000 3.71160 3.70528 3.63725 + 0.050000 3.65204 3.64568 3.57396 0.100000 3.68479 3.67845 3.61408 0.150000 3.74173 3.73336 3.66938 0.200000 3.80672 3.79754 3.73794 diff --git a/src/colvar/CoordinationBase.cpp b/src/colvar/CoordinationBase.cpp index 5806073c2..dbef34b52 100644 --- a/src/colvar/CoordinationBase.cpp +++ b/src/colvar/CoordinationBase.cpp @@ -45,7 +45,8 @@ CoordinationBase::CoordinationBase(const ActionOptions&ao): PLUMED_COLVAR_INIT(ao), pbc(true), serial(false), -reduceListAtNextStep(false) +invalidateList(true), +firsttime(true) { parseFlag("SERIAL",serial); @@ -106,12 +107,14 @@ CoordinationBase::~CoordinationBase(){ } void CoordinationBase::prepare(){ - if(reduceListAtNextStep){ + if(nl->getStride()>0) + if(firsttime || (getStep()%nl->getStride()==0)){ + requestAtoms(nl->getFullAtomList()); + invalidateList=true; + firsttime=false; + }else{ requestAtoms(nl->getReducedAtomList()); - reduceListAtNextStep=false; - } - if(nl->getStride()>0 && (getStep()-nl->getLastUpdate())>=nl->getStride()){ - requestAtoms(nl->getFullAtomList()); + invalidateList=false; } } @@ -124,7 +127,7 @@ void CoordinationBase::calculate() vector<Vector> deriv(getNumberOfAtoms()); // deriv.resize(getPositions().size()); - if(nl->getStride()>0 && (getStep()-nl->getLastUpdate())>=nl->getStride()){ + if(nl->getStride()>0 && invalidateList){ nl->update(getPositions()); } @@ -167,11 +170,6 @@ void CoordinationBase::calculate() setValue (ncoord); setBoxDerivatives (virial); - if(nl->getStride()>0 && (getStep()-nl->getLastUpdate())>=nl->getStride()){ - reduceListAtNextStep=true; - nl->setLastUpdate(getStep()); - } - } } } diff --git a/src/colvar/CoordinationBase.h b/src/colvar/CoordinationBase.h index 6bf546f35..bc32f934a 100644 --- a/src/colvar/CoordinationBase.h +++ b/src/colvar/CoordinationBase.h @@ -33,7 +33,8 @@ class CoordinationBase : public Colvar { bool pbc; bool serial; NeighborList *nl; - bool reduceListAtNextStep; + bool invalidateList; + bool firsttime; public: CoordinationBase(const ActionOptions&); -- GitLab