git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12811 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -13,28 +13,28 @@
|
||||
|
||||
// Note: "conf" is the configuration of the cvc who is using this atom group;
|
||||
// "key" is the name of the atom group (e.g. "atoms", "group1", "group2", ...)
|
||||
cvm::atom_group::atom_group (std::string const &conf,
|
||||
cvm::atom_group::atom_group(std::string const &conf,
|
||||
char const *key)
|
||||
: b_center (false), b_rotate (false), b_user_defined_fit (false),
|
||||
b_fit_gradients (false),
|
||||
ref_pos_group (NULL),
|
||||
noforce (false)
|
||||
: b_center(false), b_rotate(false), b_user_defined_fit(false),
|
||||
b_fit_gradients(false),
|
||||
ref_pos_group(NULL),
|
||||
noforce(false)
|
||||
{
|
||||
cvm::log ("Defining atom group \""+
|
||||
std::string (key)+"\".\n");
|
||||
cvm::log("Defining atom group \""+
|
||||
std::string(key)+"\".\n");
|
||||
// real work is done by parse
|
||||
parse (conf, key);
|
||||
parse(conf, key);
|
||||
}
|
||||
|
||||
|
||||
cvm::atom_group::atom_group (std::vector<cvm::atom> const &atoms)
|
||||
: b_dummy (false), b_center (false), b_rotate (false),
|
||||
b_fit_gradients (false), ref_pos_group (NULL),
|
||||
noforce (false)
|
||||
cvm::atom_group::atom_group(std::vector<cvm::atom> const &atoms)
|
||||
: b_dummy(false), b_center(false), b_rotate(false),
|
||||
b_fit_gradients(false), ref_pos_group(NULL),
|
||||
noforce(false)
|
||||
{
|
||||
this->reserve (atoms.size());
|
||||
this->reserve(atoms.size());
|
||||
for (size_t i = 0; i < atoms.size(); i++) {
|
||||
this->push_back (atoms[i]);
|
||||
this->push_back(atoms[i]);
|
||||
}
|
||||
total_mass = 0.0;
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
@ -45,9 +45,9 @@ cvm::atom_group::atom_group (std::vector<cvm::atom> const &atoms)
|
||||
|
||||
|
||||
cvm::atom_group::atom_group()
|
||||
: b_dummy (false), b_center (false), b_rotate (false),
|
||||
b_user_defined_fit (false), b_fit_gradients (false),
|
||||
ref_pos_group (NULL), noforce (false)
|
||||
: b_dummy(false), b_center(false), b_rotate(false),
|
||||
b_user_defined_fit(false), b_fit_gradients(false),
|
||||
ref_pos_group(NULL), noforce(false)
|
||||
{
|
||||
total_mass = 0.0;
|
||||
}
|
||||
@ -62,12 +62,12 @@ cvm::atom_group::~atom_group()
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::add_atom (cvm::atom const &a)
|
||||
void cvm::atom_group::add_atom(cvm::atom const &a)
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: cannot add atoms to a dummy group.\n", INPUT_ERROR);
|
||||
cvm::error("Error: cannot add atoms to a dummy group.\n", INPUT_ERROR);
|
||||
} else {
|
||||
this->push_back (a);
|
||||
this->push_back(a);
|
||||
total_mass += a.mass;
|
||||
}
|
||||
}
|
||||
@ -80,12 +80,12 @@ void cvm::atom_group::reset_mass(std::string &name, int i, int j)
|
||||
ai != this->end(); ai++) {
|
||||
total_mass += ai->mass;
|
||||
}
|
||||
cvm::log ("Re-initialized atom group "+name+":"+cvm::to_str (i)+"/"+
|
||||
cvm::to_str (j)+". "+ cvm::to_str (this->size())+
|
||||
" atoms: total mass = "+cvm::to_str (this->total_mass)+".\n");
|
||||
cvm::log("Re-initialized atom group "+name+":"+cvm::to_str(i)+"/"+
|
||||
cvm::to_str(j)+". "+ cvm::to_str(this->size())+
|
||||
" atoms: total mass = "+cvm::to_str(this->total_mass)+".\n");
|
||||
}
|
||||
|
||||
int cvm::atom_group::parse (std::string const &conf,
|
||||
int cvm::atom_group::parse(std::string const &conf,
|
||||
char const *key)
|
||||
{
|
||||
std::string group_conf;
|
||||
@ -94,13 +94,13 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
// not the config string of this group, but of its parent object
|
||||
// (which has already taken care of the delimiters)
|
||||
save_delimiters = false;
|
||||
key_lookup (conf, key, group_conf, dummy_pos);
|
||||
key_lookup(conf, key, group_conf, dummy_pos);
|
||||
// restoring the normal value, because we do want keywords checked
|
||||
// inside "group_conf"
|
||||
save_delimiters = true;
|
||||
|
||||
if (group_conf.size() == 0) {
|
||||
cvm::error ("Error: atom group \""+std::string (key)+
|
||||
cvm::error("Error: atom group \""+std::string(key)+
|
||||
"\" is set, but has no definition.\n",
|
||||
INPUT_ERROR);
|
||||
return COLVARS_ERROR;
|
||||
@ -108,7 +108,7 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
|
||||
cvm::increase_depth();
|
||||
|
||||
cvm::log ("Initializing atom group \""+std::string (key)+"\".\n");
|
||||
cvm::log("Initializing atom group \""+std::string(key)+"\".\n");
|
||||
|
||||
// whether or not to include messages in the log
|
||||
// colvarparse::Parse_Mode mode = parse_silent;
|
||||
@ -124,23 +124,23 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
std::string numbers_conf = "";
|
||||
size_t pos = 0;
|
||||
std::vector<int> atom_indexes;
|
||||
while (key_lookup (group_conf, "atomNumbers", numbers_conf, pos)) {
|
||||
while (key_lookup(group_conf, "atomNumbers", numbers_conf, pos)) {
|
||||
if (numbers_conf.size()) {
|
||||
std::istringstream is (numbers_conf);
|
||||
std::istringstream is(numbers_conf);
|
||||
int ia;
|
||||
while (is >> ia) {
|
||||
atom_indexes.push_back (ia);
|
||||
atom_indexes.push_back(ia);
|
||||
}
|
||||
}
|
||||
|
||||
if (atom_indexes.size()) {
|
||||
this->reserve (this->size()+atom_indexes.size());
|
||||
this->reserve(this->size()+atom_indexes.size());
|
||||
for (size_t i = 0; i < atom_indexes.size(); i++) {
|
||||
this->push_back (cvm::atom (atom_indexes[i]));
|
||||
this->push_back(cvm::atom(atom_indexes[i]));
|
||||
}
|
||||
if (cvm::get_error()) return COLVARS_ERROR;
|
||||
} else {
|
||||
cvm::error ("Error: no numbers provided for \""
|
||||
cvm::error("Error: no numbers provided for \""
|
||||
"atomNumbers\".\n", INPUT_ERROR);
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
@ -149,7 +149,7 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
}
|
||||
|
||||
std::string index_group_name;
|
||||
if (get_keyval (group_conf, "indexGroup", index_group_name)) {
|
||||
if (get_keyval(group_conf, "indexGroup", index_group_name)) {
|
||||
// use an index group from the index file read globally
|
||||
std::list<std::string>::iterator names_i = cvm::index_group_names.begin();
|
||||
std::list<std::vector<int> >::iterator index_groups_i = cvm::index_groups.begin();
|
||||
@ -158,14 +158,14 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
break;
|
||||
}
|
||||
if (names_i == cvm::index_group_names.end()) {
|
||||
cvm::error ("Error: could not find index group "+
|
||||
cvm::error("Error: could not find index group "+
|
||||
index_group_name+" among those provided by the index file.\n",
|
||||
INPUT_ERROR);
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
this->reserve (index_groups_i->size());
|
||||
this->reserve(index_groups_i->size());
|
||||
for (size_t i = 0; i < index_groups_i->size(); i++) {
|
||||
this->push_back (cvm::atom ((*index_groups_i)[i]));
|
||||
this->push_back(cvm::atom((*index_groups_i)[i]));
|
||||
}
|
||||
if (cvm::get_error()) return COLVARS_ERROR;
|
||||
}
|
||||
@ -174,18 +174,18 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
{
|
||||
std::string range_conf = "";
|
||||
size_t pos = 0;
|
||||
while (key_lookup (group_conf, "atomNumbersRange",
|
||||
while (key_lookup(group_conf, "atomNumbersRange",
|
||||
range_conf, pos)) {
|
||||
|
||||
if (range_conf.size()) {
|
||||
std::istringstream is (range_conf);
|
||||
std::istringstream is(range_conf);
|
||||
int initial, final;
|
||||
char dash;
|
||||
if ( (is >> initial) && (initial > 0) &&
|
||||
(is >> dash) && (dash == '-') &&
|
||||
(is >> final) && (final > 0) ) {
|
||||
for (int anum = initial; anum <= final; anum++) {
|
||||
this->push_back (cvm::atom (anum));
|
||||
this->push_back(cvm::atom(anum));
|
||||
}
|
||||
if (cvm::get_error()) return COLVARS_ERROR;
|
||||
range_conf = "";
|
||||
@ -193,18 +193,18 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
}
|
||||
}
|
||||
|
||||
cvm::error ("Error: no valid definition for \"atomNumbersRange\", \""+
|
||||
cvm::error("Error: no valid definition for \"atomNumbersRange\", \""+
|
||||
range_conf+"\".\n", INPUT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> psf_segids;
|
||||
get_keyval (group_conf, "psfSegID", psf_segids, std::vector<std::string> (), mode);
|
||||
get_keyval(group_conf, "psfSegID", psf_segids, std::vector<std::string> (), mode);
|
||||
for (std::vector<std::string>::iterator psii = psf_segids.begin();
|
||||
psii < psf_segids.end(); ++psii) {
|
||||
|
||||
if ( (psii->size() == 0) || (psii->size() > 4) ) {
|
||||
cvm::error ("Error: invalid segmend identifier provided, \""+
|
||||
cvm::error("Error: invalid segmend identifier provided, \""+
|
||||
(*psii)+"\".\n", INPUT_ERROR);
|
||||
}
|
||||
}
|
||||
@ -214,20 +214,20 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
size_t pos = 0;
|
||||
size_t range_count = 0;
|
||||
std::vector<std::string>::iterator psii = psf_segids.begin();
|
||||
while (key_lookup (group_conf, "atomNameResidueRange",
|
||||
while (key_lookup(group_conf, "atomNameResidueRange",
|
||||
range_conf, pos)) {
|
||||
range_count++;
|
||||
|
||||
if (range_count > psf_segids.size()) {
|
||||
cvm::error ("Error: more instances of \"atomNameResidueRange\" than "
|
||||
cvm::error("Error: more instances of \"atomNameResidueRange\" than "
|
||||
"values of \"psfSegID\".\n", INPUT_ERROR);
|
||||
}
|
||||
|
||||
std::string const &psf_segid = psf_segids.size() ? *psii : std::string ("");
|
||||
std::string const &psf_segid = psf_segids.size() ? *psii : std::string("");
|
||||
|
||||
if (range_conf.size()) {
|
||||
|
||||
std::istringstream is (range_conf);
|
||||
std::istringstream is(range_conf);
|
||||
std::string atom_name;
|
||||
int initial, final;
|
||||
char dash;
|
||||
@ -236,18 +236,18 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
(is >> dash) && (dash == '-') &&
|
||||
(is >> final) && (final > 0) ) {
|
||||
for (int resid = initial; resid <= final; resid++) {
|
||||
this->push_back (cvm::atom (resid, atom_name, psf_segid));
|
||||
this->push_back(cvm::atom(resid, atom_name, psf_segid));
|
||||
}
|
||||
if (cvm::get_error()) return COLVARS_ERROR;
|
||||
range_conf = "";
|
||||
} else {
|
||||
cvm::error ("Error: cannot parse definition for \""
|
||||
cvm::error("Error: cannot parse definition for \""
|
||||
"atomNameResidueRange\", \""+
|
||||
range_conf+"\".\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
cvm::error ("Error: atomNameResidueRange with empty definition.\n");
|
||||
cvm::error("Error: atomNameResidueRange with empty definition.\n");
|
||||
}
|
||||
|
||||
if (psf_segid.size())
|
||||
@ -258,21 +258,21 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
{
|
||||
// read the atoms from a file
|
||||
std::string atoms_file_name;
|
||||
if (get_keyval (group_conf, "atomsFile", atoms_file_name, std::string (""), mode)) {
|
||||
if (get_keyval(group_conf, "atomsFile", atoms_file_name, std::string(""), mode)) {
|
||||
|
||||
std::string atoms_col;
|
||||
if (!get_keyval (group_conf, "atomsCol", atoms_col, std::string (""), mode)) {
|
||||
cvm::error ("Error: parameter atomsCol is required if atomsFile is set.\n",
|
||||
if (!get_keyval(group_conf, "atomsCol", atoms_col, std::string(""), mode)) {
|
||||
cvm::error("Error: parameter atomsCol is required if atomsFile is set.\n",
|
||||
INPUT_ERROR);
|
||||
}
|
||||
|
||||
double atoms_col_value;
|
||||
bool const atoms_col_value_defined = get_keyval (group_conf, "atomsColValue", atoms_col_value, 0.0, mode);
|
||||
bool const atoms_col_value_defined = get_keyval(group_conf, "atomsColValue", atoms_col_value, 0.0, mode);
|
||||
if (atoms_col_value_defined && (!atoms_col_value)) {
|
||||
cvm::error ("Error: atomsColValue, if provided, must be non-zero.\n", INPUT_ERROR);
|
||||
cvm::error("Error: atomsColValue, if provided, must be non-zero.\n", INPUT_ERROR);
|
||||
}
|
||||
|
||||
cvm::load_atoms (atoms_file_name.c_str(), *this, atoms_col, atoms_col_value);
|
||||
cvm::load_atoms(atoms_file_name.c_str(), *this, atoms_col, atoms_col_value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,31 +286,31 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
for ( ; a2 != this->end(); ++a2) {
|
||||
if (a1->id == a2->id) {
|
||||
if (cvm::debug())
|
||||
cvm::log ("Discarding doubly counted atom with number "+
|
||||
cvm::to_str (a1->id+1)+".\n");
|
||||
a2 = this->erase (a2);
|
||||
cvm::log("Discarding doubly counted atom with number "+
|
||||
cvm::to_str(a1->id+1)+".\n");
|
||||
a2 = this->erase(a2);
|
||||
if (a2 == this->end())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (get_keyval (group_conf, "dummyAtom", dummy_atom_pos, cvm::atom_pos(), mode)) {
|
||||
if (get_keyval(group_conf, "dummyAtom", dummy_atom_pos, cvm::atom_pos(), mode)) {
|
||||
b_dummy = true;
|
||||
this->total_mass = 1.0;
|
||||
} else
|
||||
b_dummy = false;
|
||||
|
||||
if (b_dummy && (this->size())) {
|
||||
cvm::error ("Error: cannot set up group \""+
|
||||
std::string (key)+"\" as a dummy atom "
|
||||
cvm::error("Error: cannot set up group \""+
|
||||
std::string(key)+"\" as a dummy atom "
|
||||
"and provide it with atom definitions.\n", INPUT_ERROR);
|
||||
}
|
||||
|
||||
#if (! defined (COLVARS_STANDALONE))
|
||||
#if(! defined(COLVARS_STANDALONE))
|
||||
if ( (!b_dummy) && (!cvm::b_analysis) && (!(this->size())) ) {
|
||||
cvm::error ("Error: no atoms defined for atom group \""+
|
||||
std::string (key)+"\".\n");
|
||||
cvm::error("Error: no atoms defined for atom group \""+
|
||||
std::string(key)+"\".\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -325,39 +325,39 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
if (!b_dummy) {
|
||||
bool enable_forces = true;
|
||||
// disableForces is deprecated
|
||||
if (get_keyval (group_conf, "enableForces", enable_forces, true, mode)) {
|
||||
if (get_keyval(group_conf, "enableForces", enable_forces, true, mode)) {
|
||||
noforce = !enable_forces;
|
||||
} else {
|
||||
get_keyval (group_conf, "disableForces", noforce, false, mode);
|
||||
get_keyval(group_conf, "disableForces", noforce, false, mode);
|
||||
}
|
||||
}
|
||||
|
||||
// FITTING OPTIONS
|
||||
|
||||
bool b_defined_center = get_keyval (group_conf, "centerReference", b_center, false, mode);
|
||||
bool b_defined_rotate = get_keyval (group_conf, "rotateReference", b_rotate, false, mode);
|
||||
bool b_defined_center = get_keyval(group_conf, "centerReference", b_center, false, mode);
|
||||
bool b_defined_rotate = get_keyval(group_conf, "rotateReference", b_rotate, false, mode);
|
||||
// is the user setting explicit options?
|
||||
b_user_defined_fit = b_defined_center || b_defined_rotate;
|
||||
|
||||
get_keyval (group_conf, "enableFitGradients", b_fit_gradients, true, mode);
|
||||
get_keyval(group_conf, "enableFitGradients", b_fit_gradients, true, mode);
|
||||
|
||||
if (b_center || b_rotate) {
|
||||
|
||||
if (b_dummy)
|
||||
cvm::error ("Error: centerReference or rotateReference "
|
||||
cvm::error("Error: centerReference or rotateReference "
|
||||
"cannot be defined for a dummy atom.\n");
|
||||
|
||||
if (key_lookup (group_conf, "refPositionsGroup")) {
|
||||
if (key_lookup(group_conf, "refPositionsGroup")) {
|
||||
// instead of this group, define another group to compute the fit
|
||||
if (ref_pos_group) {
|
||||
cvm::error ("Error: the atom group \""+
|
||||
std::string (key)+"\" has already a reference group "
|
||||
cvm::error("Error: the atom group \""+
|
||||
std::string(key)+"\" has already a reference group "
|
||||
"for the rototranslational fit, which was communicated by the "
|
||||
"colvar component. You should not use refPositionsGroup "
|
||||
"in this case.\n");
|
||||
}
|
||||
cvm::log ("Within atom group \""+std::string (key)+"\":\n");
|
||||
ref_pos_group = new atom_group (group_conf, "refPositionsGroup");
|
||||
cvm::log("Within atom group \""+std::string(key)+"\":\n");
|
||||
ref_pos_group = new atom_group(group_conf, "refPositionsGroup");
|
||||
|
||||
// regardless of the configuration, fit gradients must be calculated by refPositionsGroup
|
||||
ref_pos_group->b_fit_gradients = this->b_fit_gradients;
|
||||
@ -366,32 +366,32 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
|
||||
atom_group *group_for_fit = ref_pos_group ? ref_pos_group : this;
|
||||
|
||||
get_keyval (group_conf, "refPositions", ref_pos, ref_pos, mode);
|
||||
get_keyval(group_conf, "refPositions", ref_pos, ref_pos, mode);
|
||||
|
||||
std::string ref_pos_file;
|
||||
if (get_keyval (group_conf, "refPositionsFile", ref_pos_file, std::string (""), mode)) {
|
||||
if (get_keyval(group_conf, "refPositionsFile", ref_pos_file, std::string(""), mode)) {
|
||||
|
||||
if (ref_pos.size()) {
|
||||
cvm::error ("Error: cannot specify \"refPositionsFile\" and "
|
||||
cvm::error("Error: cannot specify \"refPositionsFile\" and "
|
||||
"\"refPositions\" at the same time.\n");
|
||||
}
|
||||
|
||||
std::string ref_pos_col;
|
||||
double ref_pos_col_value;
|
||||
|
||||
if (get_keyval (group_conf, "refPositionsCol", ref_pos_col, std::string (""), mode)) {
|
||||
if (get_keyval(group_conf, "refPositionsCol", ref_pos_col, std::string(""), mode)) {
|
||||
// if provided, use PDB column to select coordinates
|
||||
bool found = get_keyval (group_conf, "refPositionsColValue", ref_pos_col_value, 0.0, mode);
|
||||
bool found = get_keyval(group_conf, "refPositionsColValue", ref_pos_col_value, 0.0, mode);
|
||||
if (found && !ref_pos_col_value)
|
||||
cvm::error ("Error: refPositionsColValue, "
|
||||
cvm::error("Error: refPositionsColValue, "
|
||||
"if provided, must be non-zero.\n");
|
||||
} else {
|
||||
// if not, rely on existing atom indices for the group
|
||||
group_for_fit->create_sorted_ids();
|
||||
ref_pos.resize (group_for_fit->size());
|
||||
ref_pos.resize(group_for_fit->size());
|
||||
}
|
||||
|
||||
cvm::load_coords (ref_pos_file.c_str(), ref_pos, group_for_fit->sorted_ids,
|
||||
cvm::load_coords(ref_pos_file.c_str(), ref_pos, group_for_fit->sorted_ids,
|
||||
ref_pos_col, ref_pos_col_value);
|
||||
}
|
||||
|
||||
@ -399,11 +399,11 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
|
||||
if (b_rotate) {
|
||||
if (ref_pos.size() != group_for_fit->size())
|
||||
cvm::error ("Error: the number of reference positions provided ("+
|
||||
cvm::to_str (ref_pos.size())+
|
||||
cvm::error("Error: the number of reference positions provided("+
|
||||
cvm::to_str(ref_pos.size())+
|
||||
") does not match the number of atoms within \""+
|
||||
std::string (key)+
|
||||
"\" ("+cvm::to_str (group_for_fit->size())+
|
||||
std::string(key)+
|
||||
"\" ("+cvm::to_str(group_for_fit->size())+
|
||||
"): to perform a rotational fit, "+
|
||||
"these numbers should be equal.\n", INPUT_ERROR);
|
||||
}
|
||||
@ -412,42 +412,42 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
center_ref_pos();
|
||||
|
||||
} else {
|
||||
#if (! defined (COLVARS_STANDALONE))
|
||||
cvm::error ("Error: no reference positions provided.\n");
|
||||
#if(! defined(COLVARS_STANDALONE))
|
||||
cvm::error("Error: no reference positions provided.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (b_fit_gradients) {
|
||||
group_for_fit->fit_gradients.assign (group_for_fit->size(), cvm::atom_pos (0.0, 0.0, 0.0));
|
||||
rot.request_group1_gradients (group_for_fit->size());
|
||||
group_for_fit->fit_gradients.assign(group_for_fit->size(), cvm::atom_pos(0.0, 0.0, 0.0));
|
||||
rot.request_group1_gradients(group_for_fit->size());
|
||||
}
|
||||
|
||||
if (b_rotate && !noforce) {
|
||||
cvm::log ("Warning: atom group \""+std::string (key)+
|
||||
cvm::log("Warning: atom group \""+std::string(key)+
|
||||
"\" will be aligned to a fixed orientation given by the reference positions provided. "
|
||||
"If the internal structure of the group changes too much (i.e. its RMSD is comparable "
|
||||
"to its radius of gyration), the optimal rotation and its gradients may become discontinuous. "
|
||||
"If that happens, use refPositionsGroup (or a different definition for it if already defined) "
|
||||
"to align the coordinates.\n");
|
||||
// initialize rot member data
|
||||
rot.request_group1_gradients (this->size());
|
||||
rot.request_group1_gradients(this->size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cvm::debug())
|
||||
cvm::log ("Done initializing atom group with name \""+
|
||||
std::string (key)+"\".\n");
|
||||
cvm::log("Done initializing atom group with name \""+
|
||||
std::string(key)+"\".\n");
|
||||
|
||||
this->check_keywords (group_conf, key);
|
||||
this->check_keywords(group_conf, key);
|
||||
if (cvm::get_error()) {
|
||||
cvm::error("Error setting up atom group \""+std::string (key)+"\".");
|
||||
cvm::error("Error setting up atom group \""+std::string(key)+"\".");
|
||||
return COLVARS_ERROR;
|
||||
}
|
||||
|
||||
cvm::log ("Atom group \""+std::string (key)+"\" defined, "+
|
||||
cvm::to_str (this->size())+" atoms initialized: total mass = "+
|
||||
cvm::to_str (this->total_mass)+".\n");
|
||||
cvm::log("Atom group \""+std::string(key)+"\" defined, "+
|
||||
cvm::to_str(this->size())+" atoms initialized: total mass = "+
|
||||
cvm::to_str(this->total_mass)+".\n");
|
||||
|
||||
cvm::decrease_depth();
|
||||
|
||||
@ -455,7 +455,7 @@ int cvm::atom_group::parse (std::string const &conf,
|
||||
}
|
||||
|
||||
|
||||
int cvm::atom_group::create_sorted_ids (void)
|
||||
int cvm::atom_group::create_sorted_ids(void)
|
||||
{
|
||||
// Only do the work if the vector is not yet populated
|
||||
if (sorted_ids.size())
|
||||
@ -464,12 +464,12 @@ int cvm::atom_group::create_sorted_ids (void)
|
||||
std::list<int> temp_id_list;
|
||||
cvm::atom_iter ai;
|
||||
for (ai = this->begin(); ai != this->end(); ai++) {
|
||||
temp_id_list.push_back (ai->id);
|
||||
temp_id_list.push_back(ai->id);
|
||||
}
|
||||
temp_id_list.sort();
|
||||
temp_id_list.unique();
|
||||
if (temp_id_list.size() != this->size()) {
|
||||
cvm::error ("Error: duplicate atom IDs in atom group? (found " +
|
||||
cvm::error("Error: duplicate atom IDs in atom group? (found " +
|
||||
cvm::to_str(temp_id_list.size()) +
|
||||
" unique atom IDs instead of" +
|
||||
cvm::to_str(this->size()) + ").\n");
|
||||
@ -492,7 +492,7 @@ void cvm::atom_group::center_ref_pos()
|
||||
// the rotational fit
|
||||
// This is called either by atom_group::parse or by CVCs that set
|
||||
// reference positions (eg. RMSD, eigenvector)
|
||||
ref_pos_cog = cvm::atom_pos (0.0, 0.0, 0.0);
|
||||
ref_pos_cog = cvm::atom_pos(0.0, 0.0, 0.0);
|
||||
std::vector<cvm::atom_pos>::iterator pi;
|
||||
for (pi = ref_pos.begin(); pi != ref_pos.end(); ++pi) {
|
||||
ref_pos_cog += *pi;
|
||||
@ -532,11 +532,11 @@ void cvm::atom_group::calc_apply_roto_translation()
|
||||
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(fit_group->positions(), ref_pos);
|
||||
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->pos = rot.rotate (ai->pos);
|
||||
ai->pos = rot.rotate(ai->pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ void cvm::atom_group::calc_apply_roto_translation()
|
||||
}
|
||||
}
|
||||
|
||||
void cvm::atom_group::apply_translation (cvm::rvector const &t)
|
||||
void cvm::atom_group::apply_translation(cvm::rvector const &t)
|
||||
{
|
||||
if (b_dummy) return;
|
||||
|
||||
@ -559,13 +559,13 @@ void cvm::atom_group::apply_translation (cvm::rvector const &t)
|
||||
}
|
||||
}
|
||||
|
||||
void cvm::atom_group::apply_rotation (cvm::rotation const &rot)
|
||||
void cvm::atom_group::apply_rotation(cvm::rotation const &rot)
|
||||
{
|
||||
if (b_dummy) return;
|
||||
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->pos = rot.rotate (ai->pos);
|
||||
ai->pos = rot.rotate(ai->pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ void cvm::atom_group::read_velocities()
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->read_velocity();
|
||||
ai->vel = rot.rotate (ai->vel);
|
||||
ai->vel = rot.rotate(ai->vel);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -600,7 +600,7 @@ void cvm::atom_group::read_system_forces()
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->read_system_force();
|
||||
ai->system_force = rot.rotate (ai->system_force);
|
||||
ai->system_force = rot.rotate(ai->system_force);
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -617,7 +617,7 @@ cvm::atom_pos cvm::atom_group::center_of_geometry() const
|
||||
if (b_dummy)
|
||||
return dummy_atom_pos;
|
||||
|
||||
cvm::atom_pos cog (0.0, 0.0, 0.0);
|
||||
cvm::atom_pos cog(0.0, 0.0, 0.0);
|
||||
for (cvm::atom_const_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
cog += ai->pos;
|
||||
@ -631,7 +631,7 @@ cvm::atom_pos cvm::atom_group::center_of_mass() const
|
||||
if (b_dummy)
|
||||
return dummy_atom_pos;
|
||||
|
||||
cvm::atom_pos com (0.0, 0.0, 0.0);
|
||||
cvm::atom_pos com(0.0, 0.0, 0.0);
|
||||
for (cvm::atom_const_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
com += ai->mass * ai->pos;
|
||||
@ -641,7 +641,7 @@ cvm::atom_pos cvm::atom_group::center_of_mass() const
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::set_weighted_gradient (cvm::rvector const &grad)
|
||||
void cvm::atom_group::set_weighted_gradient(cvm::rvector const &grad)
|
||||
{
|
||||
if (b_dummy) return;
|
||||
|
||||
@ -659,21 +659,21 @@ void cvm::atom_group::calc_fit_gradients()
|
||||
if ((!b_center) && (!b_rotate)) return; // no fit
|
||||
|
||||
if (cvm::debug())
|
||||
cvm::log ("Calculating fit gradients.\n");
|
||||
cvm::log("Calculating fit gradients.\n");
|
||||
|
||||
atom_group *group_for_fit = ref_pos_group ? ref_pos_group : this;
|
||||
group_for_fit->fit_gradients.assign (group_for_fit->size(), cvm::rvector (0.0, 0.0, 0.0));
|
||||
group_for_fit->fit_gradients.assign(group_for_fit->size(), cvm::rvector(0.0, 0.0, 0.0));
|
||||
|
||||
if (b_center) {
|
||||
// add the center of geometry contribution to the gradients
|
||||
for (size_t i = 0; i < this->size(); i++) {
|
||||
// need to bring the gradients in original frame first
|
||||
cvm::rvector const atom_grad = b_rotate ?
|
||||
(rot.inverse()).rotate ((*this)[i].grad) :
|
||||
(rot.inverse()).rotate((*this)[i].grad) :
|
||||
(*this)[i].grad;
|
||||
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
||||
group_for_fit->fit_gradients[j] +=
|
||||
(-1.0)/(cvm::real (group_for_fit->size())) *
|
||||
(-1.0)/(cvm::real(group_for_fit->size())) *
|
||||
atom_grad;
|
||||
}
|
||||
}
|
||||
@ -687,12 +687,12 @@ void cvm::atom_group::calc_fit_gradients()
|
||||
|
||||
for (size_t i = 0; i < this->size(); i++) {
|
||||
|
||||
cvm::atom_pos const pos_orig = rot_inv.rotate ((b_center ? ((*this)[i].pos - cog) : ((*this)[i].pos)));
|
||||
cvm::atom_pos const pos_orig = rot_inv.rotate((b_center ? ((*this)[i].pos - cog) : ((*this)[i].pos)));
|
||||
|
||||
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
||||
// calculate \partial(R(q) \vec{x}_i)/\partial q) \cdot \partial\xi/\partial\vec{x}_i
|
||||
cvm::quaternion const dxdq =
|
||||
rot.q.position_derivative_inner (pos_orig, (*this)[i].grad);
|
||||
rot.q.position_derivative_inner(pos_orig, (*this)[i].grad);
|
||||
// multiply by \cdot {\partial q}/\partial\vec{x}_j and add it to the fit gradients
|
||||
for (size_t iq = 0; iq < 4; iq++) {
|
||||
group_for_fit->fit_gradients[j] += dxdq[iq] * rot.dQ0_1[j][iq];
|
||||
@ -701,18 +701,18 @@ void cvm::atom_group::calc_fit_gradients()
|
||||
}
|
||||
}
|
||||
if (cvm::debug())
|
||||
cvm::log ("Done calculating fit gradients.\n");
|
||||
cvm::log("Done calculating fit gradients.\n");
|
||||
}
|
||||
|
||||
|
||||
std::vector<cvm::atom_pos> cvm::atom_group::positions() const
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: positions are not available "
|
||||
cvm::error("Error: positions are not available "
|
||||
"from a dummy atom group.\n");
|
||||
}
|
||||
|
||||
std::vector<cvm::atom_pos> x (this->size(), 0.0);
|
||||
std::vector<cvm::atom_pos> x(this->size(), 0.0);
|
||||
cvm::atom_const_iter ai = this->begin();
|
||||
std::vector<cvm::atom_pos>::iterator xi = x.begin();
|
||||
for ( ; ai != this->end(); ++xi, ++ai) {
|
||||
@ -721,14 +721,14 @@ std::vector<cvm::atom_pos> cvm::atom_group::positions() const
|
||||
return x;
|
||||
}
|
||||
|
||||
std::vector<cvm::atom_pos> cvm::atom_group::positions_shifted (cvm::rvector const &shift) const
|
||||
std::vector<cvm::atom_pos> cvm::atom_group::positions_shifted(cvm::rvector const &shift) const
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: positions are not available "
|
||||
cvm::error("Error: positions are not available "
|
||||
"from a dummy atom group.\n");
|
||||
}
|
||||
|
||||
std::vector<cvm::atom_pos> x (this->size(), 0.0);
|
||||
std::vector<cvm::atom_pos> x(this->size(), 0.0);
|
||||
cvm::atom_const_iter ai = this->begin();
|
||||
std::vector<cvm::atom_pos>::iterator xi = x.begin();
|
||||
for ( ; ai != this->end(); ++xi, ++ai) {
|
||||
@ -740,11 +740,11 @@ std::vector<cvm::atom_pos> cvm::atom_group::positions_shifted (cvm::rvector cons
|
||||
std::vector<cvm::rvector> cvm::atom_group::velocities() const
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: velocities are not available "
|
||||
cvm::error("Error: velocities are not available "
|
||||
"from a dummy atom group.\n");
|
||||
}
|
||||
|
||||
std::vector<cvm::rvector> v (this->size(), 0.0);
|
||||
std::vector<cvm::rvector> v(this->size(), 0.0);
|
||||
cvm::atom_const_iter ai = this->begin();
|
||||
std::vector<cvm::atom_pos>::iterator vi = v.begin();
|
||||
for ( ; ai != this->end(); vi++, ai++) {
|
||||
@ -756,11 +756,11 @@ std::vector<cvm::rvector> cvm::atom_group::velocities() const
|
||||
std::vector<cvm::rvector> cvm::atom_group::system_forces() const
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: system forces are not available "
|
||||
cvm::error("Error: system forces are not available "
|
||||
"from a dummy atom group.\n");
|
||||
}
|
||||
|
||||
std::vector<cvm::rvector> f (this->size(), 0.0);
|
||||
std::vector<cvm::rvector> f(this->size(), 0.0);
|
||||
cvm::atom_const_iter ai = this->begin();
|
||||
std::vector<cvm::atom_pos>::iterator fi = f.begin();
|
||||
for ( ; ai != this->end(); ++fi, ++ai) {
|
||||
@ -772,11 +772,11 @@ std::vector<cvm::rvector> cvm::atom_group::system_forces() const
|
||||
cvm::rvector cvm::atom_group::system_force() const
|
||||
{
|
||||
if (b_dummy) {
|
||||
cvm::error ("Error: system forces are not available "
|
||||
cvm::error("Error: system forces are not available "
|
||||
"from a dummy atom group.\n");
|
||||
}
|
||||
|
||||
cvm::rvector f (0.0);
|
||||
cvm::rvector f(0.0);
|
||||
for (cvm::atom_const_iter ai = this->begin(); ai != this->end(); ai++) {
|
||||
f += ai->system_force;
|
||||
}
|
||||
@ -784,13 +784,13 @@ cvm::rvector cvm::atom_group::system_force() const
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::apply_colvar_force (cvm::real const &force)
|
||||
void cvm::atom_group::apply_colvar_force(cvm::real const &force)
|
||||
{
|
||||
if (b_dummy)
|
||||
return;
|
||||
|
||||
if (noforce) {
|
||||
cvm::error ("Error: sending a force to a group that has "
|
||||
cvm::error("Error: sending a force to a group that has "
|
||||
"\"enableForces\" set to off.\n");
|
||||
return;
|
||||
}
|
||||
@ -801,14 +801,14 @@ void cvm::atom_group::apply_colvar_force (cvm::real const &force)
|
||||
cvm::rotation const rot_inv = rot.inverse();
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->apply_force (rot_inv.rotate (force * ai->grad));
|
||||
ai->apply_force(rot_inv.rotate(force * ai->grad));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->apply_force (force * ai->grad);
|
||||
ai->apply_force(force * ai->grad);
|
||||
}
|
||||
}
|
||||
|
||||
@ -821,11 +821,11 @@ void cvm::atom_group::apply_colvar_force (cvm::real const &force)
|
||||
// rotate forces back to the original frame
|
||||
cvm::rotation const rot_inv = rot.inverse();
|
||||
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
||||
(*group_for_fit)[j].apply_force (rot_inv.rotate (force * group_for_fit->fit_gradients[j]));
|
||||
(*group_for_fit)[j].apply_force(rot_inv.rotate(force * group_for_fit->fit_gradients[j]));
|
||||
}
|
||||
} else {
|
||||
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
||||
(*group_for_fit)[j].apply_force (force * group_for_fit->fit_gradients[j]);
|
||||
(*group_for_fit)[j].apply_force(force * group_for_fit->fit_gradients[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -833,13 +833,13 @@ void cvm::atom_group::apply_colvar_force (cvm::real const &force)
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::apply_force (cvm::rvector const &force)
|
||||
void cvm::atom_group::apply_force(cvm::rvector const &force)
|
||||
{
|
||||
if (b_dummy)
|
||||
return;
|
||||
|
||||
if (noforce) {
|
||||
cvm::error ("Error: sending a force to a group that has "
|
||||
cvm::error("Error: sending a force to a group that has "
|
||||
"\"disableForces\" defined.\n");
|
||||
return;
|
||||
}
|
||||
@ -849,30 +849,30 @@ void cvm::atom_group::apply_force (cvm::rvector const &force)
|
||||
cvm::rotation const rot_inv = rot.inverse();
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->apply_force (rot_inv.rotate ((ai->mass/this->total_mass) * force));
|
||||
ai->apply_force(rot_inv.rotate((ai->mass/this->total_mass) * force));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
for (cvm::atom_iter ai = this->begin();
|
||||
ai != this->end(); ai++) {
|
||||
ai->apply_force ((ai->mass/this->total_mass) * force);
|
||||
ai->apply_force((ai->mass/this->total_mass) * force);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cvm::atom_group::apply_forces (std::vector<cvm::rvector> const &forces)
|
||||
void cvm::atom_group::apply_forces(std::vector<cvm::rvector> const &forces)
|
||||
{
|
||||
if (b_dummy)
|
||||
return;
|
||||
|
||||
if (noforce)
|
||||
cvm::error ("Error: sending a force to a group that has "
|
||||
cvm::error("Error: sending a force to a group that has "
|
||||
"\"disableForces\" defined.\n");
|
||||
|
||||
if (forces.size() != this->size()) {
|
||||
cvm::error ("Error: trying to apply an array of forces to an atom "
|
||||
cvm::error("Error: trying to apply an array of forces to an atom "
|
||||
"group which does not have the same length.\n");
|
||||
}
|
||||
|
||||
@ -882,7 +882,7 @@ void cvm::atom_group::apply_forces (std::vector<cvm::rvector> const &forces)
|
||||
cvm::atom_iter ai = this->begin();
|
||||
std::vector<cvm::rvector>::const_iterator fi = forces.begin();
|
||||
for ( ; ai != this->end(); ++fi, ++ai) {
|
||||
ai->apply_force (rot_inv.rotate (*fi));
|
||||
ai->apply_force(rot_inv.rotate(*fi));
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -890,7 +890,7 @@ void cvm::atom_group::apply_forces (std::vector<cvm::rvector> const &forces)
|
||||
cvm::atom_iter ai = this->begin();
|
||||
std::vector<cvm::rvector>::const_iterator fi = forces.begin();
|
||||
for ( ; ai != this->end(); ++fi, ++ai) {
|
||||
ai->apply_force (*fi);
|
||||
ai->apply_force(*fi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user