version 1.18 | version 1.19 |
---|
| |
/// -*- c++ -*- | // -*- c++ -*- |
| |
#include <iostream> | #include <iostream> |
#include <sstream> | #include <sstream> |
| |
#include "colvarbias_meta.h" | #include "colvarbias_meta.h" |
| |
| |
colvarbias_meta::colvarbias_meta() | colvarbias_meta::colvarbias_meta(char const *key) |
: colvarbias(), | : colvarbias(key), |
new_hills_begin(hills.end()), | new_hills_begin(hills.end()), |
state_file_step(0) | state_file_step(0) |
{ | { |
} | } |
| |
| |
colvarbias_meta::colvarbias_meta(std::string const &conf, char const *key) | int colvarbias_meta::init(std::string const &conf) |
: colvarbias(conf, key), | |
new_hills_begin(hills.end()), | |
state_file_step(0) | |
{ | { |
if (cvm::n_abf_biases > 0) | colvarbias::init(conf); |
cvm::log("Warning: running ABF and metadynamics together is not recommended unless applyBias is off for ABF.\n"); | |
| provide(f_cvb_history_dependent); |
| |
get_keyval(conf, "hillWeight", hill_weight, 0.01); | get_keyval(conf, "hillWeight", hill_weight, 0.0); |
if (hill_weight == 0.0) | if (hill_weight > 0.0) { |
cvm::log("Warning: hillWeight has been set to zero, " | enable(f_cvb_apply_force); |
"this bias will have no effect.\n"); | } else { |
| cvm::error("Error: hillWeight must be provided, and a positive number.\n", INPUT_ERROR); |
| } |
| |
get_keyval(conf, "newHillFrequency", new_hill_freq, 1000); | get_keyval(conf, "newHillFrequency", new_hill_freq, 1000); |
| if (new_hill_freq > 0) { |
| enable(f_cvb_history_dependent); |
| } |
| |
get_keyval(conf, "hillWidth", hill_width, std::sqrt(2.0 * PI) / 2.0); | get_keyval(conf, "hillWidth", hill_width, std::sqrt(2.0 * PI) / 2.0); |
| cvm::log("Half-widths of the Gaussian hills (sigma's):\n"); |
| for (size_t i = 0; i < colvars.size(); i++) { |
| cvm::log(colvars[i]->name+std::string(": ")+ |
| cvm::to_str(0.5 * colvars[i]->width * hill_width)); |
| } |
| |
{ | { |
bool b_replicas = false; | bool b_replicas = false; |
| |
comm = single_replica; | comm = single_replica; |
} | } |
| |
| // This implies gradients for all colvars |
| enable(f_cvb_apply_force); |
| |
get_keyval(conf, "useGrids", use_grids, true); | get_keyval(conf, "useGrids", use_grids, true); |
| |
if (use_grids) { | if (use_grids) { |
| |
expand_grids = false; | expand_grids = false; |
size_t i; | size_t i; |
for (i = 0; i < colvars.size(); i++) { | for (i = 0; i < colvars.size(); i++) { |
| colvars[i]->enable(f_cv_grid); |
if (colvars[i]->expand_boundaries) { | if (colvars[i]->expand_boundaries) { |
expand_grids = true; | expand_grids = true; |
cvm::log("Metadynamics bias \""+this->name+"\""+ | cvm::log("Metadynamics bias \""+this->name+"\""+ |
| |
get_keyval(conf, "keepHills", keep_hills, false); | get_keyval(conf, "keepHills", keep_hills, false); |
if (! get_keyval(conf, "writeFreeEnergyFile", dump_fes, true)) | if (! get_keyval(conf, "writeFreeEnergyFile", dump_fes, true)) |
get_keyval(conf, "dumpFreeEnergyFile", dump_fes, true, colvarparse::parse_silent); | get_keyval(conf, "dumpFreeEnergyFile", dump_fes, true, colvarparse::parse_silent); |
get_keyval(conf, "saveFreeEnergyFile", dump_fes_save, false); | if (get_keyval(conf, "saveFreeEnergyFile", dump_fes_save, false, colvarparse::parse_silent)) { |
| cvm::log("Option \"saveFreeEnergyFile\" is deprecated, " |
for (i = 0; i < colvars.size(); i++) { | "please use \"keepFreeEnergyFiles\" instead."); |
colvars[i]->enable(colvar::task_grid); | |
} | } |
| get_keyval(conf, "keepFreeEnergyFiles", dump_fes_save, dump_fes_save); |
| |
hills_energy = new colvar_grid_scalar(colvars); | hills_energy = new colvar_grid_scalar(colvars); |
hills_energy_gradients = new colvar_grid_gradient(colvars); | hills_energy_gradients = new colvar_grid_gradient(colvars); |
| |
((comm != single_replica) ? ", replica \""+replica_id+"\"" : "")+".\n"); | ((comm != single_replica) ? ", replica \""+replica_id+"\"" : "")+".\n"); |
| |
save_delimiters = false; | save_delimiters = false; |
| return COLVARS_OK; |
} | } |
| |
| |
| |
} | } |
| |
| |
cvm::real colvarbias_meta::update() | int colvarbias_meta::update() |
{ | { |
if (cvm::debug()) | if (cvm::debug()) |
cvm::log("Updating the metadynamics bias \""+this->name+"\""+ | cvm::log("Updating the metadynamics bias \""+this->name+"\""+ |
| |
", hills forces = "+cvm::to_str(colvar_forces)+".\n"); | ", hills forces = "+cvm::to_str(colvar_forces)+".\n"); |
} | } |
| |
return bias_energy; | return COLVARS_OK; |
} | } |
| |
| |
| |
// add this replica to the registry | // add this replica to the registry |
cvm::log("Metadynamics bias \""+this->name+"\""+ | cvm::log("Metadynamics bias \""+this->name+"\""+ |
": accessing replica \""+new_replica+"\".\n"); | ": accessing replica \""+new_replica+"\".\n"); |
replicas.push_back(new colvarbias_meta()); | replicas.push_back(new colvarbias_meta("metadynamics")); |
(replicas.back())->replica_id = new_replica; | (replicas.back())->replica_id = new_replica; |
(replicas.back())->replica_list_file = new_replica_file; | (replicas.back())->replica_list_file = new_replica_file; |
(replicas.back())->replica_state_file = ""; | (replicas.back())->replica_state_file = ""; |