SSAGES  0.8.5
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 
142  void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
143 
145 
149  void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) override;
150 
152 
156  void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
157 
159 
162  void SetOutputFrequency(int outfreq)
163  {
164  outfreq_ = outfreq;
165  }
166 
168 
171  void SetAppend(bool append)
172  {
173  append_ = append;
174  }
175 
177  static Umbrella* Build(const Json::Value& json,
178  const MPI_Comm& world,
179  const MPI_Comm& comm,
180  const std::string& path);
181  };
182 }
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
std::vector< double > centers0_
Definition: Umbrella.h:43
Collective variable manager.
Definition: CVManager.h:42
std::vector< CollectiveVariable * > CVList
List of Collective Variables.
Definition: types.h:51
void SetOutputFrequency(int outfreq)
Set output frequency.
Definition: Umbrella.h:162
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
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:47
Interface for Method implementations.
Definition: Method.h:43
void PrintUmbrella(const CVList &cvs, size_t iteration)
Print umbrella values.
Definition: Umbrella.cpp:92
void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Post-integration hook.
Definition: Umbrella.cpp:57
Umbrella sampling method.
Definition: Umbrella.h:35
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
size_t time_
Amount of time over which to scale centers.
Definition: Umbrella.h:47
double GetCurrentCenter(size_t iteration, size_t i)
Get the current center of the umbrella at a given iteration.
Definition: Umbrella.h:68
std::vector< double > kspring_
Vector of spring constants.
Definition: Umbrella.h:39
bool append_
Append to output files?
Definition: Umbrella.h:59
int outfreq_
Frequency of outputting data.
Definition: Umbrella.h:53
void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Post-simulation hook.
Definition: Umbrella.cpp:86
std::string filename_
Output filename.
Definition: Umbrella.h:50
void SetAppend(bool append)
Set append mode.
Definition: Umbrella.h:171
std::ofstream umbrella_
Output stream for umbrella data.
Definition: Umbrella.h:56
void PreSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Pre-simulation hook.
Definition: Umbrella.cpp:33