Update Colvars library to version 2020-01-27

One new feature (arithmetic path variables) and several smaller enhancements
or bugfixes.

    Fix error check when loading an old state file
    https://github.com/Colvars/colvars/pull/317

    Get default values for grid boundaries when available
    https://github.com/Colvars/colvars/pull/310

    Allow redefining existing index groups (warn when this happens)
    https://github.com/Colvars/colvars/pull/302

    Simplified replica communication syntax in metadynamics
    https://github.com/Colvars/colvars/pull/301

    Obtain the bias_energy for ABF biases
    https://github.com/Colvars/colvars/pull/294

    Fix reading path file with vector CVCs
    https://github.com/Colvars/colvars/pull/288

    Fix segfault at deleting CVBasedPath
    https://github.com/Colvars/colvars/pull/286

    Parrinello's (arithmetic) pathCV in CV space
    https://github.com/Colvars/colvars/pull/274

    Fix race condition when starting a bundle of walkers
    https://github.com/Colvars/colvars/pull/279
This commit is contained in:
Giacomo Fiorin
2020-01-27 13:39:58 -05:00
parent 5eef3b1828
commit 9427fc50a5
56 changed files with 1876 additions and 1017 deletions

View File

@ -2,7 +2,7 @@
// This file is part of the Collective Variables module (Colvars).
// The original version of Colvars and its updates are located at:
// https://github.com/colvars/colvars
// https://github.com/Colvars/colvars
// Please update all Colvars source files before making any changes.
// If you wish to distribute your changes, please submit them to the
// Colvars repository at GitHub.
@ -119,9 +119,10 @@ colvar::CartesianBasedPath::~CartesianBasedPath() {
(*it_comp_atoms) = nullptr;
}
}
atom_groups.clear();
}
void colvar::CartesianBasedPath::computeReferenceDistance(std::vector<cvm::real>& result) {
void colvar::CartesianBasedPath::computeDistanceToReferenceFrames(std::vector<cvm::real>& result) {
for (size_t i_frame = 0; i_frame < reference_frames.size(); ++i_frame) {
cvm::real frame_rmsd = 0.0;
for (size_t i_atom = 0; i_atom < atoms->size(); ++i_atom) {
@ -147,13 +148,16 @@ colvar::gspath::gspath(std::string const &conf): CartesianBasedPath(conf) {
} else {
cvm::log(std::string("Geometric path s(σ) will use the neighbouring frame to compute s_(m+1)\n"));
}
if (total_reference_frames < 2) {
cvm::error("Error: you have specified " + cvm::to_str(total_reference_frames) + " reference frames, but gspath requires at least 2 frames.\n");
}
GeometricPathCV::GeometricPathBase<cvm::atom_pos, cvm::real, GeometricPathCV::path_sz::S>::initialize(atoms->size(), cvm::atom_pos(), total_reference_frames, use_second_closest_frame, use_third_closest_frame);
cvm::log(std::string("Geometric pathCV(s) is initialized.\n"));
cvm::log(std::string("Geometric pathCV(s) loaded ") + cvm::to_str(reference_frames.size()) + std::string(" frames.\n"));
}
void colvar::gspath::updateReferenceDistances() {
computeReferenceDistance(frame_distances);
void colvar::gspath::updateDistanceToReferenceFrames() {
computeDistanceToReferenceFrames(frame_distances);
}
void colvar::gspath::prepareVectors() {
@ -290,14 +294,17 @@ colvar::gzpath::gzpath(std::string const &conf): CartesianBasedPath(conf) {
if (b_use_z_square == true) {
cvm::log(std::string("Geometric path z(σ) will use the square of distance from current frame to path compute z\n"));
}
if (total_reference_frames < 2) {
cvm::error("Error: you have specified " + cvm::to_str(total_reference_frames) + " reference frames, but gzpath requires at least 2 frames.\n");
}
GeometricPathCV::GeometricPathBase<cvm::atom_pos, cvm::real, GeometricPathCV::path_sz::Z>::initialize(atoms->size(), cvm::atom_pos(), total_reference_frames, use_second_closest_frame, use_third_closest_frame, b_use_z_square);
// Logging
cvm::log(std::string("Geometric pathCV(z) is initialized.\n"));
cvm::log(std::string("Geometric pathCV(z) loaded ") + cvm::to_str(reference_frames.size()) + std::string(" frames.\n"));
}
void colvar::gzpath::updateReferenceDistances() {
computeReferenceDistance(frame_distances);
void colvar::gzpath::updateDistanceToReferenceFrames() {
computeDistanceToReferenceFrames(frame_distances);
}
void colvar::gzpath::prepareVectors() {
@ -538,6 +545,7 @@ colvar::CVBasedPath::CVBasedPath(std::string const &conf): cvc(conf) {
std::vector<std::string> fields;
split_string(line, token, fields);
size_t num_value_required = 0;
cvm::log(std::string("Reading reference frame ") + cvm::to_str(total_reference_frames + 1) + std::string("\n"));
for (size_t i_cv = 0; i_cv < tmp_cv.size(); ++i_cv) {
const size_t value_size = tmp_cv[i_cv].size();
num_value_required += value_size;
@ -545,10 +553,9 @@ colvar::CVBasedPath::CVBasedPath(std::string const &conf): cvc(conf) {
if (num_value_required <= fields.size()) {
size_t start_index = num_value_required - value_size;
for (size_t i = start_index; i < num_value_required; ++i) {
tmp_cv[i_cv][i] = std::atof(fields[i].c_str());
cvm::log(fields[i] + std::string(" "));
tmp_cv[i_cv][i - start_index] = std::atof(fields[i].c_str());
cvm::log(cvm::to_str(tmp_cv[i_cv][i - start_index]));
}
cvm::log(std::string("\n"));
} else {
cvm::error("Error: incorrect format of path file.\n");
}
@ -558,6 +565,9 @@ colvar::CVBasedPath::CVBasedPath(std::string const &conf): cvc(conf) {
++total_reference_frames;
}
}
if (total_reference_frames <= 1) {
cvm::error("Error: there is only 1 or 0 reference frame, which doesn't constitute a path.\n");
}
x.type(colvarvalue::type_scalar);
use_explicit_gradients = true;
for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) {
@ -570,7 +580,7 @@ colvar::CVBasedPath::CVBasedPath(std::string const &conf): cvc(conf) {
}
}
void colvar::CVBasedPath::computeReferenceDistance(std::vector<cvm::real>& result) {
void colvar::CVBasedPath::computeDistanceToReferenceFrames(std::vector<cvm::real>& result) {
for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) {
cv[i_cv]->calc_value();
}
@ -593,6 +603,20 @@ void colvar::CVBasedPath::computeReferenceDistance(std::vector<cvm::real>& resul
}
}
void colvar::CVBasedPath::computeDistanceBetweenReferenceFrames(std::vector<cvm::real>& result) const {
if (ref_cv.size() < 2) return;
for (size_t i_frame = 1; i_frame < ref_cv.size(); ++i_frame) {
cvm::real dist_ij = 0.0;
for (size_t i_cv = 0; i_cv < cv.size(); ++i_cv) {
colvarvalue ref_cv_value(ref_cv[i_frame][i_cv]);
colvarvalue prev_ref_cv_value(ref_cv[i_frame-1][i_cv]);
dist_ij += cv[i_cv]->dist2(ref_cv_value, prev_ref_cv_value);
}
dist_ij = cvm::sqrt(dist_ij);
result[i_frame-1] = dist_ij;
}
}
cvm::real colvar::CVBasedPath::getPolynomialFactorOfCVGradient(size_t i_cv) const {
cvm::real factor_polynomial = 1.0;
if (cv[i_cv]->value().type() == colvarvalue::type_scalar) {
@ -607,6 +631,7 @@ colvar::CVBasedPath::~CVBasedPath() {
for (auto it = cv.begin(); it != cv.end(); ++it) {
delete (*it);
}
atom_groups.clear();
}
colvar::gspathCV::gspathCV(std::string const &conf): CVBasedPath(conf) {
@ -625,6 +650,9 @@ colvar::gspathCV::gspathCV(std::string const &conf): CVBasedPath(conf) {
} else {
cvm::log(std::string("Geometric path s(σ) will use the neighbouring frame to compute s_(m+1)\n"));
}
if (total_reference_frames < 2) {
cvm::error("Error: you have specified " + cvm::to_str(total_reference_frames) + " reference frames, but gspathCV requires at least 2 frames.\n");
}
GeometricPathCV::GeometricPathBase<colvarvalue, cvm::real, GeometricPathCV::path_sz::S>::initialize(cv.size(), ref_cv[0], total_reference_frames, use_second_closest_frame, use_third_closest_frame);
x.type(colvarvalue::type_scalar);
use_explicit_gradients = true;
@ -641,8 +669,8 @@ colvar::gspathCV::gspathCV(std::string const &conf): CVBasedPath(conf) {
colvar::gspathCV::~gspathCV() {}
void colvar::gspathCV::updateReferenceDistances() {
computeReferenceDistance(frame_distances);
void colvar::gspathCV::updateDistanceToReferenceFrames() {
computeDistanceToReferenceFrames(frame_distances);
}
void colvar::gspathCV::prepareVectors() {
@ -766,6 +794,9 @@ colvar::gzpathCV::gzpathCV(std::string const &conf): CVBasedPath(conf) {
if (b_use_z_square == true) {
cvm::log(std::string("Geometric path z(σ) will use the square of distance from current frame to path compute z\n"));
}
if (total_reference_frames < 2) {
cvm::error("Error: you have specified " + cvm::to_str(total_reference_frames) + " reference frames, but gzpathCV requires at least 2 frames.\n");
}
GeometricPathCV::GeometricPathBase<colvarvalue, cvm::real, GeometricPathCV::path_sz::Z>::initialize(cv.size(), ref_cv[0], total_reference_frames, use_second_closest_frame, use_third_closest_frame, b_use_z_square);
x.type(colvarvalue::type_scalar);
use_explicit_gradients = true;
@ -783,8 +814,8 @@ colvar::gzpathCV::gzpathCV(std::string const &conf): CVBasedPath(conf) {
colvar::gzpathCV::~gzpathCV() {
}
void colvar::gzpathCV::updateReferenceDistances() {
computeReferenceDistance(frame_distances);
void colvar::gzpathCV::updateDistanceToReferenceFrames() {
computeDistanceToReferenceFrames(frame_distances);
}
void colvar::gzpathCV::prepareVectors() {