Skip to content

Commit

Permalink
Control when hills are added at the same step in metadynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomofiorin committed May 2, 2023
1 parent 6e7559f commit ffb677b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/colvarbias_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,17 @@ int colvarbias_meta::clear_state_data()
// **********************************************************************

std::list<colvarbias_meta::hill>::const_iterator
colvarbias_meta::add_hill(colvarbias_meta::hill const &h)
colvarbias_meta::add_hill(colvarbias_meta::hill const &h,
bool check_same_step)
{
hill_iter const hills_end = hills.end();
if (hills.size()) {
if (hills.end()->it == h.it && check_same_step) {
// Prevent adding multiple hills from repeated calls to update()
return hills.end();
}
}

hills.push_back(h);
if (new_hills_begin == hills_end) {
// if new_hills_begin is unset, set it for the first time
Expand Down Expand Up @@ -902,12 +910,12 @@ int colvarbias_meta::reflect_hill_multid(cvm::real const &h_scale)

case single_replica:

add_hill(hill(cvm::step_absolute(), hill_weight*h_scale, curr_cv_values, colvar_sigmas));
add_hill(hill(cvm::step_absolute(), hill_weight*h_scale, curr_cv_values, colvar_sigmas), false);

break;

case multiple_replicas:
add_hill(hill(cvm::step_absolute(), hill_weight*h_scale, curr_cv_values, colvar_sigmas, replica_id));
add_hill(hill(cvm::step_absolute(), hill_weight*h_scale, curr_cv_values, colvar_sigmas, replica_id), false);
std::ostream &replica_hills_os =
cvm::proxy->output_stream(replica_hills_file);
if (replica_hills_os) {
Expand Down
9 changes: 5 additions & 4 deletions src/colvarbias_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ class colvarbias_meta
/// Read a hill from a file
std::istream & read_hill(std::istream &is);

/// \brief Add a new hill; if a .hills trajectory is written,
/// write it there; if there is more than one replica, communicate
/// it to the others
std::list<hill>::const_iterator add_hill(hill const &h);
/// Add a new hill (also outputs to .hills trajectory if open)
/// \param h New Gaussian hill object
/// \param check_same_step Check if a hill was just added
std::list<hill>::const_iterator add_hill(hill const &h,
bool check_same_step = true);

/// \brief Remove a previously saved hill (returns an iterator for
/// the next hill in the list)
Expand Down

0 comments on commit ffb677b

Please sign in to comment.