SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Umbrella.h
1 
21 #pragma once
22 
23 #include "Method.h"
24 #include <fstream>
25 
26 namespace SSAGES
27 {
29 
35  class Umbrella : public Method
36  {
37  private:
39  std::vector<double> kspring_;
40 
43  std::vector<double> centers0_, centers1_;
45 
47  size_t time_;
48 
50  std::string filename_;
51 
53  int outfreq_;
54 
56  std::ofstream umbrella_;
57 
59  bool append_;
60 
62 
68  double GetCurrentCenter(size_t iteration, size_t i)
69  {
70  // We are at the end.
71  if(iteration >= time_) return centers1_[i];
72 
73  // Scale linearly.
74  return (centers1_[i] - centers0_[i])/time_*iteration + centers0_[i];
75  }
76 
78 
82  void PrintUmbrella(const CVList& cvs, size_t iteration);
83 
84  public:
86 
98  Umbrella(const MPI_Comm& world,
99  const MPI_Comm& comm,
100  const std::vector<double>& kspring,
101  const std::vector<double>& centers,
102  std::string name,
103  unsigned int frequency) :
104  Method(frequency, world, comm), kspring_(kspring), centers0_(centers),
105  centers1_(centers), time_(0), filename_(name), outfreq_(1), append_(false)
106  {
107  }
108 
110 
124  Umbrella(const MPI_Comm& world,
125  const MPI_Comm& comm,
126  const std::vector<double>& kspring,
127  const std::vector<double>& centers0,
128  const std::vector<double>& centers1,
129  size_t timesteps,
130  std::string name,
131  unsigned int frequency) :
132  Method(frequency, world, comm), kspring_(kspring), centers0_(centers0),
133  centers1_(centers1), time_(timesteps), filename_(name), outfreq_(1)
134  {
135  }
136 
138  void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
139 
141  void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) override;
142 
144  void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
145 
147 
150  void SetOutputFrequency(int outfreq)
151  {
152  outfreq_ = outfreq;
153  }
154 
156 
159  void SetAppend(bool append)
160  {
161  append_ = append;
162  }
163 
165  static Umbrella* Build(const Json::Value& json,
166  const MPI_Comm& world,
167  const MPI_Comm& comm,
168  const std::string& path);
169  };
170 }
Collective variable manager.
Definition: CVManager.h:43
Interface for Method implementations.
Definition: Method.h:44
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:48
Umbrella sampling method.
Definition: Umbrella.h:36
void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call post integration.
Definition: Umbrella.cpp:57
static Umbrella * Build(const Json::Value &json, const MPI_Comm &world, const MPI_Comm &comm, const std::string &path)
Build a derived method from JSON node.
Definition: Umbrella.cpp:112
int outfreq_
Frequency of outputting data.
Definition: Umbrella.h:53
std::ofstream umbrella_
Output stream for umbrella data.
Definition: Umbrella.h:56
std::vector< double > centers0_
Definition: Umbrella.h:43
void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call post simulation.
Definition: Umbrella.cpp:86
bool append_
Append to output files?
Definition: Umbrella.h:59
Umbrella(const MPI_Comm &world, const MPI_Comm &comm, const std::vector< double > &kspring, const std::vector< double > &centers, std::string name, unsigned int frequency)
Constructor.
Definition: Umbrella.h:98
void PreSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call prior to simulation initiation.
Definition: Umbrella.cpp:33
void PrintUmbrella(const CVList &cvs, size_t iteration)
Print umbrella values.
Definition: Umbrella.cpp:92
void SetOutputFrequency(int outfreq)
Set output frequency.
Definition: Umbrella.h:150
void SetAppend(bool append)
Set append mode.
Definition: Umbrella.h:159
double GetCurrentCenter(size_t iteration, size_t i)
Get the current center of the umbrella at a given iteration.
Definition: Umbrella.h:68
size_t time_
Amount of time over which to scale centers.
Definition: Umbrella.h:47
std::string filename_
Output filename.
Definition: Umbrella.h:50
Umbrella(const MPI_Comm &world, const MPI_Comm &comm, const std::vector< double > &kspring, const std::vector< double > &centers0, const std::vector< double > &centers1, size_t timesteps, std::string name, unsigned int frequency)
Constructor.
Definition: Umbrella.h:124
std::vector< double > kspring_
Vector of spring constants.
Definition: Umbrella.h:39
std::vector< CollectiveVariable * > CVList
List of Collective Variables.
Definition: types.h:51