Difference for src/colvar.h from version 1.16 to 1.17

version 1.16version 1.17
Line 1
Line 1
 /// -*- c++ -*- // -*- c++ -*-
  
 #ifndef COLVAR_H #ifndef COLVAR_H
 #define COLVAR_H #define COLVAR_H
Line 10
Line 10
 #include "colvarmodule.h" #include "colvarmodule.h"
 #include "colvarvalue.h" #include "colvarvalue.h"
 #include "colvarparse.h" #include "colvarparse.h"
  #include "colvardeps.h"
  
  
 /// \brief A collective variable (main class); to be defined, it needs /// \brief A collective variable (main class); to be defined, it needs
Line 37
Line 38
 /// \link colvarvalue \endlink type, you should also add its /// \link colvarvalue \endlink type, you should also add its
 /// initialization line in the \link colvar \endlink constructor. /// initialization line in the \link colvar \endlink constructor.
  
 class colvar : public colvarparse { class colvar : public colvarparse, public colvardeps {
  
 public: public:
  
Line 53
Line 54
   /// \brief Current velocity (previously set by calc() or by read_traj())   /// \brief Current velocity (previously set by calc() or by read_traj())
   colvarvalue const & velocity() const;   colvarvalue const & velocity() const;
  
   /// \brief Current system force (previously obtained from calc() or   /// \brief Current total force (previously obtained from calc() or
   /// read_traj()).  Note: this is calculated using the atomic forces   /// read_traj()).  Note: this is calculated using the atomic forces
   /// from the last simulation step.   /// from the last simulation step.
   ///   ///
Line 61
Line 62
   /// acting on the collective variable is calculated summing those   /// acting on the collective variable is calculated summing those
   /// from all colvar components, the bias and walls forces are   /// from all colvar components, the bias and walls forces are
   /// subtracted.   /// subtracted.
   colvarvalue const & system_force() const;   colvarvalue const & total_force() const;
  
   /// \brief 
  
   /// \brief Typical fluctuation amplitude for this collective   /// \brief Typical fluctuation amplitude for this collective
   /// variable (e.g. local width of a free energy basin)   /// variable (e.g. local width of a free energy basin)
Line 75
Line 74
   /// variable.   /// variable.
   cvm::real width;   cvm::real width;
  
   /// \brief True if this \link colvar \endlink is a linear   /// \brief Implementation of the feature list for colvar
   /// combination of \link cvc \endlink elements   static std::vector<feature *> cv_features;
   bool b_linear; 
    /// \brief Implementation of the feature list accessor for colvar
   /// \brief True if this \link colvar \endlink is a linear   std::vector<feature *> &features() {
   /// combination of cvcs with coefficients 1 or -1     return cv_features;
   bool b_homogeneous;   }
  
   /// \brief True if all \link cvc \endlink objects are capable 
   /// of calculating inverse gradients 
   bool b_inverse_gradients; 
  
   /// \brief True if all \link cvc \endlink objects are capable 
   /// of calculating Jacobian forces 
   bool b_Jacobian_force; 
  
   /// \brief Options controlling the behaviour of the colvar during 
   /// the simulation, which are set from outside the cvcs 
   enum task { 
     /// \brief Gradients are calculated and temporarily stored, so 
     /// that external forces can be applied 
     task_gradients, 
     /// \brief Collect atomic gradient data from all cvcs into vector 
     /// atomic_gradients 
     task_collect_gradients, 
     /// \brief Calculate the velocity with finite differences 
     task_fdiff_velocity, 
     /// \brief The system force is calculated, projecting the atomic 
     /// forces on the inverse gradients 
     task_system_force, 
     /// \brief The variable has a harmonic restraint around a moving 
     /// center with fictitious mass; bias forces will be applied to 
     /// the center 
     task_extended_lagrangian, 
     /// \brief The extended system coordinate undergoes Langevin 
     /// dynamics 
     task_langevin, 
     /// \brief Output the potential and kinetic energies 
     /// (for extended Lagrangian colvars only) 
     task_output_energy, 
     /// \brief Compute analytically the "force" arising from the 
     /// geometric entropy component (for example, that from the angular 
     /// states orthogonal to a distance vector) 
     task_Jacobian_force, 
     /// \brief Report the Jacobian force as part of the system force 
     /// if disabled, apply a correction internally to cancel it 
     task_report_Jacobian_force, 
     /// \brief Output the value to the trajectory file (on by default) 
     task_output_value, 
     /// \brief Output the velocity to the trajectory file 
     task_output_velocity, 
     /// \brief Output the applied force to the trajectory file 
     task_output_applied_force, 
     /// \brief Output the system force to the trajectory file 
     task_output_system_force, 
     /// \brief A lower boundary is defined 
     task_lower_boundary, 
     /// \brief An upper boundary is defined 
     task_upper_boundary, 
     /// \brief Provide a discretization of the values of the colvar to 
     /// be used by the biases or in analysis (needs lower and upper 
     /// boundary) 
     task_grid, 
     /// \brief Apply a restraining potential (|x-xb|^2) to the colvar 
     /// when it goes below the lower wall 
     task_lower_wall, 
     /// \brief Apply a restraining potential (|x-xb|^2) to the colvar 
     /// when it goes above the upper wall 
     task_upper_wall, 
     /// \brief Compute running average 
     task_runave, 
     /// \brief Compute time correlation function 
     task_corrfunc, 
     /// \brief Value and gradients computed by user script 
     task_scripted, 
     /// \brief Number of possible tasks 
     task_ntot 
   }; 
  
   /// Tasks performed by this colvar   int refresh_deps();
   bool tasks[task_ntot]; 
  
   /// List of biases that depend on this colvar   /// List of biases that depend on this colvar
   std::vector<colvarbias *> biases;   std::vector<colvarbias *> biases;
Line 213
Line 140
   /// Cached reported velocity   /// Cached reported velocity
   colvarvalue v_reported;   colvarvalue v_reported;
  
   // Options for task_extended_lagrangian   // Options for extended_lagrangian
   /// Restraint center   /// Restraint center
   colvarvalue xr;   colvarvalue xr;
   /// Velocity of the restraint center   /// Velocity of the restraint center
Line 230
Line 157
   /// \brief Harmonic restraint force   /// \brief Harmonic restraint force
   colvarvalue fr;   colvarvalue fr;
  
   /// \brief Jacobian force, when task_Jacobian_force is enabled   /// \brief Jacobian force, when Jacobian_force is enabled
   colvarvalue fj;   colvarvalue fj;
  
   /// Cached reported system force   /// Cached reported total force
   colvarvalue ft_reported;   colvarvalue ft_reported;
  
 public: public:
Line 243
Line 170
   /// the biases are updated   /// the biases are updated
   colvarvalue fb;   colvarvalue fb;
  
   /// \brief Total \em applied force; fr (if task_extended_lagrangian   /// \brief Total \em applied force; fr (if extended_lagrangian
   /// is defined), fb (if biases are applied) and the walls' forces   /// is defined), fb (if biases are applied) and the walls' forces
   /// (if defined) contribute to it   /// (if defined) contribute to it
   colvarvalue f;   colvarvalue f;
  
    /// Applied force at the previous step (to be subtracted from total force if needed)
    colvarvalue f_old;
  
   /// \brief Total force, as derived from the atomic trajectory;   /// \brief Total force, as derived from the atomic trajectory;
   /// should equal the total system force plus \link f \endlink   /// should equal the system force plus \link f \endlink
   colvarvalue ft;   colvarvalue ft;
  
  
Line 293
Line 223
   /// Constructor   /// Constructor
   colvar(std::string const &conf);   colvar(std::string const &conf);
  
   /// Enable the specified task   /// Parse the CVC configuration and allocate their data
   int enable(colvar::task const &t);   int init_components(std::string const &conf);
  
  private:
    /// Parse the CVC configuration for all components of a certain type
    template<typename def_class_name> int init_components_type(std::string const &conf,
                                                               char const *def_desc,
                                                               char const *def_config_key);
  
   /// Disable the specified task public:
   void disable(colvar::task const &t); 
  
   /// Get ready for a run and possibly re-initialize internal data   /// Get ready for a run and re-initialize internal data if needed
   void setup();   void setup();
  
   /// Destructor   /// Destructor
   ~colvar();   ~colvar();
  
  
   /// \brief Calculate the colvar value and all the other requested   /// \brief Calculate the colvar's value and related quantities
   /// quantities   int calc();
   void calc(); 
    /// \brief 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 calc_cvcs(int first = 0, size_t num_cvcs = 0);
  
    /// Ensure that the selected range of CVCs is consistent
    int check_cvc_range(int first_cvc, size_t num_cvcs);
  
    /// \brief Calculate the values of the given subset of CVCs
    int calc_cvc_values(int first, size_t num_cvcs);
    /// \brief Same as \link colvar::calc_cvc_values \endlink but for gradients
    int calc_cvc_gradients(int first, size_t num_cvcs);
    /// \brief Same as \link colvar::calc_cvc_values \endlink but for total forces
    int calc_cvc_total_force(int first, size_t num_cvcs);
    /// \brief Same as \link colvar::calc_cvc_values \endlink but for Jacobian derivatives/forces
    int calc_cvc_Jacobians(int first, size_t num_cvcs);
  
    /// \brief Collect quantities from CVCs and update aggregated data for the colvar
    int collect_cvc_data();
  
    /// \brief Collect the values of the CVCs
    int collect_cvc_values();
    /// \brief Same as \link colvar::collect_cvc_values \endlink but for gradients
    int collect_cvc_gradients();
    /// \brief Same as \link colvar::collect_cvc_values \endlink but for total forces
    int collect_cvc_total_forces();
    /// \brief Same as \link colvar::collect_cvc_values \endlink but for Jacobian derivatives/forces
    int collect_cvc_Jacobians();
    /// \brief Calculate the quantities associated to the colvar (but not to the CVCs)
    int calc_colvar_properties();
  
   /// \brief Calculate just the value, and store it in the argument   /// Get the current applied force
   void calc_value(colvarvalue &xn);   inline colvarvalue const applied_force() const
    {
      if (is_enabled(f_cv_extended_Lagrangian)) {
        return fr;
      }
      return f;
    }
  
   /// Set the total biasing force to zero   /// Set the total biasing force to zero
   void reset_bias_force();   void reset_bias_force();
Line 323
Line 294
   /// equations of motion of internal degrees of freedom; see also   /// equations of motion of internal degrees of freedom; see also
   /// colvar::communicate_forces()   /// colvar::communicate_forces()
   /// return colvar energy if extended Lagrandian active   /// return colvar energy if extended Lagrandian active
   cvm::real update();   cvm::real update_forces_energy();
  
   /// \brief Communicate forces (previously calculated in   /// \brief Communicate forces (previously calculated in
   /// colvar::update()) to the external degrees of freedom   /// colvar::update()) to the external degrees of freedom
Line 332
Line 303
   /// \brief Enables and disables individual CVCs based on flags   /// \brief Enables and disables individual CVCs based on flags
   int set_cvc_flags(std::vector<bool> const &flags);   int set_cvc_flags(std::vector<bool> const &flags);
  
    /// \brief Updates the flags in the CVC objects, and their number
    int update_cvc_flags();
  
  protected:
    /// \brief Number of CVC objects with an active flag
    size_t n_active_cvcs;
  
    /// Sum of square coefficients for active cvcs
    cvm::real active_cvc_square_norm;
  
    /// Time step multiplier (for coarse-time-step colvars)
    /// Colvar will only be calculated at those times; biases may ignore the information and
    /// always update their own forces (which is typically inexpensive) especially if
    /// they rely on other colvars. In this case, the colvar will accumulate forces applied between
    /// colvar updates. Alternately they may use it to calculate "impulse" biasing
    /// forces at longer intervals. Impulse forces must be multiplied by the timestep factor.
    int   time_step_factor;
  
    /// Biasing force collected between updates, to be applied at next update for coarse-time-step colvars
    colvarvalue f_accumulated;
  
  public:
    /// \brief Return the number of CVC objects with an active flag (as set by update_cvc_flags)
    inline size_t num_active_cvcs() const { return n_active_cvcs; }
  
    /// \brief returns time_step_factor
    inline int get_time_step_factor() const {return time_step_factor;}
  
   /// \brief Use the internal metrics (as from \link cvc   /// \brief Use the internal metrics (as from \link cvc
   /// \endlink objects) to calculate square distances and gradients   /// \endlink objects) to calculate square distances and gradients
   ///   ///
Line 384
Line 383
  
  
 protected: protected:
  
   /// Previous value (to calculate velocities during analysis)   /// Previous value (to calculate velocities during analysis)
   colvarvalue            x_old;   colvarvalue            x_old;
  
Line 486
Line 484
   class distance_inv;   class distance_inv;
   class distance_pairs;   class distance_pairs;
   class angle;   class angle;
    class dipole_angle;
   class dihedral;   class dihedral;
   class coordnum;   class coordnum;
   class selfcoordnum;   class selfcoordnum;
    class groupcoordnum;
   class h_bond;   class h_bond;
   class rmsd;   class rmsd;
   class orientation_angle;   class orientation_angle;
Line 518
Line 518
   std::vector<bool> cvc_flags;   std::vector<bool> cvc_flags;
  
   /// \brief Initialize the sorted list of atom IDs for atoms involved   /// \brief Initialize the sorted list of atom IDs for atoms involved
   /// in all cvcs (called when enabling task_collect_gradients)   /// in all cvcs (called when enabling f_cv_collect_gradients)
   void build_atom_list(void);   void build_atom_list(void);
  
 private: private:
Line 562
Line 562
 } }
  
  
 inline colvarvalue const & colvar::system_force() const inline colvarvalue const & colvar::total_force() const
 { {
   return ft_reported;   return ft_reported;
 } }
Line 570
Line 570
  
 inline void colvar::add_bias_force(colvarvalue const &force) inline void colvar::add_bias_force(colvarvalue const &force)
 { {
    if (cvm::debug()) {
      cvm::log("Adding biasing force "+cvm::to_str(force)+" to colvar \""+name+"\".\n");
    }
   fb += force;   fb += force;
 } }
  


Legend:
Removed in v.1.16 
changed lines
 Added in v.1.17



Made by using version 1.53 of cvs2html