Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
colvar Class Reference

A collective variable (main class); to be defined, it needs at least one object of a derived class of colvar::cvc; it calculates and returns a colvarvalue object. More...

#include <colvar.h>

Inheritance diagram for colvar:
Inheritance graph
[legend]
Collaboration diagram for colvar:
Collaboration graph
[legend]

Classes

class  alch_Flambda
 
class  alch_lambda
 
class  alpha_angles
 Colvar component: alpha helix content of a contiguous segment of 5 or more residues, implemented as a sum of Ca-Ca-Ca angles and hydrogen bonds (colvarvalue::type_scalar type, range [0:1]) More...
 
class  angle
 Colvar component: angle between the centers of mass of three groups (colvarvalue::type_scalar type, range [0:PI]) More...
 
class  aspath
 
class  aspathCV
 
class  azpath
 
class  azpathCV
 
class  cartesian
 
class  CartesianBasedPath
 
class  coordnum
 Colvar component: coordination number between two groups (colvarvalue::type_scalar type, range [0:N1*N2]) More...
 
class  customColvar
 custom expression of colvars More...
 
class  CVBasedPath
 
class  cvc
 Colvar component (base class for collective variables) More...
 
class  dihedPC
 Colvar component: dihedPC Projection of the config onto a dihedral principal component See e.g. Altis et al., J. Chem. Phys 126, 244111 (2007) Based on a set of 'dihedral' cvcs. More...
 
class  dihedral
 Colvar component: dihedral between the centers of mass of four groups (colvarvalue::type_scalar type, range [-PI:PI]) More...
 
class  dipole_angle
 Colvar component: angle between the dipole of a molecule and an axis formed by two groups of atoms(colvarvalue::type_scalar type, range [0:PI]) More...
 
class  dipole_magnitude
 Colvar component: dipole magnitude of a molecule. More...
 
class  distance
 Colvar component: distance between the centers of mass of two groups (colvarvalue::type_scalar type, range [0:*)) More...
 
class  distance_dir
 Colvar component: distance unit vector (direction) between centers of mass of two groups (colvarvalue::type_unit3vector type, range [-1:1]x[-1:1]x[-1:1]) More...
 
class  distance_inv
 Colvar component: average distance between two groups of atoms, weighted as the sixth power, as in NMR refinements(colvarvalue::type_scalar type, range (0:*)) More...
 
class  distance_pairs
 Colvar component: N1xN2 vector of pairwise distances (colvarvalue::type_vector type, range (0:*) for each component) More...
 
class  distance_vec
 
class  distance_xy
 Colvar component: projection of the distance vector on a plane (colvarvalue::type_scalar type, range [0:*)) More...
 
class  distance_z
 Colvar component: projection of the distance vector along an axis(colvarvalue::type_scalar type, range (-*:*)) More...
 
class  eigenvector
 Colvar component: projection of 3N coordinates onto an eigenvector(colvarvalue::type_scalar type, range (-*:*)) More...
 
class  euler_phi
 
class  euler_psi
 
class  euler_theta
 
class  groupcoordnum
 Colvar component: coordination number between two groups (colvarvalue::type_scalar type, range [0:N1*N2]) More...
 
class  gspath
 Colvar component: alternative path collective variable using geometry, variable s For more information see https://plumed.github.io/doc-v2.5/user-doc/html/_p_a_t_h.html Diaz Leines, G.; Ensing, B. Path Finding on High-Dimensional Free Energy Landscapes. Phys. Rev. Lett. 2012, 109 (2), 020601. https://doi.org/10.1103/PhysRevLett.109.020601. More...
 
class  gspathCV
 Colvar component: alternative path collective variable using geometry, variable s Allow any combination of existing (scalar) CVs For more information see https://plumed.github.io/doc-v2.5/user-doc/html/_p_a_t_h.html Diaz Leines, G.; Ensing, B. Path Finding on High-Dimensional Free Energy Landscapes. Phys. Rev. Lett. 2012, 109 (2), 020601. https://doi.org/10.1103/PhysRevLett.109.020601. More...
 
class  gyration
 Colvar component: Radius of gyration of an atom group (colvarvalue::type_scalar type, range [0:*)) More...
 
class  gzpath
 Colvar component: alternative path collective variable using geometry, variable z This should be merged with gspath in the same class by class inheritance or something else. More...
 
class  gzpathCV
 
class  h_bond
 Colvar component: hydrogen bond, defined as the product of a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol)) (colvarvalue::type_scalar type, range [0:1]) More...
 
class  inertia
 Colvar component: moment of inertia of an atom group (colvarvalue::type_scalar type, range [0:*)) More...
 
class  inertia_z
 Colvar component: moment of inertia of an atom group around a user-defined axis (colvarvalue::type_scalar type, range [0:*)) More...
 
class  linearCombination
 Current only linear combination of sub-CVCs is available. More...
 
class  map_total
 
class  neuralNetwork
 
class  orientation
 Colvar component: orientation in space of an atom group, with respect to a set of reference coordinates (colvarvalue::type_quaternion type, range [-1:1]x[-1:1]x[-1:1]x[-1:1]) More...
 
class  orientation_angle
 
class  orientation_proj
 Colvar component: cosine of the angle of rotation with respect to a set of reference coordinates (colvarvalue::type_scalar type, range [-1:1]) More...
 
class  polar_phi
 Colvar component: polar coordinate phi of a group (colvarvalue::type_scalar type, range [-180:180]) More...
 
class  polar_theta
 Colvar component: polar coordinate theta of a group (colvarvalue::type_scalar type, range [0:180]) More...
 
class  rmsd
 Colvar component: root mean square deviation (RMSD) of a group with respect to a set of reference coordinates; uses colvar::orientation to calculate the rotation matrix (colvarvalue::type_scalar type, range [0:*)) More...
 
class  selfcoordnum
 Colvar component: self-coordination number within a group (colvarvalue::type_scalar type, range [0:N*(N-1)/2]) More...
 
class  spin_angle
 Colvar component: angle of rotation around a predefined axis (colvarvalue::type_scalar type, range [-PI:PI]) More...
 
class  tilt
 Colvar component: projection of the orientation vector onto a predefined axis (colvarvalue::type_scalar type, range [-1:1]) More...
 
class  torchANN
 

Public Member Functions

colvarvalue const & value () const
 Current value (previously set by calc() or by read_traj())
 
colvarvalue const & actual_value () const
 Current actual value (not extended DOF)
 
colvarvalue const & run_ave () const
 Current running average (if calculated as set by analysis flag)
 
cvm::real const & force_constant () const
 Force constant of the spring.
 
colvarvalue const & velocity () const
 Current velocity (previously set by calc() or by read_traj())
 
colvarvalue const & total_force () const
 Current total force (previously obtained from calc() or read_traj()). Note: this is calculated using the atomic forces from the last simulation step. More...
 
virtual const std::vector< feature * > & features () const
 Implementation of the feature list accessor for colvar. More...
 
virtual std::vector< feature * > & modify_features ()
 
void do_feature_side_effects (int id)
 
bool periodic_boundaries () const
 Is the interval defined by the two boundaries periodic?
 
bool periodic_boundaries (colvarvalue const &lb, colvarvalue const &ub) const
 Is the interval defined by the two boundaries periodic?
 
 colvar ()
 Constructor.
 
int init (std::string const &conf)
 Main init function.
 
void define_component_types ()
 Populate the map of available CVC types.
 
int init_components (std::string const &conf)
 Parse the CVC configuration and allocate their data.
 
int init_custom_function (std::string const &conf)
 Parse parameters for custom function with Lepton.
 
int init_grid_parameters (std::string const &conf)
 Init defaults for grid options.
 
int check_grid_parameters ()
 Consistency check for the grid paramaters.
 
int parse_legacy_wall_params (std::string const &conf)
 Read legacy wall keyword (these are biases now)
 
int init_extended_Lagrangian (std::string const &conf)
 Init extended Lagrangian parameters.
 
int init_output_flags (std::string const &conf)
 Init output flags.
 
virtual int init_dependencies ()
 Initialize dependency tree. More...
 
void setup ()
 Get ready for a run and re-initialize internal data if needed.
 
 ~colvar ()
 Destructor.
 
int calc ()
 Calculate the colvar's value and related quantities.
 
int end_of_step ()
 Carry out operations needed before next step is run.
 
int calc_cvcs (int first=0, size_t num_cvcs=0)
 Calculate a subset of the colvar components (CVCs) currently active (default: all active CVCs) Note: both arguments refer to the sect of active CVCs, not all CVCs.
 
int check_cvc_range (int first_cvc, size_t num_cvcs)
 Ensure that the selected range of CVCs is consistent.
 
int calc_cvc_values (int first, size_t num_cvcs)
 Calculate the values of the given subset of CVCs.
 
int calc_cvc_gradients (int first, size_t num_cvcs)
 Same as colvar::calc_cvc_values but for gradients.
 
int calc_cvc_total_force (int first, size_t num_cvcs)
 Same as colvar::calc_cvc_values but for total forces.
 
int calc_cvc_Jacobians (int first, size_t num_cvcs)
 Same as colvar::calc_cvc_values but for Jacobian derivatives/forces.
 
int collect_cvc_data ()
 Collect quantities from CVCs and update aggregated data for the colvar.
 
int collect_cvc_values ()
 Collect the values of the CVCs.
 
int collect_cvc_gradients ()
 Same as colvar::collect_cvc_values but for gradients.
 
int collect_cvc_total_forces ()
 Same as colvar::collect_cvc_values but for total forces.
 
int collect_cvc_Jacobians ()
 Same as colvar::collect_cvc_values but for Jacobian derivatives/forces.
 
int calc_colvar_properties ()
 Calculate the quantities associated to the colvar (but not to the CVCs)
 
