Simpatico  v1.10
SystemInterface.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 // namespace McMd
9 #include "SystemInterface.h"
10 #include "Simulation.h"
11 #include <simp/species/Species.h>
12 
13 #include <fstream>
14 
15 namespace McMd
16 {
17 
18  using namespace Util;
19  using namespace Simp;
20 
21  /*
22  * Constructor.
23  */
25  : simulationPtr_(parent.simulationPtr_),
26  systemPtr_(&parent),
27  moleculeSetsPtr_(parent.moleculeSetsPtr_),
28  boundaryPtr_(parent.boundaryPtr_)
29  #ifdef SIMP_BOND
30  , hasBonds_(parent.simulation().nBondType() > 0)
31  #endif
32  #ifdef SIMP_ANGLE
33  , hasAngles_(parent.simulation().nAngleType() > 0)
34  #endif
35  #ifdef SIMP_DIHEDRAL
36  , hasDihedrals_(parent.simulation().nDihedralType() > 0)
37  #endif
38  #ifdef MCMD_LINK
39  , hasLinks_(parent.simulation().nLinkType() > 0)
40  #endif
41  #ifdef SIMP_EXTERNAL
42  , hasExternal_(parent.simulation().hasExternal())
43  #endif
44  #ifdef SIMP_TETHER
45  , hasTethers_(parent.simulation().hasTether())
46  #endif
47  {}
48 
49  /*
50  * Destructor.
51  */
53  {}
54 
55  /*
56  * Is this System empty (i.e., devoid of Molecules) ?
57  */
59  {
60  for (int i = 0; i < simulation().nSpecies(); ++i) {
61  if (nMolecule(i) != 0) return false;
62  }
63  return true;
64  }
65 
66  /*
67  * Return the total number of atoms in this System.
68  */
70  {
71  int sum = 0;
72  for (int i = 0; i < simulation().nSpecies(); ++i) {
73  sum += nMolecule(i)*simulation().species(i).nAtom();
74  }
75  return sum;
76  }
77 
78 }
int nAtom() const
Get number of atoms per molecule for this Species.
bool isEmpty() const
Is this an empty SystemInterface (i.e., one with no molecules) ?
SystemInterface(System &parent)
Constructor.
A set of interacting Molecules enclosed by a Boundary.
Definition: System.h:115
Classes used by all simpatico molecular simulations.
int nAtom() const
Return the total number of atoms in this SystemInterface.
Simulation & simulation() const
Get the parent Simulation by reference.
Utility classes for scientific computation.
Definition: accumulators.mod:1
virtual ~SystemInterface()
Destructor.
int nMolecule(int speciesId) const
Get the number of molecules of one Species in this SystemInterface.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int nSpecies() const
Get the number of Species in this Simulation.
Species & species(int i)
Get a specific Species by reference.