update colvars abf integrate tool from git repo

This commit is contained in:
Axel Kohlmeyer
2017-03-20 17:04:16 -04:00
parent 03828b5836
commit a42b0b7dcb
2 changed files with 15 additions and 18 deletions

View File

@ -12,13 +12,12 @@ ABFdata::ABFdata(const char *gradFileName)
std::ifstream gradFile;
std::ifstream countFile;
int n;
char hash;
double xi;
char *countFileName;
countFileName = new char[strlen (gradFileName) + 2];
strcpy (countFileName, gradFileName);
strcpy (countFileName, gradFileName);
countFileName[strlen (gradFileName) - 4] = '\0';
strcat (countFileName, "count");
@ -152,7 +151,8 @@ ABFdata::ABFdata(const char *gradFileName)
}
// Could check for end-of-file string here
countFile.close();
delete [] countFileName;
delete[] countFileName;
delete[] pos;
// for metadynamics
bias = new double[scalar_dim];
@ -269,7 +269,7 @@ void ABFdata::write_bias(const char *fileName)
if (minbias == 0.0 || (bias[index] > 0.0 && bias[index] < minbias))
minbias = bias[index];
}
for (index = 0; index < scalar_dim; index++) {
// Here we do the Euclidian division iteratively
for (i = Nvars - 1; i > 0; i--) {

View File

@ -22,10 +22,7 @@ int main(int argc, char *argv[])
char *out_file;
unsigned int step, nsteps, total, out_freq;
int *pos, *dpos, *newpos;
unsigned int *histogram;
const double *grad, *newgrad;
unsigned int offset, newoffset;
int not_accepted;
double dA;
double temp;
double mbeta;
@ -47,7 +44,7 @@ int main(int argc, char *argv[])
if (!(data_file = parse_cl(argc, argv, &nsteps, &temp, &meta, &hill, &hill_fact))) {
std::cerr << "\nabf_integrate: MC-based integration of multidimensional free energy gradient\n";
std::cerr << "Version 20110511\n\n";
std::cerr << "Version 20160420\n\n";
std::cerr << "Syntax: " << argv[0] <<
" <filename> [-n <nsteps>] [-t <temp>] [-m [0|1] (metadynamics)]"
" [-h <hill_height>] [-f <variable_hill_factor>]\n\n";
@ -62,7 +59,7 @@ int main(int argc, char *argv[])
} else {
std::cout << "\nUsing unbiased MC sampling\n";
}
if (nsteps) {
std::cout << "Sampling " << nsteps << " steps at temperature " << temp << "\n\n";
out_freq = nsteps / 10;
@ -74,7 +71,7 @@ int main(int argc, char *argv[])
converged = false;
}
// Inverse temperature in (kcal/mol)-1
// Inverse temperature in (kcal/mol)-1
mbeta = -1 / (0.001987 * temp);
ABFdata data(data_file);
@ -91,12 +88,16 @@ int main(int argc, char *argv[])
dpos = new int[data.Nvars];
newpos = new int[data.Nvars];
// TODO: this will be an infinite loop if there is no sampling
// it would be more robust to build a list of non-empty bins, and
// pick from there (or just treat the special case of no sampling
// and output a null PMF)
do {
for (int i = 0; i < data.Nvars; i++) {
pos[i] = rand() % data.sizes[i];
}
offset = data.offset(pos);
} while ( !data.allowed (offset) );
} while ( !data.allowed (offset) );
rmsd = compute_deviation(&data, meta, 0.001987 * temp);
std::cout << "\nInitial gradient RMS is " << rmsd << "\n";
@ -128,9 +129,9 @@ int main(int argc, char *argv[])
data.bias[offset] += hill;
}
grad = data.gradients + offset * data.Nvars;
const double *grad = data.gradients + offset * data.Nvars;
not_accepted = 1;
int not_accepted = 1;
while (not_accepted) {
dA = 0.0;
total++;
@ -206,7 +207,7 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
double *dev = data->deviation;
double *est = data->estimate;
const double *grad = data->gradients;
int *pos, *dpos, *newpos;
int *pos, *newpos;
double rmsd = 0.0;
unsigned int offset, newoffset;
double sum;
@ -215,7 +216,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
unsigned int norm = 0; // number of data points summmed
pos = new int[data->Nvars];
dpos = new int[data->Nvars];
newpos = new int[data->Nvars];
for (int i = 0; i < data->Nvars; i++)
@ -287,7 +287,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
delete [] pos;
delete [] newpos;
delete [] dpos;
return sqrt(rmsd / norm);
}
@ -296,8 +295,6 @@ double compute_deviation(ABFdata * data, bool meta, double kT)
char *parse_cl(int argc, char *argv[], unsigned int *nsteps, double *temp,
bool * meta, double *hill, double *hill_fact)
{
char *filename = NULL;
float f_temp, f_hill;
int meta_int;
// getting default value for the integer