Skip to content

Commit

Permalink
Added interval vectors as argument of project hills function. This fi…
Browse files Browse the repository at this point in the history
…xes the seg fault when using

multiple replicas
  • Loading branch information
fabsugar authored and giacomofiorin committed Oct 13, 2023
1 parent ee96944 commit 1585fa0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/colvarbias_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,9 @@ int colvarbias_meta::update_grid_data()
if ((cvm::step_absolute() % grids_freq) == 0) {
// map the most recent gaussians to the grids
project_hills(new_hills_begin, hills.end(),
hills_energy, hills_energy_gradients);
hills_energy, hills_energy_gradients,
which_int_llimit_cv, which_int_ulimit_cv,
interval_llimit, interval_ulimit);
new_hills_begin = hills.end();

// TODO: we may want to condense all into one replicas array,
Expand All @@ -1207,7 +1209,9 @@ int colvarbias_meta::update_grid_data()
replicas[ir]->project_hills(replicas[ir]->new_hills_begin,
replicas[ir]->hills.end(),
replicas[ir]->hills_energy,
replicas[ir]->hills_energy_gradients);
replicas[ir]->hills_energy_gradients,
which_int_llimit_cv, which_int_ulimit_cv,
interval_llimit, interval_ulimit);
replicas[ir]->new_hills_begin = replicas[ir]->hills.end();
}
}
Expand Down Expand Up @@ -1489,6 +1493,10 @@ void colvarbias_meta::project_hills(colvarbias_meta::hill_iter h_first,
colvarbias_meta::hill_iter h_last,
colvar_grid_scalar *he,
colvar_grid_gradient *hg,
std::vector<int> const &w_int_llimit_cv,
std::vector<int> const &w_int_ulimit_cv,
std::vector<cvm::real> const &int_llimit,
std::vector<cvm::real> const &int_ulimit,
bool print_progress)
{
if (cvm::debug())
Expand Down Expand Up @@ -1522,17 +1530,17 @@ void colvarbias_meta::project_hills(colvarbias_meta::hill_iter h_first,
for (i = 0; i < num_variables(); i++) {
add_force[i]=true;
new_colvar_values[i] = he->bin_to_value_scalar(he_ix[i], i);
ii=which_int_llimit_cv[i];
ii=w_int_llimit_cv[i];
if (ii>-1 ){
if ( new_colvar_values[i]<interval_llimit[ii] ) {
new_colvar_values[i]=interval_llimit[ii];
if ( new_colvar_values[i]<int_llimit[ii] ) {
new_colvar_values[i]=int_llimit[ii];
add_force[i]=false;
}
}
ii=which_int_ulimit_cv[i];
ii=w_int_ulimit_cv[i];
if (ii>-1){
if( new_colvar_values[i]>interval_ulimit[ii] ) {
new_colvar_values[i]=interval_ulimit[ii];
if( new_colvar_values[i]>int_ulimit[ii] ) {
new_colvar_values[i]=int_ulimit[ii];
add_force[i]=false;
}
}
Expand Down Expand Up @@ -2089,7 +2097,9 @@ void colvarbias_meta::rebin_grids_after_restart()
cvm::log("Rebinning the energy and forces grids from "+
cvm::to_str(hills.size())+" hills (this may take a while)...\n");
project_hills(hills.begin(), hills.end(),
new_hills_energy, new_hills_energy_gradients, true);
new_hills_energy, new_hills_energy_gradients,
which_int_llimit_cv, which_int_ulimit_cv,
interval_llimit, interval_ulimit, true);
cvm::log("rebinning done.\n");

} else {
Expand Down
2 changes: 2 additions & 0 deletions src/colvarbias_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class colvarbias_meta
/// \brief Project the selected hills onto grids
void project_hills(hill_iter h_first, hill_iter h_last,
colvar_grid_scalar *ge, colvar_grid_gradient *gf,
std::vector<int> const &w_int_llimit_cv, std::vector<int> const &w_int_ulimit_cv,
std::vector<cvm::real> const &int_llimit, std::vector<cvm::real> const &int_ulimit,
bool print_progress = false);


Expand Down

0 comments on commit 1585fa0

Please sign in to comment.