Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

colvarbias.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 
00003 // This file is part of the Collective Variables module (Colvars).
00004 // The original version of Colvars and its updates are located at:
00005 // https://github.com/Colvars/colvars
00006 // Please update all Colvars source files before making any changes.
00007 // If you wish to distribute your changes, please submit them to the
00008 // Colvars repository at GitHub.
00009 
00010 #ifndef COLVARBIAS_H
00011 #define COLVARBIAS_H
00012 
00013 #include "colvar.h"
00014 #include "colvarparse.h"
00015 #include "colvardeps.h"
00016 
00017 class colvar_grid_scalar;
00018 
00020 class colvarbias
00021   : public virtual colvarparse, public virtual colvardeps {
00022 public:
00023 
00025   std::string name;
00026 
00028   std::string bias_type;
00029 
00031   std::string state_keyword;
00032 
00034   int rank;
00035 
00037   int add_colvar(std::string const &cv_name);
00038 
00040   inline size_t num_variables() const
00041   {
00042     return colvars.size();
00043   }
00044 
00046   inline std::vector<colvar *> *variables()
00047   {
00048     return &colvars;
00049   }
00050 
00052   inline colvar * variables(int i) const
00053   {
00054     return colvars[i];
00055   }
00056 
00059   virtual int update();
00060 
00063   virtual bool can_accumulate_data();
00064 
00068   virtual int calc_energy(std::vector<colvarvalue> const *values);
00069 
00073   virtual int calc_forces(std::vector<colvarvalue> const *values);
00074 
00076   int communicate_forces();
00077 
00079   virtual int end_of_step();
00080 
00082   virtual int change_configuration(std::string const &conf);
00083 
00085   virtual cvm::real energy_difference(std::string const &conf);
00086 
00088   // FIXME this is currently 1D only
00089   virtual int bin_num();
00091   // FIXME this is currently 1D only
00092   virtual int current_bin();
00094   // FIXME this is currently 1D only
00095   virtual int bin_count(int bin_index);
00097   virtual int replica_share();
00098 
00100   virtual void analyze() {}
00101 
00103   colvarbias(char const *key);
00104 
00106   virtual int init(std::string const &conf);
00107 
00109   virtual int init_dependencies();
00110 
00112   virtual int reset();
00113 
00114 private:
00115 
00117   colvarbias();
00118 
00120   colvarbias(colvarbias &);
00121 
00122 public:
00123 
00125   virtual int clear();
00126 
00128   virtual int clear_state_data();
00129 
00131   virtual ~colvarbias();
00132 
00134   virtual std::string const get_state_params() const;
00135 
00137   virtual int set_state_params(std::string const &state_conf);
00138 
00140   virtual std::ostream & write_state_data(std::ostream &os)
00141   {
00142     return os;
00143   }
00144 
00146   virtual std::istream & read_state_data(std::istream &is)
00147   {
00148     return is;
00149   }
00150 
00154   std::istream & read_state_data_key(std::istream &is, char const *key);
00155 
00157   std::ostream & write_state(std::ostream &os);
00158 
00160   std::istream & read_state(std::istream &is);
00161 
00163   int write_state_prefix(std::string const &prefix);
00164 
00166   int write_state_string(std::string &output);
00167 
00169   int read_state_prefix(std::string const &prefix);
00170 
00172   int read_state_string(char const *buffer);
00173 
00175   virtual std::ostream & write_traj_label(std::ostream &os);
00176 
00178   virtual std::ostream & write_traj(std::ostream &os);
00179 
00181   virtual int setup_output()
00182   {
00183     return COLVARS_OK;
00184   }
00185 
00187   size_t output_freq;
00188 
00190   virtual int write_output_files()
00191   {
00192     return COLVARS_OK;
00193   }
00194 
00196   std::string output_prefix;
00197 
00199   virtual int write_state_to_replicas()
00200   {
00201     return COLVARS_OK;
00202   }
00203 
00204   inline cvm::real get_energy()
00205   {
00206     return bias_energy;
00207   }
00208 
00210   static std::vector<feature *> cvb_features;
00211 
00213   virtual const std::vector<feature *> &features() const
00214   {
00215     return cvb_features;
00216   }
00217   virtual std::vector<feature *> &modify_features()
00218   {
00219     return cvb_features;
00220   }
00221   static void delete_features() {
00222     for (size_t i=0; i < cvb_features.size(); i++) {
00223       delete cvb_features[i];
00224     }
00225     cvb_features.clear();
00226   }
00227 
00228 protected:
00229 
00233   std::vector<colvar *>    colvars;
00234 
00236   std::vector<colvarvalue> colvar_values;
00237 
00239   std::vector<colvarvalue> colvar_forces;
00240 
00242   std::vector<colvarvalue> previous_colvar_forces;
00243 
00245   cvm::real                bias_energy;
00246 
00248   bool                     b_output_energy;
00249 
00252   bool                     has_data;
00253 
00255   cvm::step_number         state_file_step;
00256 
00258   bool matching_state;
00259 
00262   colvar_grid_scalar*      biasing_force_scaling_factors;
00263   std::vector<int>         biasing_force_scaling_factors_bin;
00264 };
00265 
00266 
00267 class colvar_grid_gradient;
00268 class colvar_grid_count;
00269 
00271 class colvarbias_ti : public virtual colvarbias {
00272 public:
00273 
00274   colvarbias_ti(char const *key);
00275   virtual ~colvarbias_ti();
00276 
00277   virtual int clear_state_data();
00278 
00279   virtual int init(std::string const &conf);
00280   virtual int init_grids();
00281   virtual int update();
00282 
00285   virtual int update_system_forces(std::vector<colvarvalue> const
00286                                    *subtract_forces);
00287 
00288   virtual std::string const get_state_params() const;
00289   virtual int set_state_params(std::string const &state_conf);
00290   virtual std::ostream & write_state_data(std::ostream &os);
00291   virtual std::istream & read_state_data(std::istream &is);
00292   virtual int write_output_files();
00293 
00294 protected:
00295 
00297   std::vector<colvarvalue> ti_system_forces;
00298 
00300   colvar_grid_gradient *ti_avg_forces;
00301 
00303   colvar_grid_count *ti_count;
00304 
00307   std::vector<int> ti_bin;
00308 };
00309 
00310 #endif

Generated on Fri Oct 4 02:43:35 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002