Simpatico  v1.10
McMove.h
1 #ifndef MCMD_MC_MOVE_H
2 #define MCMD_MC_MOVE_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 <util/param/ParamComposite.h>
12 #include <util/random/Random.h>
13 #include <util/global.h>
14 
15 namespace McMd
16 {
17 
18  using namespace Util;
19 
20  class Simulation;
21 
31  class McMove : public ParamComposite
32  {
33 
34  public:
35 
41  McMove(Simulation& simulation);
42 
48  virtual ~McMove();
49 
55  virtual void readParameters(std::istream &in);
56 
62  virtual void loadParameters(Serializable::IArchive &ar);
63 
69  virtual void save(Serializable::OArchive &ar);
70 
76  void setProbability(double probability);
77 
87  virtual void setup();
88 
102  virtual bool move();
103 
104  // Accessor Functions
105 
109  double probability() const;
110 
114  long nAttempt() const;
115 
119  long nAccept() const;
120 
124  virtual void output();
125 
126  protected:
127 
131  void incrementNAttempt();
132 
136  void incrementNAccept();
137 
141  Simulation& simulation();
142 
146  Random& random();
147 
151  void readProbability(std::istream& in);
152 
153  private:
154 
156  Simulation *simulationPtr_;
157 
159  Random *randomPtr_;
160 
162  double probability_;
163 
165  long nAttempt_;
166 
168  long nAccept_;
169 
170  };
171 
172  // Public inline methods
173 
174  /*
175  * Return number of moves that have been attempted.
176  */
177  inline long McMove::nAttempt() const
178  { return nAttempt_; }
179 
180  /*
181  * Return number of moves that have been accepted.
182  */
183  inline long McMove::nAccept() const
184  { return nAccept_; }
185 
186  // Protected inline methods
187 
188  /*
189  * Increment the number of attempted moves.
190  */
192  { ++nAttempt_; }
193 
194  /*
195  * Increment the number of accepted moves.
196  */
198  { ++nAccept_; }
199 
200  /*
201  * Get parent Simulation object.
202  */
204  { return *simulationPtr_; }
205 
206  /*
207  * Get Random number generator.
208  */
210  { return *randomPtr_; }
211 
212  /*
213  * Get the probability.
214  */
215  inline double McMove::probability() const
216  { return probability_; }
217 
218  /*
219  * Set the probability.
220  */
221  inline void McMove::setProbability(double probability)
222  { probability_ = probability; }
223 
224 }
225 #endif
void incrementNAttempt()
Increment the number of attempted moves.
Definition: McMove.h:191
double probability() const
Return probability for this McMove.
Definition: McMove.h:215
McMove is an abstract base class for Monte Carlo moves.
Definition: McMove.h:31
File containing preprocessor macros for error handling.
The main object in a simulation, which coordinates others.
Saving / output archive for binary ostream.
void incrementNAccept()
Increment the number of accepted moves.
Definition: McMove.h:197
Utility classes for scientific computation.
Definition: accumulators.mod:1
long nAttempt() const
Return number of moves that have been attempted.
Definition: McMove.h:177
Random & random()
Get Random number generator of parent Simulation.
Definition: McMove.h:209
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
Random number generator.
Definition: Random.h:46
Simulation & simulation()
Get parent Simulation object.
Definition: McMove.h:203
An object that can read multiple parameters from file.
void setProbability(double probability)
Set the probability for this McMove.
Definition: McMove.h:221
long nAccept() const
Return number of moves that have been accepted.
Definition: McMove.h:183