Update Colvars library to version 2019-04-26
The following is list of relevant issues fixed and improvements: Fix forces and missing output of runtime histogram for histogramRestraint https://github.com/Colvars/colvars/pull/246 Use fix_modify to add configuration to Colvars: https://github.com/Colvars/colvars/pull/216 Fix componentCoeff and name not working with orientationAngle components: https://github.com/Colvars/colvars/issues/213 Fix 1-timestep offset with extendedLagrangian: https://github.com/Colvars/colvars/pull/210 Changes to improve compiler support: https://github.com/Colvars/colvars/pull/203 Fix ignored anisotropic cutoff3 for groupCoordNum: https://github.com/Colvars/colvars/pull/202 New dipoleMagnitude variable: https://github.com/Colvars/colvars/pull/198 Parser improvements: https://github.com/Colvars/colvars/pull/196
This commit is contained in:
@ -28,6 +28,8 @@
|
||||
colvarmodule::colvarmodule(colvarproxy *proxy_in)
|
||||
{
|
||||
depth_s = 0;
|
||||
log_level_ = 10;
|
||||
|
||||
cv_traj_os = NULL;
|
||||
|
||||
if (proxy == NULL) {
|
||||
@ -152,12 +154,12 @@ int colvarmodule::read_config_string(std::string const &config_str)
|
||||
{
|
||||
cvm::log(cvm::line_marker);
|
||||
cvm::log("Reading new configuration:\n");
|
||||
std::istringstream config_s(config_str);
|
||||
std::istringstream new_config_s(config_str);
|
||||
|
||||
// strip the comments away
|
||||
std::string conf = "";
|
||||
std::string line;
|
||||
while (parse->read_config_line(config_s, line)) {
|
||||
while (parse->read_config_line(new_config_s, line)) {
|
||||
// Delete lines that contain only white space after removing comments
|
||||
if (line.find_first_not_of(colvarparse::white_space) != std::string::npos)
|
||||
conf.append(line+"\n");
|
||||
@ -255,13 +257,16 @@ int colvarmodule::append_new_config(std::string const &new_conf)
|
||||
|
||||
int colvarmodule::parse_global_params(std::string const &conf)
|
||||
{
|
||||
colvarmodule *cvm = cvm::main();
|
||||
// TODO document and then echo this keyword
|
||||
parse->get_keyval(conf, "logLevel", log_level_, log_level_,
|
||||
colvarparse::parse_silent);
|
||||
|
||||
{
|
||||
std::string index_file_name;
|
||||
size_t pos = 0;
|
||||
while (parse->key_lookup(conf, "indexFile", &index_file_name, &pos)) {
|
||||
cvm->read_index_file(index_file_name.c_str());
|
||||
cvm::log("# indexFile = \""+index_file_name+"\"\n");
|
||||
read_index_file(index_file_name.c_str());
|
||||
index_file_name.clear();
|
||||
}
|
||||
}
|
||||
@ -580,6 +585,24 @@ cvm::atom_group *colvarmodule::atom_group_by_name(std::string const &name)
|
||||
}
|
||||
|
||||
|
||||
void colvarmodule::register_named_atom_group(atom_group *ag) {
|
||||
named_atom_groups.push_back(ag);
|
||||
}
|
||||
|
||||
|
||||
void colvarmodule::unregister_named_atom_group(cvm::atom_group *ag)
|
||||
{
|
||||
for (std::vector<cvm::atom_group *>::iterator agi = named_atom_groups.begin();
|
||||
agi != named_atom_groups.end();
|
||||
agi++) {
|
||||
if (*agi == ag) {
|
||||
named_atom_groups.erase(agi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int colvarmodule::change_configuration(std::string const &bias_name,
|
||||
std::string const &conf)
|
||||
{
|
||||
@ -1034,9 +1057,6 @@ int colvarmodule::analyze()
|
||||
cvm::log("colvarmodule::analyze(), step = "+cvm::to_str(it)+".\n");
|
||||
}
|
||||
|
||||
if (cvm::step_relative() == 0)
|
||||
cvm::log("Performing analysis.\n");
|
||||
|
||||
// perform colvar-specific analysis
|
||||
for (std::vector<colvar *>::iterator cvi = variables_active()->begin();
|
||||
cvi != variables_active()->end();
|
||||
@ -1089,7 +1109,6 @@ int colvarmodule::end_of_step()
|
||||
int colvarmodule::setup()
|
||||
{
|
||||
if (this->size() == 0) return cvm::get_error();
|
||||
// loop over all components of all colvars to reset masses of all groups
|
||||
for (std::vector<colvar *>::iterator cvi = variables()->begin();
|
||||
cvi != variables()->end(); cvi++) {
|
||||
(*cvi)->setup();
|
||||
@ -1248,13 +1267,13 @@ std::istream & colvarmodule::read_restart(std::istream &is)
|
||||
std::string restart_conf;
|
||||
if (is >> colvarparse::read_block("configuration", restart_conf)) {
|
||||
parse->get_keyval(restart_conf, "step",
|
||||
it_restart, (size_t) 0,
|
||||
colvarparse::parse_silent);
|
||||
it_restart, static_cast<step_number>(0),
|
||||
colvarparse::parse_restart);
|
||||
it = it_restart;
|
||||
std::string restart_version;
|
||||
parse->get_keyval(restart_conf, "version",
|
||||
restart_version, std::string(""),
|
||||
colvarparse::parse_silent);
|
||||
colvarparse::parse_restart);
|
||||
if (restart_version.size() && (restart_version != std::string(COLVARS_VERSION))) {
|
||||
cvm::log("This state file was generated with version "+restart_version+"\n");
|
||||
}
|
||||
@ -1600,14 +1619,16 @@ std::ostream & colvarmodule::write_traj(std::ostream &os)
|
||||
}
|
||||
|
||||
|
||||
void cvm::log(std::string const &message)
|
||||
void cvm::log(std::string const &message, int min_log_level)
|
||||
{
|
||||
if (cvm::log_level() < min_log_level) return;
|
||||
// allow logging when the module is not fully initialized
|
||||
size_t const d = (cvm::main() != NULL) ? depth() : 0;
|
||||
if (d > 0)
|
||||
if (d > 0) {
|
||||
proxy->log((std::string(2*d, ' '))+message);
|
||||
else
|
||||
} else {
|
||||
proxy->log(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1915,14 +1936,190 @@ int cvm::replica_comm_send(char* msg_data, int msg_len, int dest_rep)
|
||||
|
||||
|
||||
|
||||
template<typename T> std::string _to_str(T const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
std::ostringstream os;
|
||||
if (width) os.width(width);
|
||||
if (prec) {
|
||||
os.setf(std::ios::scientific, std::ios::floatfield);
|
||||
os.precision(prec);
|
||||
}
|
||||
os << x;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
template<typename T> std::string _to_str_vector(std::vector<T> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
if (!x.size()) return std::string("");
|
||||
std::ostringstream os;
|
||||
if (prec) {
|
||||
os.setf(std::ios::scientific, std::ios::floatfield);
|
||||
}
|
||||
os << "{ ";
|
||||
if (width) os.width(width);
|
||||
if (prec) os.precision(prec);
|
||||
os << x[0];
|
||||
for (size_t i = 1; i < x.size(); i++) {
|
||||
os << ", ";
|
||||
if (width) os.width(width);
|
||||
if (prec) os.precision(prec);
|
||||
os << x[i];
|
||||
}
|
||||
os << " }";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string colvarmodule::to_str(std::string const &x)
|
||||
{
|
||||
return std::string("\"")+x+std::string("\"");
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(char const *x)
|
||||
{
|
||||
return std::string("\"")+std::string(x)+std::string("\"");
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(bool x)
|
||||
{
|
||||
return (x ? "on" : "off");
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(int const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<int>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(size_t const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<size_t>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(long int const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<long int>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(step_number const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<step_number>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(cvm::real const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<cvm::real>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(cvm::rvector const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<cvm::rvector>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(cvm::quaternion const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<cvm::quaternion>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(colvarvalue const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str<colvarvalue>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(cvm::vector1d<cvm::real> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str< cvm::vector1d<cvm::real> >(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(cvm::matrix2d<cvm::real> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str< cvm::matrix2d<cvm::real> >(x, width, prec);
|
||||
}
|
||||
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<int> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<int>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<size_t> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<size_t>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<long int> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<long int>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<cvm::real> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<cvm::real>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<cvm::rvector> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<cvm::rvector>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<cvm::quaternion> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<cvm::quaternion>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<colvarvalue> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<colvarvalue>(x, width, prec);
|
||||
}
|
||||
|
||||
std::string colvarmodule::to_str(std::vector<std::string> const &x,
|
||||
size_t width, size_t prec)
|
||||
{
|
||||
return _to_str_vector<std::string>(x, width, prec);
|
||||
}
|
||||
|
||||
|
||||
std::string cvm::wrap_string(std::string const &s, size_t nchars)
|
||||
{
|
||||
if (!s.size()) {
|
||||
return std::string(nchars, ' ');
|
||||
} else {
|
||||
return ( (s.size() <= nchars) ?
|
||||
(s+std::string(nchars-s.size(), ' ')) :
|
||||
(std::string(s, 0, nchars)) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// shared pointer to the proxy object
|
||||
colvarproxy *colvarmodule::proxy = NULL;
|
||||
|
||||
// static runtime data
|
||||
cvm::real colvarmodule::debug_gradients_step_size = 1.0e-07;
|
||||
int colvarmodule::errorCode = 0;
|
||||
long colvarmodule::it = 0;
|
||||
long colvarmodule::it_restart = 0;
|
||||
int colvarmodule::log_level_ = 10;
|
||||
cvm::step_number colvarmodule::it = 0;
|
||||
cvm::step_number colvarmodule::it_restart = 0;
|
||||
size_t colvarmodule::restart_out_freq = 0;
|
||||
size_t colvarmodule::cv_traj_freq = 0;
|
||||
bool colvarmodule::use_scripted_forces = false;
|
||||
|
||||
Reference in New Issue
Block a user