Files
lammps/lib/colvars/colvarbias_histogram_reweight_amd.h
Giacomo Fiorin 377c652a83 Update Colvars library to version 2023-05-01
This update consists exclusively of bugfixes or maintenance-related changes.

The following is a list of pull requests in the Colvars repository since the previous update to LAMMPS:

- 532 Add XYZ trajectory reading feature
  https://github.com/Colvars/colvars/pull/532 (@jhenin, @giacomofiorin)

- 531 Delete objects quietly, unless explicitly requested via script (including VMD)
  https://github.com/Colvars/colvars/pull/531 (@giacomofiorin)

- 530 Append newline to log and error messages if not already present
  https://github.com/Colvars/colvars/pull/530 (@giacomofiorin)

- 528 Forward-declare OpenMP lock
  https://github.com/Colvars/colvars/pull/528 (@giacomofiorin)

- 527 Remove unneeded STL container
  https://github.com/Colvars/colvars/pull/527 (@giacomofiorin)

- 526 Allow collecting configuration files and strings before setting up interface
  https://github.com/Colvars/colvars/pull/526 (@giacomofiorin, @jhenin)

- 523 Fallback to linearCombination when customFunction is missing in customColvar
  https://github.com/Colvars/colvars/pull/523 (@HanatoK, @giacomofiorin)

- 522 Use iostream::fail() to check for I/O error
  https://github.com/Colvars/colvars/pull/522 (@jhenin)

- 520 Fix ref count
  https://github.com/Colvars/colvars/pull/520 (@giacomofiorin)

- 513 Set target temperature through a common code path
  https://github.com/Colvars/colvars/pull/513 (@giacomofiorin, @jhenin)

- 509 Safer detection of Windows with recent Microsoft Visual Studio versions
  https://github.com/Colvars/colvars/pull/509 (@akohlmey)

- 508 Update LAMMPS patching method to reflect Lepton availability
  https://github.com/Colvars/colvars/pull/508 (@giacomofiorin)

- 497 Increase the precision of write_multicol
  https://github.com/Colvars/colvars/pull/497 (@HanatoK)

- 496 Only perform MTS automatic enable/disable for timeStepFactor > 1
  https://github.com/Colvars/colvars/pull/496 (@giacomofiorin)

- 493 Remove unused branch of quaternion input function
  https://github.com/Colvars/colvars/pull/493 (@giacomofiorin)

- 489 Ensure there are spaces between the fields in the header
  https://github.com/Colvars/colvars/pull/489 (@HanatoK)

- 487 Use map of output streams, and return references to its elements
  https://github.com/Colvars/colvars/pull/487 (@giacomofiorin, @jhenin)

- 486 Remember first step of moving restraint
  https://github.com/Colvars/colvars/pull/486 (@jhenin)

- 485 Add decoupling option for moving restraints
  https://github.com/Colvars/colvars/pull/485 (@jhenin)

- 483 Update Lepton via patching procedure
  https://github.com/Colvars/colvars/pull/483 (@giacomofiorin)

- 481 Make file-reading operations of input data abstractable
  https://github.com/Colvars/colvars/pull/481 (@giacomofiorin)

Authors: @akohlmey, @giacomofiorin, @HanatoK, @jhenin
2023-05-17 13:29:00 -04:00

105 lines
4.0 KiB
C++

// -*- c++ -*-
// This file is part of the Collective Variables module (Colvars).
// The original version of Colvars and its updates are located at:
// https://github.com/Colvars/colvars
// Please update all Colvars source files before making any changes.
// If you wish to distribute your changes, please submit them to the
// Colvars repository at GitHub.
#ifndef COLVARBIAS_HISTOGRAM_REWEIGHT_AMD
#define COLVARBIAS_HISTOGRAM_REWEIGHT_AMD
#include "colvarbias_histogram.h"
/// Reweighted histogram for accelerated molecular dynamics (aMD) or
/// Gaussian aMD (GaMD)
class colvarbias_reweightaMD : public colvarbias_histogram {
public:
colvarbias_reweightaMD(char const *key);
virtual ~colvarbias_reweightaMD();
#if (__cplusplus >= 201103L)
virtual int init(std::string const &conf) override;
virtual int update() override;
virtual int write_output_files() override;
#else
virtual int init(std::string const &conf);
virtual int update();
virtual int write_output_files();
#endif
/// @brief convert histogram to PMF by taking logarithm and multiplying
/// it with -1/beta
/// @param[in,out] hist the origin histogram and also the output PMF
/// @param[in] hist_count the sampling or biased histogram
void hist_to_pmf(
colvar_grid_scalar* hist,
const colvar_grid_scalar* hist_count) const;
/// @brief calculate the cumulant expansion to second order
/// @param[in] hist_dV the histogram of the boosting potential, ΔV(ξ)
/// @param[in] hist_dV_square the histogram of the square of boosting
/// potential
/// @param[in] hist_count the sampling or biased histogram
/// @param[out] cumulant_expansion_factor the factor of the cumulant
/// expansion to second order
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;
/// @brief output the PMF by the exponential average estimator
/// @param[in] p_output_prefix the prefix of the output file
/// @param[in] keep_open Allow writing the history of the PMF
virtual int write_exponential_reweighted_pmf(
const std::string& p_output_prefix, bool keep_open = false);
/// @brief output the PMF by the cumulant expansion estimator
/// @param[in] p_output_prefix the prefix of the output file
/// @param[in] keep_open Allow writing the history of the expansion
virtual int write_cumulant_expansion_pmf(
const std::string& p_output_prefix, bool keep_open = false);
/// @brief output the biased sampling
/// @param[in] p_output_prefix the prefix of the output file
/// @param[in] keep_open Allow writing the history of the samples
virtual int write_count(
const std::string& p_output_prefix, bool keep_open = false);
protected:
/// Current accelMD factor is the from previous frame
std::vector<int> previous_bin;
/// Start collecting samples after N steps
colvarmodule::step_number start_after_steps;
/// Use cumulant expansion to second order?
bool b_use_cumulant_expansion;
colvar_grid_scalar* grid_count;
colvar_grid_scalar* grid_dV;
colvar_grid_scalar* grid_dV_square;
/// Number of timesteps between recording data in history files (if non-zero)
size_t history_freq;
bool b_history_files;
/// Write gradients of the PMF?
bool b_write_gradients;
/// save and restore
#if (__cplusplus >= 201103L)
virtual std::istream & read_state_data(std::istream &is) override;
virtual std::ostream & write_state_data(std::ostream &os) override;
#else
virtual std::istream & read_state_data(std::istream &is);
virtual std::ostream & write_state_data(std::ostream &os);
#endif
private:
/// temporary grids for evaluating PMFs
colvar_grid_scalar *pmf_grid_exp_avg;
colvar_grid_scalar *pmf_grid_cumulant;
colvar_grid_gradient *grad_grid_exp_avg;
colvar_grid_gradient *grad_grid_cumulant;
};
#endif // COLVARBIAS_HISTOGRAM_REWEIGHT_AMD