LCOV - code coverage report
Current view: top level - colvar - ExtraCV.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 15 15 100.0 %
Date: 2025-03-25 09:33:27 Functions: 2 3 66.7 %

          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 for 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             : This example takes the lambda variable pre-computed in GROMACS and applies a restraint to keep
      39             : it close to the value 3.
      40             : 
      41             : ```plumed
      42             : l: EXTRACV NAME=lambda
      43             : RESTRAINT ARG=l KAPPA=10 AT=3
      44             : ```
      45             : 
      46             : 
      47             : */
      48             : //+ENDPLUMEDOC
      49             : 
      50             : 
      51             : class ExtraCV : public ActionShortcut {
      52             : public:
      53             :   explicit ExtraCV(const ActionOptions&);
      54             :   static void registerKeywords( Keywords& keys );
      55             : };
      56             : 
      57             : PLUMED_REGISTER_ACTION(ExtraCV,"EXTRACV")
      58             : 
      59           3 : ExtraCV::ExtraCV(const ActionOptions&ao):
      60             :   Action(ao),
      61           3 :   ActionShortcut(ao) {
      62           3 :   std::vector<std::string> argn(1);
      63           6 :   parse("NAME",argn[0]);
      64           6 :   readInputLine( argn[0] + ": PUT UNIT=number SHAPE=0 MUTABLE PERIODIC=NO");
      65           3 :   if( getShortcutLabel()!=argn[0] ) {
      66           6 :     readInputLine( getShortcutLabel() + ": COMBINE ARG=" + argn[0] + " PERIODIC=NO");
      67             :   }
      68           3 : }
      69             : 
      70           5 : void ExtraCV::registerKeywords( Keywords& keys ) {
      71           5 :   ActionShortcut::registerKeywords( keys );
      72           5 :   keys.add("compulsory","NAME","name of the CV as computed by the MD engine");
      73          10 :   keys.setValueDescription("scalar","the value of the CV that was passed from the MD code to PLUMED");
      74           5 :   keys.needsAction("PUT");
      75           5 :   keys.needsAction("COMBINE");
      76           5 : }
      77             : 
      78             : }
      79             : }
      80             : 
      81             : 
      82             : 

Generated by: LCOV version 1.16