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