Collective Variables Module - Developer Documentation
Loading...
Searching...
No Matches
colvarbias_histogram_reweight_amd.h
1// -*- c++ -*-
2
3// This file is part of the Collective Variables module (Colvars).
4// The original version of Colvars and its updates are located at:
5// https://github.com/Colvars/colvars
6// Please update all Colvars source files before making any changes.
7// If you wish to distribute your changes, please submit them to the
8// Colvars repository at GitHub.
9
10#ifndef COLVARBIAS_HISTOGRAM_REWEIGHT_AMD
11#define COLVARBIAS_HISTOGRAM_REWEIGHT_AMD
12
13#include "colvarbias_histogram.h"
14
18public:
19 colvarbias_reweightaMD(char const *key);
21 virtual int init(std::string const &conf) override;
22 virtual int update() override;
23 virtual int write_output_files() override;
24
29 void hist_to_pmf(
31 const colvar_grid_scalar* hist_count) const;
32
41 const colvar_grid_scalar* hist_dV,
42 const colvar_grid_scalar* hist_dV_square,
43 const colvar_grid_scalar* hist_count,
44 colvar_grid_scalar* cumulant_expansion_factor) const;
45
50 const std::string& p_output_prefix, bool keep_open = false);
51
56 const std::string& p_output_prefix, bool keep_open = false);
57
61 virtual int write_count(
62 const std::string& p_output_prefix, bool keep_open = false);
63protected:
65 std::vector<int> previous_bin;
68
71 colvar_grid_scalar* grid_count;
72 colvar_grid_scalar* grid_dV;
73 colvar_grid_scalar* grid_dV_square;
74
77 bool b_history_files;
78
81
82 template <typename OST> OST & write_state_data_template_(OST& os);
83 template <typename IST> IST & read_state_data_template_(IST& is);
84
86 virtual std::istream & read_state_data(std::istream &is) override;
88 virtual std::ostream & write_state_data(std::ostream &os) override;
90
91private:
94 colvar_grid_scalar *pmf_grid_cumulant;
95 colvar_grid_gradient *grad_grid_exp_avg;
96 colvar_grid_gradient *grad_grid_cumulant;
97};
98
99#endif // COLVARBIAS_HISTOGRAM_REWEIGHT_AMD
Class for accumulating the gradient of a scalar function on a grid.
Definition: colvargrid.h:1555
Class for accumulating a scalar function on a grid.
Definition: colvargrid.h:1242
Histogram "bias" (does as the name says)
Definition: colvarbias_histogram.h:22
Definition: colvarbias_histogram_reweight_amd.h:17
virtual int write_count(const std::string &p_output_prefix, bool keep_open=false)
output the biased sampling
Definition: colvarbias_histogram_reweight_amd.cpp:262
std::vector< int > previous_bin
Current accelMD factor is the from previous frame.
Definition: colvarbias_histogram_reweight_amd.h:65
colvarmodule::step_number start_after_steps
Start collecting samples after N steps.
Definition: colvarbias_histogram_reweight_amd.h:67
bool b_use_cumulant_expansion
Use cumulant expansion to second order?
Definition: colvarbias_histogram_reweight_amd.h:70
virtual int write_cumulant_expansion_pmf(const std::string &p_output_prefix, bool keep_open=false)
output the PMF by the cumulant expansion estimator
Definition: colvarbias_histogram_reweight_amd.cpp:226
virtual int write_output_files() override
Write any output files that this bias may have (e.g. PMF files)
Definition: colvarbias_histogram_reweight_amd.cpp:148
void compute_cumulant_expansion_factor(const colvar_grid_scalar *hist_dV, const colvar_grid_scalar *hist_dV_square, const colvar_grid_scalar *hist_count, colvar_grid_scalar *cumulant_expansion_factor) const
calculate the cumulant expansion to second order
Definition: colvarbias_histogram_reweight_amd.cpp:327
virtual int init(std::string const &conf) override
Parse config string and (re)initialize.
Definition: colvarbias_histogram_reweight_amd.cpp:52
virtual int write_exponential_reweighted_pmf(const std::string &p_output_prefix, bool keep_open=false)
output the PMF by the exponential average estimator
Definition: colvarbias_histogram_reweight_amd.cpp:178
virtual std::ostream & write_state_data(std::ostream &os) override
Write all mutable data not already written by get_state_params() to a formatted stream.
Definition: colvarbias_histogram_reweight_amd.cpp:365
bool b_write_gradients
Write gradients of the PMF?
Definition: colvarbias_histogram_reweight_amd.h:80
void hist_to_pmf(colvar_grid_scalar *hist, const colvar_grid_scalar *hist_count) const
convert histogram to PMF by taking logarithm and multiplying it with -1/beta
Definition: colvarbias_histogram_reweight_amd.cpp:276
size_t history_freq
Number of timesteps between recording data in history files (if non-zero)
Definition: colvarbias_histogram_reweight_amd.h:76
virtual int update() override
Definition: colvarbias_histogram_reweight_amd.cpp:84
colvar_grid_scalar * pmf_grid_exp_avg
temporary grids for evaluating PMFs
Definition: colvarbias_histogram_reweight_amd.h:93
virtual std::istream & read_state_data(std::istream &is) override
save and restore
Definition: colvarbias_histogram_reweight_amd.cpp:407
long long step_number
Use a 64-bit integer to store the step number.
Definition: colvarmodule.h:92
Definition: colvars_memstream.h:30