Collective Variables Module - Developer Documentation
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
colvarmodule::atom_group Class Reference

Group of atom objects, mostly used by a cvc object to gather all atomic data. More...

#include <colvaratoms.h>

Inheritance diagram for colvarmodule::atom_group:
Inheritance graph
[legend]
Collaboration diagram for colvarmodule::atom_group:
Collaboration graph
[legend]

Public Member Functions

 atom_group ()
 Default constructor.
 
 atom_group (char const *key)
 Create a group object, assign a name to it.
 
 atom_group (std::vector< cvm::atom > const &atoms_in)
 Initialize the group after a (temporary) vector of atoms.
 
 ~atom_group ()
 Destructor.
 
int init ()
 Set default values for common flags.
 
int setup ()
 Update data required to calculate cvc's.
 
int parse (std::string const &conf)
 Initialize the group by looking up its configuration string in conf and parsing it.
 
int add_atom_numbers (std::string const &numbers_conf)
 
int add_atoms_of_group (atom_group const *ag)
 
int add_index_group (std::string const &index_group_name)
 
int add_atom_numbers_range (std::string const &range_conf)
 
int add_atom_name_residue_range (std::string const &psf_segid, std::string const &range_conf)
 
int parse_fitting_options (std::string const &group_conf)
 
int add_atom (cvm::atom const &a)
 Add an atom object to this group.
 
int add_atom_id (int aid)
 Add an atom ID to this group (the actual atomicdata will be not be handled by the group)
 
int remove_atom (cvm::atom_iter ai)
 Remove an atom object from this group.
 
void reset_mass (std::string &name, int i, int j)
 Re-initialize the total mass of a group. This is needed in case the hosting MD code has an option to change atom masses after their initialization.
 
virtual const std::vector< feature * > & features ()
 Implementation of the feature list accessor for atom group.
 
virtual std::vector< feature * > & modify_features ()
 
cvm::atomoperator[] (size_t const i)
 
cvm::atom const & operator[] (size_t const i) const
 
cvm::atom_iter begin ()
 
cvm::atom_const_iter begin () const
 
cvm::atom_iter end ()
 
cvm::atom_const_iter end () const
 
size_t size () const
 
std::string const print_atom_ids () const
 
int create_sorted_ids (void)
 Allocates and populates the sorted list of atom ids.
 
void update_total_mass ()
 
void update_total_charge ()
 
void read_positions ()
 Get the current positions.
 
void calc_apply_roto_translation ()
 (Re)calculate the optimal roto-translation
 
void center_ref_pos ()
 Save aside the center of geometry of the reference positions, then subtract it from them. More...
 
void apply_translation (cvm::rvector const &t)
 Move all positions.
 
void read_velocities ()
 Get the current velocities; this must be called always after read_positions(); if b_rotate is defined, the same rotation applied to the coordinates will be used.
 
void read_total_forces ()
 Get the current total_forces; this must be called always after read_positions(); if b_rotate is defined, the same rotation applied to the coordinates will be used.
 
void reset_atoms_data ()
 Call reset_data() for each atom.
 
int calc_required_properties ()
 Recompute all mutable quantities that are required to compute CVCs.
 
std::vector< cvm::atom_pospositions () const
 Return a copy of the current atom positions.
 
int calc_center_of_geometry ()
 Calculate the center of geometry of the atomic positions, assuming that they are already pbc-wrapped.
 
cvm::atom_pos center_of_geometry () const
 Return the center of geometry of the atomic positions.
 
int calc_center_of_mass ()
 Calculate the center of mass of the atomic positions, assuming that they are already pbc-wrapped.
 
cvm::atom_pos center_of_mass () const
 Return the center of mass of the atomic positions.
 
std::vector< cvm::atom_pospositions_shifted (cvm::rvector const &shift) const
 Return a copy of the current atom positions, shifted by a constant vector.
 
std::vector< cvm::rvectorvelocities () const
 Return a copy of the current atom velocities.
 
