From e262965e377889a18489fc4a31c5aede83136ddc Mon Sep 17 00:00:00 2001 From: marcodelapierre <marco.delapierre@gmail.com> Date: Fri, 10 Mar 2017 14:36:46 +0800 Subject: [PATCH] Marco De La Pierre: added WALKERS_DIR option for WALKERS_MPI (#208) * Marco De La Pierre: added WALKERS_DIR option for WALKERS_MPI * Marco De La Pierre: WALKERS_DIR option for WALKERS_MPI, not for single replica runs * Marco De La Pierre: WALKERS_DIR for multiple walkers metad made general --- src/bias/MetaD.cpp | 26 +++++++++++++++++++------- src/bias/PBMetaD.cpp | 26 +++++++++++++++++++------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/bias/MetaD.cpp b/src/bias/MetaD.cpp index 97c3392c6..2ef5a3c5b 100644 --- a/src/bias/MetaD.cpp +++ b/src/bias/MetaD.cpp @@ -433,7 +433,7 @@ void MetaD::registerKeywords(Keywords& keys){ keys.add("optional","INTERVAL","monodimensional lower and upper limits, outside the limits the system will not feel the biasing force."); keys.add("optional","SIGMA_MAX","the upper bounds for the sigmas (in CV units) when using adaptive hills. Negative number means no bounds "); keys.add("optional","SIGMA_MIN","the lower bounds for the sigmas (in CV units) when using adaptive hills. Negative number means no bounds "); - keys.addFlag("WALKERS_MPI",false,"Switch on MPI version of multiple walkers - not compatible with other WALKERS_* options"); + keys.addFlag("WALKERS_MPI",false,"Switch on MPI version of multiple walkers - not compatible with WALKERS_* options other than WALKERS_DIR"); keys.addFlag("ACCELERATION",false,"Set to TRUE if you want to compute the metadynamics acceleration factor."); keys.use("RESTART"); keys.use("UPDATE_FROM"); @@ -466,7 +466,7 @@ stride_(0), welltemp_(false), dp_(NULL), adaptive_(FlexibleBin::none), flexbin(NULL), // Multiple walkers initialization -mw_n_(1), mw_dir_("./"), mw_id_(0), mw_rstride_(1), +mw_n_(1), mw_dir_(""), mw_id_(0), mw_rstride_(1), walkers_mpi(false), mpi_nw_(0), acceleration(false), acc(0.0), // Interval initialization @@ -711,10 +711,11 @@ last_step_warn_grid(0) log.printf(" %d multiple walkers active\n",mw_n_); log.printf(" walker id %d\n",mw_id_); log.printf(" reading stride %d\n",mw_rstride_); - log.printf(" directory with hills files %s\n",mw_dir_.c_str()); + if(mw_dir_!="")log.printf(" directory with hills files %s\n",mw_dir_.c_str()); } else { if(walkers_mpi) { log.printf(" Multiple walkers active using MPI communnication\n"); + if(mw_dir_!="")log.printf(" directory with hills files %s\n",mw_dir_.c_str()); if(comm.Get_rank()==0){ // Only root of group can communicate with other walkers mpi_nw_=multi_sim_comm.Get_size(); @@ -821,11 +822,22 @@ last_step_warn_grid(0) // open all files at the beginning and read Gaussians if restarting for(int i=0;i<mw_n_;++i){ string fname; - if(mw_n_>1) { - stringstream out; out << i; - fname = mw_dir_+"/"+hillsfname+"."+out.str(); + if(mw_dir_!="") { + if(mw_n_>1) { + stringstream out; out << i; + fname = mw_dir_+"/"+hillsfname+"."+out.str(); + } else if(walkers_mpi) { + fname = mw_dir_+"/"+hillsfname; + } else { + fname = hillsfname; + } } else { - fname = hillsfname; + if(mw_n_>1) { + stringstream out; out << i; + fname = hillsfname+"."+out.str(); + } else { + fname = hillsfname; + } } IFile *ifile = new IFile(); ifile->link(*this); diff --git a/src/bias/PBMetaD.cpp b/src/bias/PBMetaD.cpp index 14a988dd5..aa244af8a 100644 --- a/src/bias/PBMetaD.cpp +++ b/src/bias/PBMetaD.cpp @@ -310,7 +310,7 @@ void PBMetaD::registerKeywords(Keywords& keys){ keys.add("optional","ADAPTIVE","use a geometric (=GEOM) or diffusion (=DIFF) based hills width scheme. Sigma is one number that has distance units or timestep dimensions"); keys.add("optional","SIGMA_MAX","the upper bounds for the sigmas (in CV units) when using adaptive hills. Negative number means no bounds "); keys.add("optional","SIGMA_MIN","the lower bounds for the sigmas (in CV units) when using adaptive hills. Negative number means no bounds "); - keys.addFlag("WALKERS_MPI",false,"Switch on MPI version of multiple walkers - not compatible with other WALKERS_* options"); + keys.addFlag("WALKERS_MPI",false,"Switch on MPI version of multiple walkers - not compatible with WALKERS_* options other than WALKERS_DIR"); keys.use("RESTART"); keys.use("UPDATE_FROM"); keys.use("UPDATE_UNTIL"); @@ -339,7 +339,7 @@ PBMetaD::PBMetaD(const ActionOptions& ao): PLUMED_BIAS_INIT(ao), grid_(false), height0_(std::numeric_limits<double>::max()), biasf_(1.0), kbt_(0.0), stride_(0), wgridstride_(0), welltemp_(false), -mw_n_(1), mw_dir_("./"), mw_id_(0), mw_rstride_(1), +mw_n_(1), mw_dir_(""), mw_id_(0), mw_rstride_(1), walkers_mpi(false), mpi_nw_(0), adaptive_(FlexibleBin::none), isFirstStep(true) @@ -555,10 +555,11 @@ isFirstStep(true) log.printf(" %d multiple walkers active\n",mw_n_); log.printf(" walker id %d\n",mw_id_); log.printf(" reading stride %d\n",mw_rstride_); - log.printf(" directory with hills files %s\n",mw_dir_.c_str()); + if(mw_dir_!="")log.printf(" directory with hills files %s\n",mw_dir_.c_str()); } else { if(walkers_mpi) { log.printf(" Multiple walkers active using MPI communnication\n"); + if(mw_dir_!="")log.printf(" directory with hills files %s\n",mw_dir_.c_str()); if(comm.Get_rank()==0){ // Only root of group can communicate with other walkers mpi_nw_ = multi_sim_comm.Get_size(); @@ -668,11 +669,22 @@ isFirstStep(true) for(unsigned i=0;i<hillsfname.size();++i){ unsigned k=j*hillsfname.size()+i; string fname; - if(mw_n_>1) { - stringstream out; out << j; - fname = mw_dir_+"/"+hillsfname[i]+"."+out.str(); + if(mw_dir_!="") { + if(mw_n_>1) { + stringstream out; out << j; + fname = mw_dir_+"/"+hillsfname[i]+"."+out.str(); + } else if(walkers_mpi) { + fname = mw_dir_+"/"+hillsfname[i]; + } else { + fname = hillsfname[i]; + } } else { - fname = hillsfname[i]; + if(mw_n_>1) { + stringstream out; out << j; + fname = hillsfname[i]+"."+out.str(); + } else { + fname = hillsfname[i]; + } } IFile *ifile = new IFile(); ifile->link(*this); -- GitLab