colvarvalue const applied_force () const
 Get the current applied force.
 
void reset_bias_force ()
 Set the total biasing force to zero.
 
void add_bias_force (colvarvalue const &force)
 Add to the total force from biases.
 
void add_bias_force_actual_value (colvarvalue const &force)
 Apply a force to the actual value (only meaningful with extended Lagrangian)
 
cvm::real update_forces_energy ()
 Collect all forces on this colvar, integrate internal equations of motion of internal degrees of freedom; see also colvar::communicate_forces() return colvar energy if extended Lagrandian active.
 
void update_extended_Lagrangian ()
 Integrate equations of motion of extended Lagrangian coordinate if needed.
 
void communicate_forces ()
 Communicate forces (previously calculated in colvar::update()) to the external degrees of freedom.
 
int set_cvc_flags (std::vector< bool > const &flags)
 Enables and disables individual CVCs based on the given array.
 
int update_cvc_flags ()
 Updates the flags in the CVC objects, and their number.
 
int update_cvc_config (std::vector< std::string > const &confs)
 Modify the configuration of CVCs (currently, only base class data)
 
int cvc_param_exists (std::string const &param_name)
 Whether this named parameter exists (in the first and only component)
 
cvm::real get_cvc_param (std::string const &param_name)
 Get the value of the named parameter (from the first and only component)
 
void const * get_cvc_param_ptr (std::string const &param_name)
 Get a pointer to the named parameter (from the first and only component)
 
colvarvalue const * get_cvc_param_grad (std::string const &param_name)
 Pointer to the derivative of the variable with respect to param_name.
 
int set_cvc_param (std::string const &param_name, void const *new_value)
 Set the named parameter in the first and only component to the given value.
 
size_t num_dimensions () const
 Number of dimensions of the value of this colvar.
 
size_t num_cvcs () const
 Number of CVC objects defined.
 
size_t num_active_cvcs () const
 number of CVC objects with an active flag (as set by update_cvc_flags)
 
cvm::real dist2 (colvarvalue const &x1, colvarvalue const &x2) const
 Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients. More...
 
colvarvalue dist2_lgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients. More...
 
colvarvalue dist2_rgrad (colvarvalue const &x1, colvarvalue const &x2) const
 Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients. More...
 
void wrap (colvarvalue &x_unwrapped) const
 Use the internal metrics (as from colvar::cvc objects) to wrap a value into a standard interval. More...
 
int parse_analysis (std::string const &conf)
 Read the analysis tasks.
 
int analyze ()
 Perform analysis tasks.
 
std::istream & read_traj (std::istream &is)
 Read the value from a collective variable trajectory file.
 
std::ostream & write_traj (std::ostream &os)
 Output formatted values to the trajectory file.
 
std::ostream & write_traj_label (std::ostream &os)
 Write a label to the trajectory file (comment line)
 
std::istream & read_state (std::istream &is)
 Read the colvar's state from a formatted input stream.
 
cvm::memory_streamread_state (cvm::memory_stream &is)
 Read the colvar's state from an unformatted input stream.
 
int check_matching_state (std::string const &state_conf)
 Check the name of the bias vs. the given string, set the matching_state flag accordingly.
 
int set_state_params (std::string const &state_conf)
 Read the values of colvar mutable data from a string (used by both versions of read_state())
 
std::string const get_state_params () const
 Write the state information of this colvar in a block of text, suitable for later parsing.
 
std::ostream & write_state (std::ostream &os) const
 Write the colvar's state to a formatted output stream.
 
cvm::memory_streamwrite_state (cvm::memory_stream &os) const
 Write the colvar's state to an unformatted output stream.
 
int write_output_files ()
 Write output files (if defined, e.g. in analysis mode)
 
virtual std::vector< std::vector< int > > get_atom_lists ()
 Get vector of vectors of atom IDs for all atom groups.
 
std::vector< int > const & get_volmap_ids ()
 Volmap numeric IDs, one for each CVC (-1 if not available)
 
- Public Member Functions inherited from colvarparse
 colvarparse ()
 Default constructor.
 
 colvarparse (const std::string &conf)
 Constructor that stores the object's config string.
 
void clear ()
 Set the object ready to parse a new configuration string.
 
void set_string (std::string const &conf)
 Set a new config string for this object.
 
 ~colvarparse () override
 Default destructor.
 
std::string const & get_config () const
 Get the configuration string (includes comments)
 
int check_keywords (std::string &conf, char const *key)
 Check that all the keywords within "conf" are in the list of allowed keywords; this will invoke strip_values() first and then loop over all words.
 
void clear_keyword_registry ()
 Use this after parsing a config string (note that check_keywords() calls it already)
 
bool get_keyval (std::string const &conf, char const *key, int &value, int const &def_value=0, 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=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, cvm::step_number &value, cvm::step_number 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=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)
 
bool get_keyval (std::string const &conf, char const *key, std::vector< int > &values, std::vector< int > const &def_values=std::vector< int >(0, 0), Parse_Mode const parse_mode=parse_normal)
 
bool get_keyval (std::string const &conf, char const *key, std::vector< size_t > &values, std::vector< size_t > const &def_values=std::vector< size_t >(0, 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, 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, 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)
 
bool key_lookup (std::string const &conf, char const *key, std::string *data=nullptr, size_t *save_pos=nullptr)
 Low-level function for parsing configuration strings; automatically adds the requested keyword to the list of valid ones. More...
 
std::istream & read_config_line (std::istream &is, std::string &line)
 Reads a configuration line, adds it to config_string, and returns the stream. More...
 
template<>
int _get_keyval_scalar_value_ (std::string const &key_str, std::string const &data, bool &value, bool const &)
 
template<>
int _get_keyval_scalar_novalue_ (std::string const &key_str, bool &value, Parse_Mode const &parse_mode)
 
- Public Member Functions inherited from colvarparams
int param_exists (std::string const &param_name)
 Whether the parameter param_name exists.
 
virtual std::vector< std::string > get_param_names ()
 Get a copy of the names of registered parameters.
 
virtual std::vector< std::string > get_param_grad_names ()
 Get a copy of the names of registered parameter gradients.
 
virtual void const * get_param_ptr (std::string const &param_name)
 Pointer to the parameter param_name.
 
virtual void const * get_param_grad_ptr (std::string const &param_name)
 Pointer to the gradient of parameter param_name.
 
virtual cvm::real get_param (std::string const &param_name)
 Value of the parameter param_name (must be a scalar)
 
virtual int set_param (std::string const &param_name, void const *new_value)
 Set the named parameter to the given value. More...
 
- Public Member Functions inherited from colvardeps
int get_time_step_factor () const
 returns time_step_factor
 
void init_feature (int feature_id, const char *description, feature_type type)
 Pair a numerical feature ID with a description and type.
 
bool is_not_set (int id)
 
bool is_dynamic (int id)
 
bool is_static (int id)
 
bool is_user (int id)
 
virtual const std::vector< feature * > & features () const =0
 
virtual std::vector< feature * > & modify_features ()=0
 
void add_child (colvardeps *child)
 
void remove_child (colvardeps *child)
 
void remove_all_children ()
 
bool is_enabled (int f=f_cv_active) const
 
bool is_available (int f=f_cv_active) const
 
void provide (int feature_id, bool truefalse=true)
 
void set_enabled (int feature_id, bool truefalse=true)
 Enable or disable, depending on flag value.
 
int enable (int f, bool dry_run=false, bool toplevel=true)
 
int disable (int f)
 
void free_children_deps ()
 
void restore_children_deps ()
 re-enable children features (to be used when object becomes active)
 
int decr_ref_count (int f)
 
virtual void do_feature_side_effects (int)
 
virtual int init_dependencies ()=0
 Initialize dependency tree for object of a derived class. More...
 
void require_feature_self (int f, int g)
 Make feature f require feature g within the same object.
 
void exclude_feature_self (int f, int g)
 Make features f and g mutually exclusive within the same object.
 
void require_feature_children (int f, int g)
 Make feature f require feature g within children.
 
void require_feature_alt (int f, int g, int h)
 Make feature f require either g or h within the same object.
 
void require_feature_alt (int f, int g, int h, int i)
 Make feature f require any of g, h, or i within the same object.
 
void require_feature_alt (int f, int g, int h, int i, int j)
 Make feature f require any of g, h, i, or j within the same object.
 
void print_state ()
 print all enabled features and those of children, for debugging
 
void check_enabled (int f, std::string const &reason) const
 Check that a feature is enabled, raising COLVARS_BUG_ERROR if not.
 

Static Public Member Functions

static void delete_features ()
 
static const std::map< std::string, std::function< colvar::cvc *()> > & get_global_cvc_map ()
 A global mapping of cvc names to the cvc constructors.
 
static bool compare_cvc (const colvar::cvc *const i, const colvar::cvc *const j)
 function for sorting cvcs by their names More...
 
- Static Public Member Functions inherited from colvarparse
static std::string to_lower_cppstr (std::string const &in)
 Return a lowercased copy of the string.
 
static std::istream & getline_nocomments (std::istream &is, std::string &s)
 Works as std::getline() but also removes everything between a comment character and the following newline.
 
static int check_braces (std::string const &conf, size_t const start_pos)
 Check if the content of a config string has matching braces. More...
 
static int check_ascii (std::string const &conf)
 Check that a config string contains non-ASCII characters. More...
 
static void split_string (const std::string &data, const std::string &delim, std::vector< std::string > &dest)
 Split a string with a specified delimiter into a vector. More...
 

Public Attributes

std::string name
 Name.
 
cvm::real width = 1.0
 Typical fluctuation amplitude for this collective variable (e.g. local width of a free energy basin) More...
 
std::vector< colvarbias * > biases
 List of biases that depend on this colvar.
 
colvarvalue fb
 Bias force; reset_bias_force() should be called before the biases are updated.
 
colvarvalue fb_actual
 Bias force to the actual value (only useful with extended Lagrangian)
 
colvarvalue f
 Total applied force; fr (if extended_lagrangian is defined), fb (if biases are applied) and the walls' forces (if defined) contribute to it.
 
colvarvalue f_old
 Applied force at the previous step (to be subtracted from total force if needed)
 
colvarvalue ft
 Total force, as derived from the atomic trajectory; should equal the system force plus f.
 
cvm::real period = 0.0
 Period, if this variable is periodic.
 
cvm::real wrap_center = 0.0
 Center of wrapping, if this variable is periodic.
 
bool expand_boundaries = false
 Expand the boundaries of multiples of width, to keep the value always within range.
 
colvarvalue lower_boundary
 Location of the lower boundary.
 
colvarvalue upper_boundary
 Location of the upper boundary.
 
std::vector< int > atom_ids
 Sorted array of (zero-based) IDs for all atoms involved.
 
std::vector< cvm::rvectoratomic_gradients
 Array of atomic gradients collected from all cvcs with appropriate components, rotations etc. For scalar variables only!
 
- Public Attributes inherited from colvardeps
std::string description
 

Static Public Attributes

static std::vector< feature * > cv_features
 Implementation of the feature list for colvar.
 
- Static Public Attributes inherited from colvarparse
static const char *const white_space = " \t"
 Accepted white space delimiters, used in key_lookup()
 

Protected Types

enum  acf_type_e { acf_notset , acf_vel , acf_coor , acf_p2coor }
 Type of autocorrelation function (ACF) More...
 
- Protected Types inherited from colvarparse
enum  key_set_mode { key_not_set = 0 , key_set_user = 1 , key_set_default = 2 }
 How a keyword has been set.
 
- Protected Types inherited from colvardeps
enum  feature_type { f_type_not_set , f_type_dynamic , f_type_user , f_type_static }
 Enum of possible feature types.
 

Protected Member Functions

colvarvalue fdiff_velocity (colvarvalue const &xold, colvarvalue const &xnew)
 
void update_active_cvc_square_norm ()
 Update the sum of square coefficients for active cvcs.
 
void calc_vel_acf (std::list< colvarvalue > &v_history, colvarvalue const &v)
 Velocity ACF, scalar product between v(0) and v(t)
 
void calc_coor_acf (std::list< colvarvalue > &x_history, colvarvalue const &x)
 Coordinate ACF, scalar product between x(0) and x(t) (does not work with scalar numbers)
 
void calc_p2coor_acf (std::list< colvarvalue > &x_history, colvarvalue const &x)
 Coordinate ACF, second order Legendre polynomial between x(0) and x(t) (does not work with scalar numbers)
 
int calc_acf ()
 Calculate the auto-correlation function (ACF)
 
int write_acf (std::ostream &os)
 Save the ACF to a file.
 
int calc_runave ()
 Calculate the running average and its standard deviation.
 
void build_atom_list (void)
 Initialize the sorted list of atom IDs for atoms involved in all cvcs (called when enabling f_cv_collect_gradients)
 
- Protected Member Functions inherited from colvarparse
bool get_key_string_value (std::string const &conf, char const *key, std::string &data)
 Get the string value of a keyword, and save it for later parsing.
 
bool get_key_string_multi_value (std::string const &conf, char const *key, std::vector< std::string > &data)
 Get multiple strings from repeated instances of a same keyword.
 
template<typename TYPE >
bool _get_keyval_scalar_ (std::string const &conf, char const *key, TYPE &value, TYPE const &def_value, Parse_Mode const &parse_mode)
 Template for single-value keyword parsers.
 
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)
 Template for multiple-value keyword parsers.
 
template<typename TYPE >
int _get_keyval_scalar_value_ (std::string const &key_str, std::string const &data, TYPE &value, TYPE const &def_value)
 Extract the value of a variable from a string.
 
template<typename TYPE >
int _get_keyval_scalar_novalue_ (std::string const &key_str, TYPE &value, Parse_Mode const &parse_mode)
 Handle the case where the user provides a keyword without value.
 
template<typename TYPE >
void mark_key_set_user (std::string const &key_str, TYPE const &value, Parse_Mode const &parse_mode)
 Record that the keyword has just been user-defined.
 
template<typename TYPE >
void mark_key_set_default (std::string const &key_str, TYPE const &def_value, Parse_Mode const &parse_mode)
 Record that the keyword has just been set to its default value.
 
void error_key_required (std::string const &key_str, Parse_Mode const &parse_mode)
 Raise error condition due to the keyword being required!
 
bool key_already_set (std::string const &key_str)
 True if the keyword has been set already.
 
void add_keyword (char const *key)
 Add a new valid keyword to the list.
 
void strip_values (std::string &conf)
 Remove all the values from the config string.
 
- Protected Member Functions inherited from colvarparams
 colvarparams ()
 Default constructor.
 
virtual ~colvarparams ()
 Default destructor.
 
void register_param (std::string const &param_name, void *param_ptr)
 Register the given parameter.
 
