00001
00002
00003
00004
00005
00006
00007
00008
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
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
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
00125
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
00136 bool shared_on;
00137 size_t shared_freq;
00138 cvm::step_number shared_last_step;
00139
00140 virtual int replica_share();
00141
00142
00143 colvar_grid_gradient *last_gradients;
00144 colvar_grid_count *last_samples;
00145
00146
00148
00150
00152
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