update colvars library to version from 2015-09-29

This commit is contained in:
Axel Kohlmeyer
2015-10-12 11:29:06 -04:00
parent 1c907e112d
commit 52d245a964
4 changed files with 55 additions and 53 deletions

Binary file not shown.

View File

@ -727,6 +727,7 @@ int colvar::enable(colvar::task const &t)
case task_output_value:
case task_runave:
case task_corrfunc:
case task_ntot:
case task_langevin:
case task_output_energy:
case task_scripted:
@ -1105,44 +1106,6 @@ cvm::real colvar::update()
f += fb;
if (tasks[task_lower_wall] || tasks[task_upper_wall]) {
// wall force
colvarvalue fw(value());
fw.reset();
if (cvm::debug())
cvm::log("Calculating wall forces for colvar \""+this->name+"\".\n");
// if the two walls are applied concurrently, decide which is the
// closer one (on a periodic colvar, both walls may be applicable
// at the same time)
if ( (!tasks[task_upper_wall]) ||
(this->dist2(x_reported, lower_wall) < this->dist2(x_reported, upper_wall)) ) {
cvm::real const grad = this->dist2_lgrad(x_reported, lower_wall);
if (grad < 0.0) {
fw = -0.5 * lower_wall_k * grad;
if (cvm::debug())
cvm::log("Applying a lower wall force("+
cvm::to_str(fw)+") to \""+this->name+"\".\n");
f += fw;
}
} else {
cvm::real const grad = this->dist2_lgrad(x_reported, upper_wall);
if (grad > 0.0) {
fw = -0.5 * upper_wall_k * grad;
if (cvm::debug())
cvm::log("Applying an upper wall force("+
cvm::to_str(fw)+") to \""+this->name+"\".\n");
f += fw;
}
}
}
if (tasks[task_Jacobian_force]) {
size_t i;
for (i = 0; i < cvcs.size(); i++) {
@ -1177,10 +1140,11 @@ cvm::real colvar::update()
// the total force is applied to the fictitious mass, while the
// atoms only feel the harmonic force
// fr: extended coordinate force (without harmonic spring), for output in trajectory
// fr: bias force on extended coordinate (without harmonic spring), for output in trajectory
// f_ext: total force on extended coordinate (including harmonic spring)
// f: - initially, external biasing force
// - after this code block, colvar force to be applied to atomic coordinates, ie. spring force
// - after this code block, colvar force to be applied to atomic coordinates, ie. spring force
// (note: wall potential is added to f after this block)
fr = f;
f_ext = f + (-0.5 * ext_force_k) * this->dist2_lgrad(xr, x);
f = (-0.5 * ext_force_k) * this->dist2_rgrad(xr, x);
@ -1202,6 +1166,44 @@ cvm::real colvar::update()
}
// Adding wall potential to "true" colvar force, whether or not an extended coordinate is in use
if (tasks[task_lower_wall] || tasks[task_upper_wall]) {
// Wall force
colvarvalue fw(x);
fw.reset();
if (cvm::debug())
cvm::log("Calculating wall forces for colvar \""+this->name+"\".\n");
// For a periodic colvar, both walls may be applicable at the same time
// in which case we pick the closer one
if ( (!tasks[task_upper_wall]) ||
(this->dist2(x, lower_wall) < this->dist2(x, upper_wall)) ) {
cvm::real const grad = this->dist2_lgrad(x, lower_wall);
if (grad < 0.0) {
fw = -0.5 * lower_wall_k * grad;
f += fw;
if (cvm::debug())
cvm::log("Applying a lower wall force("+
cvm::to_str(fw)+") to \""+this->name+"\".\n");
}
} else {
cvm::real const grad = this->dist2_lgrad(x, upper_wall);
if (grad > 0.0) {
fw = -0.5 * upper_wall_k * grad;
f += fw;
if (cvm::debug())
cvm::log("Applying an upper wall force("+
cvm::to_str(fw)+") to \""+this->name+"\".\n");
}
}
}
if (tasks[task_fdiff_velocity]) {
// set it for the next step
x_old = x;

View File

@ -4,7 +4,7 @@
#define COLVARMODULE_H
#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2015-09-03"
#define COLVARS_VERSION "2015-09-16"
#endif
#ifndef COLVARS_DEBUG
@ -20,19 +20,17 @@
/// shared between all object instances) to be accessed from other
/// objects.
// Internal method return codes
#define COLVARS_NOT_IMPLEMENTED -2
#define COLVARS_ERROR -1
// Error codes
#define COLVARS_OK 0
// On error, values of the colvars module error register
#define GENERAL_ERROR 1
#define FILE_ERROR (1<<1)
#define MEMORY_ERROR (1<<2)
#define BUG_ERROR (1<<3) // Inconsistent state indicating bug
#define INPUT_ERROR (1<<4) // out of bounds or inconsistent input
#define DELETE_COLVARS (1<<5) // Instruct the caller to delete cvm
#define FATAL_ERROR (1<<6) // Should be set, or not, together with other bits
#define COLVARS_ERROR -1
#define GENERAL_ERROR -1 // TODO this can be simply merged with COLVARS_ERROR
#define COLVARS_NOT_IMPLEMENTED (-1<<1)
#define INPUT_ERROR (-1<<2) // out of bounds or inconsistent input
#define BUG_ERROR (-1<<3) // Inconsistent state indicating bug
#define FILE_ERROR (-1<<4)
#define MEMORY_ERROR (-1<<5)
#define FATAL_ERROR (-1<<6) // Should be set, or not, together with other bits
#define DELETE_COLVARS (-1<<7) // Instruct the caller to delete cvm
#include <iostream>

View File

@ -388,6 +388,7 @@ Input and output:\n\
list -- return a list of all variables\n\
list biases -- return a list of all biases\n\
load <file name> -- load a state file (requires configuration)\n\
save <file name> -- save a state file (requires configuration)\n\
update -- recalculate colvars and biases based\n\
printframe -- return a summary of the current frame\n\
printframelabels -- return labels to annotate printframe's output\n";
@ -406,6 +407,7 @@ Accessing collective variables:\n\
colvar <name> delete -- delete colvar <name>\n\
colvar <name> addforce <F> -- apply given force on colvar <name>\n\
colvar <name> getconfig -- return config string of colvar <name>\n\
colvar <name> cvcflags <fl> -- enable or disable cvcs according to 0/1 flags\n\
\n\
Accessing biases:\n\
bias <name> energy -- return the current energy of bias <name>\n\