NAMD
Public Member Functions | List of all members
eABF2D Class Reference

#include <eabf2D.h>

Inheritance diagram for eABF2D:
eABF

Public Member Functions

 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)
 
virtual ~eABF2D ()
 
bool update (const std::string &)
 
- Public Member Functions inherited from eABF
 eABF ()
 
 eABF (const std::string &_outputfile, const int _outputfreq, const bool _restart, const std::string &_inputfile, const bool _outputgrad, const int _gradfreq, const double _temperature)
 
virtual ~eABF ()
 
bool mergefile (const std::string &inputname, const std::string &outputname)
 
bool setcolumn (std::vector< int > col)
 

Additional Inherited Members

- Protected Attributes inherited from eABF
std::vector< double > lowerboundary
 
std::vector< double > upperboundary
 
std::vector< double > width
 
std::string outputfile
 
int outputfreq
 
bool restart
 
std::string inputfile
 
bool outputgrad
 
int gradfreq
 
double temperature
 
std::vector< int > max
 
std::vector< int > min
 
std::vector< int > bins
 
std::vector< double > krestr
 
int line
 
std::vector< int > col
 

Detailed Description

Definition at line 23 of file eabf2D.h.

Constructor & Destructor Documentation

eABF2D::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 at line 28 of file eabf2D.C.

References eABF::krestr, eABF::lowerboundary, eABF::restart, eABF::upperboundary, and eABF::width.

42  :
43  eABF(_outputfile, _outputfreq, _restart, _inputfile, _outputgrad, _gradfreq, _temperature)
44 {
45  lowerboundary.push_back(_lowerboundary);
46  lowerboundary.push_back(_lowerboundary2);
47  upperboundary.push_back(_upperboundary);
48  upperboundary.push_back(_upperboundary2);
49  width.push_back(_width);
50  width.push_back(_width2);
51  krestr.push_back(_krestr);
52  krestr.push_back(_krestr2);
53  this->initialize();
54  this->restart = _restart;
55  if(restart == true)
56  this->readfile();
57 }
std::vector< double > lowerboundary
Definition: eabf.h:61
std::vector< double > width
Definition: eabf.h:63
eABF()
Definition: eabf.h:25
std::vector< double > krestr
Definition: eabf.h:93
std::vector< double > upperboundary
Definition: eabf.h:62
bool restart
Definition: eabf.h:73
virtual eABF2D::~eABF2D ( )
inlinevirtual

Definition at line 43 of file eabf2D.h.

References eABF::bins.

44  {
45  for (int i = 0; i < bins[0] * bins[0]; i++)
46  delete[] countall[i];
47  delete[] countall;
48  }
std::vector< int > bins
Definition: eabf.h:91

Member Function Documentation

bool eABF2D::update ( const std::string &  colvarstring)
virtual

Implements eABF.

Definition at line 92 of file eabf2D.C.

References eabffunc::chartodouble(), eabffunc::chartoint(), eABF::col, eABF::gradfreq, eABF::line, eABF::min, eABF::outputfreq, eABF::outputgrad, eabffunc::split(), and eABF::width.

93 {
94  // this is the string obtained from colvar each step
95  // the format of this string is the same as those in colvar.traj file
96 
97  std::vector<std::string> data;
98  eabffunc::split(colvarstring, data);
99 
100  int step;
101 
102  double abf_force;
103  double eabf_force;
104  double abf_force2;
105  double eabf_force2;
106 
107  step = eabffunc::chartoint(data[0]);
108  abf_force = eabffunc::chartodouble(data[col[0]]);
109  eabf_force = eabffunc::chartodouble(data[col[1]]);
110  abf_force2 = eabffunc::chartodouble(data[col[2]]);
111  eabf_force2 = eabffunc::chartodouble(data[col[3]]);
112 
113 
114  if (abf_force > 150 && eabf_force < -150)
115  eabf_force += 360;
116  else if (abf_force < -150 && eabf_force > 150)
117  eabf_force -= 360;
118 
119  if (abf_force2 > 150 && eabf_force2 < -150)
120  eabf_force2 += 360;
121  else if (abf_force2 < -150 && eabf_force2 > 150)
122  eabf_force2 -= 360;
123 
124  int binx = int(floor(abf_force / width[0])) - min[0];
125  int biny = int(floor(eabf_force / width[0])) - min[0];
126  int binx2 = int(floor(abf_force2 / width[1])) - min[1];
127  int biny2 = int(floor(eabf_force2 / width[1])) - min[1];
128 
129  if (step%outputfreq == 0)
130  {
131  writefile();
132  }
133 
134  if (outputgrad == true && (step%gradfreq) == 0)
135  {
136  calpmf();
137  }
138 
139 
140  if (binx < 0 || binx >= bins[0] || biny < 0 || biny >= bins[0] || binx2 < 0 || binx2 >= bins[1] || biny2 < 0 || biny2 >= bins[1])
141  return false;
142  else
143  {
144  // distribution
145  countall[binx*bins[0] + biny][binx2*bins[1] + biny2]++;
146 
147  // if this is the first time add "countall", then the line in outputfile will increase
148  if (countall[binx*bins[0] + biny][binx2*bins[1] + biny2] == 1)
149  line++;
150  county[biny][biny2]++;
151  }
152 
153  sumx1[biny][biny2] += abf_force;
154  sumx21[biny][biny2] += abf_force * abf_force;
155  sumx2[biny][biny2] += abf_force2;
156  sumx22[biny][biny2] += abf_force2 * abf_force2;
157 
158 
159  // TODO: add convergence judgement
160  return true;
161 }
std::vector< double > width
Definition: eabf.h:63
int line
Definition: eabf.h:102
int chartoint(const std::string &c)
Definition: eabffunc.C:48
int gradfreq
Definition: eabf.h:82
bool outputgrad
Definition: eabf.h:79
double chartodouble(const std::string &c)
Definition: eabffunc.C:57
std::vector< int > bins
Definition: eabf.h:91
void split(const std::string &s, std::vector< std::string > &ret)
Definition: eabffunc.C:37
int outputfreq
Definition: eabf.h:70
std::vector< int > min
Definition: eabf.h:90
std::vector< int > col
Definition: eabf.h:104

The documentation for this class was generated from the following files: