Skip to content
Snippets Groups Projects
Commit dc22e4d9 authored by Carlo Camilloni's avatar Carlo Camilloni
Browse files

Merge branch 'v2.2'

parents 0d9f8173 cbd18f53
No related branches found
No related tags found
No related merge requests found
...@@ -608,6 +608,7 @@ last_step_warn_grid(0) ...@@ -608,6 +608,7 @@ last_step_warn_grid(0)
uppI_=tmpI.at(1); uppI_=tmpI.at(1);
if(getNumberOfArguments()!=1) error("INTERVAL limits correction works only for monodimensional metadynamics!"); if(getNumberOfArguments()!=1) error("INTERVAL limits correction works only for monodimensional metadynamics!");
if(uppI_<lowI_) error("The Upper limit must be greater than the Lower limit!"); if(uppI_<lowI_) error("The Upper limit must be greater than the Lower limit!");
if(getPntrToArgument(0)->isPeriodic()) error("INTERVAL cannot be used with periodic variables!");
doInt_=true; doInt_=true;
} }
......
...@@ -205,7 +205,7 @@ private: ...@@ -205,7 +205,7 @@ private:
bool multiple_w; bool multiple_w;
vector<double> uppI_; vector<double> uppI_;
vector<double> lowI_; vector<double> lowI_;
bool doInt_; vector<bool> doInt_;
bool isFirstStep; bool isFirstStep;
void readGaussians(int iarg, IFile*); void readGaussians(int iarg, IFile*);
...@@ -273,7 +273,7 @@ PBMetaD::PBMetaD(const ActionOptions& ao): ...@@ -273,7 +273,7 @@ PBMetaD::PBMetaD(const ActionOptions& ao):
PLUMED_BIAS_INIT(ao), PLUMED_BIAS_INIT(ao),
grid_(false), height0_(std::numeric_limits<double>::max()), grid_(false), height0_(std::numeric_limits<double>::max()),
biasf_(1.0), kbt_(0.0), stride_(0), welltemp_(false), biasf_(1.0), kbt_(0.0), stride_(0), welltemp_(false),
multiple_w(false), doInt_(false), isFirstStep(true) multiple_w(false), isFirstStep(true)
{ {
parse("FMT",fmt); parse("FMT",fmt);
...@@ -371,19 +371,22 @@ multiple_w(false), doInt_(false), isFirstStep(true) ...@@ -371,19 +371,22 @@ multiple_w(false), doInt_(false), isFirstStep(true)
parseFlag("GRID_NOSPLINE",nospline); parseFlag("GRID_NOSPLINE",nospline);
bool spline=!nospline; bool spline=!nospline;
if(gbin.size()>0){grid_=true;} if(gbin.size()>0){grid_=true;}
if(!grid_&&gridfilenames_.size() > 0) error("To write a grid you need first to define it!"); if(!grid_&&gridfilenames_.size() > 0) error("To write a grid you need first to define it!");
if(!grid_&&gridreadfilenames_.size() > 0) error("To read a grid you need first to define it!"); if(!grid_&&gridreadfilenames_.size() > 0) error("To read a grid you need first to define it!");
doInt_.resize(getNumberOfArguments(),false);
// Interval keyword // Interval keyword
parseVector("INTERVAL_MIN",lowI_); parseVector("INTERVAL_MIN",lowI_);
parseVector("INTERVAL_MAX",uppI_); parseVector("INTERVAL_MAX",uppI_);
// various checks // various checks
if(lowI_.size()!=uppI_.size()) error("both a lower and an upper limits must be provided with INTERVAL"); if(lowI_.size()!=uppI_.size()) error("both a lower and an upper limits must be provided with INTERVAL");
if(lowI_.size()!=0 && lowI_.size()!=getNumberOfArguments()) error("check number of argument of INTERVAL"); if(lowI_.size()!=0 && lowI_.size()!=getNumberOfArguments()) error("check number of argument of INTERVAL");
for(unsigned i=0; i<lowI_.size(); ++i) if(uppI_[i]<lowI_[i]) error("The Upper limit must be greater than the Lower limit!"); for(unsigned i=0; i<lowI_.size(); ++i) {
if(lowI_.size()>0) doInt_=true; if(uppI_[i]<lowI_[i]) error("The Upper limit must be greater than the Lower limit!");
if(getPntrToArgument(i)->isPeriodic()) warning("INTERVAL is not used for periodic variables");
else doInt_[i]=true;
}
checkRead(); checkRead();
log.printf(" Gaussian width "); log.printf(" Gaussian width ");
...@@ -400,7 +403,9 @@ multiple_w(false), doInt_(false), isFirstStep(true) ...@@ -400,7 +403,9 @@ multiple_w(false), doInt_(false), isFirstStep(true)
log.printf(" KbT %f\n",kbt_); log.printf(" KbT %f\n",kbt_);
} }
if(multiple_w) log.printf(" Multiple walkers active using MPI communnication\n"); if(multiple_w) log.printf(" Multiple walkers active using MPI communnication\n");
if(doInt_) log.printf(" Upper and Lower limits boundaries for the bias are activated\n"); for(unsigned i=0; i<doInt_.size();i++) {
if(doInt_[i]) log.printf(" Upper and Lower limits boundaries for the bias of CV %i are activated\n", i);
}
if(grid_){ if(grid_){
log.printf(" Grid min"); log.printf(" Grid min");
for(unsigned i=0;i<gmin.size();++i) log.printf(" %s",gmin[i].c_str() ); for(unsigned i=0;i<gmin.size();++i) log.printf(" %s",gmin[i].c_str() );
...@@ -526,11 +531,11 @@ multiple_w(false), doInt_(false), isFirstStep(true) ...@@ -526,11 +531,11 @@ multiple_w(false), doInt_(false), isFirstStep(true)
comm.Bcast(r,0); comm.Bcast(r,0);
if(r>0) hillsfname_tmp="/dev/null"; if(r>0) hillsfname_tmp="/dev/null";
ofile->enforceSuffix(""); ofile->enforceSuffix("");
} }
ofile->open(hillsfname_tmp); ofile->open(hillsfname_tmp);
if(fmt.length()>0) ofile->fmtField(fmt); if(fmt.length()>0) ofile->fmtField(fmt);
ofile->addConstantField("multivariate"); ofile->addConstantField("multivariate");
if(doInt_) { if(doInt_[i]) {
ofile->addConstantField("lower_int").printField("lower_int",lowI_[i]); ofile->addConstantField("lower_int").printField("lower_int",lowI_[i]);
ofile->addConstantField("upper_int").printField("upper_int",uppI_[i]); ofile->addConstantField("upper_int").printField("upper_int",uppI_[i]);
} }
...@@ -565,7 +570,7 @@ multiple_w(false), doInt_(false), isFirstStep(true) ...@@ -565,7 +570,7 @@ multiple_w(false), doInt_(false), isFirstStep(true)
} }
log<<" Bibliography "<<plumed.cite("Pfaendtner and Bonomi. J. Chem. Theory Comput. 11, 5062 (2015)"); log<<" Bibliography "<<plumed.cite("Pfaendtner and Bonomi. J. Chem. Theory Comput. 11, 5062 (2015)");
if(doInt_) log<<plumed.cite( if(doInt_[0]) log<<plumed.cite(
"Baftizadeh, Cossio, Pietrucci, and Laio, Curr. Phys. Chem. 2, 79 (2012)"); "Baftizadeh, Cossio, Pietrucci, and Laio, Curr. Phys. Chem. 2, 79 (2012)");
if(multiple_w) log<<plumed.cite( if(multiple_w) log<<plumed.cite(
"Raiteri, Laio, Gervasio, Micheletti, and Parrinello, J. Phys. Chem. B 110, 3533 (2006)"); "Raiteri, Laio, Gervasio, Micheletti, and Parrinello, J. Phys. Chem. B 110, 3533 (2006)");
...@@ -660,9 +665,8 @@ void PBMetaD::addGaussian(int iarg, const Gaussian& hill){ ...@@ -660,9 +665,8 @@ void PBMetaD::addGaussian(int iarg, const Gaussian& hill){
vector<unsigned> PBMetaD::getGaussianSupport(int iarg, const Gaussian& hill){ vector<unsigned> PBMetaD::getGaussianSupport(int iarg, const Gaussian& hill){
vector<unsigned> nneigh; vector<unsigned> nneigh;
const double cutoff=sqrt(2.0*DP2CUTOFF)*hill.sigma[0];
if(doInt_){ if(doInt_[iarg]){
double cutoff=sqrt(2.0*DP2CUTOFF)*hill.sigma[0];
if(hill.center[0]+cutoff > uppI_[iarg] || hill.center[0]-cutoff < lowI_[iarg]) { if(hill.center[0]+cutoff > uppI_[iarg] || hill.center[0]-cutoff < lowI_[iarg]) {
// in this case, we updated the entire grid to avoid problems // in this case, we updated the entire grid to avoid problems
return BiasGrids_[iarg]->getNbin(); return BiasGrids_[iarg]->getNbin();
...@@ -672,7 +676,6 @@ vector<unsigned> PBMetaD::getGaussianSupport(int iarg, const Gaussian& hill){ ...@@ -672,7 +676,6 @@ vector<unsigned> PBMetaD::getGaussianSupport(int iarg, const Gaussian& hill){
} }
} }
double cutoff=sqrt(2.0*DP2CUTOFF)*hill.sigma[0];
nneigh.push_back( static_cast<unsigned>(ceil(cutoff/BiasGrids_[iarg]->getDx()[0])) ); nneigh.push_back( static_cast<unsigned>(ceil(cutoff/BiasGrids_[iarg]->getDx()[0])) );
return nneigh; return nneigh;
...@@ -712,7 +715,7 @@ double PBMetaD::evaluateGaussian ...@@ -712,7 +715,7 @@ double PBMetaD::evaluateGaussian
const double *pcv=NULL; // pointer to cv const double *pcv=NULL; // pointer to cv
double tmpcv[1]; // tmp array with cv (to be used with doInt_) double tmpcv[1]; // tmp array with cv (to be used with doInt_)
if(cv.size()>0) pcv=&cv[0]; if(cv.size()>0) pcv=&cv[0];
if(doInt_){ if(doInt_[iarg]){
plumed_assert(cv.size()==1); plumed_assert(cv.size()==1);
tmpcv[0]=cv[0]; tmpcv[0]=cv[0];
if(cv[0]<lowI_[iarg]) tmpcv[0]=lowI_[iarg]; if(cv[0]<lowI_[iarg]) tmpcv[0]=lowI_[iarg];
...@@ -725,7 +728,7 @@ double PBMetaD::evaluateGaussian ...@@ -725,7 +728,7 @@ double PBMetaD::evaluateGaussian
bias = hill.height*exp(-dp2); bias = hill.height*exp(-dp2);
if(der){der[0]+= -bias * dp / hill.sigma[0];} if(der){der[0]+= -bias * dp / hill.sigma[0];}
} }
if(doInt_){ if(doInt_[iarg]){
if((cv[0]<lowI_[iarg] || cv[0]>uppI_[iarg]) && der ) der[0] = 0.0; if((cv[0]<lowI_[iarg] || cv[0]>uppI_[iarg]) && der ) der[0] = 0.0;
} }
return bias; return bias;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment