@@ -739,9 +739,17 @@ int colvarbias_meta::clear_state_data()
739
739
// **********************************************************************
740
740
741
741
std::list<colvarbias_meta::hill>::const_iterator
742
- colvarbias_meta::add_hill (colvarbias_meta::hill const &h)
742
+ colvarbias_meta::add_hill (colvarbias_meta::hill const &h,
743
+ bool check_same_step)
743
744
{
744
745
hill_iter const hills_end = hills.end ();
746
+ if (hills.size ()) {
747
+ if (hills.end ()->it == h.it && check_same_step) {
748
+ // Prevent adding multiple hills from repeated calls to update()
749
+ return hills.end ();
750
+ }
751
+ }
752
+
745
753
hills.push_back (h);
746
754
if (new_hills_begin == hills_end) {
747
755
// if new_hills_begin is unset, set it for the first time
@@ -902,12 +910,12 @@ int colvarbias_meta::reflect_hill_multid(cvm::real const &h_scale)
902
910
903
911
case single_replica:
904
912
905
- add_hill (hill (cvm::step_absolute (), hill_weight*h_scale, curr_cv_values, colvar_sigmas));
913
+ add_hill (hill (cvm::step_absolute (), hill_weight*h_scale, curr_cv_values, colvar_sigmas), false );
906
914
907
915
break ;
908
916
909
917
case multiple_replicas:
910
- add_hill (hill (cvm::step_absolute (), hill_weight*h_scale, curr_cv_values, colvar_sigmas, replica_id));
918
+ add_hill (hill (cvm::step_absolute (), hill_weight*h_scale, curr_cv_values, colvar_sigmas, replica_id), false );
911
919
std::ostream &replica_hills_os =
912
920
cvm::proxy->output_stream (replica_hills_file);
913
921
if (replica_hills_os) {
0 commit comments