From c9a82052679d2a6d876671000815edbda662aaae Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Tue, 30 Jul 2013 23:47:51 +0200 Subject: [PATCH] RANDOM_EXCHANGES now appears in manual Still we should write some doc. Also, there is not regtest for this... --- src/core/PlumedMain.cpp | 5 --- src/core/PlumedMain.h | 3 ++ src/generic/RandomExchanges.cpp | 71 +++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 src/generic/RandomExchanges.cpp diff --git a/src/core/PlumedMain.cpp b/src/core/PlumedMain.cpp index 48bce35e5..a6faa3460 100644 --- a/src/core/PlumedMain.cpp +++ b/src/core/PlumedMain.cpp @@ -409,11 +409,6 @@ void PlumedMain::readInputWords(const std::vector<std::string> & words){ else if(words[0]=="_SET_SUFFIX"){ plumed_assert(words.size()==2); setSuffix(words[1]); - } - else if(words[0]=="RANDOM_EXCHANGES"){ - exchangePatterns.setFlag(exchangePatterns.RANDOM); - // I convert the seed to -seed because I think it is more general to use a positive seed in input - if(words.size()>2&&words[1]=="SEED") {int seed; Tools::convert(words[2],seed); exchangePatterns.setSeed(-seed); } } else { std::vector<std::string> interpreted(words); Tools::interpretLabel(interpreted); diff --git a/src/core/PlumedMain.h b/src/core/PlumedMain.h index 9d45fd9dc..3d035399c 100644 --- a/src/core/PlumedMain.h +++ b/src/core/PlumedMain.h @@ -271,6 +271,9 @@ public: /// This function allows to enforce active plumed when doing exchanges, /// thus fixing the bug. void resetActive(bool active); + +/// Access to exchange patterns + ExchangePatterns& getExchangePatterns(){return exchangePatterns;} }; ///// diff --git a/src/generic/RandomExchanges.cpp b/src/generic/RandomExchanges.cpp new file mode 100644 index 000000000..eb62a8811 --- /dev/null +++ b/src/generic/RandomExchanges.cpp @@ -0,0 +1,71 @@ +/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 2013 The plumed team + (see the PEOPLE file at the root of the distribution for a list of names) + + See http://www.plumed-code.org for more information. + + This file is part of plumed, version 2.0. + + plumed is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + plumed is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with plumed. If not, see <http://www.gnu.org/licenses/>. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +#include "core/Action.h" +#include "core/ActionRegister.h" +#include "core/PlumedMain.h" +#include "tools/Exception.h" +#include "core/ExchangePatterns.h" + +using namespace std; + +namespace PLMD{ +namespace generic{ + +//+PLUMEDOC GENERIC RANDOM_EXCHANGES +/* +Set random pattern for exchanges + +\par Examples + +*/ +//+ENDPLUMEDOC + +class RandomExchanges: + public Action +{ +public: + static void registerKeywords( Keywords& keys ); + RandomExchanges(const ActionOptions&ao); + void calculate(){} + void apply(){} +}; + +PLUMED_REGISTER_ACTION(RandomExchanges,"RANDOM_EXCHANGES") + +void RandomExchanges::registerKeywords( Keywords& keys ){ + Action::registerKeywords(keys); + keys.add("optional","SEED","seed for random exchanges"); +} + +RandomExchanges::RandomExchanges(const ActionOptions&ao): +Action(ao) +{ + plumed.getExchangePatterns().setFlag(ExchangePatterns::RANDOM); +// I convert the seed to -seed because I think it is more general to use a positive seed in input + int seed=-1; + parse("SEED",seed); + if(seed>=0) plumed.getExchangePatterns().setSeed(-seed); +} + +} +} + -- GitLab