LCOV - code coverage report
Current view: top level - adjmat - Bridge.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 20 20 100.0 %
Date: 2024-10-18 14:00:25 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          20 :   keys.add("atoms","GROUP","the atoms for which you would like to calculate the adjacency matrix");
      48          20 :   keys.add("atoms","GROUPA","");
      49          20 :   keys.add("atoms","GROUPB","");
      50          20 :   keys.add("atoms","BRIDGING_ATOMS","The list of atoms that can form the bridge between the two interesting parts "
      51             :            "of the structure.");
      52          20 :   keys.add("optional","SWITCH","The parameters of the two switchingfunction in the above formula");
      53          20 :   keys.add("optional","SWITCHA","The switchingfunction on the distance between bridging atoms and the atoms in "
      54             :            "group A");
      55          20 :   keys.add("optional","SWITCHB","The switchingfunction on the distance between the bridging atoms and the atoms in "
      56             :            "group B");
      57          20 :   keys.needsAction("BRIDGE_MATRIX"); keys.needsAction("SUM");
      58          10 :   keys.setValueDescription("the number of bridging atoms between the two groups");
      59          10 : }
      60             : 
      61           8 : Bridge::Bridge(const ActionOptions& ao):
      62             :   Action(ao),
      63           8 :   ActionShortcut(ao)
      64             : {
      65             :   // Need to read in switch
      66          24 :   std::string s_inp, sfinput; parse("SWITCH",sfinput); if( sfinput.length()>0 ) s_inp += "SWITCH={" + sfinput +"} ";
      67          16 :   std::string sfinputa; parse("SWITCHA",sfinputa); if( sfinputa.length()>0 ) s_inp += "SWITCHA={" + sfinputa +"} ";
      68          16 :   std::string sfinputb; parse("SWITCHB",sfinputb); if( sfinputb.length()>0 ) s_inp += "SWITCHB={" + sfinputb +"} ";
      69             :   // Create the matrix object
      70          16 :   readInputLine( getShortcutLabel() + "_mat: BRIDGE_MATRIX " + s_inp + convertInputLineToString() );
      71             :   // Add all the elements of the matrix together
      72          16 :   readInputLine( getShortcutLabel() + ": SUM ARG=" + getShortcutLabel() + "_mat PERIODIC=NO");
      73           8 : }
      74             : 
      75             : }
      76             : }

Generated by: LCOV version 1.16