diff --git a/doc/src/PDF/colvars-refman-lammps.pdf b/doc/src/PDF/colvars-refman-lammps.pdf index 6bc252156c..d1349fd424 100644 Binary files a/doc/src/PDF/colvars-refman-lammps.pdf and b/doc/src/PDF/colvars-refman-lammps.pdf differ diff --git a/lib/colvars/colvarbias.cpp b/lib/colvars/colvarbias.cpp index 22469c1b3b..90c552ac0b 100644 --- a/lib/colvars/colvarbias.cpp +++ b/lib/colvars/colvarbias.cpp @@ -172,6 +172,7 @@ int colvarbias::add_colvar(std::string const &cv_name) int colvarbias::update() { // Note: if anything is added here, it should be added also in the SMP block of calc_biases() + // TODO move here debug msg of bias update has_data = true; return COLVARS_OK; } diff --git a/lib/colvars/colvarbias_abf.cpp b/lib/colvars/colvarbias_abf.cpp index ba0d791c06..dc2a1b8dbb 100644 --- a/lib/colvars/colvarbias_abf.cpp +++ b/lib/colvars/colvarbias_abf.cpp @@ -20,6 +20,8 @@ int colvarbias_abf::init(std::string const &conf) { colvarbias::init(conf); + provide(f_cvb_history_dependent); + // TODO relax this in case of VMD plugin if (cvm::temperature() == 0.0) cvm::log("WARNING: ABF should not be run without a thermostat or at 0 Kelvin!\n"); @@ -27,10 +29,18 @@ int colvarbias_abf::init(std::string const &conf) // ************* parsing general ABF options *********************** get_keyval(conf, "applyBias", apply_bias, true); - if (!apply_bias) cvm::log("WARNING: ABF biases will *not* be applied!\n"); + if (apply_bias) { + enable(f_cvb_apply_force); + } else { + cvm::log("WARNING: ABF biases will *not* be applied!\n"); + } get_keyval(conf, "updateBias", update_bias, true); - if (!update_bias) cvm::log("WARNING: ABF biases will *not* be updated!\n"); + if (update_bias) { + enable(f_cvb_history_dependent); + } else { + cvm::log("WARNING: ABF biases will *not* be updated!\n"); + } get_keyval(conf, "hideJacobian", hide_Jacobian, false); if (hide_Jacobian) { @@ -44,7 +54,7 @@ int colvarbias_abf::init(std::string const &conf) min_samples = full_samples / 2; // full_samples - min_samples >= 1 is guaranteed - get_keyval(conf, "inputPrefix", input_prefix, std::vector ()); + get_keyval(conf, "inputPrefix", input_prefix, std::vector()); get_keyval(conf, "outputFreq", output_freq, cvm::restart_out_freq); get_keyval(conf, "historyFreq", history_freq, 0); b_history_files = (history_freq > 0); diff --git a/lib/colvars/colvarbias_alb.cpp b/lib/colvars/colvarbias_alb.cpp index b6745dabc4..e6865ae15b 100644 --- a/lib/colvars/colvarbias_alb.cpp +++ b/lib/colvars/colvarbias_alb.cpp @@ -33,6 +33,8 @@ int colvarbias_alb::init(std::string const &conf) { colvarbias::init(conf); + provide(f_cvb_history_dependent); + size_t i; // get the initial restraint centers @@ -82,6 +84,8 @@ int colvarbias_alb::init(std::string const &conf) if (update_freq == 0) cvm::fatal_error("Error: must set updateFrequency to greater than 2.\n"); + enable(f_cvb_history_dependent); + get_keyval(conf, "outputCenters", b_output_centers, false); get_keyval(conf, "outputGradient", b_output_grad, false); get_keyval(conf, "outputCoupling", b_output_coupling, true); diff --git a/lib/colvars/colvarbias_histogram.cpp b/lib/colvars/colvarbias_histogram.cpp index ff2db6cad0..0d52c18361 100644 --- a/lib/colvars/colvarbias_histogram.cpp +++ b/lib/colvars/colvarbias_histogram.cpp @@ -17,6 +17,9 @@ int colvarbias_histogram::init(std::string const &conf) { colvarbias::init(conf); + provide(f_cvb_history_dependent); + enable(f_cvb_history_dependent); + size_t i; get_keyval(conf, "outputFile", out_name, std::string("")); @@ -82,7 +85,6 @@ int colvarbias_histogram::init(std::string const &conf) } } - cvm::log("Finished histogram setup.\n"); return COLVARS_OK; } @@ -132,7 +134,7 @@ int colvarbias_histogram::update() // update indices for scalar values size_t i; for (i = 0; i < colvars.size(); i++) { - bin[i] = grid->value_to_bin_scalar(colvars[i]->value(), i); + bin[i] = grid->current_bin_scalar(i); } if (grid->index_ok(bin)) { @@ -143,7 +145,7 @@ int colvarbias_histogram::update() size_t iv, i; for (iv = 0; iv < colvar_array_size; iv++) { for (i = 0; i < colvars.size(); i++) { - bin[i] = grid->value_to_bin_scalar(colvars[i]->value().vector1d_value[iv], i); + bin[i] = grid->current_bin_scalar(i, iv); } if (grid->index_ok(bin)) { diff --git a/lib/colvars/colvarbias_meta.cpp b/lib/colvars/colvarbias_meta.cpp index 30d5f73222..eb98a99259 100644 --- a/lib/colvars/colvarbias_meta.cpp +++ b/lib/colvars/colvarbias_meta.cpp @@ -37,18 +37,26 @@ int colvarbias_meta::init(std::string const &conf) { colvarbias::init(conf); - // TODO this relies on having initialized biases in alphabetical order - if (cvm::n_abf_biases > 0) - 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.0); - if (hill_weight <= 0.0) { + if (hill_weight > 0.0) { + enable(f_cvb_apply_force); + } else { cvm::error("Error: hillWeight must be provided, and a positive number.\n", INPUT_ERROR); } 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); + 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; diff --git a/lib/colvars/colvarbias_restraint.cpp b/lib/colvars/colvarbias_restraint.cpp index 2b613e13f7..6b4f76ff7f 100644 --- a/lib/colvars/colvarbias_restraint.cpp +++ b/lib/colvars/colvarbias_restraint.cpp @@ -563,6 +563,7 @@ cvm::real colvarbias_restraint_harmonic::restraint_convert_k(cvm::real k, } + colvarbias_restraint_linear::colvarbias_restraint_linear(char const *key) : colvarbias_restraint(key) { diff --git a/lib/colvars/colvardeps.cpp b/lib/colvars/colvardeps.cpp index b5d9e09270..eabb67de4c 100644 --- a/lib/colvars/colvardeps.cpp +++ b/lib/colvars/colvardeps.cpp @@ -210,6 +210,8 @@ void cvm::deps::init_cvb_requires() { f_description(f_cvb_get_system_force, "obtain system force"); f_req_children(f_cvb_get_system_force, f_cv_system_force); + f_description(f_cvb_history_dependent, "history-dependent"); + // Initialize feature_states for each instance feature_states.reserve(f_cvb_ntot); for (i = 0; i < f_cvb_ntot; i++) { @@ -217,6 +219,9 @@ void cvm::deps::init_cvb_requires() { // Most features are available, so we set them so // and list exceptions below } + + // some biases are not history-dependent + feature_states[f_cvb_history_dependent]->available = false; } diff --git a/lib/colvars/colvardeps.h b/lib/colvars/colvardeps.h index 926746f45a..8787819b45 100644 --- a/lib/colvars/colvardeps.h +++ b/lib/colvars/colvardeps.h @@ -147,8 +147,9 @@ public: enum features_biases { /// \brief Bias is active f_cvb_active, - f_cvb_apply_force, - f_cvb_get_system_force, + f_cvb_apply_force, // will apply forces + f_cvb_get_system_force, // requires system forces + f_cvb_history_dependent, // depends on simulation history f_cvb_ntot }; diff --git a/lib/colvars/colvargrid.h b/lib/colvars/colvargrid.h index c42894c60a..405d29d972 100644 --- a/lib/colvars/colvargrid.h +++ b/lib/colvars/colvargrid.h @@ -368,6 +368,14 @@ public: return value_to_bin_scalar(actual_value[i] ? cv[i]->actual_value() : cv[i]->value(), i); } + /// \brief Report the bin corresponding to the current value of item iv in variable i + inline int current_bin_scalar(int const i, int const iv) const + { + return value_to_bin_scalar(actual_value[i] ? + cv[i]->actual_value().vector1d_value[iv] : + cv[i]->value().vector1d_value[iv], i); + } + /// \brief Use the lower boundary and the width to report which bin /// the provided value is in inline int value_to_bin_scalar(colvarvalue const &value, const int i) const diff --git a/lib/colvars/colvarmodule.cpp b/lib/colvars/colvarmodule.cpp index f95024a090..c1829bed76 100644 --- a/lib/colvars/colvarmodule.cpp +++ b/lib/colvars/colvarmodule.cpp @@ -299,12 +299,27 @@ int colvarmodule::parse_biases(std::string const &conf) cvm::decrease_depth(); } - for (size_t i = 0; i < biases.size(); i++) { + size_t i; + + for (i = 0; i < biases.size(); i++) { biases[i]->enable(cvm::deps::f_cvb_active); if (cvm::debug()) biases[i]->print_state(); } + size_t n_hist_dep_biases = 0; + for (i = 0; i < biases.size(); i++) { + if (biases[i]->is_enabled(cvm::deps::f_cvb_apply_force) && + biases[i]->is_enabled(cvm::deps::f_cvb_history_dependent)) { + n_hist_dep_biases++; + } + } + if (n_hist_dep_biases) { + cvm::log("WARNING: there are "+cvm::to_str(n_hist_dep_biases)+ + " history-dependent biases with non-zero force parameters; " + "please make sure that their forces do not counteract each other.\n"); + } + if (biases.size() || use_scripted_forces) { cvm::log(cvm::line_marker); cvm::log("Collective variables biases initialized, "+ diff --git a/lib/colvars/colvarmodule.h b/lib/colvars/colvarmodule.h index 04dcbadd61..028806594b 100644 --- a/lib/colvars/colvarmodule.h +++ b/lib/colvars/colvarmodule.h @@ -4,7 +4,7 @@ #define COLVARMODULE_H #ifndef COLVARS_VERSION -#define COLVARS_VERSION "2016-06-23" +#define COLVARS_VERSION "2016-07-05" #endif #ifndef COLVARS_DEBUG