plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
357 stars 284 forks source link

Link cells without PBC #1100

Open gtribello opened 2 months ago

gtribello commented 2 months ago
Description

I have modified the link cells class to ensure it works even if you are not running a simulation with PBC.

Please note that to use the link cell class, you need to use the functions below:

#include "tools/LinkCells.h"

// Declare a link cells object
LinkCells linkcells;

// Create a link cells object
linkcells(comm)

// Set the link cell cutoff
linkcells.setCutoff( nl_cut );

// Allocate each atom in a list to its appropriate cell
std::vector<Vector> ltmp_pos;     // Vector of atomic positions
std::vector<unsigned> indices;    // index to use for each of the atoms -- index in colvar NOT index in MD code. 
linkcells.buildCellLists( ltmp_pos, indices, getPbc() );

// Retrieve the atoms in the cells that are needed
unsigned ncells_required;
std::vector<unsigned> indices( 1+ablocks.size() )
std::vector<unsigned> cells_required( linkcells.getNumberOfCells() );
linkcells.addRequiredCells( linkcells.findMyCell( pos ), ncells_required, cells_required );
// Now get the indices of the atoms in the link cells positions
unsigned natoms=1; indices[0]=pTaskList[i];
linkcells.retrieveAtomsInCells( ncells_required, cells_required, natoms, indices );

I've copy and pasted these commands from the class where I use stuff. It dawns on me that how you use the interface in that second bunch of calls is less clear than it could be. It perhaps be worth writing a wrapper around all that stuff.

Target release

I would like my code to appear in release 2.10

Type of contribution
Copyright
Tests
gtribello commented 2 months ago

@GiovanniBussi there are regtests for this specific class in adjmat/rt-link and adjmat/rt-link-nopbc :-)