int calc_dipole (cvm::atom_pos const &com)
 Calculate the dipole of the atom group around the specified center.
 
cvm::rvector dipole () const
 Return the (previously calculated) dipole of the atom group.
 
std::vector< cvm::rvectortotal_forces () const
 Return a copy of the total forces.
 
cvm::rvector total_force () const
 Return a copy of the aggregated total force on the group.
 
void set_weighted_gradient (cvm::rvector const &grad)
 Shorthand: save the specified gradient on each atom, weighting with the atom mass (mostly used in combination with center_of_mass())
 
void calc_fit_gradients ()
 Calculate the derivatives of the fitting transformation.
 
void apply_colvar_force (cvm::real const &force)
 Used by a (scalar) colvar to apply its force on its atom_group members. More...
 
void apply_force (cvm::rvector const &force)
 Apply a force "to the center of mass", i.e. the force is distributed on each atom according to its mass. More...
 
void do_feature_side_effects (int id)
 
- Public Member Functions inherited from colvarparse
 colvarparse (const std::string &conf)
 Constructor that stores the object's config string.
 
void init ()
 Set the object ready to parse a new configuration string.
 
void init (const std::string &conf)
 Set a new config string for this object.
 
const std::string & get_config ()
 
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=(int) 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=(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)
 
bool get_keyval (std::string const &conf, char const *key, std::vector< int > &values, std::vector< int > const &def_values=std::vector< int >(0,(int) 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,(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)
 
bool key_lookup (std::string const &conf, char const *key, std::string *data=NULL, size_t *save_pos=NULL)
 Low-level function for parsing configuration strings; automatically adds the requested keyword to the list of valid ones. More...
 
bool brace_check (std::string const &conf, size_t const start_pos=0)
 Check if the content of the file has matching braces.
 
- 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=f_type_not_set)
 Pair a numerical feature ID with a description and type.
 
bool is_dynamic (int id)
 
bool is_static (int id)
 
bool is_user (int id)
 
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)
 
void init_cvb_requires ()
 
void init_cv_requires ()
 
void init_cvc_requires ()
 
void init_ag_requires ()
 
void print_state ()
 print all enabled features and those of children, for debugging
 

Static Public Member Functions

static void delete_features ()
 
static int overlap (const atom_group &g1, const atom_group &g2)
 
- 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.
 

Public Attributes

std::string name
 Optional name to reuse properties of this in other groups.
 
std::string key
 Keyword used to define the group.
 
bool b_dummy
 If this option is on, this group merely acts as a wrapper for a fixed position; any calls to atoms within or to functions that return disaggregated data will fail.
 
std::vector< int > sorted_ids
 
bool b_center
 When updating atomic coordinates, translate them to align with the center of mass of the reference coordinates.
 
bool b_rotate
 When updating atom coordinates (and after centering them if b_center is set), rotate the group to align with the reference coordinates. More...
 
cvm::rotation rot
 The rotation calculated automatically if b_rotate is defined.
 
bool b_user_defined_fit
 Indicates that the user has explicitly set centerReference or rotateReference, and the corresponding reference: cvc's (eg rmsd, eigenvector) will not override the user's choice.
 
std::vector< cvm::atom_posref_pos
 use reference coordinates for b_center or b_rotate
 
cvm::atom_pos ref_pos_cog
 Center of geometry of the reference coordinates; regardless of whether b_center is true, ref_pos is centered to zero at initialization, and ref_pos_cog serves to center the positions.
 
atom_groupfitting_group
 If b_center or b_rotate is true, use this group to define the transformation (default: this group itself)
 
cvm::real total_mass
 Total mass of the atom group.
 
cvm::real total_charge
 Total charge of the atom group.
 
bool noforce
 Don't apply any force on this group (use its coordinates only to calculate a colvar)
 
std::vector< cvm::atom_posfit_gradients
 Derivatives of the fitting transformation.
 
- Public Attributes inherited from colvardeps
std::string description
 

Static Public Attributes

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

