colvars update 2015-08-12
This commit is contained in:
@ -846,7 +846,22 @@ void colvar::calc()
|
||||
if (cvm::debug())
|
||||
cvm::log("Collecting data from atom groups.\n");
|
||||
|
||||
// Update the enabled/disabled status of cvcs if necessary
|
||||
if (cvc_flags.size()) {
|
||||
bool any = false;
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
cvcs[i]->b_enabled = cvc_flags[i];
|
||||
any = any || cvc_flags[i];
|
||||
}
|
||||
if (!any) {
|
||||
cvm::error("ERROR: All CVCs are disabled for colvar " + this->name +"\n");
|
||||
return;
|
||||
}
|
||||
cvc_flags.resize(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
for (ig = 0; ig < cvcs[i]->atom_groups.size(); ig++) {
|
||||
cvm::atom_group &atoms = *(cvcs[i]->atom_groups[ig]);
|
||||
atoms.reset_atoms_data();
|
||||
@ -1220,12 +1235,13 @@ void colvar::communicate_forces()
|
||||
return;
|
||||
}
|
||||
|
||||
int grad_index = 0; // index in the scripted gradients, to account for some components being disabled
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
if (!cvcs[i]->b_enabled) continue;
|
||||
cvm::increase_depth();
|
||||
// cvc force is colvar force times colvar/cvc Jacobian
|
||||
// (vector-matrix product)
|
||||
(cvcs[i])->apply_force(colvarvalue(f.as_vector() * func_grads[i],
|
||||
(cvcs[i])->apply_force(colvarvalue(f.as_vector() * func_grads[grad_index++],
|
||||
cvcs[i]->value().type()));
|
||||
cvm::decrease_depth();
|
||||
}
|
||||
@ -1258,20 +1274,13 @@ void colvar::communicate_forces()
|
||||
|
||||
int colvar::set_cvc_flags(std::vector<bool> const &flags) {
|
||||
|
||||
size_t i;
|
||||
if (flags.size() != cvcs.size()) {
|
||||
cvm::error("ERROR: Wrong number of CVC flags provided.");
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
bool e = false;
|
||||
for (i = 0; i < cvcs.size(); i++) {
|
||||
cvcs[i]->b_enabled = flags[i];
|
||||
e = e || flags[i];
|
||||
}
|
||||
if (!e) {
|
||||
cvm::error("ERROR: All CVCs are disabled for this colvar.");
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
// We cannot enable or disable cvcs in the middle of a timestep or colvar evaluation sequence
|
||||
// so we store the flags that will be enforced at the next call to calc()
|
||||
cvc_flags = flags;
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -514,6 +514,9 @@ protected:
|
||||
/// \brief Array of \link cvc \endlink objects
|
||||
std::vector<cvc *> cvcs;
|
||||
|
||||
/// \brief Flags to enable or disable cvcs at next colvar evaluation
|
||||
std::vector<bool> cvc_flags;
|
||||
|
||||
/// \brief Initialize the sorted list of atom IDs for atoms involved
|
||||
/// in all cvcs (called when enabling task_collect_gradients)
|
||||
void build_atom_list(void);
|
||||
|
||||
@ -24,31 +24,6 @@ colvar_grid_count::colvar_grid_count(std::vector<colvar *> &colvars,
|
||||
: colvar_grid<size_t>(colvars, def_count, 1)
|
||||
{}
|
||||
|
||||
std::istream & colvar_grid_count::read_restart(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::string key, conf;
|
||||
if ((is >> key) && (key == std::string("grid_parameters"))) {
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is >> colvarparse::read_block("grid_parameters", conf);
|
||||
parse_params(conf);
|
||||
} else {
|
||||
cvm::log("Grid parameters are missing in the restart file, using those from the configuration.\n");
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
}
|
||||
read_raw(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
std::ostream & colvar_grid_count::write_restart(std::ostream &os)
|
||||
{
|
||||
write_params(os);
|
||||
write_raw(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
colvar_grid_scalar::colvar_grid_scalar()
|
||||
: colvar_grid<cvm::real>(), samples(NULL), grad(NULL)
|
||||
{}
|
||||
@ -79,30 +54,6 @@ colvar_grid_scalar::~colvar_grid_scalar()
|
||||
}
|
||||
}
|
||||
|
||||
std::istream & colvar_grid_scalar::read_restart(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::string key, conf;
|
||||
if ((is >> key) && (key == std::string("grid_parameters"))) {
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is >> colvarparse::read_block("grid_parameters", conf);
|
||||
parse_params(conf);
|
||||
} else {
|
||||
cvm::log("Grid parameters are missing in the restart file, using those from the configuration.\n");
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
}
|
||||
read_raw(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
std::ostream & colvar_grid_scalar::write_restart(std::ostream &os)
|
||||
{
|
||||
write_params(os);
|
||||
write_raw(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
cvm::real colvar_grid_scalar::maximum_value() const
|
||||
{
|
||||
cvm::real max = data[0];
|
||||
@ -163,29 +114,6 @@ colvar_grid_gradient::colvar_grid_gradient(std::vector<colvar *> &colvars)
|
||||
: colvar_grid<cvm::real>(colvars, 0.0, colvars.size()), samples(NULL)
|
||||
{}
|
||||
|
||||
std::istream & colvar_grid_gradient::read_restart(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::string key, conf;
|
||||
if ((is >> key) && (key == std::string("grid_parameters"))) {
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is >> colvarparse::read_block("grid_parameters", conf);
|
||||
parse_params(conf);
|
||||
} else {
|
||||
cvm::log("Grid parameters are missing in the restart file, using those from the configuration.\n");
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
}
|
||||
read_raw(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
std::ostream & colvar_grid_gradient::write_restart(std::ostream &os)
|
||||
{
|
||||
write_params(os);
|
||||
write_raw(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
void colvar_grid_gradient::write_1D_integral(std::ostream &os)
|
||||
{
|
||||
cvm::real bin, min, integral;
|
||||
|
||||
@ -836,6 +836,32 @@ public:
|
||||
}
|
||||
|
||||
|
||||
/// \brief Read grid entry in restart file
|
||||
std::istream & read_restart(std::istream &is)
|
||||
{
|
||||
size_t const start_pos = is.tellg();
|
||||
std::string key, conf;
|
||||
if ((is >> key) && (key == std::string("grid_parameters"))) {
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
is >> colvarparse::read_block("grid_parameters", conf);
|
||||
parse_params(conf);
|
||||
} else {
|
||||
cvm::log("Grid parameters are missing in the restart file, using those from the configuration.\n");
|
||||
is.seekg(start_pos, std::ios::beg);
|
||||
}
|
||||
read_raw(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
/// \brief Write grid entry in restart file
|
||||
std::ostream & write_restart(std::ostream &os)
|
||||
{
|
||||
write_params(os);
|
||||
write_raw(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/// \brief Write the grid data without labels, as they are
|
||||
/// represented in memory
|
||||
/// \param buf_size Number of values per line
|
||||
@ -1106,12 +1132,6 @@ public:
|
||||
return new_data[address(ix) + imult];
|
||||
}
|
||||
|
||||
/// \brief Read the grid from a restart
|
||||
std::istream & read_restart(std::istream &is);
|
||||
|
||||
/// \brief Write the grid to a restart
|
||||
std::ostream & write_restart(std::ostream &os);
|
||||
|
||||
/// \brief Get the value from a formatted output and transform it
|
||||
/// into the internal representation (it may have been rescaled or
|
||||
/// manipulated)
|
||||
@ -1240,12 +1260,6 @@ public:
|
||||
has_data = true;
|
||||
}
|
||||
|
||||
/// \brief Read the grid from a restart
|
||||
std::istream & read_restart(std::istream &is);
|
||||
|
||||
/// \brief Write the grid to a restart
|
||||
std::ostream & write_restart(std::ostream &os);
|
||||
|
||||
/// \brief Return the highest value
|
||||
cvm::real maximum_value() const;
|
||||
|
||||
@ -1343,12 +1357,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
/// \brief Read the grid from a restart
|
||||
std::istream & read_restart(std::istream &is);
|
||||
|
||||
/// \brief Write the grid to a restart
|
||||
std::ostream & write_restart(std::ostream &os);
|
||||
|
||||
/// Compute and return average value for a 1D gradient grid
|
||||
inline cvm::real average()
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#define COLVARMODULE_H
|
||||
|
||||
#ifndef COLVARS_VERSION
|
||||
#define COLVARS_VERSION "2015-07-21"
|
||||
#define COLVARS_VERSION "2015-08-12"
|
||||
#endif
|
||||
|
||||
#ifndef COLVARS_DEBUG
|
||||
|
||||
Reference in New Issue
Block a user