Commit 969d3cf4 authored by Giacomo Fiorin's avatar Giacomo Fiorin
Browse files

Colvars update: make ABF check that the colvar isn't using already subtractAppliedForce

parent 030df745
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -242,13 +242,7 @@ int colvarbias_abf::update()
      for (size_t i = 0; i < colvars.size(); i++) {
        // get total forces (lagging by 1 timestep) from colvars
        // and subtract previous ABF force
        system_force[i] = colvars[i]->total_force().real_value
                        - colvar_forces[i].real_value;
//         if (cvm::debug())
//           cvm::log("ABF System force calc: cv " + cvm::to_str(i) +
//                   " fs " + cvm::to_str(system_force[i]) +
//                   " = ft " + cvm::to_str(colvars[i]->total_force().real_value) +
//                   " - fa " + cvm::to_str(colvar_forces[i].real_value));
        update_system_force(i);
      }
      gradients->acc_force(force_bin, system_force);
    }
@@ -260,8 +254,7 @@ int colvarbias_abf::update()
        for (size_t i = 0; i < colvars.size(); i++) {
          // If we are outside the range of xi, the force has not been obtained above
          // the function is just an accessor, so cheap to call again anyway
          system_force[i] = colvars[i]->total_force().real_value
                          - colvar_forces[i].real_value;
          update_system_force(i);
        }
        z_gradients->acc_force(z_bin, system_force);
      }
+17 −0
Original line number Diff line number Diff line
@@ -62,6 +62,23 @@ private:
  /// n-dim grid contining CZAR estimator of "real" free energy gradients
  colvar_grid_gradient  *czar_gradients;

  inline int update_system_force(size_t i)
  {
    if (colvars[i]->is_enabled(f_cv_subtract_applied_force)) {
      // this colvar is already subtracting the ABF force
      system_force[i] = colvars[i]->total_force().real_value;
    } else {
      system_force[i] = colvars[i]->total_force().real_value
        - colvar_forces[i].real_value;
    }
    if (cvm::debug())
      cvm::log("ABF System force calc: cv " + cvm::to_str(i) +
               " fs " + cvm::to_str(system_force[i]) +
               " = ft " + cvm::to_str(colvars[i]->total_force().real_value) +
               " - fa " + cvm::to_str(colvar_forces[i].real_value));
    return COLVARS_OK;
  }

  // shared ABF
  bool     shared_on;
  size_t   shared_freq;
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
#define COLVARMODULE_H

#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2016-09-30"
#define COLVARS_VERSION "2016-10-05"
#endif

#ifndef COLVARS_DEBUG
+8 −0
Original line number Diff line number Diff line
@@ -303,6 +303,14 @@ public:
                 COLVARS_NOT_IMPLEMENTED);
  }

  /// Are total forces being used?
  virtual bool total_forces_enabled() const
  {
    cvm::error("Error: total forces are currently not implemented.\n",
               COLVARS_NOT_IMPLEMENTED);
    return false;
  }

  /// \brief Get the PBC-aware distance vector between two positions
  virtual cvm::rvector position_distance(cvm::atom_pos const &pos1,
                                         cvm::atom_pos const &pos2) = 0;
+3 −3
Original line number Diff line number Diff line
@@ -299,9 +299,9 @@ void colvarproxy_lammps::error(std::string const &message)
void colvarproxy_lammps::fatal_error(std::string const &message)
{
  log(message);
  if (!cvm::debug())
    log("If this error message is unclear, try recompiling the "
         "colvars library and LAMMPS with -DCOLVARS_DEBUG.\n");
  // if (!cvm::debug())
  //   log("If this error message is unclear, try recompiling the "
  //        "colvars library and LAMMPS with -DCOLVARS_DEBUG.\n");

  _lmp->error->one(FLERR,
                   "Fatal error in the collective variables module.\n");
Loading