PairList Class Reference
[Molecular DynamicsParticle Positions]

#include <PairList.h>

Inheritance diagram for PairList:

IoList Io List of all members.

Detailed Description

A PairList (or Verlet list) is a list of neighboring particle pairs that are separated by a distance less than a specified cutoff.

The pair list is stored in integer arrays list1, list2, and first. Each element of list1 contains the integer Id of the first particle in a pair (the primary particle). Each element of list2 contains the integer Id of the second particle in a pair (secondary particle). Secondary particles that are neighbors of the same primary particle are listed consecutively. Element first[i] contains the index of the first element in list2 that contains a neighbor of primary particle list1[i]. The Ids of all the neighbors of primary particle with Id list1[i] are thus stored in first[i] <= j < first[i+1] of list2. Each pair is included only once, by including only pairs in which list2[j] > list1[i]. The total number of primary particles in list1 is nList1 (which is equal to or less than the total number of particles in the system). The total number of secondary particles in list2 (which is the total number of pairs) is nList2.

A loop over particle pairs, such as that required to calculated forces or energies, should thus take the following form:

    int i, j;
    PairList *pairlist;

    pairlist = new PairList;

    // [initialize and build the PairList]

    // Loop over primary particles
    for (i=0; i < pairList->nList1; i++) {
       Id1 = pairlist->list1[i];

       // Loop over secondary particles
       for (j = pairlist->first[i]; j < pairlist->first[i+1]; j++) {
           Id2 = pairlist->list2[j];

           // ... calculation involving particle pair Id1 and Id2... 

       }

    }

Note that the array first contains nParticle + 1 elements, and that the value of the last element, first[nParticle], is always equal to the total number of pairs nList2, which is one greater than the last valid index of array list2.

The 2D array oldPos[][] stores the positions of the particles when the PairList was last built. Element oldPos[i][j] = Particle[i].pos[j] is the jth Cartesian component of the position of particle i. This is used to test whether to the list has become outdated, and needs to be rebuilt.

Definition at line 71 of file PairList.h.

Public Member Functions

 PairList ()
 Default constructor.
 ~PairList ()
 Destructor.
void read (FILE *file)
 Read maxNPair (maximum allowable number of pairs) from file.
void initialize (int nParticle)
 Allocate first1, first2, list, and oldPos arrays.
void build (const Box *box, CellList *cellList, Particle *particles, ParticleBond *particleBonds, double cutoff)
 Create a new PairList, using the current particle positions and CellList.
bool isValid (const Box *box, Particle *particles, int nParticle, double skin) const
 Returns true if current PairList is still valid, false if it is obsolete.

Public Attributes

int * list1
 array of particle Ids for 1st particle in pair.
int * list2
 array of particle Ids for neighbors (2nd in pair).
int * first
 array of indices in list2 of 1st neighbor particle.
int nList1
 Number of primary particles in list1.
int nList2
 Number of particles (or pairs) in list2.

Friends

class PairListTest
class IntegratorTest


Constructor & Destructor Documentation

PairList::~PairList (  ) 

Destructor.

Deallocates dynamically allocated arrays list1, list2, first, and prevPos.

Definition at line 32 of file PairList.cpp.

References first, list1, and list2.


Member Function Documentation

void PairList::build ( const Box box,
CellList cellList,
Particle particles,
ParticleBond particleBonds,
double  cutoff 
)

Create a new PairList, using the current particle positions and CellList.

Preconditions:

Parameters:
box pointer to a Box object.
cellList pointer to an updated CellList object.
particles array of current Particle objects.
particleBonds array of ParticleBond objects.
cutoff cutoff radius for the pair list

Definition at line 89 of file PairList.cpp.

References ParticleBond::bond, Box::distanceSq(), first, CellList::getCellNeighbors(), CellList::getTotCells(), list1, list2, CellList::MaxNeighbor, ParticleBond::nBond, nList1, nList2, PMC_THROW, and Particle::pos.

Referenced by MdSystem::buildPairList().

void PairList::initialize ( int  nParticle  ) 

Allocate first1, first2, list, and oldPos arrays.

The arrays list1 and first are allocated with dimensions equal to the number nParticle of particles nParticle in the system, and to nParticle+1, respectively. Array list2 is allocated with a dimension given by member maxNPair, which must be greater than the maximum number of distinct pairs encountered in system during the simulation. The dimensions of 2D array oldPos are 3*nParticle.

Parameters:
nParticle number of particles in system

Definition at line 58 of file PairList.cpp.

References first, VectorArray::initialize(), list1, list2, and PMC_NULL_INDEX.

Referenced by MdSystem::initialize().

bool PairList::isValid ( const Box box,
Particle particles,
int  nParticle,
double  skin 
) const

Returns true if current PairList is still valid, false if it is obsolete.

The PairList is considered valid if no particle has moved a distance skin/2 since the PairList was built, and invalid otherwise. The parameter skin is the difference between the Verlet radius that was used to construct the PairList and the maximum range of any nonbonded potential (i.e., the maxCutoff member of a PairPotential object).

Parameters:
box Box object containing simulation cell dimensions
particles array of Particle objects for all particles
nParticle number of particles
skin difference between Verlet radius and maximum cutoff
Returns:
true if the Pairlist is valid, false if it is outdated

Definition at line 207 of file PairList.cpp.

References Box::distanceSq(), and Particle::pos.

Referenced by MdSystem::isValidPairList().

void PairList::read ( FILE *  file  )  [virtual]

Read maxNPair (maximum allowable number of pairs) from file.

Parameters:
file pointer to parameter file

Reimplemented from IoList.

Definition at line 49 of file PairList.cpp.

References IoList::readInt().


The documentation for this class was generated from the following files:
Generated on Fri Oct 31 10:28:22 2008 for Polymer Monte Carlo (PMC) by  doxygen 1.4.7