Collective Variables Module - Developer Documentation
|
Store the information of a group of atoms in a structure-of-arrays (SoA) style. More...
#include <colvaratoms.h>
Classes | |
class | atom_modifier |
The temporary AoS interface to modify cvm::atom_group . More... | |
class | group_force_object |
A helper class for applying forces on an atom group in a way that is aware of the fitting group. NOTE: you are encouraged to use get_group_force_object() to get an instance of group_force_object instead of constructing directly. More... | |
struct | simple_atom |
A simplified class of cvm::atom that can be used with cvm::atom_group::atom_modifier . More... | |
Public Member Functions | |
atom_group () | |
Default constructor. More... | |
atom_group (char const *key_in) | |
Create a group object, assign a name to it. | |
~atom_group () override | |
Destructor. More... | |
int | init () |
Set default values for common flags. | |
int | setup () |
Update data required to calculate cvc's. More... | |
int | init_dependencies () override |
Initialize dependency tree. More... | |
const std::vector< feature * > & | features () const override |
Implementation of the feature list accessor for atom group. More... | |
std::vector< feature * > & | modify_features () override |
atom_modifier | get_atom_modifier () |
Get the atom modifier object associated with this SoA atom group. More... | |
void | clear_soa () |
Remove all atoms from this SoA group and the proxy. More... | |
int | parse (std::string const &conf) |
Initialize the group by looking up its configuration. | |
int | parse_fitting_options (std::string const &group_conf) |
Initialize the fitting group by looking up its configuration. | |
int | set_dummy () |
Set this group as a dummy group (no actual atoms) | |
int | set_dummy_pos (cvm::atom_pos const &pos) |
If this group is dummy, set the corresponding position. | |
void | update_total_mass () |
Update the total mass of the atom group. | |
void | update_total_charge () |
Update the total mass of the group. | |
void | print_properties (std::string const &colvar_name, int i, int j) |
Print the updated the total mass and charge of a group. More... | |
std::vector< int > const & | ids () const |
Internal atom IDs (populated during initialization) | |
std::string const | print_atom_ids () const |
int | create_sorted_ids () |
Allocates and populates sorted_ids and sorted_ids_map. | |
std::vector< int > const & | sorted_ids () const |
Sorted internal atom IDs (populated on-demand by create_sorted_ids);. More... | |
std::vector< int > const & | sorted_ids_map () const |
Map entries of sorted_atoms_ids onto the original positions in the group. | |
void | read_positions () |
Get the current positions. | |
void | calc_apply_roto_translation () |
(Re)calculate the optimal roto-translation | |
void | setup_rotation_derivative () |
Setup the rot_deriv object for the calculation of derivative of 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 | rotate (const cvm::rmatrix &rot_mat) |
Rotate all atoms by a rotation matrix. | |
void | apply_translation (cvm::rvector const &t) |
Move all positions. | |
void | read_velocities () |
Get the current velocities. More... | |
void | read_total_forces () |
Get the current total_forces. More... | |
int | calc_required_properties () |
Recompute all mutable quantities that are required to compute CVCs. | |
int | calc_center_of_geometry () |
Calculate the center of geometry of the atomic positions, assuming that they are already pbc-wrapped. | |
std::vector< cvm::real > | positions () const |
Return a copy of the current atom positions. | |
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 (COM) of the atomic positions. | |
cvm::rvector | center_of_mass_scalar_gradient () const |
Return previously gradient of scalar variable with respect to the COM. | |
std::vector< cvm::real > | positions_shifted (cvm::rvector const &shift) const |
Return a copy of the current atom positions, shifted by a constant vector. | |
std::vector< cvm::real > | velocities () const |
Return a copy of the current atom velocities. | |
int | calc_dipole (cvm::atom_pos const &dipole_center) |
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::real > | total_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 cvm::atom_group::center_of_mass() ) | |
void | calc_fit_gradients () |
Calculate the derivatives of the fitting transformation. | |
template<bool B_ag_center, bool B_ag_rotate, typename main_force_accessor_T , typename fitting_force_accessor_T > | |
void | calc_fit_forces_impl (main_force_accessor_T accessor_main, fitting_force_accessor_T accessor_fitting) const |
Actual implementation of calc_fit_gradients and calc_fit_forces . The template is used to avoid branching inside the loops in case that the CPU branch prediction is broken (or further migration to GPU code). More... | |
template<typename main_force_accessor_T , typename fitting_force_accessor_T > | |
void | calc_fit_forces (main_force_accessor_T accessor_main, fitting_force_accessor_T accessor_fitting) const |
Calculate or apply the fitting group forces from the main group forces. More... | |
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) override |
size_t | size () const |
Return the number of atoms of this group. | |
void | reset_atoms_data () |
Clear the atom positions, velocities, gradients and total forces. | |
void | set_ref_pos_from_aos (const std::vector< cvm::atom_pos > &pos_aos) |
Setup reference positions from AOS. | |
simple_atom | operator[] (size_t i) const |
Read-only operator[]. | |
group_force_object | get_group_force_object () |
Accessors to atom IDs | |
int & | id (size_t i) |
const int & | id (size_t i) const |
Accessors to positions | |
cvm::real & | pos_x (size_t i) |
cvm::real & | pos_y (size_t i) |
cvm::real & | pos_z (size_t i) |
const cvm::real & | pos_x (size_t i) const |
const cvm::real & | pos_y (size_t i) const |
const cvm::real & | pos_z (size_t i) const |
Accessors to velocities | |
cvm::real & | vel_x (size_t i) |
cvm::real & | vel_y (size_t i) |
cvm::real & | vel_z (size_t i) |
const cvm::real & | vel_x (size_t i) const |
const cvm::real & | vel_y (size_t i) const |
const cvm::real & | vel_z (size_t i) const |
Accessors to gradients | |
cvm::real & | grad_x (size_t i) |
cvm::real & | grad_y (size_t i) |
cvm::real & | grad_z (size_t i) |
const cvm::real & | grad_x (size_t i) const |
const cvm::real & | grad_y (size_t i) const |
const cvm::real & | grad_z (size_t i) const |
Accessors to total forces | |
cvm::real & | total_force_x (size_t i) |
cvm::real & | total_force_y (size_t i) |
cvm::real & | total_force_z (size_t i) |
const cvm::real & | total_force_x (size_t i) const |
const cvm::real & | total_force_y (size_t i) const |
const cvm::real & | total_force_z (size_t i) const |
Accessors to reference positions | |
cvm::real & | ref_pos_x (size_t i) |
cvm::real & | ref_pos_y (size_t i) |
cvm::real & | ref_pos_z (size_t i) |
const cvm::real & | ref_pos_x (size_t i) const |
const cvm::real & | ref_pos_y (size_t i) const |
const cvm::real & | ref_pos_z (size_t i) const |
Accessors to positions before rotation | |
cvm::real & | pos_unrotated_x (size_t i) |
cvm::real & | pos_unrotated_y (size_t i) |
cvm::real & | pos_unrotated_z (size_t i) |
const cvm::real & | pos_unrotated_x (size_t i) const |
const cvm::real & | pos_unrotated_y (size_t i) const |
const cvm::real & | pos_unrotated_z (size_t i) const |
Accessors to masses | |
cvm::real & | mass (size_t i) |
const cvm::real & | mass (size_t i) const |
Accessors to weights | |
cvm::real & | weight (size_t i) |
const cvm::real & | weight (size_t i) const |
Accessors to charges | |
cvm::real & | charge (size_t i) |
const cvm::real & | charge (size_t i) const |
Accessors to fit gradients | |
cvm::real & | fit_gradients_x (size_t i) |
cvm::real & | fit_gradients_y (size_t i) |
cvm::real & | fit_gradients_z (size_t i) |
const cvm::real & | fit_gradients_x (size_t i) const |
const cvm::real & | fit_gradients_y (size_t i) const |
const cvm::real & | fit_gradients_z (size_t i) const |
Accessors to group forces | |
cvm::real & | group_forces_x (size_t i) |
cvm::real & | group_forces_y (size_t i) |
cvm::real & | group_forces_z (size_t i) |
const cvm::real & | group_forces_x (size_t i) const |
const cvm::real & | group_forces_y (size_t i) const |
const cvm::real & | group_forces_z (size_t i) const |
![]() | |
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) |
![]() | |
int | param_exists (std::string const ¶m_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 ¶m_name) |
Pointer to the parameter param_name. | |
virtual void const * | get_param_grad_ptr (std::string const ¶m_name) |
Pointer to the gradient of parameter param_name. | |
virtual cvm::real | get_param (std::string const ¶m_name) |
Value of the parameter param_name (must be a scalar) | |
virtual int | set_param (std::string const ¶m_name, void const *new_value) |
Set the named parameter to the given value. More... | |
![]() | |
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, bool error=false) |
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 std::vector< cvm::real > | pos_aos_to_soa (const std::vector< cvm::atom_pos > &aos_in) |
A helper function to re-arrange the a vector of cvm::atom_pos (in AoS style xyz...xyz) to an SoA vector (x...xy...yz...z) | |
static void | delete_features () |
static simple_atom | init_atom_from_proxy (colvarproxy *const p, cvm::residue_id const &residue, std::string const &atom_name, std::string const &segment_id) |
Initialize an instance of cvm::atom_group::simple_atom from colvarproxy . More... | |
static simple_atom | init_atom_from_proxy (colvarproxy *const p, int atom_number) |
Initialize an instance of cvm::atom_group::simple_atom from colvarproxy . More... | |
static simple_atom | init_atom_from_proxy (colvarproxy *const p, const simple_atom &atom) |
Initialize an instance of cvm::atom_group::simple_atom from colvarproxy . More... | |
static int | overlap (const atom_group &g1, const atom_group &g2) |
Detect whether two groups share atoms. More... | |
![]() | |
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 |
Optional name to reuse properties of this in other groups. | |
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::string | key |
Keyword used to define the group. | |
cvm::atom_group * | fitting_group |
If f_ag_center or f_ag_rotate is true, use this group to define the transformation (default: this group itself) | |
cvm::rotation | rot |
The rotation calculated automatically if f_ag_rotate is defined. | |
bool | noforce |
Don't apply any force on this group (use its coordinates only to calculate a colvar) | |
bool | b_user_defined_fit |
Indicates that the user has explicitly set centerToReference or rotateReference, and the corresponding reference: cvc's (eg rmsd, eigenvector) will not override the user's choice. | |
std::vector< cvm::real > | fit_gradients |
Derivatives of the fitting transformation. | |
cvm::real | total_mass |
Total mass of the atom group. | |
cvm::real | total_charge |
Total charge of the atom group. | |
rotation_derivative * | rot_deriv |
Rotation derivative;. | |
![]() | |
std::string | description |
Static Public Attributes | |
static std::vector< feature * > | ag_features |
Implementation of the feature list for atom group. | |
![]() | |
static const char *const | white_space = " \t" |
Accepted white space delimiters, used in key_lookup() | |
Private Attributes | |
size_t | num_atoms |
Number of atoms. | |
std::vector< int > | atoms_index |
SOA atom indices (size: num_atoms) | |
std::vector< cvm::real > | atoms_pos |
SOA atom positions (size: 3 * num_atoms) | |
std::vector< cvm::real > | atoms_charge |
SOA atom charges (size: num_atoms) | |
std::vector< cvm::real > | atoms_vel |
SOA atom velocities (size: 3 * num_atoms) | |
std::vector< cvm::real > | atoms_mass |
SOA atom mass (size: num_atoms) | |
std::vector< cvm::real > | atoms_grad |
SOA atom gradients (size: 3 * num_atoms) | |
std::vector< cvm::real > | atoms_total_force |
SOA atom total forces (size: 3 * num_atoms) | |
std::vector< cvm::real > | atoms_weight |
Atom masses divided by total mass (size: num_atoms) | |
std::vector< int > | atoms_ids |
Internal atom IDs for host code. | |
std::vector< int > | sorted_atoms_ids |
Sorted list of internal atom IDs (populated on-demand by create_sorted_ids); used to read coordinate files. | |
std::vector< int > | sorted_atoms_ids_map |
Map entries of sorted_atoms_ids onto the original positions in the group. | |
cvm::atom_pos | dummy_atom_pos |
Dummy atom position. | |
int | index |
Index in the colvarproxy arrays (if the group is scalable) | |
std::vector< cvm::real > | group_forces |
The temporary forces acting on the main group atoms. Currently this is only used for calculating the fitting group forces for non-scalar components. | |
std::vector< cvm::real > | ref_pos |
use reference coordinates for f_ag_center or f_ag_rotate | |
size_t | num_ref_pos |
cvm::atom_pos | ref_pos_cog |
Center of geometry of the reference coordinates; regardless of whether f_ag_center is true, ref_pos is centered to zero at initialization, and ref_pos_cog serves to center the positions. | |
cvm::atom_pos | cog |
Center of geometry. | |
cvm::atom_pos | cog_orig |
Center of geometry before any fitting. | |
std::vector< cvm::real > | atoms_pos_unrotated |
Unrotated atom positions for fit gradients. | |
cvm::atom_pos | com |
Center of mass. | |
cvm::rvector | scalar_com_gradient |
The derivative of a scalar variable with respect to the COM. | |
cvm::rvector | dip |
Dipole moment of the atom group. | |
std::mutex | modify_lock |
Lock for modifier. | |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
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_smp , f_cvb_ntot } |
enum | features_colvar { f_cv_active , f_cv_awake , f_cv_apply_force , 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_total_force_current_step , 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 } |
![]() | |
enum | key_set_mode { key_not_set = 0 , key_set_user = 1 , key_set_default = 2 } |
How a keyword has been set. | |
![]() | |
enum | feature_type { f_type_not_set , f_type_dynamic , f_type_user , f_type_static } |
Enum of possible feature types. | |
![]() | |
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. | |
![]() | |
colvarparams () | |
Default constructor. | |
virtual | ~colvarparams () |
Default destructor. | |
void | register_param (std::string const ¶m_name, void *param_ptr) |
Register the given parameter. | |
void | register_param_grad (std::string const ¶m_name, colvarvalue *param_grad_ptr) |
Register the gradient of the given parameter. | |
![]() | |
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. | |
![]() | |
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_mode > | key_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) | |
![]() | |
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. | |
![]() | |
int | time_step_factor |
std::vector< feature_state > | feature_states |
List of the states of all features. | |
Store the information of a group of atoms in a structure-of-arrays (SoA) style.
This class keeps the information of a group of atoms. These information includes the internal indices in the colvarproxy class, positions, charges, velocities, masses, gradients, total forces and atom IDs of all atoms in the atom group. The memory layout of this class is different from the traditional cvm::atom_group class as this class uses the SoA layout to group each atom properties in their own array instead of using a single array of cvm::atom (array-of-structures or AoS). According to various micro-benchmarks, the use of SoA can significantly improve the performance. There are two disadvantages of adopting SoA:
cvm::atom_group::atom_modifier
has been implemented as a temporary AoS class that shares the same interfaces like cvm::atom_group::atom_modifier::add_atom_numbers
as the traditional AoS class cvm::atom_group. To add or remove atoms in the SoA class, you can do the following: get_atom_modifier
is called, the temporary AoS atom group will be created based on this SoA atom group, and after the modification of the temporary AoS atom group is completed, the destructor cvm::atom_group::atom_modifier::~atom_modifier
will synchronize the changes back to this SoA atom group.cvm::atom_group::atom_group | ( | ) |
Default constructor.
init_dependencies()
to initialize the dependency tree.
|
override |
Destructor.
clear_soa()
to de-reference all atoms (if not scalable) from the proxy class. 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.
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
void cvm::atom_group::calc_fit_forces | ( | main_force_accessor_T | accessor_main, |
fitting_force_accessor_T | accessor_fitting | ||
) | const |
Calculate or apply the fitting group forces from the main group forces.
main_force_accessor_T | The type of accessor of the main group forces or gradients. |
fitting_force_accessor_T | The type of accessor of the fitting group forces or gradients. |
accessor_main | The accessor of the main group forces or gradients. accessor_main(i) should return the i-th force or gradient of the main group. |
accessor_fitting | The accessor of the fitting group forces or gradients. accessor_fitting(j, v) should store/apply the j-th atom gradient or force in the fitting group. |
This function just dispatches the parameters to calc_fit_forces_impl that really performs the calculations.
void cvm::atom_group::calc_fit_forces_impl | ( | main_force_accessor_T | accessor_main, |
fitting_force_accessor_T | accessor_fitting | ||
) | const |
Actual implementation of calc_fit_gradients
and calc_fit_forces
. The template is used to avoid branching inside the loops in case that the CPU branch prediction is broken (or further migration to GPU code).
B_ag_center | Centered the reference to origin? This should follow the value of is_enabled(f_ag_center) . |
B_ag_rotate | Calculate the optimal rotation? This should follow the value of is_enabled(f_ag_rotate) . |
main_force_accessor_T | The type of accessor of the main group forces or gradients acting on the rotated frame. |
fitting_force_accessor_T | The type of accessor of the fitting group forces or gradients. |
accessor_main | The accessor of the main group forces or gradients. accessor_main(i) should return the i-th force or gradient of the rotated main group. |
accessor_fitting | The accessor of the fitting group forces or gradients. accessor_fitting(j, v) should store/apply the j-th atom gradient or force in the fitting group. |
This function is used to (i) project the gradients of CV with respect to rotated main group atoms to fitting group atoms, or (ii) project the forces on rotated main group atoms to fitting group atoms, by the following two steps (using the goal (ii) for example): (1) Loop over the positions of main group atoms and call cvm::quaternion::position_derivative_inner to project the forces on rotated main group atoms to the forces on quaternion. (2) Loop over the positions of fitting group atoms, compute the gradients of \(\mathbf{q}\) with respect to the position of each atom, and then multiply that with the force on \(\mathbf{q}\) (chain rule).
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).
void cvm::atom_group::clear_soa | ( | ) |
Remove all atoms from this SoA group and the proxy.
atoms_ids
, sorted_atoms_ids
, sorted_atoms_ids_map
total mass, total charge, reference positions and the fitting group are kept.
|
overridevirtual |
Implements possible actions to be carried out when a given feature is enabled This overloads the base function in colvardeps
Reimplemented from colvardeps.
|
inlineoverridevirtual |
Implementation of the feature list accessor for atom group.
Implements colvardeps.
|
inline |
Get the atom modifier object associated with this SoA atom group.
cvm::atom_group::atom_modifier
in a scope. To prevent acquiring multiple instances of atom_modifier
at the same time which may corrupt the SoA layout. The associated cvm::atom_group::atom_modifier
will try locking mutex_lock
.
|
static |
Initialize an instance of cvm::atom_group::simple_atom
from colvarproxy
.
p | The pointer to the colvarproxy instance. |
simple_atom | The existing object of cvm::atom_group::simple_atom |
cvm::atom_group::simple_atom::proxy_index
of input atom must be known. The reference count in the proxy will be increased.
|
static |
Initialize an instance of cvm::atom_group::simple_atom
from colvarproxy
.
p | The pointer to the colvarproxy instance. |
residue | The residue number of the atom |
atom_name | The name of the atom in the residue |
segment_id | For PSF topologies, the segment identifier; for other type of topologies, may not be required |
|
static |
Initialize an instance of cvm::atom_group::simple_atom
from colvarproxy
.
p | The pointer to the colvarproxy instance. |
atom_number | Atom index in the system topology (1-based) |
|
overridevirtual |
Initialize dependency tree.
Implements colvardeps.
|
inlineoverridevirtual |
Implements colvardeps.
|
static |
Detect whether two groups share atoms.
If yes, returns 1-based number of a common atom; else, returns 0
void cvm::atom_group::print_properties | ( | std::string const & | colvar_name, |
int | i, | ||
int | j | ||
) |
Print the updated the total mass and charge of a group.
This is needed in case the hosting MD code has an option to change atom masses after their initialization.
void cvm::atom_group::read_total_forces | ( | ) |
Get the current total_forces.
this must be called always after read_positions(); if f_ag_rotate is defined, the same rotation applied to the coordinates will be used.
void cvm::atom_group::read_velocities | ( | ) |
Get the current velocities.
this must be called always after read_positions(); if f_ag_rotate is defined, the same rotation applied to the coordinates will be used.
int cvm::atom_group::setup | ( | ) |
Update data required to calculate cvc's.
The data updated includes atomic charges and masses, and also the total charge and total mass of this atom group.
|
inline |
Sorted internal atom IDs (populated on-demand by create_sorted_ids);.
Used to read coordinate files