Protected Attributes

std::vector< cvm::atomatoms
 Array of atom objects.
 
std::vector< int > atoms_ids
 Array of atom identifiers for the MD program (0-based)
 
cvm::atom_pos dummy_atom_pos
 Dummy atom position.
 
int index
 Index in the colvarproxy arrays (if the group is scalable)
 
- Protected Attributes inherited from colvardeps
int time_step_factor
 

Additional Inherited Members

- Public Types inherited from colvarparse
enum  Parse_Mode { parse_normal, parse_silent }
 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_apply_force, f_cvb_get_total_force,
  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_ntot
}
 
enum  features_colvar {
  f_cv_active, f_cv_awake, f_cv_gradient, f_cv_collect_gradient,
  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_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_grid,
  f_cv_runave, f_cv_corrfunc, f_cv_scripted, f_cv_custom_function,
  f_cv_periodic, 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_gradient, f_cvc_implicit_gradient,
  f_cvc_inv_gradient, f_cvc_debug_gradient, f_cvc_Jacobian, f_cvc_pbc_minimum_image,
  f_cvc_one_site_total_force, f_cvc_com_based, f_cvc_scalable, f_cvc_scalable_com,
  f_cvc_ntot
}
 
enum  features_atomgroup {
  f_ag_active, f_ag_center, f_ag_rotate, f_ag_fitting_group,
  f_ag_implicit_gradient, f_ag_fit_gradients, f_ag_atom_forces, f_ag_scalable,
  f_ag_scalable_com, f_ag_ntot
}
 
- Protected Member Functions inherited from colvarparse
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)
 
bool _get_keyval_scalar_string_ (std::string const &conf, 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)
 
- 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.
 

Detailed Description

Group of atom objects, mostly used by a cvc object to gather all atomic data.

Member Function Documentation

◆ apply_colvar_force()

void cvm::atom_group::apply_colvar_force ( cvm::real const &  force)

Used by a (scalar) colvar to apply its force on its atom_group members.

The (scalar) force is multiplied by the colvar gradient for each atom; this should be used when a colvar with scalar colvarvalue type is used (this is the most frequent case: for colvars with a non-scalar type, the most convenient solution is to sum together the Cartesian forces from all the colvar components, and use apply_force() or apply_forces()). If the group is being rotated to a reference frame (e.g. to express the colvar independently from the solute rotation), the gradients are temporarily rotated to the original frame.

◆ apply_force()

void cvm::atom_group::apply_force ( cvm::rvector const &  force)

Apply a force "to the center of mass", i.e. the force is distributed on each atom according to its mass.

If the group is being rotated to a reference frame (e.g. to express the colvar independently from the solute rotation), the force is rotated back to the original frame. Colvar gradients are not used, either because they were not defined (e.g because the colvar has not a scalar value) or the biases require to micromanage the force. This function will be phased out eventually, in favor of apply_colvar_force() once that is implemented for non-scalar values

◆ center_ref_pos()

void cvm::atom_group::center_ref_pos ( )

Save aside the center of geometry of the reference positions, then subtract it from them.

In this way it will be possible to use ref_pos also for the rotational fit. This is called either by atom_group::parse or by CVCs that assign reference positions (eg. RMSD, eigenvector).

◆ do_feature_side_effects()

void cvm::atom_group::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.

◆ overlap()

int cvm::atom_group::overlap ( const atom_group g1,
const atom_group g2 
)
static

Detect whether two groups share atoms If yes, returns 1-based number of a common atom; else, returns 0

Member Data Documentation

◆ b_rotate

bool colvarmodule::atom_group::b_rotate

When updating atom coordinates (and after centering them if b_center is set), rotate the group to align with the reference coordinates.

Note: gradients will be calculated in the rotated frame: when forces will be applied, they will rotated back to the original frame

◆ sorted_ids

std::vector<int> colvarmodule::atom_group::sorted_ids

Sorted list of zero-based (internal) atom ids (populated on-demand by create_sorted_ids)


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