Update Colvars to version 2022-05-09

This update includes one new feature (neural-network based collective
variables), several small enhancements (including an automatic definition of
grid boundaries for angle-based CVs, and a normalization option for
eigenvector-based CVs), bugfixes and documentation improvements.

Usage information for specific features included in the Colvars library
(i.e. not just the library as a whole) is now also reported to the screen or
LAMMPS logfile (as is done already in other LAMMPS classes).

Notable to LAMMPS code development are the removals of duplicated code and of
ambiguously-named preprocessor defines in the Colvars headers.  Since the
last PR, the existing regression tests have also been running automatically
via GitHub Actions.

The following pull requests in the Colvars repository are relevant to LAMMPS:

- 475 Remove fatal error condition
  https://github.com/Colvars/colvars/pull/475 (@jhenin, @giacomofiorin)

- 474 Allow normalizing eigenvector vector components to deal with unit change
  https://github.com/Colvars/colvars/pull/474 (@giacomofiorin, @jhenin)

- 470 Better error handling in the initialization of NeuralNetwork CV
  https://github.com/Colvars/colvars/pull/470 (@HanatoK)

- 468 Add examples of histogram configuration, with and without explicit grid parameters
  https://github.com/Colvars/colvars/pull/468 (@giacomofiorin)

- 464 Fix #463 using more fine-grained features
  https://github.com/Colvars/colvars/pull/464 (@jhenin, @giacomofiorin)

- 447 [RFC] New option "scaledBiasingForce" for colvarbias
  https://github.com/Colvars/colvars/pull/447 (@HanatoK, @jhenin)

- 444 [RFC] Implementation of dense neural network as CV
  https://github.com/Colvars/colvars/pull/444 (@HanatoK, @giacomofiorin, @jhenin)

- 443 Fix explicit gradient dependency of sub-CVs
  https://github.com/Colvars/colvars/pull/443 (@HanatoK, @jhenin)

- 442 Persistent bias count
  https://github.com/Colvars/colvars/pull/442 (@jhenin, @giacomofiorin)

- 437 Return type of bias from scripting interface
  https://github.com/Colvars/colvars/pull/437 (@giacomofiorin)

- 434 More flexible use of boundaries from colvars by grids
  https://github.com/Colvars/colvars/pull/434 (@jhenin)

- 433 Prevent double-free in linearCombination
  https://github.com/Colvars/colvars/pull/433 (@HanatoK)

- 428 More complete documentation for index file format (NDX)
  https://github.com/Colvars/colvars/pull/428 (@giacomofiorin)

- 426 Integrate functional version of backup_file() into base proxy class
  https://github.com/Colvars/colvars/pull/426 (@giacomofiorin)

- 424 Track CVC inheritance when documenting feature usage
  https://github.com/Colvars/colvars/pull/424 (@giacomofiorin)

- 419 Generate citation report while running computations
  https://github.com/Colvars/colvars/pull/419 (@giacomofiorin, @jhenin)

- 415 Rebin metadynamics bias from explicit hills when available
  https://github.com/Colvars/colvars/pull/415 (@giacomofiorin)

- 312 Ignore a keyword if it has content to the left of it (regardless of braces)
  https://github.com/Colvars/colvars/pull/312 (@giacomofiorin)

Authors: @giacomofiorin, @HanatoK, @jhenin
This commit is contained in:
Giacomo Fiorin
2022-05-10 11:24:54 -04:00
parent 4737b9efb7
commit 1220bea011
66 changed files with 4040 additions and 1221 deletions

View File

