Simpatico  v1.10
McMove.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 "McMove.h"
9 #include <mcMd/simulation/Simulation.h>
10 #include <util/archives/Serializable_includes.h>
11 
12 namespace McMd
13 {
14 
15  using namespace Util;
16 
17  /*
18  * Constructor.
19  */
20  McMove::McMove(Simulation& simulation)
21  : simulationPtr_(&simulation),
22  randomPtr_(&simulation.random()),
23  nAttempt_(0),
24  nAccept_(0)
25  {}
26 
27  /*
28  * Destructor, empty default implementation.
29  */
31  {}
32 
33  /*
34  * readParam, empty default implementation.
35  */
36  void McMove::readParameters(std::istream &in)
37  {}
38 
39  /*
40  * Read the probability from file.
41  */
42  void McMove::readProbability(std::istream &in)
43  { read<double>(in, "probability", probability_); }
44 
45  /*
46  * Load internal state from an archive.
47  */
49  {
50  loadParameter<double>(ar, "probability", probability_);
51  ar & nAttempt_;
52  ar & nAccept_;
53  }
54 
55  /*
56  * Save internal state to an archive.
57  */
59  {
60  ar & probability_;
61  ar & nAttempt_;
62  ar & nAccept_;
63  }
64 
65  /*
66  * Trivial implementation - initializes counters.
67  */
69  {
70  nAttempt_ = 0;
71  nAccept_ = 0;
72  }
73 
74  /*
75  * Trivial default implementation - always returns false.
76  */
77  bool McMove::move()
78  {
79  ++nAttempt_;
80  return false;
81  }
82 
83  /*
84  * Trivial default implementation - do nothing
85  */
87  {}
88 
89 }
virtual bool move()
Generate, attempt, and accept or reject a Monte Carlo move.
Definition: McMove.cpp:77
virtual void readParameters(std::istream &in)
Read required parameters from file.
Definition: McMove.cpp:36
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Definition: McMove.cpp:58
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from an archive.
Definition: McMove.cpp:48
The main object in a simulation, which coordinates others.
Saving / output archive for binary ostream.
virtual ~McMove()
Destructor.
Definition: McMove.cpp:30
virtual void setup()
Setup before the beginning of each simulation run.
Definition: McMove.cpp:68
Utility classes for scientific computation.
Definition: accumulators.mod:1
Saving archive for binary istream.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void readProbability(std::istream &in)
Read the probability from file.
Definition: McMove.cpp:42
virtual void output()
Output statistics for this move (called at the end of the simulation)
Definition: McMove.cpp:86
McMove(Simulation &simulation)
Constructor.
Definition: McMove.cpp:20