SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
BasisFunc.h
1 
21 #pragma once
22 
23 #include "Method.h"
24 #include "Utility/Basis.h"
25 #include "Grids/Grid.h"
26 #include <fstream>
27 #include <vector>
28 
29 namespace SSAGES
30 {
32 
38  class BFS : public Method
39  {
40  private:
41 
43 
47 
49 
53 
55 
59 
61 
66  std::vector<double> unbias_;
67 
69  std::vector<double> coeffArr_;
70 
72 
77 
79 
84  std::vector<double> restraint_;
85 
87  std::vector<double> boundUp_;
88 
90  std::vector<double> boundLow_;
91 
93  unsigned int cyclefreq_;
94 
96  unsigned int cyclefreqTmp_;
97 
99  unsigned int step_;
100 
102  unsigned int mpiid_;
103 
105 
110  double weight_;
111 
113 
118  double temperature_;
119 
121  double tol_;
122 
124  bool bounds_;
125 
128 
130 
134  void ProjectBias(const CVList& cvs, const double beta);
135 
137 
140  void InBounds(const CVList& cvs);
141 
143 
147  void PrintBias(const CVList& cvs, const double beta);
148 
151  std::string bnme_;
152 
154  unsigned int iteration_;
155 
156  public:
158 
181  BFS(const MPI_Comm& world,
182  const MPI_Comm& comm,
184  Grid<std::vector<double>> *f,
185  Grid<double> *b,
186  const std::vector<BasisFunction*>& functions,
187  const std::vector<double>& restraint,
188  const std::vector<double>& boundUp,
189  const std::vector<double>& boundLow,
190  unsigned int cyclefreq,
191  unsigned int frequency,
192  const std::string bnme,
193  const double temperature,
194  const double tol,
195  const double weight,
196  bool converge) :
197  Method(frequency, world, comm),
198  h_(h), b_(b), f_(f), unbias_(), coeffArr_(), evaluator_(functions),
199  restraint_(restraint), boundUp_(boundUp), boundLow_(boundLow),
200  cyclefreq_(cyclefreq), mpiid_(0), weight_(weight),
201  temperature_(temperature), tol_(tol),
202  convergeExit_(converge), bnme_(bnme), iteration_(0)
203  {
204  }
205 
207  void PreSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
208 
210  void PostIntegration(Snapshot* snapshot, const class CVManager& cvmanager) override;
211 
213  void PostSimulation(Snapshot* snapshot, const class CVManager& cvmanager) override;
214 
216 
222  void SetIteration(const int iter)
223  {
224  iteration_ = iter;
225  }
226 
228 
235  void SetBasis(const std::vector<double>&coeff, std::vector<double>&unbias)
236  {
237  evaluator_.SetCoeff(coeff);
238  unbias_ = unbias;
239  }
240 
242  static BFS* Build(const Json::Value& json,
243  const MPI_Comm& world,
244  const MPI_Comm& comm,
245  const std::string& path);
246 
249  {
250  //delete h_;
251  //delete f_;
252  //delete b_;
253  }
254  };
255 }
256 
Basis Function Sampling Algorithm.
Definition: BasisFunc.h:39
double weight_
Weighting for potentially faster sampling.
Definition: BasisFunc.h:110
unsigned int cyclefreqTmp_
Temporary cyclefrequency that ensures sweeps are of proper length for restrained simulations.
Definition: BasisFunc.h:96
void PostSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call post simulation.
Definition: BasisFunc.cpp:160
bool convergeExit_
A check to see if you want the system to end when it reaches the convergence criteria.
Definition: BasisFunc.h:127
std::vector< double > restraint_
Spring constants for restrained system.
Definition: BasisFunc.h:84
double temperature_
Self-defined temperature.
Definition: BasisFunc.h:118
Grid< unsigned int > * h_
Grid of visited states.
Definition: BasisFunc.h:46
Grid< std::vector< double > > * f_
Stored gradients.
Definition: BasisFunc.h:58
BasisEvaluator evaluator_
The basis evaluator class.
Definition: BasisFunc.h:76
void ProjectBias(const CVList &cvs, const double beta)
The functions which calculates the updated bias and coefficients and then stores them.
Definition: BasisFunc.cpp:166
Grid< double > * b_
Stored bias potential.
Definition: BasisFunc.h:52
std::string bnme_
Definition: BasisFunc.h:151
std::vector< double > coeffArr_
The coefficient array for restart runs.
Definition: BasisFunc.h:69
std::vector< double > boundUp_
Upper position of the spring restraint.
Definition: BasisFunc.h:87
double tol_
The tolerance criteria for the system .
Definition: BasisFunc.h:121
unsigned int cyclefreq_
Frequency of coefficient updates.
Definition: BasisFunc.h:93
void SetIteration(const int iter)
Set the current iteration.
Definition: BasisFunc.h:222
void PostIntegration(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call post integration.
Definition: BasisFunc.cpp:81
unsigned int iteration_
Iteration counter.
Definition: BasisFunc.h:154
void InBounds(const CVList &cvs)
A function which checks to see if the CVs are still in bounds.
Definition: BasisFunc.cpp:272
unsigned int step_
Step counter for the cyclefrequency.
Definition: BasisFunc.h:99
BFS(const MPI_Comm &world, const MPI_Comm &comm, Grid< unsigned int > *h, Grid< std::vector< double >> *f, Grid< double > *b, const std::vector< BasisFunction * > &functions, const std::vector< double > &restraint, const std::vector< double > &boundUp, const std::vector< double > &boundLow, unsigned int cyclefreq, unsigned int frequency, const std::string bnme, const double temperature, const double tol, const double weight, bool converge)
Constructor.
Definition: BasisFunc.h:181
std::vector< double > boundLow_
Lower position of the spring restraint.
Definition: BasisFunc.h:90
static BFS * 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: BasisFunc.cpp:308
void PrintBias(const CVList &cvs, const double beta)
Prints the current bias to a defined file from the JSON.
Definition: BasisFunc.cpp:227
void PreSimulation(Snapshot *snapshot, const class CVManager &cvmanager) override
Method call prior to simulation initiation.
Definition: BasisFunc.cpp:36
void SetBasis(const std::vector< double > &coeff, std::vector< double > &unbias)
Set the values for the basis.
Definition: BasisFunc.h:235
~BFS()
Destructor.
Definition: BasisFunc.h:248
unsigned int mpiid_
The node that the current system belongs to, primarily for printing and debugging.
Definition: BasisFunc.h:102
std::vector< double > unbias_
The biased histogram of states.
Definition: BasisFunc.h:66
bool bounds_
A variable to check to see if the simulation is in bounds or not.
Definition: BasisFunc.h:124
Calculates the inner product of all the basis functions and the histogram.
Definition: Basis.h:348
void SetCoeff(const std::vector< double > &coeff)
Set the coefficient array in the event of a restart run.
Definition: Basis.h:408
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
std::vector< CollectiveVariable * > CVList
List of Collective Variables.
Definition: types.h:51