| version 1.21 | version 1.22 |
|---|
| |
| /// -*- c++ -*- | // -*- c++ -*- |
| | |
| #ifndef COLVARCOMP_H | #ifndef COLVARCOMP_H |
| #define COLVARCOMP_H | #define COLVARCOMP_H |
| |
| /// call to e.g. apply_force(). | /// call to e.g. apply_force(). |
| | |
| class colvar::cvc | class colvar::cvc |
| : public colvarparse | : public colvarparse, public colvardeps |
| { | { |
| public: | public: |
| | |
| |
| /// \brief Exponent in the polynomial combination (default: 1) | /// \brief Exponent in the polynomial combination (default: 1) |
| int sup_np; | int sup_np; |
| | |
| /// \brief This defaults to true; setting it to false disables | |
| /// update of this cvc to save compute time (useful with scriptedFunction) | |
| bool b_enabled; | |
| | |
| /// \brief Is this a periodic component? | /// \brief Is this a periodic component? |
| bool b_periodic; | bool b_periodic; |
| | |
| |
| | |
| /// \brief Within the constructor, make a group parse its own | /// \brief Within the constructor, make a group parse its own |
| /// options from the provided configuration string | /// options from the provided configuration string |
| void parse_group(std::string const &conf, | /// Returns reference to new group |
| | cvm::atom_group *parse_group(std::string const &conf, |
| char const *group_key, | char const *group_key, |
| cvm::atom_group &group, | |
| bool optional = false); | bool optional = false); |
| | |
| | /// \brief Parse options pertaining to total force calculation |
| | virtual int init_total_force_params(std::string const &conf); |
| | |
| | /// \brief After construction, set data related to dependency handling |
| | int setup(); |
| | |
| /// \brief Default constructor (used when \link cvc \endlink | /// \brief Default constructor (used when \link cvc \endlink |
| /// objects are declared within other ones) | /// objects are declared within other ones) |
| cvc(); | cvc(); |
| |
| /// Destructor | /// Destructor |
| virtual ~cvc(); | virtual ~cvc(); |
| | |
| | /// \brief Implementation of the feature list for colvar |
| | static std::vector<feature *> cvc_features; |
| | |
| /// \brief If this flag is false (default), inverse gradients | /// \brief Implementation of the feature list accessor for colvar |
| /// (derivatives of atom coordinates with respect to x) are | virtual std::vector<feature *> &features() { |
| /// unavailable; it should be set to true by the constructor of each | return cvc_features; |
| /// derived object capable of calculating them | } |
| bool b_inverse_gradients; | |
| | /// \brief Obtain data needed for the calculation for the backend |
| /// \brief If this flag is false (default), the Jacobian derivative | void read_data(); |
| /// (divergence of the inverse gradients) is unavailable; it should | |
| /// be set to true by the constructor of each derived object capable | |
| /// of calculating it | |
| bool b_Jacobian_derivative; | |
| | |
| /// \brief Calculate the variable | /// \brief Calculate the variable |
| virtual void calc_value() = 0; | virtual void calc_value() = 0; |
| |
| /// order to apply forces | /// order to apply forces |
| virtual void calc_gradients() = 0; | virtual void calc_gradients() = 0; |
| | |
| /// \brief If true, calc_gradients() will call debug_gradients() for every group needed | |
| bool b_debug_gradients; | |
| | |
| /// \brief Calculate finite-difference gradients alongside the analytical ones, for each Cartesian component | /// \brief Calculate finite-difference gradients alongside the analytical ones, for each Cartesian component |
| virtual void debug_gradients(cvm::atom_group &group); | virtual void debug_gradients(cvm::atom_group *group); |
| | |
| /// \brief Calculate the total force from the system using the | /// \brief Calculate the total force from the system using the |
| /// inverse atomic gradients | /// inverse atomic gradients |
| |
| // /// \brief Return const pointer to the previously calculated value | // /// \brief Return const pointer to the previously calculated value |
| // virtual const colvarvalue *p_value() const; | // virtual const colvarvalue *p_value() const; |
| | |
| /// \brief Return the previously calculated system force | /// \brief Return the previously calculated total force |
| virtual colvarvalue const & system_force() const; | virtual colvarvalue const & total_force() const; |
| | |
| /// \brief Return the previously calculated divergence of the | /// \brief Return the previously calculated divergence of the |
| /// inverse atomic gradients | /// inverse atomic gradients |
| |
| /// e.g. atomic gradients | /// e.g. atomic gradients |
| std::vector<cvm::atom_group *> atom_groups; | std::vector<cvm::atom_group *> atom_groups; |
| | |
| | /// \brief Whether or not this CVC will be computed in parallel whenever possible |
| | bool b_try_scalable; |
| | |
| protected: | protected: |
| | |
| /// \brief Cached value | /// \brief Cached value |
| |
| /// \brief Value at the previous step | /// \brief Value at the previous step |
| colvarvalue x_old; | colvarvalue x_old; |
| | |
| /// \brief Calculated system force (\b Note: this is calculated from | /// \brief Calculated total force (\b Note: this is calculated from |
| /// the total atomic forces read from the program, subtracting fromt | /// the total atomic forces read from the program, subtracting fromt |
| /// the "internal" forces of the system the "external" forces from | /// the "internal" forces of the system the "external" forces from |
| /// the colvar biases) | /// the colvar biases) |
| |
| // return &x; | // return &x; |
| // } | // } |
| | |
| inline colvarvalue const & colvar::cvc::system_force() const | inline colvarvalue const & colvar::cvc::total_force() const |
| { | { |
| return ft; | return ft; |
| } | } |
| |
| | |
| /// \brief Colvar component: distance between the centers of mass of | /// \brief Colvar component: distance between the centers of mass of |
| /// two groups (colvarvalue::type_scalar type, range [0:*)) | /// two groups (colvarvalue::type_scalar type, range [0:*)) |
| /// | |
| /// This class also serves as the template for many collective | |
| /// variables with two atom groups: in this case, the | |
| /// distance::distance() constructor should be called on the same | |
| /// configuration string, to make the same member data and functions | |
| /// available to the derived object | |
| class colvar::distance | class colvar::distance |
| : public colvar::cvc | : public colvar::cvc |
| { | { |
| protected: | protected: |
| /// First atom group | /// First atom group |
| cvm::atom_group group1; | cvm::atom_group *group1; |
| /// Second atom group | /// Second atom group |
| cvm::atom_group group2; | cvm::atom_group *group2; |
| /// Vector distance, cached to be recycled | /// Vector distance, cached to be recycled |
| cvm::rvector dist_v; | cvm::rvector dist_v; |
| /// Use absolute positions, ignoring PBCs when present | /// Use absolute positions, ignoring PBCs when present |
| bool b_no_PBC; | bool b_no_PBC; |
| /// Compute system force on first site only to avoid unwanted | |
| /// coupling to other colvars (see e.g. Ciccotti et al., 2005) | |
| bool b_1site_force; | |
| public: | public: |
| distance(std::string const &conf, bool twogroups = true); | distance(std::string const &conf); |
| distance(); | distance(); |
| virtual inline ~distance() {} | virtual inline ~distance() {} |
| virtual void calc_value(); | virtual void calc_value(); |
| |
| { | { |
| protected: | protected: |
| /// Main atom group | /// Main atom group |
| cvm::atom_group main; | cvm::atom_group *main; |
| /// Reference atom group | /// Reference atom group |
| cvm::atom_group ref1; | cvm::atom_group *ref1; |
| /// Optional, second ref atom group | /// Optional, second ref atom group |
| cvm::atom_group ref2; | cvm::atom_group *ref2; |
| /// Use absolute positions, ignoring PBCs when present | /// Use absolute positions, ignoring PBCs when present |
| bool b_no_PBC; | bool b_no_PBC; |
| /// Compute system force on one site only to avoid unwanted | |
| /// coupling to other colvars (see e.g. Ciccotti et al., 2005) | |
| bool b_1site_force; | |
| /// Vector on which the distance vector is projected | /// Vector on which the distance vector is projected |
| cvm::rvector axis; | cvm::rvector axis; |
| /// Norm of the axis | /// Norm of the axis |
| |
| { | { |
| protected: | protected: |
| /// First atom group | /// First atom group |
| cvm::atom_group group1; | cvm::atom_group *group1; |
| /// Second atom group | /// Second atom group |
| cvm::atom_group group2; | cvm::atom_group *group2; |
| /// Use absolute positions, ignoring PBCs when present | /// Use absolute positions, ignoring PBCs when present |
| bool b_no_PBC; | bool b_no_PBC; |
| public: | public: |
| |
| { | { |
| protected: | protected: |
| /// Atoms involved | /// Atoms involved |
| cvm::atom_group atoms; | cvm::atom_group *atoms; |
| public: | public: |
| /// Constructor | /// Constructor |
| gyration(std::string const &conf); | gyration(std::string const &conf); |
| |
| protected: | protected: |
| | |
| /// Atom group | /// Atom group |
| cvm::atom_group atoms; | cvm::atom_group * atoms; |
| | |
| /// Reference coordinates | /// Reference coordinates |
| std::vector<cvm::atom_pos> ref_pos; | std::vector<cvm::atom_pos> ref_pos; |
| |
| protected: | protected: |
| | |
| /// Atom group | /// Atom group |
| cvm::atom_group group1; | cvm::atom_group *group1; |
| /// Atom group | /// Atom group |
| cvm::atom_group group2; | cvm::atom_group *group2; |
| /// Atom group | /// Atom group |
| cvm::atom_group group3; | cvm::atom_group *group3; |
| | |
| /// Inter site vectors | /// Inter site vectors |
| cvm::rvector r21, r23; | cvm::rvector r21, r23; |
| |
| /// Derivatives wrt group centers of mass | /// Derivatives wrt group centers of mass |
| cvm::rvector dxdr1, dxdr3; | cvm::rvector dxdr1, dxdr3; |
| | |
| /// Compute system force on first site only to avoid unwanted | /// Compute total force on first site only to avoid unwanted |
| /// coupling to other colvars (see e.g. Ciccotti et al., 2005) | /// coupling to other colvars (see e.g. Ciccotti et al., 2005) |
| /// (or to allow dummy atoms) | /// (or to allow dummy atoms) |
| bool b_1site_force; | bool b_1site_force; |
| |
| colvarvalue const &x2) const; | colvarvalue const &x2) const; |
| }; | }; |
| | |
| | /// \brief 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]) |
| | class colvar::dipole_angle |
| | : public colvar::cvc |
| | { |
| | protected: |
| | |
| | /// Dipole atom group |
| | cvm::atom_group *group1; |
| | /// Atom group |
| | cvm::atom_group *group2; |
| | /// Atom group |
| | cvm::atom_group *group3; |
| | |
| | /// Inter site vectors |
| | cvm::rvector r21, r23; |
| | /// Inter site vector norms |
| | cvm::real r21l, r23l; |
| | /// Derivatives wrt group centers of mass |
| | cvm::rvector dxdr1, dxdr3; |
| | |
| | /// Compute total force on first site only to avoid unwanted |
| | /// coupling to other colvars (see e.g. Ciccotti et al., 2005) |
| | /// (or to allow dummy atoms) |
| | bool b_1site_force; |
| | public: |
| | |
| | /// Initialize by parsing the configuration |
| | dipole_angle (std::string const &conf); |
| | /// \brief Initialize the three groups after three atoms |
| | dipole_angle (cvm::atom const &a1, cvm::atom const &a2, cvm::atom const &a3); |
| | dipole_angle(); |
| | virtual inline ~dipole_angle() {} |
| | virtual void calc_value(); |
| | virtual void calc_gradients(); |
| | virtual void apply_force (colvarvalue const &force); |
| | virtual cvm::real dist2 (colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | virtual colvarvalue dist2_lgrad (colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | virtual colvarvalue dist2_rgrad (colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | }; |
| | |
| /// \brief Colvar component: dihedral between the centers of mass of | /// \brief Colvar component: dihedral between the centers of mass of |
| /// four groups (colvarvalue::type_scalar type, range [-PI:PI]) | /// four groups (colvarvalue::type_scalar type, range [-PI:PI]) |
| |
| protected: | protected: |
| | |
| /// Atom group | /// Atom group |
| cvm::atom_group group1; | cvm::atom_group *group1; |
| /// Atom group | /// Atom group |
| cvm::atom_group group2; | cvm::atom_group *group2; |
| /// Atom group | /// Atom group |
| cvm::atom_group group3; | cvm::atom_group *group3; |
| /// Atom group | /// Atom group |
| cvm::atom_group group4; | cvm::atom_group *group4; |
| /// Inter site vectors | /// Inter site vectors |
| cvm::rvector r12, r23, r34; | cvm::rvector r12, r23, r34; |
| | |
| /// \brief Compute system force on first site only to avoid unwanted | /// \brief Compute total force on first site only to avoid unwanted |
| /// coupling to other colvars (see e.g. Ciccotti et al., 2005) | /// coupling to other colvars (see e.g. Ciccotti et al., 2005) |
| bool b_1site_force; | bool b_1site_force; |
| | |
| |
| /// \brief Colvar component: coordination number between two groups | /// \brief Colvar component: coordination number between two groups |
| /// (colvarvalue::type_scalar type, range [0:N1*N2]) | /// (colvarvalue::type_scalar type, range [0:N1*N2]) |
| class colvar::coordnum | class colvar::coordnum |
| : public colvar::distance | : public colvar::cvc |
| { | { |
| protected: | protected: |
| | /// First atom group |
| | cvm::atom_group *group1; |
| | /// Second atom group |
| | cvm::atom_group *group2; |
| /// \brief "Cutoff" for isotropic calculation (default) | /// \brief "Cutoff" for isotropic calculation (default) |
| cvm::real r0; | cvm::real r0; |
| /// \brief "Cutoff vector" for anisotropic calculation | /// \brief "Cutoff vector" for anisotropic calculation |
| |
| /// \brief Colvar component: self-coordination number within a group | /// \brief Colvar component: self-coordination number within a group |
| /// (colvarvalue::type_scalar type, range [0:N*(N-1)/2]) | /// (colvarvalue::type_scalar type, range [0:N*(N-1)/2]) |
| class colvar::selfcoordnum | class colvar::selfcoordnum |
| : public colvar::distance | : public colvar::cvc |
| { | { |
| protected: | protected: |
| | /// First atom group |
| | cvm::atom_group *group1; |
| /// \brief "Cutoff" for isotropic calculation (default) | /// \brief "Cutoff" for isotropic calculation (default) |
| cvm::real r0; | cvm::real r0; |
| /// Integer exponent of the function numerator | /// Integer exponent of the function numerator |
| |
| colvarvalue const &x2) const; | colvarvalue const &x2) const; |
| }; | }; |
| | |
| | |
| | /// \brief Colvar component: coordination number between two groups |
| | /// (colvarvalue::type_scalar type, range [0:N1*N2]) |
| | class colvar::groupcoordnum |
| | : public colvar::distance |
| | { |
| | protected: |
| | /// \brief "Cutoff" for isotropic calculation (default) |
| | cvm::real r0; |
| | /// \brief "Cutoff vector" for anisotropic calculation |
| | cvm::rvector r0_vec; |
| | /// \brief Wheter dist/r0 or \vec{dist}*\vec{1/r0_vec} should ne be |
| | /// used |
| | bool b_anisotropic; |
| | /// Integer exponent of the function numerator |
| | int en; |
| | /// Integer exponent of the function denominator |
| | int ed; |
| | public: |
| | /// Constructor |
| | groupcoordnum(std::string const &conf); |
| | groupcoordnum(); |
| | virtual inline ~groupcoordnum() {} |
| | virtual void calc_value(); |
| | virtual void calc_gradients(); |
| | virtual void apply_force(colvarvalue const &force); |
| | template<bool b_gradients> |
| | /// \brief Calculate a coordination number through the function |
| | /// (1-x**n)/(1-x**m), x = |A1-A2|/r0 \param r0 "cutoff" for the |
| | /// coordination number \param exp_num \i n exponent \param exp_den |
| | /// \i m exponent \param A1 atom \param A2 atom |
| | static cvm::real switching_function(cvm::real const &r0, |
| | int const &exp_num, int const &exp_den, |
| | cvm::atom &A1, cvm::atom &A2); |
| | |
| | /* |
| | template<bool b_gradients> |
| | /// \brief Calculate a coordination number through the function |
| | /// (1-x**n)/(1-x**m), x = |(A1-A2)*(r0_vec)^-|1 \param r0_vec |
| | /// vector of different cutoffs in the three directions \param |
| | /// exp_num \i n exponent \param exp_den \i m exponent \param A1 |
| | /// atom \param A2 atom |
| | static cvm::real switching_function(cvm::rvector const &r0_vec, |
| | int const &exp_num, int const &exp_den, |
| | cvm::atom &A1, cvm::atom &A2); |
| | |
| | virtual cvm::real dist2(colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | virtual colvarvalue dist2_lgrad(colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | virtual colvarvalue dist2_rgrad(colvarvalue const &x1, |
| | colvarvalue const &x2) const; |
| | */ |
| | }; |
| | |
| | |
| /// \brief Colvar component: hydrogen bond, defined as the product of | /// \brief Colvar component: hydrogen bond, defined as the product of |
| /// a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol)) | /// a colvar::coordnum and 1/2*(1-cos((180-ang)/ang_tol)) |
| /// (colvarvalue::type_scalar type, range [0:1]) | /// (colvarvalue::type_scalar type, range [0:1]) |
| |
| protected: | protected: |
| | |
| /// Atom group | /// Atom group |
| cvm::atom_group atoms; | cvm::atom_group * atoms; |
| /// Center of geometry of the group | /// Center of geometry of the group |
| cvm::atom_pos atoms_cog; | cvm::atom_pos atoms_cog; |
| | |
| |
| protected: | protected: |
| | |
| /// Atom group | /// Atom group |
| cvm::atom_group atoms; | cvm::atom_group *atoms; |
| | |
| /// Reference coordinates (for RMSD calculation only) | /// Reference coordinates (for RMSD calculation only) |
| std::vector<cvm::atom_pos> ref_pos; | std::vector<cvm::atom_pos> ref_pos; |
| |
| { | { |
| protected: | protected: |
| /// Atom group | /// Atom group |
| cvm::atom_group atoms; | cvm::atom_group *atoms; |
| /// Which Cartesian coordinates to include | /// Which Cartesian coordinates to include |
| std::vector<size_t> axes; | std::vector<size_t> axes; |
| public: | public: |
| |
| simple_scalar_dist_functions(distance_xy) | simple_scalar_dist_functions(distance_xy) |
| simple_scalar_dist_functions(distance_inv) | simple_scalar_dist_functions(distance_inv) |
| simple_scalar_dist_functions(angle) | simple_scalar_dist_functions(angle) |
| | simple_scalar_dist_functions(dipole_angle) |
| simple_scalar_dist_functions(coordnum) | simple_scalar_dist_functions(coordnum) |
| simple_scalar_dist_functions(selfcoordnum) | simple_scalar_dist_functions(selfcoordnum) |
| simple_scalar_dist_functions(h_bond) | simple_scalar_dist_functions(h_bond) |