git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15200 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarvalue.h"
|
#include "colvarvalue.h"
|
||||||
@ -19,8 +19,8 @@ bool compare(colvar::cvc *i, colvar::cvc *j) {
|
|||||||
colvar::colvar(std::string const &conf)
|
colvar::colvar(std::string const &conf)
|
||||||
: colvarparse(conf)
|
: colvarparse(conf)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
cvm::log("Initializing a new collective variable.\n");
|
cvm::log("Initializing a new collective variable.\n");
|
||||||
|
int error_code = COLVARS_OK;
|
||||||
|
|
||||||
get_keyval(conf, "name", this->name,
|
get_keyval(conf, "name", this->name,
|
||||||
(std::string("colvar")+cvm::to_str(cvm::colvars.size()+1)));
|
(std::string("colvar")+cvm::to_str(cvm::colvars.size()+1)));
|
||||||
@ -43,141 +43,9 @@ colvar::colvar(std::string const &conf)
|
|||||||
kinetic_energy = 0.0;
|
kinetic_energy = 0.0;
|
||||||
potential_energy = 0.0;
|
potential_energy = 0.0;
|
||||||
|
|
||||||
// read the configuration and set up corresponding instances, for
|
cvm::combine_errors(error_code, init_components(conf));
|
||||||
// each type of component implemented
|
|
||||||
#define initialize_components(def_desc,def_config_key,def_class_name) \
|
|
||||||
{ \
|
|
||||||
size_t def_count = 0; \
|
|
||||||
std::string def_conf = ""; \
|
|
||||||
size_t pos = 0; \
|
|
||||||
while ( this->key_lookup(conf, \
|
|
||||||
def_config_key, \
|
|
||||||
def_conf, \
|
|
||||||
pos) ) { \
|
|
||||||
if (!def_conf.size()) continue; \
|
|
||||||
cvm::log("Initializing " \
|
|
||||||
"a new \""+std::string(def_config_key)+"\" component"+ \
|
|
||||||
(cvm::debug() ? ", with configuration:\n"+def_conf \
|
|
||||||
: ".\n")); \
|
|
||||||
cvm::increase_depth(); \
|
|
||||||
cvc *cvcp = new colvar::def_class_name(def_conf); \
|
|
||||||
if (cvcp != NULL) { \
|
|
||||||
cvcs.push_back(cvcp); \
|
|
||||||
cvcp->check_keywords(def_conf, def_config_key); \
|
|
||||||
if (cvm::get_error()) { \
|
|
||||||
cvm::error("Error: in setting up component \"" \
|
|
||||||
def_config_key"\".\n"); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
cvm::decrease_depth(); \
|
|
||||||
} else { \
|
|
||||||
cvm::error("Error: in allocating component \"" \
|
|
||||||
def_config_key"\".\n", \
|
|
||||||
MEMORY_ERROR); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
if ( (cvcp->period != 0.0) || (cvcp->wrap_center != 0.0) ) { \
|
|
||||||
if ( (cvcp->function_type != std::string("distance_z")) && \
|
|
||||||
(cvcp->function_type != std::string("dihedral")) && \
|
|
||||||
(cvcp->function_type != std::string("spin_angle")) ) { \
|
|
||||||
cvm::error("Error: invalid use of period and/or " \
|
|
||||||
"wrapAround in a \""+ \
|
|
||||||
std::string(def_config_key)+ \
|
|
||||||
"\" component.\n"+ \
|
|
||||||
"Period: "+cvm::to_str(cvcp->period) + \
|
|
||||||
" wrapAround: "+cvm::to_str(cvcp->wrap_center), \
|
|
||||||
INPUT_ERROR); \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
if ( ! cvcs.back()->name.size()){ \
|
|
||||||
std::ostringstream s; \
|
|
||||||
s << def_config_key << std::setfill('0') << std::setw(4) << ++def_count;\
|
|
||||||
cvcs.back()->name = s.str(); \
|
|
||||||
/* pad cvc number for correct ordering when sorting by name */\
|
|
||||||
} \
|
|
||||||
cvcs.back()->setup(); \
|
|
||||||
if (cvm::debug()) \
|
|
||||||
cvm::log("Done initializing a \""+ \
|
|
||||||
std::string(def_config_key)+ \
|
|
||||||
"\" component"+ \
|
|
||||||
(cvm::debug() ? \
|
|
||||||
", named \""+cvcs.back()->name+"\"" \
|
|
||||||
: "")+".\n"); \
|
|
||||||
def_conf = ""; \
|
|
||||||
if (cvm::debug()) \
|
|
||||||
cvm::log("Parsed "+cvm::to_str(cvcs.size())+ \
|
|
||||||
" components at this time.\n"); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
size_t i;
|
||||||
initialize_components("distance", "distance", distance);
|
|
||||||
initialize_components("distance vector", "distanceVec", distance_vec);
|
|
||||||
initialize_components("Cartesian coordinates", "cartesian", cartesian);
|
|
||||||
initialize_components("distance vector "
|
|
||||||
"direction", "distanceDir", distance_dir);
|
|
||||||
initialize_components("distance projection "
|
|
||||||
"on an axis", "distanceZ", distance_z);
|
|
||||||
initialize_components("distance projection "
|
|
||||||
"on a plane", "distanceXY", distance_xy);
|
|
||||||
initialize_components("average distance weighted by inverse power",
|
|
||||||
"distanceInv", distance_inv);
|
|
||||||
initialize_components("N1xN2-long vector of pairwise distances",
|
|
||||||
"distancePairs", distance_pairs);
|
|
||||||
|
|
||||||
initialize_components("coordination "
|
|
||||||
"number", "coordNum", coordnum);
|
|
||||||
initialize_components("self-coordination "
|
|
||||||
"number", "selfCoordNum", selfcoordnum);
|
|
||||||
|
|
||||||
initialize_components("angle", "angle", angle);
|
|
||||||
initialize_components("dipole angle", "dipoleAngle", dipole_angle);
|
|
||||||
initialize_components("dihedral", "dihedral", dihedral);
|
|
||||||
|
|
||||||
initialize_components("hydrogen bond", "hBond", h_bond);
|
|
||||||
|
|
||||||
// initialize_components ("alpha helix", "alphaDihedrals", alpha_dihedrals);
|
|
||||||
initialize_components("alpha helix", "alpha", alpha_angles);
|
|
||||||
|
|
||||||
initialize_components("dihedral principal "
|
|
||||||
"component", "dihedralPC", dihedPC);
|
|
||||||
|
|
||||||
initialize_components("orientation", "orientation", orientation);
|
|
||||||
initialize_components("orientation "
|
|
||||||
"angle", "orientationAngle",orientation_angle);
|
|
||||||
initialize_components("orientation "
|
|
||||||
"projection", "orientationProj",orientation_proj);
|
|
||||||
initialize_components("tilt", "tilt", tilt);
|
|
||||||
initialize_components("spin angle", "spinAngle", spin_angle);
|
|
||||||
|
|
||||||
initialize_components("RMSD", "rmsd", rmsd);
|
|
||||||
|
|
||||||
// initialize_components ("logarithm of MSD", "logmsd", logmsd);
|
|
||||||
|
|
||||||
initialize_components("radius of "
|
|
||||||
"gyration", "gyration", gyration);
|
|
||||||
initialize_components("moment of "
|
|
||||||
"inertia", "inertia", inertia);
|
|
||||||
initialize_components("moment of inertia around an axis",
|
|
||||||
"inertiaZ", inertia_z);
|
|
||||||
initialize_components("eigenvector", "eigenvector", eigenvector);
|
|
||||||
|
|
||||||
if (!cvcs.size()) {
|
|
||||||
cvm::error("Error: no valid components were provided "
|
|
||||||
"for this collective variable.\n",
|
|
||||||
INPUT_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
n_active_cvcs = cvcs.size();
|
|
||||||
|
|
||||||
cvm::log("All components initialized.\n");
|
|
||||||
|
|
||||||
// Store list of children cvcs for dependency checking purposes
|
|
||||||
for (i = 0; i < cvcs.size(); i++) {
|
|
||||||
add_child(cvcs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup colvar as scripted function of components
|
// Setup colvar as scripted function of components
|
||||||
if (get_keyval(conf, "scriptedFunction", scripted_function,
|
if (get_keyval(conf, "scriptedFunction", scripted_function,
|
||||||
@ -540,6 +408,215 @@ colvar::colvar(std::string const &conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// read the configuration and set up corresponding instances, for
|
||||||
|
// each type of component implemented
|
||||||
|
template<typename def_class_name> int colvar::init_components_type(std::string const &conf,
|
||||||
|
char const *def_desc,
|
||||||
|
char const *def_config_key)
|
||||||
|
{
|
||||||
|
size_t def_count = 0;
|
||||||
|
std::string def_conf = "";
|
||||||
|
size_t pos = 0;
|
||||||
|
while ( this->key_lookup(conf,
|
||||||
|
def_config_key,
|
||||||
|
def_conf,
|
||||||
|
pos) ) {
|
||||||
|
if (!def_conf.size()) continue;
|
||||||
|
cvm::log("Initializing "
|
||||||
|
"a new \""+std::string(def_config_key)+"\" component"+
|
||||||
|
(cvm::debug() ? ", with configuration:\n"+def_conf
|
||||||
|
: ".\n"));
|
||||||
|
cvm::increase_depth();
|
||||||
|
cvc *cvcp = new def_class_name(def_conf);
|
||||||
|
if (cvcp != NULL) {
|
||||||
|
cvcs.push_back(cvcp);
|
||||||
|
cvcp->check_keywords(def_conf, def_config_key);
|
||||||
|
if (cvm::get_error()) {
|
||||||
|
cvm::error("Error: in setting up component \""+
|
||||||
|
std::string(def_config_key)+"\".\n", INPUT_ERROR);
|
||||||
|
return INPUT_ERROR;
|
||||||
|
}
|
||||||
|
cvm::decrease_depth();
|
||||||
|
} else {
|
||||||
|
cvm::error("Error: in allocating component \""+
|
||||||
|
std::string(def_config_key)+"\".\n",
|
||||||
|
MEMORY_ERROR);
|
||||||
|
return MEMORY_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (cvcp->period != 0.0) || (cvcp->wrap_center != 0.0) ) {
|
||||||
|
if ( (cvcp->function_type != std::string("distance_z")) &&
|
||||||
|
(cvcp->function_type != std::string("dihedral")) &&
|
||||||
|
(cvcp->function_type != std::string("spin_angle")) ) {
|
||||||
|
cvm::error("Error: invalid use of period and/or "
|
||||||
|
"wrapAround in a \""+
|
||||||
|
std::string(def_config_key)+
|
||||||
|
"\" component.\n"+
|
||||||
|
"Period: "+cvm::to_str(cvcp->period) +
|
||||||
|
" wrapAround: "+cvm::to_str(cvcp->wrap_center),
|
||||||
|
INPUT_ERROR);
|
||||||
|
return INPUT_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! cvcs.back()->name.size()) {
|
||||||
|
std::ostringstream s;
|
||||||
|
s << def_config_key << std::setfill('0') << std::setw(4) << ++def_count;
|
||||||
|
cvcs.back()->name = s.str();
|
||||||
|
/* pad cvc number for correct ordering when sorting by name */
|
||||||
|
}
|
||||||
|
|
||||||
|
cvcs.back()->setup();
|
||||||
|
if (cvm::debug()) {
|
||||||
|
cvm::log("Done initializing a \""+
|
||||||
|
std::string(def_config_key)+
|
||||||
|
"\" component"+
|
||||||
|
(cvm::debug() ?
|
||||||
|
", named \""+cvcs.back()->name+"\""
|
||||||
|
: "")+".\n");
|
||||||
|
}
|
||||||
|
def_conf = "";
|
||||||
|
if (cvm::debug()) {
|
||||||
|
cvm::log("Parsed "+cvm::to_str(cvcs.size())+
|
||||||
|
" components at this time.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return COLVARS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int colvar::init_components(std::string const &conf)
|
||||||
|
{
|
||||||
|
int error_code = COLVARS_OK;
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance>(conf,
|
||||||
|
"distance", "distance"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_vec>(conf,
|
||||||
|
"distance vector", "distanceVec"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<cartesian>(conf,
|
||||||
|
"Cartesian coordinates", "cartesian"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_dir>(conf,
|
||||||
|
"distance vector "
|
||||||
|
"direction", "distanceDir"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_z>(conf,
|
||||||
|
"distance projection "
|
||||||
|
"on an axis", "distanceZ"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_xy>(conf,
|
||||||
|
"distance projection "
|
||||||
|
"on a plane", "distanceXY"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_inv>(conf,
|
||||||
|
"average distance "
|
||||||
|
"weighted by inverse power",
|
||||||
|
"distanceInv"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<distance_pairs>(conf,
|
||||||
|
"N1xN2-long vector "
|
||||||
|
"of pairwise distances",
|
||||||
|
"distancePairs"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<coordnum>(conf,
|
||||||
|
"coordination "
|
||||||
|
"number", "coordNum"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<selfcoordnum>(conf,
|
||||||
|
"self-coordination "
|
||||||
|
"number", "selfCoordNum"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<angle>(conf,
|
||||||
|
"angle", "angle"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<dipole_angle>(conf,
|
||||||
|
"dipole angle", "dipoleAngle"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<dihedral>(conf,
|
||||||
|
"dihedral", "dihedral"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<h_bond>(conf,
|
||||||
|
"hydrogen bond", "hBond"));
|
||||||
|
|
||||||
|
// cvm::combine_errors(error_code, init_components_type<alpha_dihedrals>(conf, "alpha helix", "alphaDihedrals"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<alpha_angles>(conf,
|
||||||
|
"alpha helix", "alpha"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<dihedPC>(conf,
|
||||||
|
"dihedral "
|
||||||
|
"principal component", "dihedralPC"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<orientation>(conf,
|
||||||
|
"orientation", "orientation"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<orientation_angle>(conf,
|
||||||
|
"orientation "
|
||||||
|
"angle", "orientationAngle"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<orientation_proj>(conf,
|
||||||
|
"orientation "
|
||||||
|
"projection", "orientationProj"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<tilt>(conf,
|
||||||
|
"tilt", "tilt"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<spin_angle>(conf,
|
||||||
|
"spin angle", "spinAngle"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<rmsd>(conf,
|
||||||
|
"RMSD", "rmsd"));
|
||||||
|
|
||||||
|
// cvm::combine_errors(error_code, init_components_type <logmsd>(conf,"logarithm of MSD", "logmsd"));
|
||||||
|
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<gyration>(conf,
|
||||||
|
"radius of "
|
||||||
|
"gyration", "gyration"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<inertia>(conf,
|
||||||
|
"moment of "
|
||||||
|
"inertia", "inertia"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<inertia_z>(conf,
|
||||||
|
"moment of inertia around an axis",
|
||||||
|
"inertiaZ"));
|
||||||
|
cvm::combine_errors(error_code,
|
||||||
|
init_components_type<eigenvector>(conf,
|
||||||
|
"eigenvector", "eigenvector"));
|
||||||
|
|
||||||
|
if (!cvcs.size() || (error_code != COLVARS_OK)) {
|
||||||
|
cvm::error("Error: no valid components were provided "
|
||||||
|
"for this collective variable.\n",
|
||||||
|
INPUT_ERROR);
|
||||||
|
return INPUT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
n_active_cvcs = cvcs.size();
|
||||||
|
|
||||||
|
cvm::log("All components initialized.\n");
|
||||||
|
|
||||||
|
// Store list of children cvcs for dependency checking purposes
|
||||||
|
for (size_t i = 0; i < cvcs.size(); i++) {
|
||||||
|
add_child(cvcs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return COLVARS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int colvar::refresh_deps()
|
int colvar::refresh_deps()
|
||||||
{
|
{
|
||||||
// If enabled features are changed upstream, the features below should be refreshed
|
// If enabled features are changed upstream, the features below should be refreshed
|
||||||
@ -959,18 +1036,7 @@ int colvar::calc_cvc_sys_forces(int first_cvc, size_t num_cvcs)
|
|||||||
size_t const cvc_max_count = num_cvcs ? num_cvcs : num_active_cvcs();
|
size_t const cvc_max_count = num_cvcs ? num_cvcs : num_active_cvcs();
|
||||||
size_t i, cvc_count;
|
size_t i, cvc_count;
|
||||||
|
|
||||||
if (is_enabled(f_cv_system_force) && !is_enabled(f_cv_extended_Lagrangian)) {
|
if (is_enabled(f_cv_system_force_calc)) {
|
||||||
// If extended Lagrangian is enabled, system force calculation is trivial
|
|
||||||
// and done together with integration of the extended coordinate.
|
|
||||||
|
|
||||||
if (is_enabled(f_cv_scripted)) {
|
|
||||||
// TODO see if this could reasonably be done in a generic way
|
|
||||||
// from generic inverse gradients
|
|
||||||
cvm::error("System force is not implemented for "
|
|
||||||
"scripted colvars.", COLVARS_NOT_IMPLEMENTED);
|
|
||||||
return COLVARS_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cvm::debug())
|
if (cvm::debug())
|
||||||
cvm::log("Calculating system force of colvar \""+this->name+"\".\n");
|
cvm::log("Calculating system force of colvar \""+this->name+"\".\n");
|
||||||
|
|
||||||
@ -1001,9 +1067,7 @@ int colvar::calc_cvc_sys_forces(int first_cvc, size_t num_cvcs)
|
|||||||
|
|
||||||
int colvar::collect_cvc_sys_forces()
|
int colvar::collect_cvc_sys_forces()
|
||||||
{
|
{
|
||||||
if (is_enabled(f_cv_system_force) && !is_enabled(f_cv_extended_Lagrangian)) {
|
if (is_enabled(f_cv_system_force_calc)) {
|
||||||
// If extended Lagrangian is enabled, system force calculation is trivial
|
|
||||||
// and done together with integration of the extended coordinate.
|
|
||||||
ft.reset();
|
ft.reset();
|
||||||
|
|
||||||
if (cvm::step_relative() > 0) {
|
if (cvm::step_relative() > 0) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVAR_H
|
#ifndef COLVAR_H
|
||||||
#define COLVAR_H
|
#define COLVAR_H
|
||||||
@ -220,7 +220,18 @@ public:
|
|||||||
/// Constructor
|
/// Constructor
|
||||||
colvar(std::string const &conf);
|
colvar(std::string const &conf);
|
||||||
|
|
||||||
/// Get ready for a run and possibly re-initialize internal data
|
/// Parse the CVC configuration and allocate their data
|
||||||
|
int init_components(std::string const &conf);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Parse the CVC configuration for all components of a certain type
|
||||||
|
template<typename def_class_name> int init_components_type(std::string const &conf,
|
||||||
|
char const *def_desc,
|
||||||
|
char const *def_config_key);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// Get ready for a run and re-initialize internal data if needed
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarparse.h"
|
#include "colvarparse.h"
|
||||||
@ -96,9 +96,9 @@ cvm::atom_group::~atom_group()
|
|||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
delete ref_pos_group;
|
delete fitting_group;
|
||||||
ref_pos_group = NULL;
|
fitting_group = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ int cvm::atom_group::init()
|
|||||||
b_rotate = false;
|
b_rotate = false;
|
||||||
b_user_defined_fit = false;
|
b_user_defined_fit = false;
|
||||||
b_fit_gradients = false;
|
b_fit_gradients = false;
|
||||||
ref_pos_group = NULL;
|
fitting_group = NULL;
|
||||||
|
|
||||||
noforce = false;
|
noforce = false;
|
||||||
|
|
||||||
@ -598,23 +598,31 @@ int cvm::atom_group::parse_fitting_options(std::string const &group_conf)
|
|||||||
cvm::error("Error: centerReference or rotateReference "
|
cvm::error("Error: centerReference or rotateReference "
|
||||||
"cannot be defined for a dummy atom.\n");
|
"cannot be defined for a dummy atom.\n");
|
||||||
|
|
||||||
|
bool b_ref_pos_group = false;
|
||||||
if (key_lookup(group_conf, "refPositionsGroup")) {
|
if (key_lookup(group_conf, "refPositionsGroup")) {
|
||||||
|
b_ref_pos_group = true;
|
||||||
|
cvm::log("Warning: keyword \"refPositionsGroup\" is deprecated: please use \"fittingGroup\" instead.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b_ref_pos_group || key_lookup(group_conf, "fittingGroup")) {
|
||||||
// instead of this group, define another group to compute the fit
|
// instead of this group, define another group to compute the fit
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
cvm::error("Error: the atom group \""+
|
cvm::error("Error: the atom group \""+
|
||||||
key+"\" has already a reference group "
|
key+"\" has already a reference group "
|
||||||
"for the rototranslational fit, which was communicated by the "
|
"for the rototranslational fit, which was communicated by the "
|
||||||
"colvar component. You should not use refPositionsGroup "
|
"colvar component. You should not use fittingGroup "
|
||||||
"in this case.\n");
|
"in this case.\n");
|
||||||
}
|
}
|
||||||
cvm::log("Within atom group \""+key+"\":\n");
|
cvm::log("Within atom group \""+key+"\":\n");
|
||||||
ref_pos_group = new atom_group(group_conf, "refPositionsGroup");
|
fitting_group = b_ref_pos_group ?
|
||||||
|
new atom_group(group_conf, "refPositionsGroup") :
|
||||||
|
new atom_group(group_conf, "fittingGroup");
|
||||||
|
|
||||||
// regardless of the configuration, fit gradients must be calculated by refPositionsGroup
|
// regardless of the configuration, fit gradients must be calculated by fittingGroup
|
||||||
ref_pos_group->b_fit_gradients = this->b_fit_gradients;
|
fitting_group->b_fit_gradients = this->b_fit_gradients;
|
||||||
}
|
}
|
||||||
|
|
||||||
atom_group *group_for_fit = ref_pos_group ? ref_pos_group : this;
|
atom_group *group_for_fit = fitting_group ? fitting_group : this;
|
||||||
|
|
||||||
get_keyval(group_conf, "refPositions", ref_pos, ref_pos);
|
get_keyval(group_conf, "refPositions", ref_pos, ref_pos);
|
||||||
|
|
||||||
@ -678,7 +686,7 @@ int cvm::atom_group::parse_fitting_options(std::string const &group_conf)
|
|||||||
"\" will be aligned to a fixed orientation given by the reference positions provided. "
|
"\" 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 "
|
"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. "
|
"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) "
|
"If that happens, use fittingGroup (or a different definition for it if already defined) "
|
||||||
"to align the coordinates.\n");
|
"to align the coordinates.\n");
|
||||||
// initialize rot member data
|
// initialize rot member data
|
||||||
rot.request_group1_gradients(group_for_fit->size());
|
rot.request_group1_gradients(group_for_fit->size());
|
||||||
@ -741,8 +749,8 @@ void cvm::atom_group::read_positions()
|
|||||||
ai->read_position();
|
ai->read_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref_pos_group)
|
if (fitting_group)
|
||||||
ref_pos_group->read_positions();
|
fitting_group->read_positions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -754,8 +762,8 @@ int cvm::atom_group::calc_required_properties()
|
|||||||
|
|
||||||
if (!is_enabled(f_ag_scalable)) {
|
if (!is_enabled(f_ag_scalable)) {
|
||||||
if (b_center || b_rotate) {
|
if (b_center || b_rotate) {
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
ref_pos_group->calc_center_of_geometry();
|
fitting_group->calc_center_of_geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_apply_roto_translation();
|
calc_apply_roto_translation();
|
||||||
@ -763,8 +771,8 @@ int cvm::atom_group::calc_required_properties()
|
|||||||
// update COM and COG after fitting
|
// update COM and COG after fitting
|
||||||
calc_center_of_geometry();
|
calc_center_of_geometry();
|
||||||
calc_center_of_mass();
|
calc_center_of_mass();
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
ref_pos_group->calc_center_of_geometry();
|
fitting_group->calc_center_of_geometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -779,25 +787,25 @@ void cvm::atom_group::calc_apply_roto_translation()
|
|||||||
{
|
{
|
||||||
// store the laborarory-frame COGs for when they are needed later
|
// store the laborarory-frame COGs for when they are needed later
|
||||||
cog_orig = this->center_of_geometry();
|
cog_orig = this->center_of_geometry();
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
ref_pos_group->cog_orig = ref_pos_group->center_of_geometry();
|
fitting_group->cog_orig = fitting_group->center_of_geometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b_center) {
|
if (b_center) {
|
||||||
// center on the origin first
|
// center on the origin first
|
||||||
cvm::atom_pos const rpg_cog = ref_pos_group ?
|
cvm::atom_pos const rpg_cog = fitting_group ?
|
||||||
ref_pos_group->center_of_geometry() : this->center_of_geometry();
|
fitting_group->center_of_geometry() : this->center_of_geometry();
|
||||||
apply_translation(-1.0 * rpg_cog);
|
apply_translation(-1.0 * rpg_cog);
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
ref_pos_group->apply_translation(-1.0 * rpg_cog);
|
fitting_group->apply_translation(-1.0 * rpg_cog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b_rotate) {
|
if (b_rotate) {
|
||||||
// rotate the group (around the center of geometry if b_center is
|
// rotate the group (around the center of geometry if b_center is
|
||||||
// true, around the origin otherwise)
|
// true, around the origin otherwise)
|
||||||
rot.calc_optimal_rotation(ref_pos_group ?
|
rot.calc_optimal_rotation(fitting_group ?
|
||||||
ref_pos_group->positions() :
|
fitting_group->positions() :
|
||||||
this->positions(),
|
this->positions(),
|
||||||
ref_pos);
|
ref_pos);
|
||||||
|
|
||||||
@ -805,8 +813,8 @@ void cvm::atom_group::calc_apply_roto_translation()
|
|||||||
for (ai = this->begin(); ai != this->end(); ai++) {
|
for (ai = this->begin(); ai != this->end(); ai++) {
|
||||||
ai->pos = rot.rotate(ai->pos);
|
ai->pos = rot.rotate(ai->pos);
|
||||||
}
|
}
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
for (ai = ref_pos_group->begin(); ai != ref_pos_group->end(); ai++) {
|
for (ai = fitting_group->begin(); ai != fitting_group->end(); ai++) {
|
||||||
ai->pos = rot.rotate(ai->pos);
|
ai->pos = rot.rotate(ai->pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,8 +823,8 @@ void cvm::atom_group::calc_apply_roto_translation()
|
|||||||
if (b_center) {
|
if (b_center) {
|
||||||
// align with the center of geometry of ref_pos
|
// align with the center of geometry of ref_pos
|
||||||
apply_translation(ref_pos_cog);
|
apply_translation(ref_pos_cog);
|
||||||
if (ref_pos_group) {
|
if (fitting_group) {
|
||||||
ref_pos_group->apply_translation(ref_pos_cog);
|
fitting_group->apply_translation(ref_pos_cog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update of COM and COG is done from the calling routine
|
// update of COM and COG is done from the calling routine
|
||||||
@ -953,7 +961,7 @@ void cvm::atom_group::calc_fit_gradients()
|
|||||||
if (cvm::debug())
|
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;
|
atom_group *group_for_fit = fitting_group ? fitting_group : this;
|
||||||
|
|
||||||
if (b_center) {
|
if (b_center) {
|
||||||
// add the center of geometry contribution to the gradients
|
// add the center of geometry contribution to the gradients
|
||||||
@ -1141,7 +1149,7 @@ void cvm::atom_group::apply_colvar_force(cvm::real const &force)
|
|||||||
|
|
||||||
if ((b_center || b_rotate) && b_fit_gradients) {
|
if ((b_center || b_rotate) && b_fit_gradients) {
|
||||||
|
|
||||||
atom_group *group_for_fit = ref_pos_group ? ref_pos_group : this;
|
atom_group *group_for_fit = fitting_group ? fitting_group : this;
|
||||||
|
|
||||||
// Fit gradients are already calculated in "laboratory" frame
|
// Fit gradients are already calculated in "laboratory" frame
|
||||||
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
for (size_t j = 0; j < group_for_fit->size(); j++) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARATOMS_H
|
#ifndef COLVARATOMS_H
|
||||||
#define COLVARATOMS_H
|
#define COLVARATOMS_H
|
||||||
@ -299,7 +299,7 @@ public:
|
|||||||
|
|
||||||
/// \brief If b_center or b_rotate is true, use this group to
|
/// \brief If b_center or b_rotate is true, use this group to
|
||||||
/// define the transformation (default: this group itself)
|
/// define the transformation (default: this group itself)
|
||||||
atom_group *ref_pos_group;
|
atom_group *fitting_group;
|
||||||
|
|
||||||
/// Total mass of the atom group
|
/// Total mass of the atom group
|
||||||
cvm::real total_mass;
|
cvm::real total_mass;
|
||||||
@ -346,8 +346,8 @@ public:
|
|||||||
{
|
{
|
||||||
for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++)
|
for (cvm::atom_iter ai = atoms.begin(); ai != atoms.end(); ai++)
|
||||||
ai->reset_data();
|
ai->reset_data();
|
||||||
if (ref_pos_group)
|
if (fitting_group)
|
||||||
ref_pos_group->reset_atoms_data();
|
fitting_group->reset_atoms_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Recompute all mutable quantities that are required to compute CVCs
|
/// \brief Recompute all mutable quantities that are required to compute CVCs
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarvalue.h"
|
#include "colvarvalue.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARBIAS_H
|
#ifndef COLVARBIAS_H
|
||||||
#define COLVARBIAS_H
|
#define COLVARBIAS_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvar.h"
|
#include "colvar.h"
|
||||||
@ -8,8 +8,11 @@
|
|||||||
|
|
||||||
colvarbias_abf::colvarbias_abf(std::string const &conf, char const *key)
|
colvarbias_abf::colvarbias_abf(std::string const &conf, char const *key)
|
||||||
: colvarbias(conf, key),
|
: colvarbias(conf, key),
|
||||||
|
force(NULL),
|
||||||
gradients(NULL),
|
gradients(NULL),
|
||||||
samples(NULL)
|
samples(NULL),
|
||||||
|
last_gradients(NULL),
|
||||||
|
last_samples(NULL)
|
||||||
{
|
{
|
||||||
// TODO relax this in case of VMD plugin
|
// TODO relax this in case of VMD plugin
|
||||||
if (cvm::temperature() == 0.0)
|
if (cvm::temperature() == 0.0)
|
||||||
@ -60,10 +63,10 @@ colvarbias_abf::colvarbias_abf(std::string const &conf, char const *key)
|
|||||||
|
|
||||||
if (update_bias) {
|
if (update_bias) {
|
||||||
// Request calculation of system force (which also checks for availability)
|
// Request calculation of system force (which also checks for availability)
|
||||||
enable(f_cvb_get_system_force);
|
if(enable(f_cvb_get_system_force)) return;
|
||||||
}
|
}
|
||||||
if (apply_bias) {
|
if (apply_bias) {
|
||||||
enable(f_cvb_apply_force);
|
if(enable(f_cvb_apply_force)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < colvars.size(); i++) {
|
for (size_t i = 0; i < colvars.size(); i++) {
|
||||||
@ -151,7 +154,10 @@ colvarbias_abf::~colvarbias_abf()
|
|||||||
last_gradients = NULL;
|
last_gradients = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (force) {
|
||||||
delete [] force;
|
delete [] force;
|
||||||
|
force = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (cvm::n_abf_biases > 0)
|
if (cvm::n_abf_biases > 0)
|
||||||
cvm::n_abf_biases -= 1;
|
cvm::n_abf_biases -= 1;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvar.h"
|
#include "colvar.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -41,10 +41,10 @@ colvarbias_meta::colvarbias_meta(std::string const &conf, char const *key)
|
|||||||
if (cvm::n_abf_biases > 0)
|
if (cvm::n_abf_biases > 0)
|
||||||
cvm::log("Warning: running ABF and metadynamics together is not recommended unless applyBias is off for ABF.\n");
|
cvm::log("Warning: running ABF and metadynamics together is not recommended unless applyBias is off for ABF.\n");
|
||||||
|
|
||||||
get_keyval(conf, "hillWeight", hill_weight, 0.01);
|
get_keyval(conf, "hillWeight", hill_weight, 0.0);
|
||||||
if (hill_weight == 0.0)
|
if (hill_weight <= 0.0) {
|
||||||
cvm::log("Warning: hillWeight has been set to zero, "
|
cvm::error("Error: hillWeight must be provided, and a positive number.\n", INPUT_ERROR);
|
||||||
"this bias will have no effect.\n");
|
}
|
||||||
|
|
||||||
get_keyval(conf, "newHillFrequency", new_hill_freq, 1000);
|
get_keyval(conf, "newHillFrequency", new_hill_freq, 1000);
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARBIAS_META_H
|
#ifndef COLVARBIAS_META_H
|
||||||
#define COLVARBIAS_META_H
|
#define COLVARBIAS_META_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarvalue.h"
|
#include "colvarvalue.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARBIAS_RESTRAINT_H
|
#ifndef COLVARBIAS_RESTRAINT_H
|
||||||
#define COLVARBIAS_RESTRAINT_H
|
#define COLVARBIAS_RESTRAINT_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarvalue.h"
|
#include "colvarvalue.h"
|
||||||
@ -68,6 +68,7 @@ cvm::atom_group *colvar::cvc::parse_group(std::string const &conf,
|
|||||||
group->key = group_key;
|
group->key = group_key;
|
||||||
|
|
||||||
if (b_try_scalable) {
|
if (b_try_scalable) {
|
||||||
|
// TODO rewrite this logic in terms of dependencies
|
||||||
if (is_available(f_cvc_scalable_com) && is_available(f_cvc_com_based)) {
|
if (is_available(f_cvc_scalable_com) && is_available(f_cvc_com_based)) {
|
||||||
enable(f_cvc_scalable_com);
|
enable(f_cvc_scalable_com);
|
||||||
enable(f_cvc_scalable);
|
enable(f_cvc_scalable);
|
||||||
@ -109,10 +110,6 @@ int colvar::cvc::setup()
|
|||||||
add_child((cvm::deps *) atom_groups[i]);
|
add_child((cvm::deps *) atom_groups[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b_try_scalable && is_available(f_cvc_scalable)) {
|
|
||||||
enable(f_cvc_scalable);
|
|
||||||
}
|
|
||||||
|
|
||||||
return COLVARS_OK;
|
return COLVARS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +131,7 @@ void colvar::cvc::read_data()
|
|||||||
atoms.reset_atoms_data();
|
atoms.reset_atoms_data();
|
||||||
atoms.read_positions();
|
atoms.read_positions();
|
||||||
atoms.calc_required_properties();
|
atoms.calc_required_properties();
|
||||||
// each atom group will take care of its own ref_pos_group, if defined
|
// each atom group will take care of its own fitting_group, if defined
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Don't try to get atom velocities, as no back-end currently implements it
|
//// Don't try to get atom velocities, as no back-end currently implements it
|
||||||
@ -179,7 +176,7 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
|
|||||||
|
|
||||||
// cvm::log("gradients = "+cvm::to_str (gradients)+"\n");
|
// cvm::log("gradients = "+cvm::to_str (gradients)+"\n");
|
||||||
|
|
||||||
cvm::atom_group *group_for_fit = group->ref_pos_group ? group->ref_pos_group : group;
|
cvm::atom_group *group_for_fit = group->fitting_group ? group->fitting_group : group;
|
||||||
cvm::atom_pos fit_gradient_sum, gradient_sum;
|
cvm::atom_pos fit_gradient_sum, gradient_sum;
|
||||||
|
|
||||||
// print the values of the fit gradients
|
// print the values of the fit gradients
|
||||||
@ -190,7 +187,7 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
|
|||||||
// fit_gradients are in the simulation frame: we should print them in the rotated frame
|
// fit_gradients are in the simulation frame: we should print them in the rotated frame
|
||||||
cvm::log("Fit gradients:\n");
|
cvm::log("Fit gradients:\n");
|
||||||
for (j = 0; j < group_for_fit->fit_gradients.size(); j++) {
|
for (j = 0; j < group_for_fit->fit_gradients.size(); j++) {
|
||||||
cvm::log((group->ref_pos_group ? std::string("refPosGroup") : group->key) +
|
cvm::log((group->fitting_group ? std::string("refPosGroup") : group->key) +
|
||||||
"[" + cvm::to_str(j) + "] = " +
|
"[" + cvm::to_str(j) + "] = " +
|
||||||
(group->b_rotate ?
|
(group->b_rotate ?
|
||||||
cvm::to_str(rot_0.rotate(group_for_fit->fit_gradients[j])) :
|
cvm::to_str(rot_0.rotate(group_for_fit->fit_gradients[j])) :
|
||||||
@ -231,8 +228,8 @@ void colvar::cvc::debug_gradients(cvm::atom_group *group)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((group->b_fit_gradients) && (group->ref_pos_group != NULL)) {
|
if ((group->b_fit_gradients) && (group->fitting_group != NULL)) {
|
||||||
cvm::atom_group *ref_group = group->ref_pos_group;
|
cvm::atom_group *ref_group = group->fitting_group;
|
||||||
group->read_positions();
|
group->read_positions();
|
||||||
group->calc_required_properties();
|
group->calc_required_properties();
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARCOMP_H
|
#ifndef COLVARCOMP_H
|
||||||
#define COLVARCOMP_H
|
#define COLVARCOMP_H
|
||||||
@ -293,12 +293,7 @@ inline void colvar::cvc::wrap(colvarvalue &x) const
|
|||||||
|
|
||||||
/// \brief Colvar component: distance between the centers of mass of
|
/// \brief Colvar component: distance between the centers of mass of
|
||||||
/// two groups (colvarvalue::type_scalar type, range [0:*))
|
/// two groups (colvarvalue::type_scalar type, range [0:*))
|
||||||
///
|
|
||||||
/// This class also serves as the template for many collective
|
|
||||||
/// variables with two atom groups: in this case, the
|
|
||||||
/// distance::distance() constructor should be called on the same
|
|
||||||
/// configuration string, to make the same member data and functions
|
|
||||||
/// available to the derived object
|
|
||||||
class colvar::distance
|
class colvar::distance
|
||||||
: public colvar::cvc
|
: public colvar::cvc
|
||||||
{
|
{
|
||||||
@ -315,7 +310,7 @@ protected:
|
|||||||
/// coupling to other colvars (see e.g. Ciccotti et al., 2005)
|
/// coupling to other colvars (see e.g. Ciccotti et al., 2005)
|
||||||
bool b_1site_force;
|
bool b_1site_force;
|
||||||
public:
|
public:
|
||||||
distance(std::string const &conf, bool twogroups = true);
|
distance(std::string const &conf);
|
||||||
distance();
|
distance();
|
||||||
virtual inline ~distance() {}
|
virtual inline ~distance() {}
|
||||||
virtual void calc_value();
|
virtual void calc_value();
|
||||||
@ -764,9 +759,13 @@ public:
|
|||||||
/// \brief Colvar component: coordination number between two groups
|
/// \brief Colvar component: coordination number between two groups
|
||||||
/// (colvarvalue::type_scalar type, range [0:N1*N2])
|
/// (colvarvalue::type_scalar type, range [0:N1*N2])
|
||||||
class colvar::coordnum
|
class colvar::coordnum
|
||||||
: public colvar::distance
|
: public colvar::cvc
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
/// First atom group
|
||||||
|
cvm::atom_group *group1;
|
||||||
|
/// Second atom group
|
||||||
|
cvm::atom_group *group2;
|
||||||
/// \brief "Cutoff" for isotropic calculation (default)
|
/// \brief "Cutoff" for isotropic calculation (default)
|
||||||
cvm::real r0;
|
cvm::real r0;
|
||||||
/// \brief "Cutoff vector" for anisotropic calculation
|
/// \brief "Cutoff vector" for anisotropic calculation
|
||||||
@ -819,9 +818,11 @@ public:
|
|||||||
/// \brief Colvar component: self-coordination number within a group
|
/// \brief Colvar component: self-coordination number within a group
|
||||||
/// (colvarvalue::type_scalar type, range [0:N*(N-1)/2])
|
/// (colvarvalue::type_scalar type, range [0:N*(N-1)/2])
|
||||||
class colvar::selfcoordnum
|
class colvar::selfcoordnum
|
||||||
: public colvar::distance
|
: public colvar::cvc
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
/// First atom group
|
||||||
|
cvm::atom_group *group1;
|
||||||
/// \brief "Cutoff" for isotropic calculation (default)
|
/// \brief "Cutoff" for isotropic calculation (default)
|
||||||
cvm::real r0;
|
cvm::real r0;
|
||||||
/// Integer exponent of the function numerator
|
/// Integer exponent of the function numerator
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvar.h"
|
#include "colvar.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@ -71,31 +71,29 @@ cvm::real colvar::coordnum::switching_function(cvm::rvector const &r0_vec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
colvar::coordnum::coordnum(std::string const &conf)
|
colvar::coordnum::coordnum(std::string const &conf)
|
||||||
: distance(conf), b_anisotropic(false), b_group2_center_only(false)
|
: cvc(conf), b_anisotropic(false), b_group2_center_only(false)
|
||||||
{
|
{
|
||||||
function_type = "coordnum";
|
function_type = "coordnum";
|
||||||
x.type(colvarvalue::type_scalar);
|
x.type(colvarvalue::type_scalar);
|
||||||
|
|
||||||
// group1 and group2 are already initialized by distance()
|
group1 = parse_group(conf, "group1");
|
||||||
|
group2 = parse_group(conf, "group2");
|
||||||
|
|
||||||
if (group1->b_dummy)
|
if (group1->b_dummy)
|
||||||
cvm::fatal_error("Error: only group2 is allowed to be a dummy atom\n");
|
cvm::fatal_error("Error: only group2 is allowed to be a dummy atom\n");
|
||||||
|
|
||||||
|
bool const b_isotropic = get_keyval(conf, "cutoff", r0,
|
||||||
// need to specify this explicitly because the distance() constructor
|
|
||||||
// has set it to true
|
|
||||||
feature_states[f_cvc_inv_gradient]->available = false;
|
|
||||||
|
|
||||||
bool const b_scale = get_keyval(conf, "cutoff", r0,
|
|
||||||
cvm::real(4.0 * cvm::unit_angstrom()));
|
cvm::real(4.0 * cvm::unit_angstrom()));
|
||||||
|
|
||||||
if (get_keyval(conf, "cutoff3", r0_vec,
|
if (get_keyval(conf, "cutoff3", r0_vec, cvm::rvector(4.0 * cvm::unit_angstrom(),
|
||||||
cvm::rvector(4.0, 4.0, 4.0), parse_silent)) {
|
4.0 * cvm::unit_angstrom(),
|
||||||
|
4.0 * cvm::unit_angstrom()))) {
|
||||||
|
if (b_isotropic) {
|
||||||
|
cvm::error("Error: cannot specify \"cutoff\" and \"cutoff3\" at the same time.\n",
|
||||||
|
INPUT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
if (b_scale)
|
|
||||||
cvm::fatal_error("Error: cannot specify \"scale\" and "
|
|
||||||
"\"scale3\" at the same time.\n");
|
|
||||||
b_anisotropic = true;
|
b_anisotropic = true;
|
||||||
// remove meaningless negative signs
|
// remove meaningless negative signs
|
||||||
if (r0_vec.x < 0.0) r0_vec.x *= -1.0;
|
if (r0_vec.x < 0.0) r0_vec.x *= -1.0;
|
||||||
@ -107,7 +105,7 @@ colvar::coordnum::coordnum(std::string const &conf)
|
|||||||
get_keyval(conf, "expDenom", ed, int(12));
|
get_keyval(conf, "expDenom", ed, int(12));
|
||||||
|
|
||||||
if ( (en%2) || (ed%2) ) {
|
if ( (en%2) || (ed%2) ) {
|
||||||
cvm::fatal_error("Error: odd exponents provided, can only use even ones.\n");
|
cvm::error("Error: odd exponents provided, can only use even ones.\n", INPUT_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_keyval(conf, "group2CenterOnly", b_group2_center_only, group2->b_dummy);
|
get_keyval(conf, "group2CenterOnly", b_group2_center_only, group2->b_dummy);
|
||||||
@ -289,17 +287,12 @@ void colvar::h_bond::apply_force(colvarvalue const &force)
|
|||||||
|
|
||||||
|
|
||||||
colvar::selfcoordnum::selfcoordnum(std::string const &conf)
|
colvar::selfcoordnum::selfcoordnum(std::string const &conf)
|
||||||
: distance(conf, false)
|
: cvc(conf)
|
||||||
{
|
{
|
||||||
function_type = "selfcoordnum";
|
function_type = "selfcoordnum";
|
||||||
x.type(colvarvalue::type_scalar);
|
x.type(colvarvalue::type_scalar);
|
||||||
|
|
||||||
// group1 is already initialized by distance()
|
group1 = parse_group(conf, "group1");
|
||||||
|
|
||||||
// need to specify this explicitly because the distance() constructor
|
|
||||||
// has set it to true
|
|
||||||
feature_states[f_cvc_inv_gradient]->available = false;
|
|
||||||
|
|
||||||
|
|
||||||
get_keyval(conf, "cutoff", r0, cvm::real(4.0 * cvm::unit_angstrom()));
|
get_keyval(conf, "cutoff", r0, cvm::real(4.0 * cvm::unit_angstrom()));
|
||||||
get_keyval(conf, "expNumer", en, int(6) );
|
get_keyval(conf, "expNumer", en, int(6) );
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@ -10,10 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// "twogroup" flag defaults to true; set to false by selfCoordNum
|
colvar::distance::distance(std::string const &conf)
|
||||||
// (only distance-derived component based on only one group)
|
|
||||||
|
|
||||||
colvar::distance::distance(std::string const &conf, bool twogroups)
|
|
||||||
: cvc(conf)
|
: cvc(conf)
|
||||||
{
|
{
|
||||||
function_type = "distance";
|
function_type = "distance";
|
||||||
@ -24,13 +21,12 @@ colvar::distance::distance(std::string const &conf, bool twogroups)
|
|||||||
if (get_keyval(conf, "forceNoPBC", b_no_PBC, false)) {
|
if (get_keyval(conf, "forceNoPBC", b_no_PBC, false)) {
|
||||||
cvm::log("Computing distance using absolute positions (not minimal-image)");
|
cvm::log("Computing distance using absolute positions (not minimal-image)");
|
||||||
}
|
}
|
||||||
if (twogroups && get_keyval(conf, "oneSiteSystemForce", b_1site_force, false)) {
|
if (get_keyval(conf, "oneSiteSystemForce", b_1site_force, false)) {
|
||||||
cvm::log("Computing system force on group 1 only");
|
cvm::log("Computing system force on group 1 only");
|
||||||
}
|
}
|
||||||
group1 = parse_group(conf, "group1");
|
group1 = parse_group(conf, "group1");
|
||||||
if (twogroups) {
|
|
||||||
group2 = parse_group(conf, "group2");
|
group2 = parse_group(conf, "group2");
|
||||||
}
|
|
||||||
x.type(colvarvalue::type_scalar);
|
x.type(colvarvalue::type_scalar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -789,7 +785,7 @@ colvar::rmsd::rmsd(std::string const &conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool b_Jacobian_derivative = true;
|
bool b_Jacobian_derivative = true;
|
||||||
if (atoms->ref_pos_group != NULL && b_Jacobian_derivative) {
|
if (atoms->fitting_group != NULL && b_Jacobian_derivative) {
|
||||||
cvm::log("The option \"refPositionsGroup\" (alternative group for fitting) was enabled: "
|
cvm::log("The option \"refPositionsGroup\" (alternative group for fitting) was enabled: "
|
||||||
"Jacobian derivatives of the RMSD will not be calculated.\n");
|
"Jacobian derivatives of the RMSD will not be calculated.\n");
|
||||||
b_Jacobian_derivative = false;
|
b_Jacobian_derivative = false;
|
||||||
@ -798,7 +794,7 @@ colvar::rmsd::rmsd(std::string const &conf)
|
|||||||
|
|
||||||
// the following is a simplified version of the corresponding atom group options;
|
// the following is a simplified version of the corresponding atom group options;
|
||||||
// we need this because the reference coordinates defined inside the atom group
|
// we need this because the reference coordinates defined inside the atom group
|
||||||
// may be used only for fitting, and even more so if ref_pos_group is used
|
// may be used only for fitting, and even more so if fitting_group is used
|
||||||
if (get_keyval(conf, "refPositions", ref_pos, ref_pos)) {
|
if (get_keyval(conf, "refPositions", ref_pos, ref_pos)) {
|
||||||
cvm::log("Using reference positions from configuration file to calculate the variable.\n");
|
cvm::log("Using reference positions from configuration file to calculate the variable.\n");
|
||||||
if (ref_pos.size() != atoms->size()) {
|
if (ref_pos.size() != atoms->size()) {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|||||||
@ -196,7 +196,7 @@ int cvm::deps::enable(int feature_id,
|
|||||||
void cvm::deps::init_cvb_requires() {
|
void cvm::deps::init_cvb_requires() {
|
||||||
int i;
|
int i;
|
||||||
if (features().size() == 0) {
|
if (features().size() == 0) {
|
||||||
for (i = 0; i < f_cv_ntot; i++) {
|
for (i = 0; i < f_cvb_ntot; i++) {
|
||||||
features().push_back(new feature);
|
features().push_back(new feature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,11 +362,15 @@ void cvm::deps::init_cvc_requires() {
|
|||||||
f_description(f_cvc_Jacobian, "Jacobian");
|
f_description(f_cvc_Jacobian, "Jacobian");
|
||||||
f_req_self(f_cvc_Jacobian, f_cvc_inv_gradient);
|
f_req_self(f_cvc_Jacobian, f_cvc_inv_gradient);
|
||||||
|
|
||||||
f_description(f_cvc_scalable, "scalable calculation");
|
f_description(f_cvc_com_based, "depends on group centers of mass");
|
||||||
f_description(f_cvc_scalable_com, "scalable calculation of centers of mass");
|
|
||||||
|
|
||||||
|
f_description(f_cvc_scalable, "scalable calculation");
|
||||||
f_req_self(f_cvc_scalable, f_cvc_scalable_com);
|
f_req_self(f_cvc_scalable, f_cvc_scalable_com);
|
||||||
|
|
||||||
|
f_description(f_cvc_scalable_com, "scalable calculation of centers of mass");
|
||||||
|
f_req_self(f_cvc_scalable_com, f_cvc_com_based);
|
||||||
|
|
||||||
|
|
||||||
// TODO only enable this when f_ag_scalable can be turned on for a pre-initialized group
|
// TODO only enable this when f_ag_scalable can be turned on for a pre-initialized group
|
||||||
// f_req_children(f_cvc_scalable, f_ag_scalable);
|
// f_req_children(f_cvc_scalable, f_ag_scalable);
|
||||||
// f_req_children(f_cvc_scalable_com, f_ag_scalable_com);
|
// f_req_children(f_cvc_scalable_com, f_ag_scalable_com);
|
||||||
@ -380,9 +384,9 @@ void cvm::deps::init_cvc_requires() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Features that are implemented by all cvcs by default
|
// Features that are implemented by all cvcs by default
|
||||||
|
// Each cvc specifies what other features are available
|
||||||
feature_states[f_cvc_active]->available = true;
|
feature_states[f_cvc_active]->available = true;
|
||||||
feature_states[f_cvc_gradient]->available = true;
|
feature_states[f_cvc_gradient]->available = true;
|
||||||
// Each cvc specifies what other features are available
|
|
||||||
feature_states[f_cvc_scalable_com]->available = (proxy->scalable_group_coms() == COLVARS_OK);
|
feature_states[f_cvc_scalable_com]->available = (proxy->scalable_group_coms() == COLVARS_OK);
|
||||||
feature_states[f_cvc_scalable]->available = feature_states[f_cvc_scalable_com]->available;
|
feature_states[f_cvc_scalable]->available = feature_states[f_cvc_scalable_com]->available;
|
||||||
}
|
}
|
||||||
@ -399,7 +403,7 @@ void cvm::deps::init_ag_requires() {
|
|||||||
f_description(f_ag_active, "active");
|
f_description(f_ag_active, "active");
|
||||||
f_description(f_ag_center, "translational fit");
|
f_description(f_ag_center, "translational fit");
|
||||||
f_description(f_ag_rotate, "rotational fit");
|
f_description(f_ag_rotate, "rotational fit");
|
||||||
f_description(f_ag_ref_pos_group, "reference positions group");
|
f_description(f_ag_fitting_group, "reference positions group");
|
||||||
f_description(f_ag_fit_gradient_group, "fit gradient for main group");
|
f_description(f_ag_fit_gradient_group, "fit gradient for main group");
|
||||||
f_description(f_ag_fit_gradient_ref, "fit gradient for reference group");
|
f_description(f_ag_fit_gradient_ref, "fit gradient for reference group");
|
||||||
f_description(f_ag_atom_forces, "atomic forces");
|
f_description(f_ag_atom_forces, "atomic forces");
|
||||||
@ -413,7 +417,7 @@ void cvm::deps::init_ag_requires() {
|
|||||||
// f_description(f_ag_min_msd_fit, "minimum MSD fit")
|
// f_description(f_ag_min_msd_fit, "minimum MSD fit")
|
||||||
// f_req_self(f_ag_min_msd_fit, f_ag_center)
|
// f_req_self(f_ag_min_msd_fit, f_ag_center)
|
||||||
// f_req_self(f_ag_min_msd_fit, f_ag_rotate)
|
// f_req_self(f_ag_min_msd_fit, f_ag_rotate)
|
||||||
// f_req_exclude(f_ag_min_msd_fit, f_ag_ref_pos_group)
|
// f_req_exclude(f_ag_min_msd_fit, f_ag_fitting_group)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize feature_states for each instance
|
// Initialize feature_states for each instance
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ public:
|
|||||||
f_ag_active,
|
f_ag_active,
|
||||||
f_ag_center,
|
f_ag_center,
|
||||||
f_ag_rotate,
|
f_ag_rotate,
|
||||||
f_ag_ref_pos_group,
|
f_ag_fitting_group,
|
||||||
/// Perform a standard minimum msd fit for given atoms
|
/// Perform a standard minimum msd fit for given atoms
|
||||||
/// ie. not using refpositionsgroup
|
/// ie. not using refpositionsgroup
|
||||||
// f_ag_min_msd_fit,
|
// f_ag_min_msd_fit,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include "colvarmodule.h"
|
#include "colvarmodule.h"
|
||||||
#include "colvarvalue.h"
|
#include "colvarvalue.h"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARGRID_H
|
#ifndef COLVARGRID_H
|
||||||
#define COLVARGRID_H
|
#define COLVARGRID_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARMODULE_H
|
#ifndef COLVARMODULE_H
|
||||||
#define COLVARMODULE_H
|
#define COLVARMODULE_H
|
||||||
|
|
||||||
#ifndef COLVARS_VERSION
|
#ifndef COLVARS_VERSION
|
||||||
#define COLVARS_VERSION "2016-05-23"
|
#define COLVARS_VERSION "2016-06-14"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COLVARS_DEBUG
|
#ifndef COLVARS_DEBUG
|
||||||
#define COLVARS_DEBUG false
|
#define COLVARS_DEBUG false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*! \mainpage Main page
|
||||||
|
*/
|
||||||
|
|
||||||
/// \file colvarmodule.h
|
/// \file colvarmodule.h
|
||||||
/// \brief Collective variables main module
|
/// \brief Collective variables main module
|
||||||
///
|
///
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -17,235 +17,280 @@ size_t colvarparse::dummy_pos = 0;
|
|||||||
|
|
||||||
// definition of single-value keyword parsers
|
// definition of single-value keyword parsers
|
||||||
|
|
||||||
#define _get_keyval_scalar_string_(TYPE) \
|
template<typename TYPE> bool colvarparse::_get_keyval_scalar_(std::string const &conf,
|
||||||
\
|
char const *key,
|
||||||
bool colvarparse::get_keyval(std::string const &conf, \
|
TYPE &value,
|
||||||
char const *key, \
|
TYPE const &def_value,
|
||||||
TYPE &value, \
|
Parse_Mode const parse_mode)
|
||||||
TYPE const &def_value, \
|
{
|
||||||
Parse_Mode const parse_mode) \
|
std::string data;
|
||||||
{ \
|
bool b_found = false, b_found_any = false;
|
||||||
std::string data; \
|
size_t save_pos = 0, found_count = 0;
|
||||||
bool b_found = false, b_found_any = false; \
|
|
||||||
size_t save_pos = 0, found_count = 0; \
|
do {
|
||||||
\
|
std::string data_this = "";
|
||||||
do { \
|
b_found = key_lookup(conf, key, data_this, save_pos);
|
||||||
std::string data_this = ""; \
|
if (b_found) {
|
||||||
b_found = key_lookup(conf, key, data_this, save_pos); \
|
if (!b_found_any)
|
||||||
if (b_found) { \
|
b_found_any = true;
|
||||||
if (!b_found_any) \
|
found_count++;
|
||||||
b_found_any = true; \
|
data = data_this;
|
||||||
found_count++; \
|
}
|
||||||
data = data_this; \
|
} while (b_found);
|
||||||
} \
|
|
||||||
} while (b_found); \
|
if (found_count > 1)
|
||||||
\
|
cvm::log("Warning: found more than one instance of \""+
|
||||||
if (found_count > 1) \
|
std::string(key)+"\".\n");
|
||||||
cvm::log("Warning: found more than one instance of \""+ \
|
|
||||||
std::string(key)+"\".\n"); \
|
if (data.size()) {
|
||||||
\
|
std::istringstream is(data);
|
||||||
if (data.size()) { \
|
TYPE x(def_value);
|
||||||
std::istringstream is(data); \
|
if (is >> x) {
|
||||||
TYPE x(def_value); \
|
value = x;
|
||||||
if (is >> x) { \
|
} else {
|
||||||
value = x; \
|
cvm::error("Error: in parsing \""+
|
||||||
} else { \
|
std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: in parsing \""+ \
|
}
|
||||||
std::string(key)+"\".\n", INPUT_ERROR); \
|
if (parse_mode != parse_silent) {
|
||||||
} \
|
cvm::log("# "+std::string(key)+" = "+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(value)+"\n");
|
||||||
cvm::log("# "+std::string(key)+" = "+ \
|
}
|
||||||
cvm::to_str(value)+"\n"); \
|
} else {
|
||||||
} \
|
|
||||||
} else { \
|
if (b_found_any) {
|
||||||
\
|
cvm::error("Error: improper or missing value "
|
||||||
if (b_found_any) { \
|
"for \""+std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: improper or missing value " \
|
}
|
||||||
"for \""+std::string(key)+"\".\n", INPUT_ERROR); \
|
value = def_value;
|
||||||
} \
|
if (parse_mode != parse_silent) {
|
||||||
value = def_value; \
|
cvm::log("# "+std::string(key)+" = "+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(def_value)+" [default]\n");
|
||||||
cvm::log("# "+std::string(key)+" = \""+ \
|
}
|
||||||
cvm::to_str(def_value)+"\" [default]\n"); \
|
}
|
||||||
} \
|
|
||||||
} \
|
return b_found_any;
|
||||||
\
|
|
||||||
return b_found_any; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define _get_keyval_scalar_(TYPE) \
|
bool colvarparse::_get_keyval_scalar_string_(std::string const &conf,
|
||||||
\
|
char const *key,
|
||||||
bool colvarparse::get_keyval(std::string const &conf, \
|
std::string &value,
|
||||||
char const *key, \
|
std::string const &def_value,
|
||||||
TYPE &value, \
|
Parse_Mode const parse_mode)
|
||||||
TYPE const &def_value, \
|
{
|
||||||
Parse_Mode const parse_mode) \
|
std::string data;
|
||||||
{ \
|
bool b_found = false, b_found_any = false;
|
||||||
std::string data; \
|
size_t save_pos = 0, found_count = 0;
|
||||||
bool b_found = false, b_found_any = false; \
|
|
||||||
size_t save_pos = 0, found_count = 0; \
|
do {
|
||||||
\
|
std::string data_this = "";
|
||||||
do { \
|
b_found = key_lookup(conf, key, data_this, save_pos);
|
||||||
std::string data_this = ""; \
|
if (b_found) {
|
||||||
b_found = key_lookup(conf, key, data_this, save_pos); \
|
if (!b_found_any)
|
||||||
if (b_found) { \
|
b_found_any = true;
|
||||||
if (!b_found_any) \
|
found_count++;
|
||||||
b_found_any = true; \
|
data = data_this;
|
||||||
found_count++; \
|
}
|
||||||
data = data_this; \
|
} while (b_found);
|
||||||
} \
|
|
||||||
} while (b_found); \
|
if (found_count > 1)
|
||||||
\
|
cvm::log("Warning: found more than one instance of \""+
|
||||||
if (found_count > 1) \
|
std::string(key)+"\".\n");
|
||||||
cvm::log("Warning: found more than one instance of \""+ \
|
|
||||||
std::string(key)+"\".\n"); \
|
if (data.size()) {
|
||||||
\
|
std::istringstream is(data);
|
||||||
if (data.size()) { \
|
size_t data_count = 0;
|
||||||
std::istringstream is(data); \
|
std::string x(def_value);
|
||||||
size_t data_count = 0; \
|
while (is >> x) {
|
||||||
TYPE x(def_value); \
|
value = x;
|
||||||
while (is >> x) { \
|
data_count++;
|
||||||
value = x; \
|
}
|
||||||
data_count++; \
|
if (data_count == 0)
|
||||||
} \
|
cvm::error("Error: in parsing \""+
|
||||||
if (data_count == 0) \
|
std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: in parsing \""+ \
|
if (data_count > 1) {
|
||||||
std::string(key)+"\".\n", INPUT_ERROR); \
|
cvm::error("Error: multiple values "
|
||||||
if (data_count > 1) { \
|
"are not allowed for keyword \""+
|
||||||
cvm::error("Error: multiple values " \
|
std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
"are not allowed for keyword \""+ \
|
}
|
||||||
std::string(key)+"\".\n", INPUT_ERROR); \
|
if (parse_mode != parse_silent) {
|
||||||
} \
|
cvm::log("# "+std::string(key)+" = \""+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(value)+"\"\n");
|
||||||
cvm::log("# "+std::string(key)+" = "+ \
|
}
|
||||||
cvm::to_str(value)+"\n"); \
|
} else {
|
||||||
} \
|
|
||||||
} else { \
|
if (b_found_any) {
|
||||||
\
|
cvm::error("Error: improper or missing value "
|
||||||
if (b_found_any) { \
|
"for \""+std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: improper or missing value " \
|
}
|
||||||
"for \""+std::string(key)+"\".\n", INPUT_ERROR); \
|
value = def_value;
|
||||||
} \
|
if (parse_mode != parse_silent) {
|
||||||
value = def_value; \
|
cvm::log("# "+std::string(key)+" = \""+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(def_value)+"\" [default]\n");
|
||||||
cvm::log("# "+std::string(key)+" = "+ \
|
}
|
||||||
cvm::to_str(def_value)+" [default]\n"); \
|
}
|
||||||
} \
|
|
||||||
} \
|
return b_found_any;
|
||||||
\
|
|
||||||
return b_found_any; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// definition of multiple-value keyword parsers
|
// multiple-value keyword parsers
|
||||||
|
|
||||||
#define _get_keyval_vector_(TYPE) \
|
template<typename TYPE> bool colvarparse::_get_keyval_vector_(std::string const &conf,
|
||||||
\
|
char const *key,
|
||||||
bool colvarparse::get_keyval(std::string const &conf, \
|
std::vector<TYPE> &values,
|
||||||
char const *key, \
|
std::vector<TYPE> const &def_values,
|
||||||
std::vector<TYPE> &values, \
|
Parse_Mode const parse_mode)
|
||||||
std::vector<TYPE> const &def_values, \
|
{
|
||||||
Parse_Mode const parse_mode) \
|
std::string data;
|
||||||
{ \
|
bool b_found = false, b_found_any = false;
|
||||||
std::string data; \
|
size_t save_pos = 0, found_count = 0;
|
||||||
bool b_found = false, b_found_any = false; \
|
|
||||||
size_t save_pos = 0, found_count = 0; \
|
do {
|
||||||
\
|
std::string data_this = "";
|
||||||
do { \
|
b_found = key_lookup(conf, key, data_this, save_pos);
|
||||||
std::string data_this = ""; \
|
if (b_found) {
|
||||||
b_found = key_lookup(conf, key, data_this, save_pos); \
|
if (!b_found_any)
|
||||||
if (b_found) { \
|
b_found_any = true;
|
||||||
if (!b_found_any) \
|
found_count++;
|
||||||
b_found_any = true; \
|
data = data_this;
|
||||||
found_count++; \
|
}
|
||||||
data = data_this; \
|
} while (b_found);
|
||||||
} \
|
|
||||||
} while (b_found); \
|
if (found_count > 1)
|
||||||
\
|
cvm::log("Warning: found more than one instance of \""+
|
||||||
if (found_count > 1) \
|
std::string(key)+"\".\n");
|
||||||
cvm::log("Warning: found more than one instance of \""+ \
|
|
||||||
std::string(key)+"\".\n"); \
|
if (data.size()) {
|
||||||
\
|
std::istringstream is(data);
|
||||||
if (data.size()) { \
|
|
||||||
std::istringstream is(data); \
|
if (values.size() == 0) {
|
||||||
\
|
|
||||||
if (values.size() == 0) { \
|
std::vector<TYPE> x;
|
||||||
\
|
if (def_values.size())
|
||||||
std::vector<TYPE> x; \
|
x = def_values;
|
||||||
if (def_values.size()) \
|
else
|
||||||
x = def_values; \
|
x.assign(1, TYPE());
|
||||||
else \
|
|
||||||
x.assign(1, TYPE()); \
|
for (size_t i = 0;
|
||||||
\
|
( is >> x[ ((i<x.size()) ? i : x.size()-1) ] );
|
||||||
for (size_t i = 0; \
|
i++) {
|
||||||
( is >> x[ ((i<x.size()) ? i : x.size()-1) ] ); \
|
values.push_back(x[ ((i<x.size()) ? i : x.size()-1) ]);
|
||||||
i++) { \
|
}
|
||||||
values.push_back(x[ ((i<x.size()) ? i : x.size()-1) ]); \
|
|
||||||
} \
|
} else {
|
||||||
\
|
|
||||||
} else { \
|
size_t i = 0;
|
||||||
\
|
for ( ; i < values.size(); i++) {
|
||||||
size_t i = 0; \
|
TYPE x(values[i]);
|
||||||
for ( ; i < values.size(); i++) { \
|
if (is >> x) {
|
||||||
TYPE x(values[i]); \
|
values[i] = x;
|
||||||
if (is >> x) { \
|
} else {
|
||||||
values[i] = x; \
|
cvm::error("Error: in parsing \""+
|
||||||
} else { \
|
std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: in parsing \""+ \
|
}
|
||||||
std::string(key)+"\".\n", INPUT_ERROR); \
|
}
|
||||||
} \
|
}
|
||||||
} \
|
|
||||||
} \
|
if (parse_mode != parse_silent) {
|
||||||
\
|
cvm::log("# "+std::string(key)+" = "+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(values)+"\n");
|
||||||
cvm::log("# "+std::string(key)+" = "+ \
|
}
|
||||||
cvm::to_str(values)+"\n"); \
|
|
||||||
} \
|
} else {
|
||||||
\
|
|
||||||
} else { \
|
if (b_found_any) {
|
||||||
\
|
cvm::error("Error: improper or missing values for \""+
|
||||||
if (b_found_any) { \
|
std::string(key)+"\".\n", INPUT_ERROR);
|
||||||
cvm::error("Error: improper or missing values for \""+ \
|
}
|
||||||
std::string(key)+"\".\n", INPUT_ERROR); \
|
|
||||||
} \
|
for (size_t i = 0; i < values.size(); i++)
|
||||||
\
|
values[i] = def_values[ (i > def_values.size()) ? 0 : i ];
|
||||||
for (size_t i = 0; i < values.size(); i++) \
|
|
||||||
values[i] = def_values[ (i > def_values.size()) ? 0 : i ]; \
|
if (parse_mode != parse_silent) {
|
||||||
\
|
cvm::log("# "+std::string(key)+" = "+
|
||||||
if (parse_mode != parse_silent) { \
|
cvm::to_str(def_values)+" [default]\n");
|
||||||
cvm::log("# "+std::string(key)+" = "+ \
|
}
|
||||||
cvm::to_str(def_values)+" [default]\n"); \
|
}
|
||||||
} \
|
|
||||||
} \
|
return b_found_any;
|
||||||
\
|
|
||||||
return b_found_any; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// single-value keyword parsers
|
// single-value keyword parsers
|
||||||
|
|
||||||
_get_keyval_scalar_(int);
|
|
||||||
_get_keyval_scalar_(size_t);
|
|
||||||
_get_keyval_scalar_(long);
|
|
||||||
_get_keyval_scalar_string_(std::string);
|
|
||||||
_get_keyval_scalar_(cvm::real);
|
|
||||||
_get_keyval_scalar_(cvm::rvector);
|
|
||||||
_get_keyval_scalar_(cvm::quaternion);
|
|
||||||
_get_keyval_scalar_(colvarvalue);
|
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
int &value,
|
||||||
|
int const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<int>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
// multiple-value keyword parsers
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
size_t &value,
|
||||||
|
size_t const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<size_t>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
_get_keyval_vector_(int);
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
_get_keyval_vector_(size_t);
|
char const *key,
|
||||||
_get_keyval_vector_(long);
|
long &value,
|
||||||
_get_keyval_vector_(std::string);
|
long const &def_value,
|
||||||
_get_keyval_vector_(cvm::real);
|
Parse_Mode const parse_mode)
|
||||||
_get_keyval_vector_(cvm::rvector);
|
{
|
||||||
_get_keyval_vector_(cvm::quaternion);
|
return _get_keyval_scalar_<long>(conf, key, value, def_value, parse_mode);
|
||||||
_get_keyval_vector_(colvarvalue);
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::string &value,
|
||||||
|
std::string const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_string_(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::real &value,
|
||||||
|
cvm::real const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<cvm::real>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::rvector &value,
|
||||||
|
cvm::rvector const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<cvm::rvector>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::quaternion &value,
|
||||||
|
cvm::quaternion const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<cvm::quaternion>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
colvarvalue &value,
|
||||||
|
colvarvalue const &def_value,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_scalar_<colvarvalue>(conf, key, value, def_value, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool colvarparse::get_keyval(std::string const &conf,
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
@ -309,6 +354,81 @@ bool colvarparse::get_keyval(std::string const &conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// multiple-value keyword parsers
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<int> &values,
|
||||||
|
std::vector<int> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<int>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<size_t> &values,
|
||||||
|
std::vector<size_t> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<size_t>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<long> &values,
|
||||||
|
std::vector<long> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<long>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<std::string> &values,
|
||||||
|
std::vector<std::string> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<std::string>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::real> &values,
|
||||||
|
std::vector<cvm::real> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<cvm::real>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::rvector> &values,
|
||||||
|
std::vector<cvm::rvector> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<cvm::rvector>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::quaternion> &values,
|
||||||
|
std::vector<cvm::quaternion> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<cvm::quaternion>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool colvarparse::get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<colvarvalue> &values,
|
||||||
|
std::vector<colvarvalue> const &def_values,
|
||||||
|
Parse_Mode const parse_mode)
|
||||||
|
{
|
||||||
|
return _get_keyval_vector_<colvarvalue>(conf, key, values, def_values, parse_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void colvarparse::add_keyword(char const *key)
|
void colvarparse::add_keyword(char const *key)
|
||||||
{
|
{
|
||||||
for (std::list<std::string>::iterator ki = allowed_keywords.begin();
|
for (std::list<std::string>::iterator ki = allowed_keywords.begin();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARPARSE_H
|
#ifndef COLVARPARSE_H
|
||||||
#define COLVARPARSE_H
|
#define COLVARPARSE_H
|
||||||
@ -104,40 +104,113 @@ public:
|
|||||||
/// functions, or insert this type in the \link colvarvalue \endlink
|
/// functions, or insert this type in the \link colvarvalue \endlink
|
||||||
/// wrapper class (colvarvalue.h).
|
/// wrapper class (colvarvalue.h).
|
||||||
|
|
||||||
#define _get_keyval_scalar_proto_(_type_,_def_value_) \
|
bool get_keyval(std::string const &conf,
|
||||||
bool get_keyval(std::string const &conf, \
|
char const *key,
|
||||||
char const *key, \
|
int &value,
|
||||||
_type_ &value, \
|
int const &def_value = (int)0,
|
||||||
_type_ const &def_value = _def_value_, \
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
Parse_Mode const parse_mode = parse_normal)
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
size_t &value,
|
||||||
|
size_t const &def_value = (size_t)0,
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
long &value,
|
||||||
|
long const &def_value = 0,
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::string &value,
|
||||||
|
std::string const &def_value = std::string(""),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::real &value,
|
||||||
|
cvm::real const &def_value = (cvm::real)0.0,
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::rvector &value,
|
||||||
|
cvm::rvector const &def_value = cvm::rvector(),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
cvm::quaternion &value,
|
||||||
|
cvm::quaternion const &def_value = cvm::quaternion(),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
colvarvalue &value,
|
||||||
|
colvarvalue const &def_value = colvarvalue(colvarvalue::type_notset),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
bool &value,
|
||||||
|
bool const &def_value = false,
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
|
||||||
_get_keyval_scalar_proto_(int, (int)0);
|
bool get_keyval(std::string const &conf,
|
||||||
_get_keyval_scalar_proto_(size_t, (size_t)0);
|
char const *key,
|
||||||
_get_keyval_scalar_proto_(long, 0);
|
std::vector<int> &values,
|
||||||
_get_keyval_scalar_proto_(std::string, std::string(""));
|
std::vector<int> const &def_values = std::vector<int>(0, (int)0),
|
||||||
_get_keyval_scalar_proto_(cvm::real, (cvm::real)0.0);
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
_get_keyval_scalar_proto_(cvm::rvector, cvm::rvector());
|
bool get_keyval(std::string const &conf,
|
||||||
_get_keyval_scalar_proto_(cvm::quaternion, cvm::quaternion());
|
char const *key,
|
||||||
_get_keyval_scalar_proto_(colvarvalue, colvarvalue(colvarvalue::type_notset));
|
std::vector<size_t> &values,
|
||||||
_get_keyval_scalar_proto_(bool, false);
|
std::vector<size_t> const &def_values = std::vector<size_t>(0, (size_t)0),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<long> &values,
|
||||||
|
std::vector<long> const &def_values = std::vector<long>(0, (long)0),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<std::string> &values,
|
||||||
|
std::vector<std::string> const &def_values = std::vector<std::string>(0, std::string("")),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::real> &values,
|
||||||
|
std::vector<cvm::real> const &def_values = std::vector<cvm::real>(0, (cvm::real)0.0),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::rvector> &values,
|
||||||
|
std::vector<cvm::rvector> const &def_values = std::vector<cvm::rvector>(0, cvm::rvector()),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<cvm::quaternion> &values,
|
||||||
|
std::vector<cvm::quaternion> const &def_values = std::vector<cvm::quaternion>(0, cvm::quaternion()),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
bool get_keyval(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<colvarvalue> &values,
|
||||||
|
std::vector<colvarvalue> const &def_values = std::vector<colvarvalue>(0, colvarvalue(colvarvalue::type_notset)),
|
||||||
|
Parse_Mode const parse_mode = parse_normal);
|
||||||
|
|
||||||
#define _get_keyval_vector_proto_(_type_,_def_value_) \
|
protected:
|
||||||
bool get_keyval(std::string const &conf, \
|
|
||||||
char const *key, \
|
|
||||||
std::vector<_type_> &values, \
|
|
||||||
std::vector<_type_> const &def_values = \
|
|
||||||
std::vector<_type_> (0, static_cast<_type_>(_def_value_)), \
|
|
||||||
Parse_Mode const parse_mode = parse_normal)
|
|
||||||
|
|
||||||
_get_keyval_vector_proto_(int, 0);
|
// Templates
|
||||||
_get_keyval_vector_proto_(size_t, 0);
|
template<typename TYPE> bool _get_keyval_scalar_(std::string const &conf,
|
||||||
_get_keyval_vector_proto_(long, 0);
|
char const *key,
|
||||||
_get_keyval_vector_proto_(std::string, std::string(""));
|
TYPE &value,
|
||||||
_get_keyval_vector_proto_(cvm::real, 0.0);
|
TYPE const &def_value,
|
||||||
_get_keyval_vector_proto_(cvm::rvector, cvm::rvector());
|
Parse_Mode const parse_mode);
|
||||||
_get_keyval_vector_proto_(cvm::quaternion, cvm::quaternion());
|
bool _get_keyval_scalar_string_(std::string const &conf,
|
||||||
_get_keyval_vector_proto_(colvarvalue, colvarvalue(colvarvalue::type_notset));
|
char const *key,
|
||||||
|
std::string &value,
|
||||||
|
std::string const &def_value,
|
||||||
|
Parse_Mode const parse_mode);
|
||||||
|
|
||||||
|
template<typename TYPE> bool _get_keyval_vector_(std::string const &conf,
|
||||||
|
char const *key,
|
||||||
|
std::vector<TYPE> &values,
|
||||||
|
std::vector<TYPE> const &def_values,
|
||||||
|
Parse_Mode const parse_mode);
|
||||||
|
public:
|
||||||
|
|
||||||
/// \brief Check that all the keywords within "conf" are in the list
|
/// \brief Check that all the keywords within "conf" are in the list
|
||||||
/// of allowed keywords; this will invoke strip_values() first and
|
/// of allowed keywords; this will invoke strip_values() first and
|
||||||
@ -184,13 +257,12 @@ public:
|
|||||||
static std::string const white_space;
|
static std::string const white_space;
|
||||||
|
|
||||||
/// \brief Low-level function for parsing configuration strings;
|
/// \brief Low-level function for parsing configuration strings;
|
||||||
/// automatically adds the requested keywords to the list of valid
|
/// automatically adds the requested keyword to the list of valid
|
||||||
/// ones. \param conf the content of the configuration file or one
|
/// ones. \param conf the content of the configuration file or one
|
||||||
/// of its blocks \param key the keyword to search in "conf" \param
|
/// of its blocks \param key the keyword to search within "conf" \param
|
||||||
/// data (optional) holds the string provided after "key", if any
|
/// data (optional) holds the string provided after "key", if any
|
||||||
/// \param save_pos (optional) stores the position of the keyword
|
/// \param save_pos (optional) stores the position of the keyword
|
||||||
/// within "conf", useful when doing multiple calls \param
|
/// within "conf", useful when doing multiple calls
|
||||||
/// save_delimiters (optional)
|
|
||||||
bool key_lookup(std::string const &conf,
|
bool key_lookup(std::string const &conf,
|
||||||
char const *key,
|
char const *key,
|
||||||
std::string &data = dummy_string,
|
std::string &data = dummy_string,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARPROXY_H
|
#ifndef COLVARPROXY_H
|
||||||
#define COLVARPROXY_H
|
#define COLVARPROXY_H
|
||||||
|
|||||||
@ -295,6 +295,11 @@ int colvarscript::proc_colvar(int argc, char const *argv[]) {
|
|||||||
return COLVARS_OK;
|
return COLVARS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (subcmd == "state") {
|
||||||
|
cv->print_state();
|
||||||
|
return COLVARS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
result = "Syntax error\n" + help_string();
|
result = "Syntax error\n" + help_string();
|
||||||
return COLVARSCRIPT_ERROR;
|
return COLVARSCRIPT_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARSCRIPT_H
|
#ifndef COLVARSCRIPT_H
|
||||||
#define COLVARSCRIPT_H
|
#define COLVARSCRIPT_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARTYPES_H
|
#ifndef COLVARTYPES_H
|
||||||
#define COLVARTYPES_H
|
#define COLVARTYPES_H
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/// -*- c++ -*-
|
// -*- c++ -*-
|
||||||
|
|
||||||
#ifndef COLVARVALUE_H
|
#ifndef COLVARVALUE_H
|
||||||
#define COLVARVALUE_H
|
#define COLVARVALUE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user