void register_param_grad (std::string const &param_name, colvarvalue *param_grad_ptr)
 Register the gradient of the given parameter.
 
- Protected Member Functions inherited from colvardeps
bool get_keyval_feature (colvarparse *cvp, std::string const &conf, char const *key, int feature_id, bool const &def_value, colvarparse::Parse_Mode const parse_mode=colvarparse::parse_normal)
 Parse a keyword and enable a feature accordingly.
 

Protected Attributes

colvarvalue x
 Value of the colvar.
 
colvarvalue x_reported
 Cached reported value (x may be manipulated)
 
colvarvalue v_fdiff
 Finite-difference velocity.
 
colvarvalue v_reported
 Cached reported velocity.
 
colvarvalue x_ext
 Restraint center.
 
colvarvalue prev_x_ext
 Previous value of the restraint center;.
 
colvarvalue v_ext
 Velocity of the restraint center.
 
colvarvalue prev_v_ext
 Previous velocity of the restraint center.
 
cvm::real ext_mass = 0.0
 Mass of the restraint center.
 
cvm::real ext_force_k = 0.0
 Restraint force constant.
 
cvm::real ext_gamma = 0.0
 Friction coefficient for Langevin extended dynamics.
 
cvm::real ext_sigma = 0.0
 Amplitude of Gaussian white noise for Langevin extended dynamics.
 
colvarvalue fr
 Applied force on extended DOF, for output (unscaled if using MTS)
 
colvarvalue fj
 Jacobian force, when Jacobian_force is enabled.
 
colvarvalue ft_reported
 Cached reported total force.
 
size_t n_active_cvcs = 0
 Number of CVC objects with an active flag.
 
cvm::real active_cvc_square_norm = 0.0
 Sum of square coefficients for active cvcs.
 
cvm::step_number prev_timestep
 Absolute timestep number when this colvar was last updated.
 
bool matching_state
 Flag used to tell if the state string being read is for this colvar.
 
colvarvalue x_old
 Previous value (to calculate velocities during analysis)
 
colvarvalue x_restart
 Value read from the most recent state file (if any)
 
bool after_restart
 True if a state file was just read.
 
std::list< std::list< colvarvalue > > acf_x_history
 
std::list< std::list< colvarvalue > > acf_v_history
 
std::list< std::list< colvarvalue > >::iterator acf_x_history_p
 
std::list< std::list< colvarvalue > >::iterator acf_v_history_p
 
std::list< std::list< colvarvalue > > x_history
 Time series of values and velocities used in running averages.
 
std::list< std::list< colvarvalue > >::iterator x_history_p
 
std::string acf_colvar_name
 Collective variable with which the correlation is calculated (default: itself)
 
size_t acf_length
 Length of autocorrelation function (ACF)
 
size_t acf_offset
 After how many steps the ACF starts.
 
size_t acf_stride
 How many timesteps separate two ACF values.
 
size_t acf_nframes
 Number of frames for each ACF point.
 
bool acf_normalize
 Normalize the ACF to a maximum value of 1?
 
std::vector< cvm::realacf
 ACF values.
 
std::string acf_outfile
 Name of the file to write the ACF.
 
acf_type_e acf_type
 Type of autocorrelation function (ACF)
 
size_t runave_length
 Length of running average series.
 
size_t runave_stride
 Timesteps to skip between two values in the running average series.
 
std::string runave_outfile
 Name of the file to write the running average.
 
colvarvalue runave
 Current value of the running average.
 
cvm::real runave_variance = 0.0
 Current value of the square deviation from the running average.
 
cvm::real kinetic_energy = 0.0
 If extended Lagrangian active: colvar kinetic energy.
 
cvm::real potential_energy = 0.0
 If extended Lagrangian active: colvar harmonic potential.
 
std::vector< std::shared_ptr< colvar::cvc > > cvcs
 Array of components objects.
 
std::vector< bool > cvc_flags
 Flags to enable or disable cvcs at next colvar evaluation.
 
std::string scripted_function
 Name of scripted function to be used.
 
std::vector< const colvarvalue * > sorted_cvc_values
 
std::vector< int > volmap_ids_
 Volmap numeric IDs, one for each CVC (-1 if not available)
 
- Protected Attributes inherited from colvarparse
std::string const keyword_delimiters_left
 Characters allowed immediately to the left of a kewyord.
 
std::string const keyword_delimiters_right
 Characters allowed immediately to the right of a kewyord.
 
std::list< std::string > allowed_keywords
 List of legal keywords for this object: this is updated by each call to colvarparse::get_keyval() or colvarparse::key_lookup()
 
std::map< std::string, key_set_modekey_set_modes
 Track which keywords have been already set, and how.
 
