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

colvarbias_abf.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_ABF_H
00011 #define COLVARBIAS_ABF_H
00012 
00013 #include <vector>
00014 #include <list>
00015 #include <sstream>
00016 #include <iomanip>
00017 
00018 #include "colvarproxy.h"
00019 #include "colvarbias.h"
00020 #include "colvargrid.h"
00021 #include "colvar_UIestimator.h"
00022 
00023 typedef cvm::real* gradient_t;
00024 
00025 
00027 class colvarbias_abf : public colvarbias {
00028 
00029 public:
00030 
00032   colvarbias_abf(char const *key);
00034   virtual int init(std::string const &conf);
00036   virtual ~colvarbias_abf();
00038   virtual int update();
00039 
00040 private:
00041 
00043   std::string  output_prefix;
00044 
00046   std::vector<std::string> input_prefix;
00047 
00049   bool    update_bias;
00052   bool    hide_Jacobian;
00054   bool    b_integrate;
00055 
00057   size_t  full_samples;
00059   size_t  min_samples;
00061   bool    b_history_files;
00063   bool    b_czar_window_file;
00065   size_t  history_freq;
00067   UIestimator::UIestimator eabf_UI;
00069   bool  b_UI_estimator;
00071   bool  b_CZAR_estimator;
00072 
00074   int   pabf_freq;
00076   int       integrate_iterations;
00078   cvm::real integrate_tol;
00080   int       pabf_integrate_iterations;
00082   cvm::real pabf_integrate_tol;
00083 
00085   bool                    cap_force;
00087   std::vector<cvm::real>  max_force;
00088 
00089   // Internal data and methods
00090 
00092   std::vector<int>  bin;
00094   std::vector<int> force_bin;
00096   std::vector<int> z_bin;
00097 
00099   gradient_t system_force;
00100 
00102   colvar_grid_gradient  *gradients;
00104   colvar_grid_count     *samples;
00106   integrate_potential   *pmf;
00108   colvar_grid_gradient  *z_gradients;
00110   colvar_grid_count     *z_samples;
00112   colvar_grid_gradient  *czar_gradients;
00114   integrate_potential   *czar_pmf;
00115 
00116   inline int update_system_force(size_t i)
00117   {
00118     if (colvars[i]->is_enabled(f_cv_subtract_applied_force)) {
00119       // this colvar is already subtracting the ABF force
00120       system_force[i] = colvars[i]->total_force().real_value;
00121     } else {
00122       system_force[i] = colvars[i]->total_force().real_value
00123         - colvar_forces[i].real_value;
00124         // If hideJacobian is active then total_force has an extra term of -fj
00125         // which is the Jacobian-compensating force at the colvar level
00126     }
00127     if (cvm::debug())
00128       cvm::log("ABF System force calc: cv " + cvm::to_str(i) +
00129                " fs " + cvm::to_str(system_force[i]) +
00130                " = ft " + cvm::to_str(colvars[i]->total_force().real_value) +
00131                " - fa " + cvm::to_str(colvar_forces[i].real_value));
00132     return COLVARS_OK;
00133   }
00134 
00135   // shared ABF
00136   bool    shared_on;
00137   size_t  shared_freq;
00138   cvm::step_number shared_last_step;
00139   // Share between replicas -- may be called independently of update
00140   virtual int replica_share();
00141 
00142   // Store the last set for shared ABF
00143   colvar_grid_gradient  *last_gradients;
00144   colvar_grid_count     *last_samples;
00145 
00146   // For Tcl implementation of selection rules.
00148   virtual int bin_num();
00150   virtual int current_bin();
00152   virtual int bin_count(int bin_index);
00153 
00155   void write_gradients_samples(const std::string &prefix, bool close = true);
00156 
00158   int read_gradients_samples();
00159 
00161   template <class T> int write_grid_to_file(T const *grid,
00162                                             std::string const &name,
00163                                             bool close);
00164 
00165   virtual std::istream& read_state_data(std::istream&);
00166   virtual std::ostream& write_state_data(std::ostream&);
00167   virtual int write_output_files();
00168 
00170   virtual int calc_energy(std::vector<colvarvalue> const *values);
00171 };
00172 
00173 #endif

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