NAMD
eabf.h
Go to the documentation of this file.
1 //
2 // The extended adaptive biasing force method has been contributed to NAMD by the following authors:
3 //
4 // Haohao Fu and Christophe Chipot
5 // Laboratoire International Associ\'e
6 // Centre National de la Recherche Scientifique et University of Illinois at Urbana--Champaign
7 // Unit\'e Mixte de Recherche No. 7565, Universit\'e de Lorraine
8 // B.P. 70239, 54506 Vand\oe uvre-lès-Nancy cedex, France
9 //
10 // Copyright 2016, Centre National de la Recherche Scientifique
11 //
12 
13 #ifndef EABF_H
14 #define EABF_H
15 
16 #include <iostream>
17 #include <string>
18 #include <sstream>
19 #include <vector>
20 class ofstream_namd;
21 
22 class eABF
23 {
24 public:
25  eABF() {}
26  eABF(const std::string& _outputfile,
27  const int _outputfreq,
28  const bool _restart, const std::string& _inputfile,
29  const bool _outputgrad, const int _gradfreq, const double _temperature):
30  outputfile(_outputfile), outputfreq(_outputfreq), restart(_restart), inputfile(_inputfile),
31  outputgrad(_outputgrad), gradfreq(_gradfreq), temperature(_temperature)
32  {}
33  virtual ~eABF() {}
34 
35  // called by colvar each step, update the sampling point
36  virtual bool update(const std::string&) = 0;
37 
38  // merge another file, used when reading another file
39  bool mergefile(const std::string& inputname, const std::string& outputname)
40  {
41  this->inputfile = inputname;
42  this->readfile();
43  std::string temp = this->outputfile;
44  this->outputfile = outputname;
45  this->writefile();
46  this->calpmf();
47  this->outputfile = temp;
48  return true;
49  }
50 
51  // which coloum in the string provided by colvar is used
52  bool setcolumn(std::vector<int> col)
53  {
54  this->col = col;
55  return true;
56  }
57 
58 protected:
59  // the colvar setting
61  std::vector<double> lowerboundary;
62  std::vector<double> upperboundary;
63  std::vector<double> width;
65 
66  // the restart (output) file generated by parseABF
67  std::string outputfile;
68 
69  // the frequency writing a restart file
71 
72  // whether restart
73  bool restart;
74 
75  // the restart input file
76  std::string inputfile;
77 
78  // whether output gradient and pmf
79  bool outputgrad;
80 
81  // the frequency writing grad and pmf file
82  int gradfreq;
83 
84  // the temperature of simulation
85  double temperature;
86 
87  // internal variables
89  std::vector<int> max; // the max index of the RC
90  std::vector<int> min; // the min index of the RC
91  std::vector<int> bins; // the number of bins
92 
93  std::vector<double> krestr; // force constant
94 
96  // need to be defined
98  // countall; // the distribution of samples, needed for eABF
99  // sumx; // the sum of x in each bin, needed for eABF
100  // sumx2; // the sum of x^2, needed for eABF
101  // county; // the distribution in each bin, needed for eABF
102  int line; // the number of non-zero countall
103 
104  std::vector<int> col; // the column read by the program
106 
107  // initialize the variables
108  virtual bool initialize() = 0;
109 
110  // read variables from a restart file
111  virtual bool readfile() = 0;
112 
113  // write restart file
114  virtual bool writefile() const = 0;
115 
116  // write the head of the pmf file
117  virtual bool writehead(ofstream_namd&) const = 0;
118 
119  // calculate grad and pmf
120  virtual bool calpmf() const = 0;
121 
122 };
123 
124 #endif // EABF_H
std::string inputfile
Definition: eabf.h:76
virtual bool initialize()=0
std::vector< double > lowerboundary
Definition: eabf.h:61
std::vector< double > width
Definition: eabf.h:63
eABF()
Definition: eabf.h:25
Definition: eabf.h:22
double temperature
Definition: eabf.h:85
int line
Definition: eabf.h:102
std::vector< double > krestr
Definition: eabf.h:93
eABF(const std::string &_outputfile, const int _outputfreq, const bool _restart, const std::string &_inputfile, const bool _outputgrad, const int _gradfreq, const double _temperature)
Definition: eabf.h:26
bool mergefile(const std::string &inputname, const std::string &outputname)
Definition: eabf.h:39
int gradfreq
Definition: eabf.h:82
virtual bool calpmf() const =0
bool outputgrad
Definition: eabf.h:79
bool setcolumn(std::vector< int > col)
Definition: eabf.h:52
std::vector< int > bins
Definition: eabf.h:91
virtual ~eABF()
Definition: eabf.h:33
virtual bool writehead(ofstream_namd &) const =0
std::vector< int > max
Definition: eabf.h:89
virtual bool update(const std::string &)=0
std::string outputfile
Definition: eabf.h:67
int outputfreq
Definition: eabf.h:70
virtual bool readfile()=0
std::vector< int > min
Definition: eabf.h:90
std::vector< double > upperboundary
Definition: eabf.h:62
bool restart
Definition: eabf.h:73
std::vector< int > col
Definition: eabf.h:104
virtual bool writefile() const =0