Simpatico  v1.10
MdPairPotential.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "MdPairPotential.h"
9 #include <mcMd/simulation/System.h>
10 #include <mcMd/simulation/Simulation.h>
11 #include <simp/boundary/Boundary.h>
12 #include <util/global.h>
13 
14 #include <fstream>
15 
16 namespace McMd
17 {
18 
19  using namespace Util;
20  using namespace Simp;
21 
22  /*
23  * Constructor.
24  */
26  : ParamComposite(),
27  SystemInterface(system)
28  { setClassName("MdPairPotential"); }
29 
30  /*
31  * Destructor.
32  */
34  {}
35 
36  /*
37  * Build the PairList.
38  */
40  {
41  // Precondition
42  if (!pairList_.isInitialized()) {
43  UTIL_THROW("PairList not initialized in MdPairPotential::buildPairList");
44  }
45 
46  // Set up an empty PairList with an empty internal CellList.
48 
49  // Add every Atom in this System to the CellList
51  Molecule::AtomIterator atomIter;
52  for (int iSpec=0; iSpec < simulation().nSpecies(); ++iSpec) {
53  for (begin(iSpec, molIter); molIter.notEnd(); ++molIter) {
54  molIter->begin(atomIter);
55  for ( ; atomIter.notEnd(); ++atomIter) {
56  #ifdef MCMD_SHIFT
57  boundary().shift(atomIter->position(), atomIter->shift());
58  #else
59  boundary().shift(atomIter->position());
60  #endif
61  pairList_.addAtom(*atomIter);
62  }
63  }
64  }
65 
66  // Use the completed CellList to build the PairList
68  }
69 
70  /*
71  * Clear the PairList statistical accumulators
72  */
75 
76  /*
77  * Return true if the pair list is current, false if it is obsolete.
78  */
80  { return pairList_.isCurrent(boundary()); }
81 
82 }
void addAtom(Atom &atom)
Add an Atom to the CellList.
An interface to a System.
void build(const Boundary &boundary)
Use a complete CellList to build a new PairList.
bool notEnd() const
Is the current pointer not at the end of the array?
Definition: ArrayIterator.h:83
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
File containing preprocessor macros for error handling.
Classes used by all simpatico molecular simulations.
bool isInitialized() const
Has the initialize function been called?
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
void setup(const Boundary &boundary)
Setup an empty grid of cells for the internal cell list.
Simulation & simulation() const
Get the parent Simulation by reference.
MdPairPotential(System &system)
Constructor.
bool notEnd() const
Is the current pointer not at the end of the PArray?
Utility classes for scientific computation.
Definition: accumulators.mod:1
void shift(Vector &r) const
Shift Cartesian Vector r to its primary image.
Forward iterator for an Array or a C array.
Definition: ArrayIterator.h:39
Forward iterator for a PArray.
Definition: ArraySet.h:19
PairList pairList_
Verlet neighbor pair list for nonbonded interactions.
void clearStatistics()
Clear statistical accumulators (maxNAtom, maxNPair, buildCounter).
void begin(int speciesId, System::MoleculeIterator &iterator)
Initialize an iterator for molecules of one species in this SystemInterface.
bool isPairListCurrent()
Return true if PairList is current, false if obsolete.
virtual ~MdPairPotential()
Destructor.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
void buildPairList()
Build the internal PairList.
void clearPairListStatistics()
Clear all statistical accumulators stored in PairList.
void setClassName(const char *className)
Set class name string.
bool isCurrent(const Boundary &boundary) const
Returns true if PairList is current, false otherwise.
Boundary & boundary() const
Get the Boundary by reference.
An object that can read multiple parameters from file.