Skip to content

Commit

Permalink
Second attempt to ensure all atoms are in single link cell if structu…
Browse files Browse the repository at this point in the history
…re has nopbc
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Jan 20, 2025
1 parent c49e339 commit 6336911
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/tools/LinkCells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void LinkCells::buildCellLists( const std::vector<Vector>& pos, const std::vecto
// Must be able to check that pbcs are not nonsensical in some way?? -- GAT
auto box = pbc.getBox();
if(box(0,0)==0.0 && box(0,1)==0.0 && box(0,2)==0.0 && box(1,0)==0.0 && box(1,1)==0.0 && box(1,2)==0.0 && box(2,0)==0.0 && box(2,1)==0 && box(2,2)==0) {
box(0,0) = box(1,1) = box(2,2) = 1e200;
box(0,0) = box(1,1) = box(2,2) = link_cutoff;
} else {
auto determinant = box.determinant();
plumed_assert(determinant > epsilon) <<"Cell lists cannot be built when passing a box with null volume. Volume is "<<determinant;
Expand Down Expand Up @@ -114,7 +114,7 @@ void LinkCells::buildCellLists( const std::vector<Vector>& pos, const std::vecto
tot+=lcell_tots[i];
lcell_tots[i]=0;
}
plumed_assert( tot==pos.size() );
plumed_assert( tot==pos.size() ) <<"Total number of atoms found in link cells is "<<tot<<" number of atoms is "<<pos.size();

// And setup the link cells properly
for(unsigned j=0; j<pos.size(); ++j) {
Expand Down Expand Up @@ -186,8 +186,12 @@ void LinkCells::retrieveAtomsInCells( const unsigned& ncells_required,
}

std::array<unsigned,3> LinkCells::findMyCell( const Vector& pos ) const {
Vector fpos=mypbc.realToScaled( pos );
std::array<unsigned,3> celn;
if( ncells[0]*ncells[1]*ncells[2] == 1 ) {
celn[0]=celn[1]=celn[2]=0;
return celn;
}
Vector fpos=mypbc.realToScaled( pos );
for(unsigned j=0; j<3; ++j) {
celn[j] = std::floor( ( Tools::pbc(fpos[j]) + 0.5 ) * ncells[j] );
plumed_assert( celn[j]>=0 && celn[j]<ncells[j] ); // Check that atom is in box
Expand Down

1 comment on commit 6336911

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/a-masterclass-22-09.txt
Found broken examples in automatic/a-masterclass-22-11.txt
Found broken examples in automatic/a-masterclass-22-12.txt
Found broken examples in automatic/performance-optimization.txt
Found broken examples in automatic/a-trieste-6.txt
Found broken examples in automatic/munster.txt
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in MiscelaneousPP.md

Please sign in to comment.