NAMD
eabf2D.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 EABF2D_H
14 #define EABF2D_H
15 
16 #include <iostream>
17 #include <string>
18 #include <sstream>
19 #include <vector>
20 
21 #include "eabf.h"
22 
23 class eABF2D : public eABF
24 {
25 public:
26  // called when (re)start a namd run
27  eABF2D(const double _lowerboundary,
28  const double _upperboundary,
29  const double _width,
30  const double _krestr,
31  const double _lowerboundary2,
32  const double _upperboundary2,
33  const double _width2,
34  const double _krestr2,
35  const std::string& _outputfile,
36  const int _outputfreq,
37  const bool _restart,
38  const std::string& _inputfile,
39  const bool _outputgrad,
40  const int _gradfreq,
41  const double _temperature);
42 
43  virtual ~eABF2D()
44  {
45  for (int i = 0; i < bins[0] * bins[0]; i++)
46  delete[] countall[i];
47  delete[] countall;
48  }
49 
50  // called by colvar each step, update the sampling point
51  bool update(const std::string&);
52 
53 
54 private:
55  // for 2D eABF, much memories are need, I have to use C-style pointer and array
56  // BE VERY CAREFUL ABOUT IT!
57  int** countall; // the distribution of samples, needed for eABF
58  std::vector<std::vector<double> > sumx1; // the sum of x in each bin, needed for eABF
59  std::vector<std::vector<double> > sumx21; // the sum of x^2, needed for eABF
60  std::vector<std::vector<double> > sumx2;
61  std::vector<std::vector<double> > sumx22;
62  std::vector<std::vector <int> > county; // the distribution in each bin, needed for eABF
64 
65  // initialize the variables
66  bool initialize();
67 
68  // read variables from a restart file
69  bool readfile();
70 
71  // write restart file
72  bool writefile() const;
73 
74  // write the head of grad file
75  bool writehead(ofstream_namd&) const;
76 
77  // calculate grad and pmf
78  bool calpmf() const;
79 
80  // convert the scale in file to the scale in this eabf
81  virtual int convertscale(double lowerboundary, int window, int dimension) const
82  {
83  if (dimension == 1)
84  return int((lowerboundary - this->lowerboundary[0]) / width[0] + window);
85  if (dimension == 2)
86  return int((lowerboundary - this->lowerboundary[1]) / width[1] + window);
87  return 0;
88  }
89 };
90 #endif // EABF2D_H
std::vector< double > lowerboundary
Definition: eabf.h:61
std::vector< double > width
Definition: eabf.h:63
virtual ~eABF2D()
Definition: eabf2D.h:43
Definition: eabf.h:22
Definition: eabf2D.h:23
eABF2D(const double _lowerboundary, const double _upperboundary, const double _width, const double _krestr, const double _lowerboundary2, const double _upperboundary2, const double _width2, const double _krestr2, const std::string &_outputfile, const int _outputfreq, const bool _restart, const std::string &_inputfile, const bool _outputgrad, const int _gradfreq, const double _temperature)
Definition: eabf2D.C:28
std::vector< int > bins
Definition: eabf.h:91
bool update(const std::string &)
Definition: eabf2D.C:92