Skip to content
Snippets Groups Projects
Commit 7257c96d authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Merge branch 'fixing-nlist' into v2.0

parents 10108579 2bf30f5d
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,12 @@ c1: ... ...@@ -4,7 +4,12 @@ c1: ...
COORDINATION GROUPA=1 GROUPB=2-100 NLIST NL_CUTOFF=2.5 NL_STRIDE=20 COORDINATION GROUPA=1 GROUPB=2-100 NLIST NL_CUTOFF=2.5 NL_STRIDE=20
SWITCH={RATIONAL NN=6 MM=12 R_0=1.0} SWITCH={RATIONAL NN=6 MM=12 R_0=1.0}
... ...
c1x: ...
COORDINATION GROUPA=1 GROUPB=2-100 NLIST NL_CUTOFF=2.5 NL_STRIDE=30
SWITCH={RATIONAL NN=6 MM=12 R_0=1.0}
...
PRINT ARG=d1.*,d2.*,c1 FILE=colvar FMT=%8.5f STRIDE=1 PRINT ARG=d1.*,d2.*,c1 FILE=colvar FMT=%8.5f STRIDE=1
PRINT ARG=c1x FILE=colvarx
COORDINATIONNUMBER SPECIES=1-5 SWITCH={RATIONAL R_0=0.5} MORE_THAN={EXP R_0=4.0} LABEL=c2 COORDINATIONNUMBER SPECIES=1-5 SWITCH={RATIONAL R_0=0.5} MORE_THAN={EXP R_0=4.0} LABEL=c2
COORDINATIONNUMBER SPECIES=1-5 SWITCH={RATIONAL R_0=0.5} MORE_THAN={EXP R_0=4.0} NUMERICAL_DERIVATIVES LABEL=c2n COORDINATIONNUMBER SPECIES=1-5 SWITCH={RATIONAL R_0=0.5} MORE_THAN={EXP R_0=4.0} NUMERICAL_DERIVATIVES LABEL=c2n
DUMPDERIVATIVES ARG=c2.*,c2n.* FILE=derivatives FMT=%8.4f DUMPDERIVATIVES ARG=c2.*,c2n.* FILE=derivatives FMT=%8.4f
...@@ -32,7 +32,7 @@ using namespace std; ...@@ -32,7 +32,7 @@ using namespace std;
NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNumber>& list1, NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNumber>& list1,
const bool& do_pair, const bool& do_pbc, const Pbc& pbc, const bool& do_pair, const bool& do_pbc, const Pbc& pbc,
const double& distance, const unsigned& stride): const double& distance, const unsigned& stride): reduced(false),
do_pair_(do_pair), do_pbc_(do_pbc), pbc_(&pbc), do_pair_(do_pair), do_pbc_(do_pbc), pbc_(&pbc),
distance_(distance), stride_(stride) distance_(distance), stride_(stride)
{ {
...@@ -54,7 +54,7 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNum ...@@ -54,7 +54,7 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNum
NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc, NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc,
const Pbc& pbc, const double& distance, const Pbc& pbc, const double& distance,
const unsigned& stride): const unsigned& stride): reduced(false),
do_pbc_(do_pbc), pbc_(&pbc), do_pbc_(do_pbc), pbc_(&pbc),
distance_(distance), stride_(stride){ distance_(distance), stride_(stride){
fullatomlist_=list0; fullatomlist_=list0;
...@@ -119,10 +119,11 @@ void NeighborList::setRequestList() { ...@@ -119,10 +119,11 @@ void NeighborList::setRequestList() {
requestlist_.push_back(fullatomlist_[neighbors_[i].second]); requestlist_.push_back(fullatomlist_[neighbors_[i].second]);
} }
Tools::removeDuplicates(requestlist_); Tools::removeDuplicates(requestlist_);
reduced=false;
} }
vector<AtomNumber>& NeighborList::getReducedAtomList() { vector<AtomNumber>& NeighborList::getReducedAtomList() {
for(unsigned int i=0;i<size();++i){ if(!reduced)for(unsigned int i=0;i<size();++i){
unsigned newindex0=0,newindex1=0; unsigned newindex0=0,newindex1=0;
AtomNumber index0=fullatomlist_[neighbors_[i].first]; AtomNumber index0=fullatomlist_[neighbors_[i].first];
AtomNumber index1=fullatomlist_[neighbors_[i].second]; AtomNumber index1=fullatomlist_[neighbors_[i].second];
...@@ -132,6 +133,7 @@ vector<AtomNumber>& NeighborList::getReducedAtomList() { ...@@ -132,6 +133,7 @@ vector<AtomNumber>& NeighborList::getReducedAtomList() {
p = std::find(requestlist_.begin(), requestlist_.end(), index1); plumed_assert(p!=requestlist_.end()); newindex1=p-requestlist_.begin(); p = std::find(requestlist_.begin(), requestlist_.end(), index1); plumed_assert(p!=requestlist_.end()); newindex1=p-requestlist_.begin();
neighbors_[i]=pair<unsigned,unsigned>(newindex0,newindex1); neighbors_[i]=pair<unsigned,unsigned>(newindex0,newindex1);
} }
reduced=true;
return requestlist_; return requestlist_;
} }
......
...@@ -35,6 +35,7 @@ class Pbc; ...@@ -35,6 +35,7 @@ class Pbc;
/// A class that implements neighbor lists from two lists or a single list of atoms /// A class that implements neighbor lists from two lists or a single list of atoms
class NeighborList class NeighborList
{ {
bool reduced;
bool do_pair_,do_pbc_,twolists_; bool do_pair_,do_pbc_,twolists_;
const PLMD::Pbc* pbc_; const PLMD::Pbc* pbc_;
std::vector<PLMD::AtomNumber> fullatomlist_,requestlist_; std::vector<PLMD::AtomNumber> fullatomlist_,requestlist_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment