Update Colvars to version 2020-02-27
This update contains several small new features or usability improvements.
Descriptions and authorship information can be accessed from the pull
requests listed below.
Allow setting sigma parameter directly for metadynamics
https://github.com/Colvars/colvars/pull/325
Remove default values for lowerWall and upperWall legacy keywords
https://github.com/Colvars/colvars/pull/324
biasActualColvar option to bypass extended-Lagragian for a bias
https://github.com/Colvars/colvars/pull/321
Flexible restart-reading
https://github.com/Colvars/colvars/pull/320
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
colvarbias_restraint::colvarbias_restraint(char const *key)
|
||||
: colvarbias(key), colvarbias_ti(key)
|
||||
{
|
||||
state_keyword = "restraint";
|
||||
}
|
||||
|
||||
|
||||
@ -705,67 +706,6 @@ std::ostream & colvarbias_restraint_k_moving::write_traj(std::ostream &os)
|
||||
|
||||
|
||||
|
||||
// redefined due to legacy state file keyword "harmonic"
|
||||
std::istream & colvarbias_restraint::read_state(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
|
||||
std::string key, brace, conf;
|
||||
if ( !(is >> key) || !(key == "restraint" || key == "harmonic") ||
|
||||
!(is >> brace) || !(brace == "{") ||
|
||||
!(is >> colvarparse::read_block("configuration", conf)) ||
|
||||
(set_state_params(conf) != COLVARS_OK) ) {
|
||||
cvm::error("Error: in reading state configuration for \""+bias_type+"\" bias \""+
|
||||
this->name+"\" at position "+
|
||||
cvm::to_str(static_cast<size_t>(is.tellg()))+
|
||||
" in stream.\n", INPUT_ERROR);
|
||||
is.clear();
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is.setstate(std::ios::failbit);
|
||||
return is;
|
||||
}
|
||||
|
||||
if (!read_state_data(is)) {
|
||||
cvm::error("Error: in reading state data for \""+bias_type+"\" bias \""+
|
||||
this->name+"\" at position "+
|
||||
cvm::to_str(static_cast<size_t>(is.tellg()))+
|
||||
" in stream.\n", INPUT_ERROR);
|
||||
is.clear();
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is.setstate(std::ios::failbit);
|
||||
}
|
||||
|
||||
is >> brace;
|
||||
if (brace != "}") {
|
||||
cvm::log("brace = "+brace+"\n");
|
||||
cvm::error("Error: corrupt restart information for \""+bias_type+"\" bias \""+
|
||||
this->name+"\": no matching brace at position "+
|
||||
cvm::to_str(static_cast<size_t>(is.tellg()))+" in stream.\n");
|
||||
is.setstate(std::ios::failbit);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
std::ostream & colvarbias_restraint::write_state(std::ostream &os)
|
||||
{
|
||||
os.setf(std::ios::scientific, std::ios::floatfield);
|
||||
os << "restraint {\n"
|
||||
<< " configuration {\n";
|
||||
std::istringstream is(get_state_params());
|
||||
std::string line;
|
||||
while (std::getline(is, line)) {
|
||||
os << " " << line << "\n";
|
||||
}
|
||||
os << " }\n";
|
||||
write_state_data(os);
|
||||
os << "}\n\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
colvarbias_restraint_harmonic::colvarbias_restraint_harmonic(char const *key)
|
||||
: colvarbias(key),
|
||||
colvarbias_ti(key),
|
||||
@ -928,6 +868,9 @@ colvarbias_restraint_harmonic_walls::colvarbias_restraint_harmonic_walls(char co
|
||||
{
|
||||
lower_wall_k = -1.0;
|
||||
upper_wall_k = -1.0;
|
||||
// This bias implements the bias_actual_colvars feature (most others do not)
|
||||
provide(f_cvb_bypass_ext_lagrangian);
|
||||
set_enabled(f_cvb_bypass_ext_lagrangian); // Defaults to enabled
|
||||
}
|
||||
|
||||
|
||||
@ -1075,23 +1018,13 @@ int colvarbias_restraint_harmonic_walls::update()
|
||||
}
|
||||
|
||||
|
||||
void colvarbias_restraint_harmonic_walls::communicate_forces()
|
||||
{
|
||||
for (size_t i = 0; i < num_variables(); i++) {
|
||||
if (cvm::debug()) {
|
||||
cvm::log("Communicating a force to colvar \""+
|
||||
variables(i)->name+"\".\n");
|
||||
}
|
||||
// Impulse-style multiple timestep
|
||||
variables(i)->add_bias_force_actual_value(cvm::real(time_step_factor) * colvar_forces[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cvm::real colvarbias_restraint_harmonic_walls::colvar_distance(size_t i) const
|
||||
{
|
||||
colvar *cv = variables(i);
|
||||
colvarvalue const &cvv = variables(i)->actual_value();
|
||||
|
||||
colvarvalue const &cvv = is_enabled(f_cvb_bypass_ext_lagrangian) ?
|
||||
variables(i)->actual_value() :
|
||||
variables(i)->value();
|
||||
|
||||
// For a periodic colvar, both walls may be applicable at the same time
|
||||
// in which case we pick the closer one
|
||||
|
||||
Reference in New Issue
Block a user