diff --git a/CHANGES/v2.2.txt b/CHANGES/v2.2.txt index 280db0b8434a5da4e15040ad0e4d62d0ff0b090c..c8243a2ed67a8f04547fa441c4df36d94dda87fd 100644 --- a/CHANGES/v2.2.txt +++ b/CHANGES/v2.2.txt @@ -173,6 +173,7 @@ For users: - Fix a bug in \ref PBMETAD when biasing periodic and not periodic collective variables at the same time - GSL library is now treated by `./configure` in the same way as other libraries, that is `-lgsl -lgslcblas` are only added if necessary. +- Fix a bug in \ref METAD when using INTERVAL and ADAPTIVE gaussians at the same time For developers: - Macports portile is now tested on travis at every plumed push. diff --git a/src/bias/MetaD.cpp b/src/bias/MetaD.cpp index 8dd77a36637479e9a8499bc0d156f56ee2008249..dd83ccd6ad1325bbebb5dcdbec103f2a2fcf568c 100644 --- a/src/bias/MetaD.cpp +++ b/src/bias/MetaD.cpp @@ -491,11 +491,11 @@ last_step_warn_grid(0) } else { error("I do not know this type of adaptive scheme"); } - // parse the sigma - parseVector("SIGMA",sigma0_); parse("FMT",fmt); + // parse the sigma + parseVector("SIGMA",sigma0_); if(adaptive_==FlexibleBin::none){ // if you use normal sigma you need one sigma per argument if( sigma0_.size()!=getNumberOfArguments() ) error("number of arguments does not match number of SIGMA parameters"); @@ -1060,20 +1060,11 @@ void MetaD::addGaussian(const Gaussian& hill) vector<unsigned> MetaD::getGaussianSupport(const Gaussian& hill) { vector<unsigned> nneigh; - if(doInt_){ - double cutoff=sqrt(2.0*DP2CUTOFF)*hill.sigma[0]; - if(hill.center[0]+cutoff > uppI_ || hill.center[0]-cutoff < lowI_) { - // in this case, we updated the entire grid to avoid problems - return BiasGrid_->getNbin(); - } else { - nneigh.push_back( static_cast<unsigned>(ceil(cutoff/BiasGrid_->getDx()[0])) ); - return nneigh; - } - } - + vector<double> cutoff; + unsigned ncv=getNumberOfArguments(); + // traditional or flexible hill? if(hill.multivariate){ - unsigned ncv=getNumberOfArguments(); unsigned k=0; Matrix<double> mymatrix(ncv,ncv); for(unsigned i=0;i<ncv;i++){ @@ -1095,15 +1086,28 @@ vector<unsigned> MetaD::getGaussianSupport(const Gaussian& hill) if(myautoval[i]>maxautoval){maxautoval=myautoval[i];ind_maxautoval=i;} } for(unsigned i=0;i<ncv;i++){ - const double cutoff=sqrt(2.0*DP2CUTOFF)*abs(sqrt(maxautoval)*myautovec(i,ind_maxautoval)); - nneigh.push_back( static_cast<unsigned>(ceil(cutoff/BiasGrid_->getDx()[i])) ); + cutoff.push_back(sqrt(2.0*DP2CUTOFF)*abs(sqrt(maxautoval)*myautovec(i,ind_maxautoval))); } } else { - for(unsigned i=0;i<getNumberOfArguments();++i){ - const double cutoff=sqrt(2.0*DP2CUTOFF)*hill.sigma[i]; - nneigh.push_back( static_cast<unsigned>(ceil(cutoff/BiasGrid_->getDx()[i])) ); + for(unsigned i=0;i<ncv;++i){ + cutoff.push_back(sqrt(2.0*DP2CUTOFF)*hill.sigma[i]); + } + } + + if(doInt_){ + if(hill.center[0]+cutoff[0] > uppI_ || hill.center[0]-cutoff[0] < lowI_) { + // in this case, we updated the entire grid to avoid problems + return BiasGrid_->getNbin(); + } else { + nneigh.push_back( static_cast<unsigned>(ceil(cutoff[0]/BiasGrid_->getDx()[0])) ); + return nneigh; + } + } else { + for(unsigned i=0;i<ncv;i++){ + nneigh.push_back( static_cast<unsigned>(ceil(cutoff[i]/BiasGrid_->getDx()[i])) ); } } + return nneigh; } @@ -1209,7 +1213,6 @@ double MetaD::evaluateGaussian(const vector<double>& cv, const Gaussian& hill, d if(der){ for(unsigned i=0;i<cv.size();++i){ double tmp=0.0; - k=i; for(unsigned j=0;j<cv.size();++j){ tmp += dp_[j]*mymatrix(i,j)*bias; }