std::list< size_t > data_begin_pos
 List of delimiters for the values of each keyword in the configuration string; all keywords will be stripped of their values before the keyword check is performed.
 
std::list< size_t > data_end_pos
 List of delimiters for the values of each keyword in the configuration string; all keywords will be stripped of their values before the keyword check is performed.
 
std::string config_string
 Configuration string of the object (includes comments)
 
- Protected Attributes inherited from colvarparams
std::map< std::string, void const * > param_map
 Pointers to relevant parameters that may be accessed by other objects.
 
std::map< std::string, colvarvalue const * > param_grad_map
 Derivatives of the object with respect to internal parameters.
 
- Protected Attributes inherited from colvardeps
int time_step_factor
 
std::vector< feature_statefeature_states
 List of the states of all features.
 

Static Protected Attributes

static std::map< std::string, std::function< colvar::cvc *()> > global_cvc_map
 A global mapping of cvc names to the cvc constructors. More...
 
static std::map< std::string, std::string > global_cvc_desc_map
 A global mapping of cvc names to the corresponding descriptions. More...
 

Private Member Functions

template<typename def_class_name >
void add_component_type (char const *description, char const *config_key)
 Declare an available CVC type and its description, register them in the global map.
 
int init_components_type (const std::string &conf, const char *config_key)
 Initialize any CVC objects matching the given key.
 

Additional Inherited Members

- Public Types inherited from colvarparse
enum  Parse_Mode {
  parse_null = 0 , parse_echo = (1<<1) , parse_echo_default = (1<<2) , parse_deprecation_warning = (1<<3) ,
  parse_silent = 0 , parse_required = (1<<16) , parse_override = (1<<17) , parse_restart = (1<<18) ,
  parse_normal = (1<<1) | (1<<2) | (1<<17) , parse_deprecated = (1<<1) | (1<<3) | (1<<17)
}
 How a keyword is parsed in a string. More...
 
- Public Types inherited from colvardeps
enum  features_biases {
  f_cvb_active , f_cvb_awake , f_cvb_step_zero_data , f_cvb_apply_force ,
  f_cvb_bypass_ext_lagrangian , f_cvb_get_total_force , f_cvb_output_acc_work , f_cvb_history_dependent ,
  f_cvb_time_dependent , f_cvb_scalar_variables , f_cvb_calc_pmf , f_cvb_calc_ti_samples ,
  f_cvb_write_ti_samples , f_cvb_write_ti_pmf , f_cvb_scale_biasing_force , f_cvb_extended ,
  f_cvb_ntot
}
 
enum  features_colvar {
  f_cv_active , f_cv_awake , f_cv_gradient , f_cv_collect_gradient ,
  f_cv_collect_atom_ids , f_cv_fdiff_velocity , f_cv_total_force , f_cv_total_force_calc ,
  f_cv_subtract_applied_force , f_cv_Jacobian , f_cv_hide_Jacobian , f_cv_extended_Lagrangian ,
  f_cv_external , f_cv_Langevin , f_cv_output_energy , f_cv_output_value ,
  f_cv_output_velocity , f_cv_output_applied_force , f_cv_output_total_force , f_cv_lower_boundary ,
  f_cv_upper_boundary , f_cv_hard_lower_boundary , f_cv_hard_upper_boundary , f_cv_reflecting_lower_boundary ,
  f_cv_reflecting_upper_boundary , f_cv_grid , f_cv_runave , f_cv_corrfunc ,
  f_cv_scripted , f_cv_custom_function , f_cv_periodic , f_cv_single_cvc ,
  f_cv_scalar , f_cv_linear , f_cv_homogeneous , f_cv_multiple_ts ,
  f_cv_ntot
}
 
enum  features_cvc {
  f_cvc_active , f_cvc_scalar , f_cvc_periodic , f_cvc_width ,
  f_cvc_lower_boundary , f_cvc_upper_boundary , f_cvc_explicit_atom_groups , f_cvc_gradient ,
  f_cvc_explicit_gradient , f_cvc_inv_gradient , f_cvc_Jacobian , f_cvc_one_site_total_force ,
  f_cvc_debug_gradient , f_cvc_pbc_minimum_image , f_cvc_com_based , f_cvc_scalable ,
  f_cvc_scalable_com , f_cvc_collect_atom_ids , f_cvc_ntot
}
 
enum  features_atomgroup {
  f_ag_active , f_ag_center , f_ag_center_origin , f_ag_rotate ,
  f_ag_fitting_group , f_ag_explicit_gradient , f_ag_fit_gradients , f_ag_atom_forces ,
  f_ag_scalable , f_ag_scalable_com , f_ag_collect_atom_ids , f_ag_ntot
}
 

Detailed Description

A collective variable (main class); to be defined, it needs at least one object of a derived class of colvar::cvc; it calculates and returns a colvarvalue object.

