28 eABF1D::eABF1D(
const double _lowerboundary,
const double _upperboundary,
const double _width,
30 const std::string& _outputfile,
31 const int _outputfreq,
32 const bool _restart,
const std::string& _inputfile,
33 const bool _outputgrad,
const int _gradfreq,
const double _temperature) :
34 eABF(_outputfile, _outputfreq, _restart, _inputfile, _outputgrad, _gradfreq, _temperature)
38 width.push_back(_width);
54 for (
int i = 0; i <
bins[0]; i++)
60 sumx = std::vector<double>(
bins[0], 0);
72 std::vector<std::string> data;
86 if(abf_force > 150 && eabf_force < -150)
88 else if(abf_force < -150 && eabf_force > 150)
92 int binx = int(floor(abf_force /
width[0])) -
min[0];
93 int biny = int(floor(eabf_force /
width[0])) -
min[0];
96 if (binx < 0 || binx >=
bins[0] || biny < 0 || biny >=
bins[0])
107 sumx[biny] += abf_force;
108 sumx2[biny] += abf_force * abf_force;
125 std::ifstream file(
inputfile.c_str(), std::ios::in);
133 int temp_line, temp_bins;
134 double temp_lowerboundary, temp_width;
135 file >> temp_line >> temp_lowerboundary >> temp_width >> temp_bins >>
krestr[0] >>
temperature;
137 temp_bins = temp_bins + 20;
139 int x = 0, y = 0, temp_countall;
140 for (
int i = 0; i < temp_line; i++)
143 file >> temp_countall;
152 double temp_sumx, temp_sumx2;
154 for (
int i = 0; i < temp_bins; i++)
156 file >> x >> temp_sumx >> temp_sumx2 >> temp_county;
172 file<<std::setprecision(15);
176 for (
int i = 0; i <
bins[0]; i++)
177 for (
int j = 0; j <
bins[0]; j++)
180 file << i <<
" " << j <<
" " <<
countall[i][j] << std::endl;
182 for (
int i = 0; i <
bins[0]; i++)
183 file << i <<
" " <<
sumx[i] <<
" " <<
sumx2[i] <<
" " <<
county[i] <<
" " << std::endl;
191 os <<
"# 1" << std::endl;
202 std::vector<double> x_av(
bins[0]);
203 std::vector<double> sigma2(
bins[0]);
204 for (
int biny = 0; biny <
bins[0]; biny++)
207 x_av[biny] =
sumx[biny] / norm;
208 sigma2[biny] =
sumx2[biny] / norm - x_av[biny] * x_av[biny];
211 static std::string gridfilename =
outputfile +
".grad";
212 static std::string histfilename =
outputfile +
".hist.grad";
213 static std::string pmffilename =
outputfile +
".pmf";
214 static std::string countfilename =
outputfile +
".count";
217 ofstream_namd ofile_hist(histfilename.c_str(), std::ios::app);
227 double pmf = 0, pmf_x = 0;
228 double x, y, av, diff_av, grad;
229 for (
int binx = 0; binx <
bins[0]; binx++)
231 x = (binx +
min[0] + 0.5) *
width[0];
236 for (
int biny = 0; biny <
bins[0]; biny++)
238 y = (biny +
min[0] + 0.5) *
width[0];
241 if (sigma2[biny] > 0.00001 || sigma2[biny] < -0.00001)
243 av +=
countall[binx][biny] * (x - x_av[biny]) / sigma2[biny];
249 diff_av +=
countall[binx][biny] * (x - y);
252 diff_av /= (norm > 0 ? norm : 1);
254 grad = av -
krestr[0] * diff_av;
259 ofile << x <<
" " << grad << std::endl;
260 ofile_hist << x <<
" " << grad << std::endl;
261 pmf += grad *
width[0];
262 pmf_x = x + 0.5 *
width[0];
263 ofile_pmf << pmf_x <<
" " << pmf << std::endl;
264 ofile_count << x <<
" " << norm << std::endl;
bool writehead(ofstream_namd &) const
std::vector< double > lowerboundary
std::vector< double > width
std::vector< double > sumx
std::vector< double > krestr
int chartoint(const std::string &c)
std::vector< double > sumx2
bool update(const std::string &)
double chartodouble(const std::string &c)
std::vector< int > county
int convertscale(double lowerboundary, int window) const
void split(const std::string &s, std::vector< std::string > &ret)
std::vector< double > upperboundary
int doubletoint(const double)
std::vector< std::vector< int > > countall