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/ActionShortcut.h" 23 : #include "core/ActionRegister.h" 24 : #include "core/PlumedMain.h" 25 : 26 : namespace PLMD { 27 : namespace colvar { 28 : 29 : //+PLUMEDOC COLVAR EXTRACV 30 : /* 31 : Allow PLUMED to use collective variables computed in the MD engine. 32 : 33 : This feature requires the MD engine to use special instructions to pass to PLUMED the value of 34 : some pre-computed collective variable. Check the documentation of the MD code to find out which 35 : collective variables can be computed and passed to PLUMED. These variables can then be accessed by 36 : name using the EXTRACV action. 37 : 38 : \par Examples 39 : 40 : This example takes the lambda variable pre-computed in GROMACS and apply to it a restraint to keep 41 : it close to the value 3. 42 : \plumedfile 43 : l: EXTRACV NAME=lambda 44 : RESTRAINT ARG=l KAPPA=10 AT=3 45 : \endplumedfile 46 : 47 : 48 : */ 49 : //+ENDPLUMEDOC 50 : 51 : 52 : class ExtraCV : public ActionShortcut { 53 : public: 54 : explicit ExtraCV(const ActionOptions&); 55 : static void registerKeywords( Keywords& keys ); 56 : }; 57 : 58 : PLUMED_REGISTER_ACTION(ExtraCV,"EXTRACV") 59 : 60 3 : ExtraCV::ExtraCV(const ActionOptions&ao): 61 : Action(ao), 62 3 : ActionShortcut(ao) 63 : { 64 6 : std::vector<std::string> argn(1); parse("NAME",argn[0]); 65 6 : readInputLine( argn[0] + ": PUT UNIT=number SHAPE=0 MUTABLE PERIODIC=NO"); 66 6 : if( getShortcutLabel()!=argn[0] ) readInputLine( getShortcutLabel() + ": COMBINE ARG=" + argn[0] + " PERIODIC=NO"); 67 3 : } 68 : 69 5 : void ExtraCV::registerKeywords( Keywords& keys ) { 70 5 : ActionShortcut::registerKeywords( keys ); 71 10 : keys.add("compulsory","NAME","name of the CV as computed by the MD engine"); 72 10 : keys.setValueDescription("scalar","the value of the CV that was passed from the MD code to PLUMED"); 73 10 : keys.needsAction("PUT"); keys.needsAction("COMBINE"); 74 5 : } 75 : 76 : } 77 : } 78 : 79 : 80 :