Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2013-2019 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.org for more information.
6 :
7 : This file is part of plumed, version 2.
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.0.dat
47 : \plumedfile
48 : RANDOM_EXCHANGES
49 : t: TORSION ATOMS=1,2,3,4
50 : METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
51 : \endplumedfile
52 :
53 : Here is plumed.1.dat
54 : \plumedfile
55 : RANDOM_EXCHANGES
56 : t: TORSION ATOMS=2,3,4,5
57 : METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
58 : \endplumedfile
59 :
60 : Here is plumed.2.dat
61 : \plumedfile
62 : RANDOM_EXCHANGES
63 : t: TORSION ATOMS=3,4,5,6
64 : METAD ARG=t HEIGHT=0.1 PACE=100 SIGMA=0.3
65 : \endplumedfile
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 :
75 0 : class RandomExchanges:
76 : public Action
77 : {
78 : public:
79 : static void registerKeywords( Keywords& keys );
80 : explicit RandomExchanges(const ActionOptions&ao);
81 0 : void calculate() {}
82 0 : void apply() {}
83 : };
84 :
85 6452 : PLUMED_REGISTER_ACTION(RandomExchanges,"RANDOM_EXCHANGES")
86 :
87 1 : void RandomExchanges::registerKeywords( Keywords& keys ) {
88 1 : Action::registerKeywords(keys);
89 4 : keys.add("optional","SEED","seed for random exchanges");
90 1 : }
91 :
92 0 : RandomExchanges::RandomExchanges(const ActionOptions&ao):
93 0 : Action(ao)
94 : {
95 0 : 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 0 : int seed=-1;
98 0 : parse("SEED",seed);
99 0 : if(seed>=0) plumed.getExchangePatterns().setSeed(-seed);
100 0 : }
101 :
102 : }
103 4839 : }
104 :
|