This class parses the configuration, defines the behaviour and stores the value (colvar::x) and all related data of a collective variable. How the value is calculated is defined in colvar::cvc and its derived classes. The colvar object contains pointers to multiple colvar::cvc derived objects, which can be combined together into one collective variable. This makes possible to implement new collective variables at runtime based on the existing ones. Currently, this possibility is limited to a polynomial, using the coefficients cvc::sup_coeff and the exponents cvc::sup_np. In case of non-scalar variables, only exponents equal to 1 are accepted.

Please note that most of its members are colvarvalue objects, i.e. they can handle different data types together, and must all be set to the same type of colvar::value() before using them together in assignments or other operations; this is usually done automatically in the constructor. If you add a new member of colvarvalue type, you should also add its initialization line in the colvar constructor.

Member Enumeration Documentation

◆ acf_type_e

enum colvar::acf_type_e
protected

Type of autocorrelation function (ACF)

Enumerator
acf_notset 

Unset type.

acf_vel 

Velocity ACF, scalar product between v(0) and v(t)

acf_coor 

Coordinate ACF, scalar product between x(0) and x(t)

acf_p2coor 

Coordinate ACF, second order Legendre polynomial between x(0) and x(t) (does not work with scalar numbers)

Member Function Documentation

◆ compare_cvc()

bool colvar::compare_cvc ( const colvar::cvc *const  i,
const colvar::cvc *const  j 
)
static

function for sorting cvcs by their names

Compare two cvcs using their names Used to sort CVC array in scripted coordinates

◆ dist2()

cvm::real colvar::dist2 ( colvarvalue const &  x1,
colvarvalue const &  x2 
) const

Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.

Handles correctly symmetries and periodic boundary conditions

◆ dist2_lgrad()

colvarvalue colvar::dist2_lgrad ( colvarvalue const &  x1,
colvarvalue const &  x2 
) const

Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.

Handles correctly symmetries and periodic boundary conditions

◆ dist2_rgrad()

colvarvalue colvar::dist2_rgrad ( colvarvalue const &  x1,
colvarvalue const &  x2 
) const

Use the internal metrics (as from colvar::cvc objects) to calculate square distances and gradients.

Handles correctly symmetries and periodic boundary conditions

◆ do_feature_side_effects()

void colvar::do_feature_side_effects ( int  id)
virtual

Implements possible actions to be carried out when a given feature is enabled This overloads the base function in colvardeps

Reimplemented from colvardeps.

◆ features()

virtual const std::vector< feature * > & colvar::features ( ) const
inlinevirtual

Implementation of the feature list accessor for colvar.

Implements colvardeps.

◆ init_dependencies()

int colvar::init_dependencies ( )
virtual

Initialize dependency tree.

Implements colvardeps.

◆ modify_features()

virtual std::vector< feature * > & colvar::modify_features ( )
inlinevirtual

Implements colvardeps.

◆ total_force()

colvarvalue const & colvar::total_force ( ) const
inline

Current total force (previously obtained from calc() or read_traj()). Note: this is calculated using the atomic forces from the last simulation step.

Total atom forces are read from the MD program, the total force acting on the collective variable is calculated summing those from all colvar components, the bias and walls forces are subtracted.

◆ wrap()

void colvar::wrap ( colvarvalue x_unwrapped) const

Use the internal metrics (as from colvar::cvc objects) to wrap a value into a standard interval.

Handles correctly symmetries and periodic boundary conditions

Member Data Documentation

◆ acf_x_history

std::list< std::list<colvarvalue> > colvar::acf_x_history
protected

Time series of values and velocities used in correlation functions

◆ acf_x_history_p

std::list<std::list<colvarvalue>>::iterator colvar::acf_x_history_p
protected

Time series of values and velocities used in correlation functions (pointers)x

◆ global_cvc_desc_map

std::map< std::string, std::string > colvar::global_cvc_desc_map
staticprotected
Initial value:
=
std::map<std::string, std::string>()

A global mapping of cvc names to the corresponding descriptions.

◆ global_cvc_map

std::map< std::string, std::function< colvar::cvc *()> > colvar::global_cvc_map
staticprotected
Initial value:
=
std::map<std::string, std::function<colvar::cvc *()>>()
Colvar component (base class for collective variables)
Definition: colvarcomp.h:70

A global mapping of cvc names to the cvc constructors.

◆ sorted_cvc_values

std::vector<const colvarvalue *> colvar::sorted_cvc_values
protected

Current cvc values in the order requested by script when using scriptedFunction

◆ width

cvm::real colvar::width = 1.0

Typical fluctuation amplitude for this collective variable (e.g. local width of a free energy basin)

In metadynamics calculations, colvarbias_meta, this value is used to calculate the width of a gaussian. In ABF calculations, colvarbias_abf, it is used to calculate the grid spacing in the direction of this collective variable.

◆ x_history_p

std::list<std::list<colvarvalue>>::iterator colvar::x_history_p
protected

Time series of values and velocities used in correlation functions (pointers)x


The documentation for this class was generated from the following files: