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

colvarbias_restraint.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_RESTRAINT_H
00011 #define COLVARBIAS_RESTRAINT_H
00012 
00013 #include "colvarbias.h"
00014 
00015 #ifdef _MSC_VER
00016 #pragma warning(push)
00017 #pragma warning(disable : 4250) // Silence diamond inheritance warning
00018 #endif
00019 
00023 class colvarbias_restraint
00024   : public virtual colvarbias,
00025     public virtual colvarbias_ti
00026 {
00027 
00028 public:
00029 
00031   virtual int update();
00032 
00034   virtual int change_configuration(std::string const & /* conf */) { return COLVARS_NOT_IMPLEMENTED; }
00035 
00037   virtual cvm::real energy_difference(std::string const & /* conf */) { return 0.0; }
00038 
00039   virtual std::string const get_state_params() const;
00040   virtual int set_state_params(std::string const &conf);
00041   // virtual std::ostream & write_state_data(std::ostream &os);
00042   // virtual std::istream & read_state_data(std::istream &os);
00043 
00044   virtual std::ostream & write_traj_label(std::ostream &os);
00045   virtual std::ostream & write_traj(std::ostream &os);
00046 
00048   colvarbias_restraint(char const *key);
00049 
00050   virtual int init(std::string const &conf);
00051   virtual ~colvarbias_restraint();
00052 
00053 
00054 protected:
00055 
00057   virtual cvm::real restraint_potential(size_t i) const = 0;
00058 
00060   virtual colvarvalue const restraint_force(size_t i) const = 0;
00061 
00063   virtual cvm::real d_restraint_potential_dk(size_t i) const = 0;
00064 };
00065 
00066 
00068 class colvarbias_restraint_centers
00069   : public virtual colvarbias_restraint
00070 {
00071 public:
00072 
00073   colvarbias_restraint_centers(char const *key);
00074   virtual int init(std::string const &conf);
00075   virtual int change_configuration(std::string const &conf);
00076 
00077 protected:
00078 
00080   std::vector<colvarvalue> colvar_centers;
00081 };
00082 
00083 
00085 class colvarbias_restraint_k
00086   : public virtual colvarbias_restraint
00087 {
00088 public:
00089 
00090   colvarbias_restraint_k(char const *key);
00091   virtual int init(std::string const &conf);
00092   virtual int change_configuration(std::string const &conf);
00093 
00094 protected:
00095 
00097   cvm::real force_k;
00098 
00100   bool check_positive_k;
00101 };
00102 
00103 
00105 class colvarbias_restraint_moving
00106   : public virtual colvarparse, public virtual colvardeps {
00107 public:
00108 
00109   colvarbias_restraint_moving(char const *key);
00110   // Note: despite the diamond inheritance, most of this function gets only executed once
00111   virtual int init(std::string const &conf);
00112   virtual int update() { return COLVARS_OK; }
00113   virtual int change_configuration(std::string const & /* conf */) { return COLVARS_NOT_IMPLEMENTED; }
00114 
00115   virtual std::string const get_state_params() const;
00116   virtual int set_state_params(std::string const &conf);
00117 
00118 protected:
00119 
00121   bool b_chg_centers;
00122 
00124   bool b_chg_force_k;
00125 
00127   bool b_decoupling;
00128 
00131   int target_nstages;
00132 
00134   int stage;
00135 
00137   std::vector<cvm::real> lambda_schedule;
00138 
00141   cvm::step_number target_nsteps;
00142 
00144   cvm::step_number first_step;
00145 
00147   cvm::real acc_work;
00148 };
00149 
00150 
00152 class colvarbias_restraint_centers_moving
00153   : public virtual colvarbias_restraint_centers,
00154     public virtual colvarbias_restraint_moving
00155 {
00156 public:
00157 
00158   colvarbias_restraint_centers_moving(char const *key);
00159   virtual int init(std::string const &conf);
00160   virtual int update();
00161   virtual int change_configuration(std::string const & /* conf */) { return COLVARS_NOT_IMPLEMENTED; }
00162 
00163   virtual std::string const get_state_params() const;
00164   virtual int set_state_params(std::string const &conf);
00165   virtual std::ostream & write_traj_label(std::ostream &os);
00166   virtual std::ostream & write_traj(std::ostream &os);
00167 
00168 protected:
00169 
00171   std::vector<colvarvalue> target_centers;
00172 
00174   std::vector<colvarvalue> initial_centers;
00175 
00177   std::vector<colvarvalue> centers_incr;
00178 
00180   virtual int update_centers(cvm::real lambda);
00181 
00183   bool b_output_centers;
00184 
00186   int update_acc_work();
00187 };
00188 
00189 
00191 class colvarbias_restraint_k_moving
00192   : public virtual colvarbias_restraint_k,
00193     public virtual colvarbias_restraint_moving
00194 {
00195 public:
00196 
00197   colvarbias_restraint_k_moving(char const *key);
00198   virtual int init(std::string const &conf);
00199   virtual int update();
00200   virtual int change_configuration(std::string const & /* conf */) { return COLVARS_NOT_IMPLEMENTED; }
00201 
00202   virtual std::string const get_state_params() const;
00203   virtual int set_state_params(std::string const &conf);
00204   virtual std::ostream & write_traj_label(std::ostream &os);
00205   virtual std::ostream & write_traj(std::ostream &os);
00206 
00207 protected:
00208 
00210   cvm::real target_force_k;
00211 
00213   cvm::real starting_force_k;
00214 
00216   cvm::real lambda_exp;
00217 
00220   cvm::real restraint_FE;
00221 
00223   cvm::real target_equil_steps;
00224 
00226   cvm::real force_k_incr;
00227 
00229   int update_acc_work();
00230 };
00231 
00232 
00235 class colvarbias_restraint_harmonic
00236   : public colvarbias_restraint_centers_moving,
00237     public colvarbias_restraint_k_moving
00238 {
00239 public:
00240   colvarbias_restraint_harmonic(char const *key);
00241   virtual int init(std::string const &conf);
00242   virtual int update();
00243   virtual std::string const get_state_params() const;
00244   virtual int set_state_params(std::string const &conf);
00245   virtual std::ostream & write_state_data(std::ostream &os);
00246   virtual std::istream & read_state_data(std::istream &os);
00247   virtual std::ostream & write_traj_label(std::ostream &os);
00248   virtual std::ostream & write_traj(std::ostream &os);
00249   virtual int change_configuration(std::string const &conf);
00250   virtual cvm::real energy_difference(std::string const &conf);
00251 
00252 protected:
00253 
00254   virtual cvm::real restraint_potential(size_t i) const;
00255   virtual colvarvalue const restraint_force(size_t i) const;
00256   virtual cvm::real d_restraint_potential_dk(size_t i) const;
00257 };
00258 
00259 
00262 class colvarbias_restraint_harmonic_walls
00263   : public colvarbias_restraint_k_moving
00264 {
00265 public:
00266 
00267   colvarbias_restraint_harmonic_walls(char const *key);
00268   virtual int init(std::string const &conf);
00269   virtual int update();
00270   virtual std::string const get_state_params() const;
00271   virtual int set_state_params(std::string const &conf);
00272   virtual std::ostream & write_state_data(std::ostream &os);
00273   virtual std::istream & read_state_data(std::istream &os);
00274   virtual std::ostream & write_traj_label(std::ostream &os);
00275   virtual std::ostream & write_traj(std::ostream &os);
00276 
00277 protected:
00278 
00280   std::vector<colvarvalue> lower_walls;
00281 
00283   std::vector<colvarvalue> upper_walls;
00284 
00286   cvm::real lower_wall_k;
00287 
00289   cvm::real upper_wall_k;
00290 
00291   virtual cvm::real colvar_distance(size_t i) const;
00292   virtual cvm::real restraint_potential(size_t i) const;
00293   virtual colvarvalue const restraint_force(size_t i) const;
00294   virtual cvm::real d_restraint_potential_dk(size_t i) const;
00295 };
00296 
00297 
00300 class colvarbias_restraint_linear
00301   : public colvarbias_restraint_centers_moving,
00302     public colvarbias_restraint_k_moving
00303 {
00304 
00305 public:
00306   colvarbias_restraint_linear(char const *key);
00307   virtual int init(std::string const &conf);
00308   virtual int update();
00309   virtual int change_configuration(std::string const &conf);
00310   virtual cvm::real energy_difference(std::string const &conf);
00311 
00312   virtual std::string const get_state_params() const;
00313   virtual int set_state_params(std::string const &conf);
00314   virtual std::ostream & write_state_data(std::ostream &os);
00315   virtual std::istream & read_state_data(std::istream &os);
00316   virtual std::ostream & write_traj_label(std::ostream &os);
00317   virtual std::ostream & write_traj(std::ostream &os);
00318 
00319 protected:
00320 
00321   virtual cvm::real restraint_potential(size_t i) const;
00322   virtual colvarvalue const restraint_force(size_t i) const;
00323   virtual cvm::real d_restraint_potential_dk(size_t i) const;
00324 };
00325 
00326 
00328 // TODO this could be reimplemented more cleanly as a derived class of both restraint and histogram
00329 class colvarbias_restraint_histogram : public colvarbias {
00330 
00331 public:
00332 
00333   colvarbias_restraint_histogram(char const *key);
00334   int init(std::string const &conf);
00335   ~colvarbias_restraint_histogram();
00336 
00337   virtual int update();
00338 
00339   virtual int write_output_files();
00340   virtual std::ostream & write_traj_label(std::ostream &os);
00341   virtual std::ostream & write_traj(std::ostream &os);
00342 
00343 protected:
00344 
00346   cvm::vector1d<cvm::real> p;
00347 
00349   cvm::vector1d<cvm::real> ref_p;
00350 
00352   cvm::vector1d<cvm::real> p_diff;
00353 
00355   cvm::real lower_boundary;
00356 
00358   cvm::real upper_boundary;
00359 
00361   cvm::real width;
00362 
00364   cvm::real gaussian_width;
00365 
00367   cvm::real force_k;
00368 
00370   bool b_write_histogram;
00371 };
00372 
00373 #ifdef _MSC_VER
00374 #pragma warning(pop)
00375 #endif
00376 
00377 #endif

Generated on Fri Nov 8 02:44:10 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002