Skip to content

Commit

Permalink
Createe abf::setup_output() for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenin committed Apr 12, 2024
1 parent 2c21cf5 commit f99c2a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions src/colvarbias_abf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,6 @@ int colvarbias_abf::update()
// *********************************


// update the output prefix; TODO: move later to setup_output() function
if (cvm::main()->num_biases_feature(colvardeps::f_cvb_calc_pmf) == 1) {
// This is the only bias computing PMFs
output_prefix = cvm::output_prefix();
} else {
output_prefix = cvm::output_prefix() + "." + this->name;
}


// Prepare for the first sharing.
if (shared_last_step < 0) {
// Copy the current gradient and count values into last.
Expand All @@ -440,7 +431,6 @@ int colvarbias_abf::update()
x[i] = colvars[i]->actual_value();
y[i] = colvars[i]->value();
}
eabf_UI.update_output_filename(output_prefix);
eabf_UI.update(cvm::step_absolute(), x, y);
}

Expand Down Expand Up @@ -738,6 +728,20 @@ size_t colvarbias_abf::replica_share_freq() const
return shared_freq;
}

int colvarbias_abf::setup_output()
{
// update the output prefix
if (cvm::main()->num_biases_feature(colvardeps::f_cvb_calc_pmf) == 1) {
// This is the only bias computing PMFs
output_prefix = cvm::output_prefix();
} else {
output_prefix = cvm::output_prefix() + "." + this->name;
}
if (b_UI_estimator)
eabf_UI.update_output_filename(output_prefix);

return COLVARS_OK;
}

template <class T> int colvarbias_abf::write_grid_to_file(T const *grid,
std::string const &filename,
Expand Down
1 change: 1 addition & 0 deletions src/colvarbias_abf.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class colvarbias_abf : public colvarbias {
~colvarbias_abf() override;
/// Per-timestep update of ABF bias
int update() override;
int setup_output() override;

private:

Expand Down
3 changes: 1 addition & 2 deletions src/colvarscript_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ CVSCRIPT(cv_save,
cvm::state_file_prefix(script->obj_to_str(script->get_module_cmd_arg(0, objc, objv)));
int error_code = script->proxy()->set_output_prefix(prefix);
error_code |= script->module()->setup_output();
error_code |= script->module()->write_restart_file(prefix+
".colvars.state");
error_code |= script->module()->write_restart_file(prefix + ".colvars.state");
error_code |= script->module()->write_output_files();
return error_code;
)
Expand Down

0 comments on commit f99c2a0

Please sign in to comment.