@ -121,14 +121,14 @@ int colvarbias_restraint_centers::init(std::string const &conf)
if (null_centers) {
colvar_centers.clear();
cvm::error("Error: must define the initial centers of the restraints.\n", INPUT_ERROR);
return INPUT_ERROR;
cvm::error("Error: must define the initial centers of the restraints.\n", COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
if (colvar_centers.size() != num_variables()) {
cvm::error("Error: number of centers does not match "
"that of collective variables.\n", INPUT_ERROR);
return INPUT_ERROR;
"that of collective variables.\n", COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
return COLVARS_OK;
@ -160,8 +160,8 @@ int colvarbias_restraint_k::init(std::string const &conf)
{
get_keyval(conf, "forceConstant", force_k, (force_k > 0.0 ? force_k : 1.0));
if (check_positive_k && (force_k < 0.0)) {
cvm::error("Error: undefined or invalid force constant.\n", INPUT_ERROR);
return INPUT_ERROR;
cvm::error("Error: undefined or invalid force constant.\n", COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
return COLVARS_OK;
}
@ -190,21 +190,21 @@ int colvarbias_restraint_moving::init(std::string const &conf)
{
if (b_chg_centers && b_chg_force_k) {
cvm::error("Error: cannot specify both targetCenters and targetForceConstant.\n",
INPUT_ERROR);
return INPUT_ERROR;
COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
if (b_chg_centers || b_chg_force_k) {
get_keyval(conf, "targetNumSteps", target_nsteps, target_nsteps);
if (!target_nsteps) {
cvm::error("Error: targetNumSteps must be non-zero.\n", INPUT_ERROR);
cvm::error("Error: targetNumSteps must be non-zero.\n", COLVARS_INPUT_ERROR);
return cvm::get_error();
}
if (get_keyval(conf, "targetNumStages", target_nstages, target_nstages) &&
lambda_schedule.size()) {
cvm::error("Error: targetNumStages and lambdaSchedule are incompatible.\n", INPUT_ERROR);
cvm::error("Error: targetNumStages and lambdaSchedule are incompatible.\n", COLVARS_INPUT_ERROR);
return cvm::get_error();
}
@ -213,7 +213,7 @@ int colvarbias_restraint_moving::init(std::string const &conf)
is_enabled(f_cvb_output_acc_work));
if (is_enabled(f_cvb_output_acc_work) && (target_nstages > 0)) {
return cvm::error("Error: outputAccumulatedWork and targetNumStages "
"are incompatible.\n", INPUT_ERROR);
"are incompatible.\n", COLVARS_INPUT_ERROR);
}
}
@ -273,7 +273,7 @@ int colvarbias_restraint_centers_moving::init(std::string const &conf)
if (get_keyval(conf, "targetCenters", target_centers, colvar_centers)) {
if (target_centers.size() != num_variables()) {
cvm::error("Error: number of target centers does not match "
"that of collective variables.\n", INPUT_ERROR);
"that of collective variables.\n", COLVARS_INPUT_ERROR);
}
b_chg_centers = true;
for (i = 0; i < target_centers.size(); i++) {
@ -525,7 +525,7 @@ int colvarbias_restraint_k_moving::init(std::string const &conf)
if (get_keyval(conf, "lambdaSchedule", lambda_schedule, lambda_schedule) &&
target_nstages > 0) {
cvm::error("Error: targetNumStages and lambdaSchedule are incompatible.\n", INPUT_ERROR);
cvm::error("Error: targetNumStages and lambdaSchedule are incompatible.\n", COLVARS_INPUT_ERROR);
return cvm::get_error();
}
@ -726,6 +726,8 @@ int colvarbias_restraint_harmonic::init(std::string const &conf)
colvarbias_restraint_centers_moving::init(conf);
colvarbias_restraint_k_moving::init(conf);
cvm::main()->cite_feature("Harmonic colvar bias implementation");
for (size_t i = 0; i < num_variables(); i++) {
cvm::real const w = variables(i)->width;
cvm::log("The force constant for colvar \""+variables(i)->name+
@ -880,6 +882,8 @@ int colvarbias_restraint_harmonic_walls::init(std::string const &conf)
colvarbias_restraint_moving::init(conf);
colvarbias_restraint_k_moving::init(conf);
cvm::main()->cite_feature("harmonicWalls colvar bias implementation");
enable(f_cvb_scalar_variables);
size_t i;
@ -915,7 +919,7 @@ int colvarbias_restraint_harmonic_walls::init(std::string const &conf)
}
if ((lower_walls.size() == 0) && (upper_walls.size() == 0)) {
return cvm::error("Error: no walls provided.\n", INPUT_ERROR);
return cvm::error("Error: no walls provided.\n", COLVARS_INPUT_ERROR);
}
if (lower_walls.size() > 0) {
@ -931,7 +935,7 @@ int colvarbias_restraint_harmonic_walls::init(std::string const &conf)
for (i = 0; i < num_variables(); i++) {
if (variables(i)->is_enabled(f_cv_periodic)) {
return cvm::error("Error: at least one variable is periodic, "
"both walls must be provided.\n", INPUT_ERROR);
"both walls must be provided.\n", COLVARS_INPUT_ERROR);
}
}
}
@ -943,19 +947,19 @@ int colvarbias_restraint_harmonic_walls::init(std::string const &conf)
cvm::to_str(upper_walls[i])+
", is not higher than the lower wall, "+
cvm::to_str(lower_walls[i])+".\n",
INPUT_ERROR);
COLVARS_INPUT_ERROR);
}
if (variables(i)->dist2(lower_walls[i], upper_walls[i]) < 1.0e-12) {
return cvm::error("Error: lower wall and upper wall are equal "
"in the domain of the variable \""+
variables(i)->name+"\".\n", INPUT_ERROR);
variables(i)->name+"\".\n", COLVARS_INPUT_ERROR);
}
}
if (lower_wall_k * upper_wall_k == 0.0) {
cvm::error("Error: lowerWallConstant and upperWallConstant, "
"when defined, must both be positive.\n",
INPUT_ERROR);
return INPUT_ERROR;
COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
force_k = cvm::sqrt(lower_wall_k * upper_wall_k);
// transform the two constants to relative values using gemetric mean as ref
@ -1148,11 +1152,13 @@ int colvarbias_restraint_linear::init(std::string const &conf)
colvarbias_restraint_centers_moving::init(conf);
colvarbias_restraint_k_moving::init(conf);
cvm::main()->cite_feature("harmonicWalls colvar bias implementation");
for (size_t i = 0; i < num_variables(); i++) {
if (variables(i)->is_enabled(f_cv_periodic)) {
cvm::error("Error: linear biases cannot be applied to periodic variables.\n",
INPUT_ERROR);
return INPUT_ERROR;
COLVARS_INPUT_ERROR);
return COLVARS_INPUT_ERROR;
}
cvm::real const w = variables(i)->width;
cvm::log("The force constant for colvar \""+variables(i)->name+
@ -1299,12 +1305,14 @@ int colvarbias_restraint_histogram::init(std::string const &conf)
colvarbias::init(conf);
enable(f_cvb_apply_force);
cvm::main()->cite_feature("histogramRestraint colvar bias implementation");
get_keyval(conf, "lowerBoundary", lower_boundary, lower_boundary);
get_keyval(conf, "upperBoundary", upper_boundary, upper_boundary);
get_keyval(conf, "width", width, width);
if (width <= 0.0) {
cvm::error("Error: \"width\" must be positive.\n", INPUT_ERROR);
cvm::error("Error: \"width\" must be positive.\n", COLVARS_INPUT_ERROR);
}
get_keyval(conf, "gaussianWidth", gaussian_width, 2.0 * width, colvarparse::parse_silent);
@ -1315,7 +1323,7 @@ int colvarbias_restraint_histogram::init(std::string const &conf)
cvm::to_str(upper_boundary)+
", is not higher than the lower boundary, "+
cvm::to_str(lower_boundary)+".\n",
INPUT_ERROR);
COLVARS_INPUT_ERROR);
}
cvm::real const nbins = (upper_boundary - lower_boundary) / width;
@ -1340,7 +1348,7 @@ int colvarbias_restraint_histogram::init(std::string const &conf)
if (ref_p_file.size()) {
if (inline_ref_p) {
cvm::error("Error: cannot specify both refHistogram and refHistogramFile at the same time.\n",
INPUT_ERROR);
COLVARS_INPUT_ERROR);
} else {
std::ifstream is(ref_p_file.c_str());
std::string data_s = "";
@ -1349,7 +1357,7 @@ int colvarbias_restraint_histogram::init(std::string const &conf)
data_s.append(line+"\n");
}
if (data_s.size() == 0) {
cvm::error("Error: file \""+ref_p_file+"\" empty or unreadable.\n", FILE_ERROR);
cvm::error("Error: file \""+ref_p_file+"\" empty or unreadable.\n", COLVARS_FILE_ERROR);
}
is.close();
cvm::vector1d<cvm::real> data;
@ -1366,7 +1374,7 @@ int colvarbias_restraint_histogram::init(std::string const &conf)
ref_p = data;
} else {
cvm::error("Error: file \""+ref_p_file+"\" contains a histogram of different length.\n",
INPUT_ERROR);
COLVARS_INPUT_ERROR);
}
}
}