Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2017-2020 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 <string> 26 : 27 : using namespace std; 28 : 29 : namespace PLMD { 30 : namespace isdb { 31 : 32 : //+PLUMEDOC ISDB_GENERIC SELECTOR 33 : /* 34 : Defines a variable (of the type double) inside the PLUMED code that can be used and modified by other actions. 35 : 36 : A \ref SELECTOR can be used for example to activate or modify a bias based on its current value. 37 : 38 : \par Examples 39 : 40 : A typical example is the simulated-tempering like approach activated by \ref RESCALE. 41 : In this example the total potential energy of the system is scaled 42 : by a parameter defined on a grid of dimension NBIN in the range from 1 to MAX_RESCALE. 43 : The value of the scaling parameter is determined by the current value of the \ref SELECTOR GAMMA. 44 : The value of the \ref SELECTOR is updated by a MC protocol inside the \ref RESCALE class. 45 : A well-tempered metadynamics potential is used to enhance sampling in the \ref SELECTOR space. 46 : 47 : \plumedfile 48 : ene: ENERGY 49 : 50 : SELECTOR NAME=GAMMA VALUE=0 51 : 52 : RESCALE ... 53 : LABEL=res ARG=ene TEMP=300 54 : SELECTOR=GAMMA MAX_RESCALE=1.2 NBIN=2 55 : W0=1000 BIASFACTOR=100.0 BSTRIDE=2000 BFILE=bias.dat 56 : ... 57 : 58 : PRINT FILE=COLVAR ARG=* STRIDE=100 59 : \endplumedfile 60 : 61 : */ 62 : //+ENDPLUMEDOC 63 : 64 2 : class Selector: 65 : public Action 66 : { 67 : public: 68 : static void registerKeywords( Keywords& keys ); 69 : explicit Selector(const ActionOptions&ao); 70 0 : void calculate() {} 71 0 : void apply() {} 72 : }; 73 : 74 7360 : PLUMED_REGISTER_ACTION(Selector,"SELECTOR") 75 : 76 3 : void Selector::registerKeywords( Keywords& keys ) { 77 3 : Action::registerKeywords(keys); 78 12 : keys.add("compulsory","NAME","name of the SELECTOR"); 79 12 : keys.add("compulsory","VALUE","set (initial) value of the SELECTOR"); 80 3 : } 81 : 82 2 : Selector::Selector(const ActionOptions&ao): 83 2 : Action(ao) 84 : { 85 : string name; 86 4 : parse("NAME", name); 87 : double value; 88 4 : parse("VALUE", value); 89 2 : plumed.passMap[name] = value; 90 2 : } 91 : 92 : } 93 5517 : } 94 :