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

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2018 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             : 
      25             : //+PLUMEDOC MCOLVAR BRIDGE
      26             : /*
      27             : Calculate a matrix with elements equal to one if there is a bridging atom between the two atoms
      28             : 
      29             : \par Examples
      30             : 
      31             : */
      32             : //+ENDPLUMEDOC
      33             : 
      34             : namespace PLMD {
      35             : namespace adjmat {
      36             : 
      37             : class Bridge : public ActionShortcut {
      38             : public:
      39             :   static void registerKeywords(Keywords& keys);
      40             :   explicit Bridge(const ActionOptions&);
      41             : };
      42             : 
      43             : PLUMED_REGISTER_ACTION(Bridge,"BRIDGE")
      44             : 
      45          10 : void Bridge::registerKeywords(Keywords& keys) {
      46          10 :   ActionShortcut::registerKeywords(keys);
      47          10 :   keys.add("atoms","GROUP","the atoms for which you would like to calculate the adjacency matrix");
      48          10 :   keys.add("atoms","GROUPA","when you are calculating the adjacency matrix between two sets of atoms this keyword is used to specify the atoms along with the keyword GROUPB");
      49          10 :   keys.add("atoms","GROUPB","when you are calculating the adjacency matrix between two sets of atoms this keyword is used to specify the atoms along with the keyword GROUPA");
      50          10 :   keys.add("atoms","BRIDGING_ATOMS","The list of atoms that can form the bridge between the two interesting parts "
      51             :            "of the structure.");
      52          10 :   keys.add("optional","SWITCH","The parameters of the two switching functions in the above formula");
      53          20 :   keys.linkActionInDocs("SWITCH","LESS_THAN");
      54          10 :   keys.add("optional","SWITCHA","The switching function on the distance between bridging atoms and the atoms in group A");
      55          20 :   keys.linkActionInDocs("SWITCHA","LESS_THAN");
      56          10 :   keys.add("optional","SWITCHB","The switching function on the distance between the bridging atoms and the atoms in group B");
      57          20 :   keys.linkActionInDocs("SWITCHB","LESS_THAN");
      58          10 :   keys.needsAction("BRIDGE_MATRIX");
      59          10 :   keys.needsAction("SUM");
      60          20 :   keys.setValueDescription("scalar","the number of bridging atoms between the two groups");
      61          10 : }
      62             : 
      63           8 : Bridge::Bridge(const ActionOptions& ao):
      64             :   Action(ao),
      65           8 :   ActionShortcut(ao) {
      66             :   // Need to read in switch
      67             :   std::string s_inp, sfinput;
      68          16 :   parse("SWITCH",sfinput);
      69           8 :   if( sfinput.length()>0 ) {
      70          16 :     s_inp += "SWITCH={" + sfinput +"} ";
      71             :   }
      72             :   std::string sfinputa;
      73          16 :   parse("SWITCHA",sfinputa);
      74           8 :   if( sfinputa.length()>0 ) {
      75           0 :     s_inp += "SWITCHA={" + sfinputa +"} ";
      76             :   }
      77             :   std::string sfinputb;
      78          16 :   parse("SWITCHB",sfinputb);
      79           8 :   if( sfinputb.length()>0 ) {
      80           0 :     s_inp += "SWITCHB={" + sfinputb +"} ";
      81             :   }
      82             :   // Create the matrix object
      83          16 :   readInputLine( getShortcutLabel() + "_mat: BRIDGE_MATRIX " + s_inp + convertInputLineToString() );
      84             :   // Add all the elements of the matrix together
      85          16 :   readInputLine( getShortcutLabel() + ": SUM ARG=" + getShortcutLabel() + "_mat PERIODIC=NO");
      86           8 : }
      87             : 
      88             : }
      89             : }

Generated by: LCOV version 1.16