2015-02-20 02:20:52 +08:00
|
|
|
// -*- c++ -*-
|
2012-05-24 00:20:04 +08:00
|
|
|
|
|
|
|
#ifndef COLVARBIAS_ABF_H
|
|
|
|
#define COLVARBIAS_ABF_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <list>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
#include "colvarbias.h"
|
|
|
|
#include "colvargrid.h"
|
|
|
|
|
|
|
|
typedef cvm::real* gradient_t;
|
|
|
|
|
|
|
|
|
|
|
|
/// ABF bias
|
|
|
|
class colvarbias_abf : public colvarbias {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-12-02 10:09:53 +08:00
|
|
|
colvarbias_abf(std::string const &conf, char const *key);
|
|
|
|
~colvarbias_abf();
|
2012-05-24 00:20:04 +08:00
|
|
|
|
2016-04-16 00:07:01 +08:00
|
|
|
int update();
|
2012-05-24 00:20:04 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/// Filename prefix for human-readable gradient/sample count output
|
|
|
|
std::string output_prefix;
|
|
|
|
|
|
|
|
/// Base filename(s) for reading previous gradient data (replaces data from restart file)
|
|
|
|
std::vector<std::string> input_prefix;
|
|
|
|
|
|
|
|
bool apply_bias;
|
|
|
|
bool update_bias;
|
|
|
|
bool hide_Jacobian;
|
|
|
|
size_t full_samples;
|
|
|
|
size_t min_samples;
|
2015-04-30 22:09:42 +08:00
|
|
|
/// frequency for updating output files
|
2012-05-24 00:20:04 +08:00
|
|
|
int output_freq;
|
|
|
|
/// Write combined files with a history of all output data?
|
|
|
|
bool b_history_files;
|
|
|
|
size_t history_freq;
|
|
|
|
|
2013-06-28 06:48:27 +08:00
|
|
|
/// Cap applied biasing force?
|
|
|
|
bool cap_force;
|
|
|
|
std::vector<cvm::real> max_force;
|
|
|
|
|
2012-05-24 00:20:04 +08:00
|
|
|
// Internal data and methods
|
|
|
|
|
|
|
|
std::vector<int> bin, force_bin;
|
|
|
|
gradient_t force;
|
|
|
|
|
|
|
|
/// n-dim grid of free energy gradients
|
|
|
|
colvar_grid_gradient *gradients;
|
|
|
|
/// n-dim grid of number of samples
|
|
|
|
colvar_grid_count *samples;
|
|
|
|
|
2014-10-29 03:53:17 +08:00
|
|
|
// shared ABF
|
|
|
|
bool shared_on;
|
|
|
|
size_t shared_freq;
|
|
|
|
int shared_last_step;
|
|
|
|
// Share between replicas -- may be called independently of update
|
2014-12-02 10:09:53 +08:00
|
|
|
virtual int replica_share();
|
2014-10-29 03:53:17 +08:00
|
|
|
|
|
|
|
// Store the last set for shared ABF
|
|
|
|
colvar_grid_gradient *last_gradients;
|
|
|
|
colvar_grid_count *last_samples;
|
|
|
|
|
|
|
|
// For Tcl implementation of selection rules.
|
|
|
|
/// Give the total number of bins for a given bias.
|
|
|
|
virtual int bin_num();
|
|
|
|
/// Calculate the bin index for a given bias.
|
|
|
|
virtual int current_bin();
|
|
|
|
//// Give the count at a given bin index.
|
|
|
|
virtual int bin_count(int bin_index);
|
|
|
|
|
2012-05-24 00:20:04 +08:00
|
|
|
/// Write human-readable FE gradients and sample count
|
2014-12-02 10:09:53 +08:00
|
|
|
void write_gradients_samples(const std::string &prefix, bool append = false);
|
|
|
|
void write_last_gradients_samples(const std::string &prefix, bool append = false);
|
2012-05-24 00:20:04 +08:00
|
|
|
|
|
|
|
/// Read human-readable FE gradients and sample count (if not using restart)
|
2014-12-02 10:09:53 +08:00
|
|
|
void read_gradients_samples();
|
2012-05-24 00:20:04 +08:00
|
|
|
|
2014-12-02 10:09:53 +08:00
|
|
|
std::istream& read_restart(std::istream&);
|
|
|
|
std::ostream& write_restart(std::ostream&);
|
2012-05-24 00:20:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2015-04-30 22:09:42 +08:00
|
|
|
|