All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RandomExchanges.cpp
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 The plumed team
3  (see the PEOPLE file at the root of the distribution for a list of names)
4 
5  See http://www.plumed-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
8 
9  plumed is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  plumed is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 #include "core/Action.h"
23 #include "core/ActionRegister.h"
24 #include "core/PlumedMain.h"
25 #include "tools/Exception.h"
26 #include "core/ExchangePatterns.h"
27 
28 using namespace std;
29 
30 namespace PLMD{
31 namespace generic{
32 
33 //+PLUMEDOC GENERIC RANDOM_EXCHANGES
34 /*
35 Set random pattern for exchanges.
36 
37 In this way, exchanges will not be done between replicas with consecutive index, but
38 will be done using a random pattern. Typically used in bias exchange \cite piana.
39 
40 \par Examples
41 
42 Using the following three input files one can run a bias exchange
43 metadynamics simulation using a different angle in each replica.
44 Exchanges will be randomly tried between replicas 0-1, 0-2 and 1-2
45 
46 Here is plumed.dat.0
47 \verbatim
48 RANDOM_EXCHANGES
49 t: TORSION ATOMS=1,2,3,4
50 METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
51 \endverbatim
52 
53 Here is plumed.dat.1
54 \verbatim
55 RANDOM_EXCHANGES
56 t: TORSION ATOMS=2,3,4,5
57 METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
58 \endverbatim
59 
60 Here is plumed.dat.2
61 \verbatim
62 RANDOM_EXCHANGES
63 t: TORSION ATOMS=3,4,5,6
64 METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
65 \endverbatim
66 
67 \warning Multi replica simulations are presently only working with gromacs.
68 
69 \warning The directive should appear in input files for every replicas. In case SEED is specified, it
70 should be the same in all input files.
71 
72 */
73 //+ENDPLUMEDOC
74 
76  public Action
77 {
78 public:
79  static void registerKeywords( Keywords& keys );
81  void calculate(){}
82  void apply(){}
83 };
84 
85 PLUMED_REGISTER_ACTION(RandomExchanges,"RANDOM_EXCHANGES")
86 
87 void RandomExchanges::registerKeywords( Keywords& keys ){
88  Action::registerKeywords(keys);
89  keys.add("optional","SEED","seed for random exchanges");
90 }
91 
92 RandomExchanges::RandomExchanges(const ActionOptions&ao):
93 Action(ao)
94 {
95  plumed.getExchangePatterns().setFlag(ExchangePatterns::RANDOM);
96 // I convert the seed to -seed because I think it is more general to use a positive seed in input
97  int seed=-1;
98  parse("SEED",seed);
99  if(seed>=0) plumed.getExchangePatterns().setSeed(-seed);
100 }
101 
102 }
103 }
104 
void calculate()
Calculate an Action.
STL namespace.
Provides the keyword RANDOM_EXCHANGES
void apply()
Apply an Action.
void parse(const std::string &key, T &t)
Parse one keyword as generic type.
Definition: Action.h:273
This class holds the keywords and their documentation.
Definition: Keywords.h:36
This class is used to bring the relevant information to the Action constructor.
Definition: Action.h:41
Base class for all the input Actions.
Definition: Action.h:60
Main plumed object.
Definition: Plumed.h:201