Simpatico  v1.10
ddMd/potentials/pair/PairPotential.h
1 #ifndef DDMD_PAIR_POTENTIAL_H
2 #define DDMD_PAIR_POTENTIAL_H
3 
4 #include <ddMd/potentials/Potential.h> // base class
5 #include <ddMd/neighbor/CellList.h> // member
6 #include <ddMd/neighbor/PairList.h> // member
7 #include <ddMd/misc/DdTimer.h> // member
8 #include <simp/boundary/Boundary.h> // member (typedef)
9 #include <util/global.h>
10 
11 #include <iostream>
12 
13 #define DDMD_PAIR_POTENTIAL_TIMER
14 
15 /*
16 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
17 *
18 * Copyright 2010 - 2017, The Regents of the University of Minnesota
19 * Distributed under the terms of the GNU General Public License.
20 */
21 
22 namespace Util
23 { class Tensor; }
24 
25 namespace DdMd
26 {
27 
28  class Simulation;
29  class AtomStorage;
30  class Domain;
31 
32  using namespace Util;
33  using namespace Simp;
34 
44  class PairPotential : public Potential
45  {
46 
47  public:
48 
57  PairPotential(Simulation& simulation);
58 
64  PairPotential();
65 
69  virtual ~PairPotential();
70 
72 
73 
85  void associate(Domain& domain, Boundary& boundary, AtomStorage& storage);
86 
96  virtual void setNAtomType(int nAtomType) = 0;
97 
109  void
110  initialize(const Boundary& maxBoundary, double skin, int pairCapacity);
111 
117  void readParameters(std::istream& in);
118 
124  virtual void loadParameters(Serializable::IArchive &ar);
125 
133  virtual void save(Serializable::OArchive &ar);
134 
143  void setMethodId(int methodId);
144 
146 
148 
157  virtual
158  double pairEnergy(double rsq, int iAtomType, int jAtomType) const = 0;
159 
168  virtual
169  double pairForceOverR(double rsq, int iAtomType, int jAtomType) const = 0;
170 
179  virtual void set(std::string name, int i, int j, double value) = 0;
180 
188  virtual double get(std::string name, int i, int j) const = 0;
189 
193  virtual double maxPairCutoff() const = 0;
194 
198  virtual std::string interactionClassName() const = 0;
199 
201 
203 
213  void buildCellList();
214 
222  void buildPairList();
223 
231  #ifdef UTIL_MPI
232  virtual void computePairEnergies(MPI::Intracomm& communicator) = 0;
233  #else
234  virtual void computePairEnergies() = 0;
235  #endif
236 
243  DMatrix<double> pairEnergies() const;
244 
248  void unsetPairEnergies();
249 
259  #ifdef UTIL_MPI
260  void computeNPair(MPI::Intracomm& communicator);
261  #else
262  void computeNPair();
263  #endif
264 
271  int nPair() const;
272 
276  CellList& cellList();
277 
281  PairList& pairList();
282 
284 
288  double skin() const;
289 
293  double cutoff() const;
294 
298  int methodId() const;
299 
300  protected:
301 
304 
307 
310 
312  double skin_;
313 
315  double cutoff_;
316 
319 
322 
326  Boundary& boundary();
327 
331  Domain& domain();
332 
336  AtomStorage& storage();
337 
341  void setPairEnergies(DMatrix<double> pairEnergies);
342 
343  private:
344 
346  Domain* domainPtr_;
347 
349  Boundary* boundaryPtr_;
350 
352  AtomStorage* storagePtr_;
353 
355  int methodId_;
356 
358  int nPair_;
359 
361  Setable< DMatrix<double> > pairEnergies_;
362 
364  int nPairList(double cutoffSq);
365  int nPairCell(double cutoffSq);
366  int nPairNSq(double cutoffSq);
367 
371  void allocate();
372 
373  };
374 
375  inline CellList& PairPotential::cellList()
376  { return cellList_; }
377 
378  inline PairList& PairPotential::pairList()
379  { return pairList_; }
380 
381  inline double PairPotential::skin() const
382  { return skin_; }
383 
384  inline double PairPotential::cutoff() const
385  { return cutoff_; }
386 
387  inline Boundary& PairPotential::boundary()
388  { return *boundaryPtr_; }
389 
390  inline Domain& PairPotential::domain()
391  { return *domainPtr_; }
392 
393  inline AtomStorage& PairPotential::storage()
394  { return *storagePtr_; }
395 
396  inline void PairPotential::setMethodId(int methodId)
397  { methodId_ = methodId; }
398 
399  inline int PairPotential::methodId() const
400  { return methodId_; }
401 
402 }
403 #endif
A cell list used only to identify nearby atom pairs.
A Verlet nonbonded pair list.
int nCellCut_
Approximate number of cells per cutoff distance in each direction.
An orthorhombic periodic unit cell.
double skin_
Difference between pairlist cutoff and pair potential cutoff.
Template for a value that can be set or declared null (i.e., unknown).
Definition: Setable.h:38
double cutoff_
Minimum cell size = pair potential cutoff + skin.
File containing preprocessor macros for error handling.
Parallel domain decomposition (DD) MD simulation.
Classes used by all simpatico molecular simulations.
Main object for a domain-decomposition MD simulation.
int pairCapacity_
Maximum number of nonbonded pairs in pair list.
A Potential represents a potential energy contribution.
Definition: Potential.h:28
Saving / output archive for binary ostream.
CellList cellList_
CellList to construct PairList or calculate nonbonded pair forces.
Utility classes for scientific computation.
Definition: accumulators.mod:1
A container for all the atoms and ghost atoms on this processor.
PairList pairList_
Verlet pair list, to calculate nonbonded pair forces.
Decomposition of the system into domains associated with processors.
Definition: Domain.h:31
Saving archive for binary istream.
Boundary maxBoundary_
Boundary used to allocate space for the cell list.
Abstract base class for computing nonbonded pair forces and energies.