Update Colvars to version 2020-07-07
This update contains several fixes and small new features or usability improvements. Descriptions and authorship information can be accessed from the pull requests listed below. Skip the zero-step also when multiple run commands are executed in sequence (@giacomofiorin) https://github.com/Colvars/colvars/pull/357 Do not accumulate data at step 0 (@giacomofiorin) https://github.com/Colvars/colvars/pull/345 Support for symmetry permutations of atoms in RMSD (@jhenin) https://github.com/Colvars/colvars/pull/344 Detect new grid parameters (@jhenin) https://github.com/Colvars/colvars/pull/341 Only access the output streams in non-threaded regions (@giacomofiorin) https://github.com/Colvars/colvars/pull/338 Fix incomplete setting of default colvarsRestartFrequency (@giacomofiorin) https://github.com/Colvars/colvars/pull/334 Fix typo (@e-kwsm) https://github.com/Colvars/colvars/pull/333 Convert the input keyword to lowercase in read_state_data_key (@HanatoK) https://github.com/Colvars/colvars/pull/332 Implement reflecting b.c. for ext Lagrangian (@jhenin) https://github.com/Colvars/colvars/pull/329
This commit is contained in:
@ -541,7 +541,7 @@ int colvar::init_grid_parameters(std::string const &conf)
|
||||
cvm::log("Reading legacy options lowerWall and lowerWallConstant: "
|
||||
"consider using a harmonicWalls restraint (caution: force constant would then be scaled by width^2).\n");
|
||||
if (!get_keyval(conf, "lowerWall", lower_wall)) {
|
||||
error_code != cvm::error("Error: the value of lowerWall must be set "
|
||||
error_code |= cvm::error("Error: the value of lowerWall must be set "
|
||||
"explicitly.\n", INPUT_ERROR);
|
||||
}
|
||||
lw_conf = std::string("\n\
|
||||
@ -554,7 +554,7 @@ int colvar::init_grid_parameters(std::string const &conf)
|
||||
cvm::log("Reading legacy options upperWall and upperWallConstant: "
|
||||
"consider using a harmonicWalls restraint (caution: force constant would then be scaled by width^2).\n");
|
||||
if (!get_keyval(conf, "upperWall", upper_wall)) {
|
||||
error_code != cvm::error("Error: the value of upperWall must be set "
|
||||
error_code |= cvm::error("Error: the value of upperWall must be set "
|
||||
"explicitly.\n", INPUT_ERROR);
|
||||
}
|
||||
uw_conf = std::string("\n\
|
||||
@ -616,7 +616,7 @@ harmonicWalls {\n\
|
||||
"are enabled).\n", INPUT_ERROR);
|
||||
}
|
||||
|
||||
return COLVARS_OK;
|
||||
return error_code;
|
||||
}
|
||||
|
||||
|
||||
@ -681,6 +681,9 @@ int colvar::init_extended_Lagrangian(std::string const &conf)
|
||||
// Adjust Langevin sigma for slow time step if time_step_factor != 1
|
||||
ext_sigma = cvm::sqrt(2.0 * cvm::boltzmann() * temp * ext_gamma * ext_mass / (cvm::dt() * cvm::real(time_step_factor)));
|
||||
}
|
||||
|
||||
get_keyval_feature(this, conf, "reflectingLowerBoundary", f_cv_reflecting_lower_boundary, false);
|
||||
get_keyval_feature(this, conf, "reflectingUpperBoundary", f_cv_reflecting_upper_boundary, false);
|
||||
}
|
||||
|
||||
return COLVARS_OK;
|
||||
@ -863,6 +866,8 @@ int colvar::init_components(std::string const &conf)
|
||||
error_code |= init_components_type<aspathCV>(conf, "arithmetic path collective variables (s) for other CVs", "aspathCV");
|
||||
error_code |= init_components_type<azpathCV>(conf, "arithmetic path collective variables (s) for other CVs", "azpathCV");
|
||||
|
||||
error_code |= init_components_type<map_total>(conf, "total value of atomic map", "mapTotal");
|
||||
|
||||
if (!cvcs.size() || (error_code != COLVARS_OK)) {
|
||||
cvm::error("Error: no valid components were provided "
|
||||
"for this collective variable.\n",
|
||||
@ -1040,85 +1045,93 @@ int colvar::init_dependencies() {
|
||||
init_feature(f_cv_gradient, "gradient", f_type_dynamic);
|
||||
require_feature_children(f_cv_gradient, f_cvc_gradient);
|
||||
|
||||
init_feature(f_cv_collect_gradient, "collect gradient", f_type_dynamic);
|
||||
init_feature(f_cv_collect_gradient, "collect_gradient", f_type_dynamic);
|
||||
require_feature_self(f_cv_collect_gradient, f_cv_gradient);
|
||||
require_feature_self(f_cv_collect_gradient, f_cv_scalar);
|
||||
// The following exlusion could be lifted by implementing the feature
|
||||
exclude_feature_self(f_cv_collect_gradient, f_cv_scripted);
|
||||
require_feature_children(f_cv_collect_gradient, f_cvc_explicit_gradient);
|
||||
|
||||
init_feature(f_cv_fdiff_velocity, "velocity from finite differences", f_type_dynamic);
|
||||
init_feature(f_cv_fdiff_velocity, "velocity_from_finite_differences", f_type_dynamic);
|
||||
|
||||
// System force: either trivial (spring force); through extended Lagrangian, or calculated explicitly
|
||||
init_feature(f_cv_total_force, "total force", f_type_dynamic);
|
||||
init_feature(f_cv_total_force, "total_force", f_type_dynamic);
|
||||
require_feature_alt(f_cv_total_force, f_cv_extended_Lagrangian, f_cv_total_force_calc);
|
||||
|
||||
// Deps for explicit total force calculation
|
||||
init_feature(f_cv_total_force_calc, "total force calculation", f_type_dynamic);
|
||||
init_feature(f_cv_total_force_calc, "total_force_calculation", f_type_dynamic);
|
||||
require_feature_self(f_cv_total_force_calc, f_cv_scalar);
|
||||
require_feature_self(f_cv_total_force_calc, f_cv_linear);
|
||||
require_feature_children(f_cv_total_force_calc, f_cvc_inv_gradient);
|
||||
require_feature_self(f_cv_total_force_calc, f_cv_Jacobian);
|
||||
|
||||
init_feature(f_cv_Jacobian, "Jacobian derivative", f_type_dynamic);
|
||||
init_feature(f_cv_Jacobian, "Jacobian_derivative", f_type_dynamic);
|
||||
require_feature_self(f_cv_Jacobian, f_cv_scalar);
|
||||
require_feature_self(f_cv_Jacobian, f_cv_linear);
|
||||
require_feature_children(f_cv_Jacobian, f_cvc_Jacobian);
|
||||
|
||||
init_feature(f_cv_hide_Jacobian, "hide Jacobian force", f_type_user);
|
||||
init_feature(f_cv_hide_Jacobian, "hide_Jacobian_force", f_type_user);
|
||||
require_feature_self(f_cv_hide_Jacobian, f_cv_Jacobian); // can only hide if calculated
|
||||
|
||||
init_feature(f_cv_extended_Lagrangian, "extended Lagrangian", f_type_user);
|
||||
init_feature(f_cv_extended_Lagrangian, "extended_Lagrangian", f_type_user);
|
||||
require_feature_self(f_cv_extended_Lagrangian, f_cv_scalar);
|
||||
require_feature_self(f_cv_extended_Lagrangian, f_cv_gradient);
|
||||
|
||||
init_feature(f_cv_Langevin, "Langevin dynamics", f_type_user);
|
||||
init_feature(f_cv_Langevin, "Langevin_dynamics", f_type_user);
|
||||
require_feature_self(f_cv_Langevin, f_cv_extended_Lagrangian);
|
||||
|
||||
init_feature(f_cv_single_cvc, "single component", f_type_static);
|
||||
init_feature(f_cv_single_cvc, "single_component", f_type_static);
|
||||
|
||||
init_feature(f_cv_linear, "linear", f_type_static);
|
||||
|
||||
init_feature(f_cv_scalar, "scalar", f_type_static);
|
||||
|
||||
init_feature(f_cv_output_energy, "output energy", f_type_user);
|
||||
init_feature(f_cv_output_energy, "output_energy", f_type_user);
|
||||
|
||||
init_feature(f_cv_output_value, "output value", f_type_user);
|
||||
init_feature(f_cv_output_value, "output_value", f_type_user);
|
||||
|
||||
init_feature(f_cv_output_velocity, "output velocity", f_type_user);
|
||||
init_feature(f_cv_output_velocity, "output_velocity", f_type_user);
|
||||
require_feature_self(f_cv_output_velocity, f_cv_fdiff_velocity);
|
||||
|
||||
init_feature(f_cv_output_applied_force, "output applied force", f_type_user);
|
||||
init_feature(f_cv_output_applied_force, "output_applied_force", f_type_user);
|
||||
|
||||
init_feature(f_cv_output_total_force, "output total force", f_type_user);
|
||||
init_feature(f_cv_output_total_force, "output_total_force", f_type_user);
|
||||
require_feature_self(f_cv_output_total_force, f_cv_total_force);
|
||||
|
||||
init_feature(f_cv_subtract_applied_force, "subtract applied force from total force", f_type_user);
|
||||
init_feature(f_cv_subtract_applied_force, "subtract_applied_force_from_total_force", f_type_user);
|
||||
require_feature_self(f_cv_subtract_applied_force, f_cv_total_force);
|
||||
|
||||
init_feature(f_cv_lower_boundary, "lower boundary", f_type_user);
|
||||
init_feature(f_cv_lower_boundary, "lower_boundary", f_type_user);
|
||||
require_feature_self(f_cv_lower_boundary, f_cv_scalar);
|
||||
|
||||
init_feature(f_cv_upper_boundary, "upper boundary", f_type_user);
|
||||
init_feature(f_cv_upper_boundary, "upper_boundary", f_type_user);
|
||||
require_feature_self(f_cv_upper_boundary, f_cv_scalar);
|
||||
|
||||
init_feature(f_cv_hard_lower_boundary, "hard lower boundary", f_type_user);
|
||||
init_feature(f_cv_hard_lower_boundary, "hard_lower_boundary", f_type_user);
|
||||
require_feature_self(f_cv_hard_lower_boundary, f_cv_lower_boundary);
|
||||
|
||||
init_feature(f_cv_hard_upper_boundary, "hard upper boundary", f_type_user);
|
||||
init_feature(f_cv_hard_upper_boundary, "hard_upper_boundary", f_type_user);
|
||||
require_feature_self(f_cv_hard_upper_boundary, f_cv_upper_boundary);
|
||||
|
||||
init_feature(f_cv_reflecting_lower_boundary, "reflecting_lower_boundary", f_type_user);
|
||||
require_feature_self(f_cv_reflecting_lower_boundary, f_cv_lower_boundary);
|
||||
require_feature_self(f_cv_reflecting_lower_boundary, f_cv_extended_Lagrangian);
|
||||
|
||||
init_feature(f_cv_reflecting_upper_boundary, "reflecting_upper_boundary", f_type_user);
|
||||
require_feature_self(f_cv_reflecting_upper_boundary, f_cv_upper_boundary);
|
||||
require_feature_self(f_cv_reflecting_upper_boundary, f_cv_extended_Lagrangian);
|
||||
|
||||
init_feature(f_cv_grid, "grid", f_type_dynamic);
|
||||
require_feature_self(f_cv_grid, f_cv_lower_boundary);
|
||||
require_feature_self(f_cv_grid, f_cv_upper_boundary);
|
||||
|
||||
init_feature(f_cv_runave, "running average", f_type_user);
|
||||
init_feature(f_cv_runave, "running_average", f_type_user);
|
||||
|
||||
init_feature(f_cv_corrfunc, "correlation function", f_type_user);
|
||||
init_feature(f_cv_corrfunc, "correlation_function", f_type_user);
|
||||
|
||||
init_feature(f_cv_scripted, "scripted", f_type_user);
|
||||
|
||||
init_feature(f_cv_custom_function, "custom function", f_type_user);
|
||||
init_feature(f_cv_custom_function, "custom_function", f_type_user);
|
||||
exclude_feature_self(f_cv_custom_function, f_cv_scripted);
|
||||
|
||||
init_feature(f_cv_periodic, "periodic", f_type_static);
|
||||
@ -1129,7 +1142,7 @@ int colvar::init_dependencies() {
|
||||
|
||||
// because total forces are obtained from the previous time step,
|
||||
// we cannot (currently) have colvar values and total forces for the same timestep
|
||||
init_feature(f_cv_multiple_ts, "multiple timestep colvar", f_type_static);
|
||||
init_feature(f_cv_multiple_ts, "multiple_timestep", f_type_static);
|
||||
exclude_feature_self(f_cv_multiple_ts, f_cv_total_force_calc);
|
||||
|
||||
// check that everything is initialized
|
||||
@ -1199,8 +1212,17 @@ colvar::~colvar()
|
||||
(*ci)->remove_all_children();
|
||||
delete *ci;
|
||||
}
|
||||
cvcs.clear();
|
||||
|
||||
// remove reference to this colvar from the CVM
|
||||
while (biases.size() > 0) {
|
||||
size_t const i = biases.size()-1;
|
||||
cvm::log("Warning: before deleting colvar " + name
|
||||
+ ", deleting related bias " + biases[i]->name);
|
||||
delete biases[i];
|
||||
}
|
||||
biases.clear();
|
||||
|
||||
// remove reference to this colvar from the module
|
||||
colvarmodule *cv = cvm::main();
|
||||
for (std::vector<colvar *>::iterator cvi = cv->variables()->begin();
|
||||
cvi != cv->variables()->end();
|
||||
@ -1211,6 +1233,8 @@ colvar::~colvar()
|
||||
}
|
||||
}
|
||||
|
||||
cv->config_changed();
|
||||
|
||||
#ifdef LEPTON
|
||||
for (std::vector<Lepton::CompiledExpression *>::iterator cei = value_evaluators.begin();
|
||||
cei != value_evaluators.end();
|
||||
@ -1599,6 +1623,15 @@ int colvar::calc_colvar_properties()
|
||||
// just calculated from the cvcs
|
||||
if ((cvm::step_relative() == 0 && !after_restart) || x_ext.type() == colvarvalue::type_notset) {
|
||||
x_ext = x;
|
||||
if (is_enabled(f_cv_reflecting_lower_boundary) && x_ext < lower_boundary) {
|
||||
cvm::log("Warning: initializing extended coordinate to reflective lower boundary, as colvar value is below.");
|
||||
x_ext = lower_boundary;
|
||||
}
|
||||
if (is_enabled(f_cv_reflecting_upper_boundary) && x_ext > upper_boundary) {
|
||||
cvm::log("Warning: initializing extended coordinate to reflective upper boundary, as colvar value is above.");
|
||||
x_ext = upper_boundary;
|
||||
}
|
||||
|
||||
v_ext.reset(); // (already 0; added for clarity)
|
||||
}
|
||||
|
||||
@ -1672,10 +1705,10 @@ cvm::real colvar::update_forces_energy()
|
||||
cvm::log("Updating extended-Lagrangian degree of freedom.\n");
|
||||
}
|
||||
|
||||
if (prev_timestep > -1) {
|
||||
if (prev_timestep > -1L) {
|
||||
// Keep track of slow timestep to integrate MTS colvars
|
||||
// the colvar checks the interval after waking up twice
|
||||
int n_timesteps = cvm::step_relative() - prev_timestep;
|
||||
cvm::step_number n_timesteps = cvm::step_relative() - prev_timestep;
|
||||
if (n_timesteps != 0 && n_timesteps != time_step_factor) {
|
||||
cvm::error("Error: extended-Lagrangian " + description + " has timeStepFactor " +
|
||||
cvm::to_str(time_step_factor) + ", but was activated after " + cvm::to_str(n_timesteps) +
|
||||
@ -1737,6 +1770,14 @@ cvm::real colvar::update_forces_energy()
|
||||
}
|
||||
v_ext += (0.5 * dt) * f_ext / ext_mass;
|
||||
x_ext += dt * v_ext;
|
||||
|
||||
cvm::real delta = 0; // Length of overshoot past either reflecting boundary
|
||||
if ((is_enabled(f_cv_reflecting_lower_boundary) && (delta = x_ext - lower_boundary) < 0) ||
|
||||
(is_enabled(f_cv_reflecting_upper_boundary) && (delta = x_ext - upper_boundary) > 0)) {
|
||||
x_ext -= 2.0 * delta;
|
||||
v_ext *= -1.0;
|
||||
}
|
||||
|
||||
x_ext.apply_constraints();
|
||||
this->wrap(x_ext);
|
||||
} else {
|
||||
@ -2082,7 +2123,7 @@ void colvar::wrap(colvarvalue &x_unwrapped) const
|
||||
|
||||
std::istream & colvar::read_state(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::streampos const start_pos = is.tellg();
|
||||
|
||||
std::string conf;
|
||||
if ( !(is >> colvarparse::read_block("colvar", &conf)) ) {
|
||||
@ -2163,7 +2204,7 @@ std::istream & colvar::read_state(std::istream &is)
|
||||
|
||||
std::istream & colvar::read_traj(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::streampos const start_pos = is.tellg();
|
||||
|
||||
if (is_enabled(f_cv_output_value)) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user