update colvars library with bugfixes/updates from giacomo and jerome
This commit is contained in:
Binary file not shown.
@ -610,6 +610,7 @@ int colvar::parse_analysis(std::string const &conf)
|
||||
this->name+".runave.traj"));
|
||||
|
||||
size_t const this_cv_width = x.output_width(cvm::cv_width);
|
||||
cvm::backup_file(runave_outfile.c_str());
|
||||
runave_os.open(runave_outfile.c_str());
|
||||
runave_os << "# " << cvm::wrap_string("step", cvm::it_width-2)
|
||||
<< " "
|
||||
@ -1634,15 +1635,16 @@ int colvar::write_output_files()
|
||||
if (acf.size()) {
|
||||
cvm::log("Writing acf to file \""+acf_outfile+"\".\n");
|
||||
|
||||
cvm::backup_file(acf_outfile.c_str());
|
||||
cvm::ofstream acf_os(acf_outfile.c_str());
|
||||
if (! acf_os.good()) {
|
||||
if (! acf_os.is_open()) {
|
||||
cvm::error("Cannot open file \""+acf_outfile+"\".\n", FILE_ERROR);
|
||||
}
|
||||
write_acf(acf_os);
|
||||
acf_os.close();
|
||||
}
|
||||
|
||||
if (runave_os.good()) {
|
||||
if (runave_os.is_open()) {
|
||||
runave_os.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,10 +374,6 @@ int cvm::atom_group::parse(std::string const &conf)
|
||||
// Catch any errors from all the initialization steps above
|
||||
if (parse_error || cvm::get_error()) return (parse_error || cvm::get_error());
|
||||
|
||||
if (is_enabled(f_ag_scalable)) {
|
||||
index = (cvm::proxy)->init_atom_group(atoms_ids);
|
||||
}
|
||||
|
||||
// checks of doubly-counted atoms have been handled by add_atom() already
|
||||
|
||||
if (get_keyval(group_conf, "dummyAtom", dummy_atom_pos, cvm::atom_pos())) {
|
||||
@ -407,6 +403,10 @@ int cvm::atom_group::parse(std::string const &conf)
|
||||
}
|
||||
}
|
||||
|
||||
if (is_enabled(f_ag_scalable) && !b_dummy) {
|
||||
index = (cvm::proxy)->init_atom_group(atoms_ids);
|
||||
}
|
||||
|
||||
parse_error |= parse_fitting_options(group_conf);
|
||||
|
||||
// TODO move this to colvarparse object
|
||||
@ -749,15 +749,24 @@ void cvm::atom_group::read_positions()
|
||||
|
||||
int cvm::atom_group::calc_required_properties()
|
||||
{
|
||||
if (b_dummy) return COLVARS_OK;
|
||||
|
||||
// TODO check if the com is needed?
|
||||
calc_center_of_mass();
|
||||
calc_center_of_geometry();
|
||||
|
||||
if (!is_enabled(f_ag_scalable)) {
|
||||
// TODO check if calc_center_of_geometry() is needed without a fit?
|
||||
calc_center_of_geometry();
|
||||
if (b_center || b_rotate) {
|
||||
if (ref_pos_group) {
|
||||
ref_pos_group->calc_center_of_geometry();
|
||||
}
|
||||
|
||||
calc_apply_roto_translation();
|
||||
|
||||
// update COM and COG after fitting
|
||||
calc_center_of_geometry();
|
||||
calc_center_of_mass();
|
||||
if (ref_pos_group) {
|
||||
ref_pos_group->calc_center_of_geometry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,37 +775,49 @@ int cvm::atom_group::calc_required_properties()
|
||||
return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::calc_apply_roto_translation()
|
||||
{
|
||||
atom_group *fit_group = ref_pos_group ? ref_pos_group : this;
|
||||
|
||||
if (b_center) {
|
||||
// center on the origin first
|
||||
cvm::atom_pos const cog = fit_group->center_of_geometry();
|
||||
cvm::atom_pos const cog = ref_pos_group ?
|
||||
ref_pos_group->center_of_geometry() : this->center_of_geometry();
|
||||
apply_translation(-1.0 * cog);
|
||||
if (ref_pos_group) {
|
||||
ref_pos_group->apply_translation(-1.0 * cog);
|
||||
}
|
||||
}
|
||||
|
||||
if (b_rotate) {
|
||||
// rotate the group (around the center of geometry if b_center is
|
||||
// true, around the origin otherwise)
|
||||
rot.calc_optimal_rotation(fit_group->positions(), ref_pos);
|
||||
rot.calc_optimal_rotation(ref_pos_group ?
|
||||
ref_pos_group->positions() :
|
||||
this->positions(),
|
||||
ref_pos);
|
||||
|
||||
for (cvm::atom_iter ai = this->begin(); ai != this->end(); ai++) {
|
||||
cvm::atom_iter ai;
|
||||
for (ai = this->begin(); ai != this->end(); ai++) {
|
||||
ai->pos = rot.rotate(ai->pos);
|
||||
}
|
||||
if (ref_pos_group) {
|
||||
for (ai = ref_pos_group->begin(); ai != ref_pos_group->end(); ai++) {
|
||||
ai->pos = rot.rotate(ai->pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (b_center) {
|
||||
// align with the center of geometry of ref_pos
|
||||
apply_translation(ref_pos_cog);
|
||||
// update the center of geometry for external use
|
||||
cog = ref_pos_cog;
|
||||
if (ref_pos_group) {
|
||||
ref_pos_group->apply_translation(ref_pos_cog);
|
||||
}
|
||||
}
|
||||
|
||||
// recalculate the center of mass
|
||||
calc_center_of_mass();
|
||||
// update of COM and COG is done from the calling routine
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::apply_translation(cvm::rvector const &t)
|
||||
{
|
||||
if (b_dummy) {
|
||||
@ -814,23 +835,6 @@ void cvm::atom_group::apply_translation(cvm::rvector const &t)
|
||||
}
|
||||
}
|
||||
|
||||
void cvm::atom_group::apply_rotation(cvm::rotation const &rot)
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error("Error: cannot rotate the coordinates of a dummy atom group.\n", INPUT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_enabled(f_ag_scalable)) {
|
||||
cvm::error("Error: cannot rotate the coordinates of a scalable atom group.\n", INPUT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
for (cvm::atom_iter ai = this->begin(); ai != this->end(); ai++) {
|
||||
ai->pos = rot.rotate(ai->pos - center_of_geometry()) + center_of_geometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::read_velocities()
|
||||
{
|
||||
@ -892,6 +896,9 @@ int cvm::atom_group::calc_center_of_mass()
|
||||
{
|
||||
if (b_dummy) {
|
||||
com = dummy_atom_pos;
|
||||
if (cvm::debug()) {
|
||||
cvm::log("Dummy atom center of mass = "+cvm::to_str(com)+"\n");
|
||||
}
|
||||
} else if (is_enabled(f_ag_scalable)) {
|
||||
com = (cvm::proxy)->get_atom_group_com(index);
|
||||
} else {
|
||||
|
||||
@ -331,10 +331,6 @@ public:
|
||||
/// \brief Move all positions
|
||||
void apply_translation(cvm::rvector const &t);
|
||||
|
||||
/// \brief Rotate all positions around the center of geometry
|
||||
void apply_rotation(cvm::rotation const &q);
|
||||
|
||||
|
||||
/// \brief Get the current velocities; this must be called always
|
||||
/// *after* read_positions(); if b_rotate is defined, the same
|
||||
/// rotation applied to the coordinates will be used
|
||||
|
||||
@ -56,6 +56,10 @@ colvarbias_restraint::colvarbias_restraint(std::string const &conf,
|
||||
|
||||
size_t i;
|
||||
if (get_keyval(conf, "targetCenters", target_centers, colvar_centers)) {
|
||||
if (colvar_centers.size() != colvars.size()) {
|
||||
cvm::error("Error: number of target centers does not match "
|
||||
"that of collective variables.\n");
|
||||
}
|
||||
b_chg_centers = true;
|
||||
for (i = 0; i < target_centers.size(); i++) {
|
||||
target_centers[i].apply_constraints();
|
||||
|
||||
@ -1107,7 +1107,7 @@ int colvarmodule::open_traj_file(std::string const &file_name)
|
||||
|
||||
int colvarmodule::close_traj_file()
|
||||
{
|
||||
if (cv_traj_os.good()) {
|
||||
if (cv_traj_os.is_open()) {
|
||||
cv_traj_os.close();
|
||||
}
|
||||
return (cvm::get_error() ? COLVARS_ERROR : COLVARS_OK);
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#define COLVARMODULE_H
|
||||
|
||||
#ifndef COLVARS_VERSION
|
||||
#define COLVARS_VERSION "2016-04-08"
|
||||
#define COLVARS_VERSION "2016-04-14"
|
||||
#endif
|
||||
|
||||
#ifndef COLVARS_DEBUG
|
||||
|
||||
Reference in New Issue
Block a user