Simpatico  v1.10
McMuExchange.h
1 #ifndef MCMD_MC_MU_EXCHANGE_H
2 #define MCMD_MC_MU_EXCHANGE_H
3 
4 /*
5 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <mcMd/analyzers/SystemAnalyzer.h> // base class template
12 #include <mcMd/mcSimulation/McSystem.h> // base template parameter
13 #include <util/accumulators/Average.h> // member
14 #include <util/containers/DArray.h> // member template
15 #include <util/containers/DSArray.h> // member template
16 #include <util/archives/Serializable.h> // typedef
17 
18 #include <cstdio>
19 
20 namespace McMd
21 {
22 
23  using namespace Util;
24 
25  class Atom;
26 
41  class McMuExchange : public SystemAnalyzer<McSystem>
42  {
43 
44  public:
45 
49  McMuExchange(McSystem& system);
50 
54  virtual void readParameters(std::istream& in);
55 
59  virtual void setup();
60 
64  virtual void sample(long iStep);
65 
69  virtual void output();
70 
76  virtual void save(Serializable::OArchive& ar);
77 
83  virtual void loadParameters(Serializable::IArchive& ar);
84 
91  template <class Archive>
92  void serialize(Archive& ar, const unsigned int version);
93 
94  private:
95 
97  Simulation& simulation();
98 
100  Boundary& boundary();
101 
103  Simulation *simulationPtr_;
104 
106  Boundary *boundaryPtr_;
107 
109  std::ofstream outputFile_;
110 
112  DArray<Average> accumulators_;
113 
115  DArray<int> newTypeIds_;
116 
118  DArray<int> isAtomFlipped_;
119 
121  DSArray<int> flipAtomIds_;
122 
124  CellList::NeighborArray neighbors_;
125 
127  int speciesId_;
128 
130  int nMolecule_;
131 
133  int nAtom_;
134 
136  bool isInitialized_;
137 
138  };
139 
140  // Inline methods
141 
142  /*
143  * Get Simulation object of parent McSystem.
144  */
145  inline Simulation& McMuExchange::simulation()
146  { return *simulationPtr_; }
147 
148  /*
149  * Get Boundary object of parent McSystem.
150  */
151  inline Boundary& McMuExchange::boundary()
152  { return *boundaryPtr_; }
153 
154  /*
155  * Serialize to/from an archive.
156  */
157  template <class Archive>
158  void McMuExchange::serialize(Archive& ar,
159  const unsigned int version)
160  {
161  ar & interval_;
162  ar & outputFileName_;
163  ar & speciesId_;
164  ar & nAtom_;
165  ar & newTypeIds_;
166  ar & nMolecule_;
167  for (int i = 0; i < nMolecule_; ++i) {
168  ar & accumulators_[i];
169  }
170  }
171 
172 }
173 #endif
A System for use in a Markov chain Monte Carlo simulation.
Definition: McSystem.h:52
Exchange chemical potential for semigrand ensemble.
Definition: McMuExchange.h:41
An orthorhombic periodic unit cell.
void serialize(Archive &ar, PairSelector &selector, const unsigned int version)
Serialize a PairSelector.
Definition: PairSelector.h:167
The main object in a simulation, which coordinates others.
Saving / output archive for binary ostream.
Utility classes for scientific computation.
Definition: accumulators.mod:1
Template for Analyzer associated with one System.
Dynamically allocatable contiguous array template.
Definition: DArray.h:31
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
Definition: McMuExchange.h:158