LCOV - code coverage report
Current view: top level - multicolvar - InPlaneDistances.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 25 25 100.0 %
Date: 2024-10-18 13:59:31 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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 "MultiColvarShortcuts.h"
      25             : 
      26             : #include <string>
      27             : #include <cmath>
      28             : 
      29             : //+PLUMEDOC MCOLVAR INPLANEDISTANCES
      30             : /*
      31             : Calculate the distance between a pair of atoms in the plane
      32             : 
      33             : \par Examples
      34             : 
      35             : */
      36             : //+ENDPLUMEDOC
      37             : 
      38             : namespace PLMD {
      39             : namespace multicolvar {
      40             : 
      41             : class InPlaneDistances : public ActionShortcut {
      42             : public:
      43             :   explicit InPlaneDistances(const ActionOptions&);
      44             :   static void registerKeywords( Keywords& keys );
      45             : };
      46             : 
      47             : PLUMED_REGISTER_ACTION(InPlaneDistances,"INPLANEDISTANCES")
      48             : 
      49           3 : void InPlaneDistances::registerKeywords( Keywords& keys ) {
      50           3 :   ActionShortcut::registerKeywords( keys );
      51           6 :   keys.add("atoms","GROUP","calculate distance for each distinct set of three atoms in the group");
      52           6 :   keys.add("atoms","VECTORSTART","The first atom position that is used to define the normal to the plane of interest");
      53           6 :   keys.add("atoms","VECTOREND","The second atom position that is used to defin the normal to the plane of interest");
      54           6 :   keys.setValueDescription("vector","the INPLANEDISTANCE between each of the atoms specified using the GROUP keyword and atom A in the plane perpendicular to the vector connecting the atoms specified using VECTORSTART and VECTOREND");
      55           3 :   MultiColvarShortcuts::shortcutKeywords( keys );
      56           6 :   keys.needsAction("DISTANCE"); keys.needsAction("ANGLE");
      57           3 : }
      58             : 
      59           1 : InPlaneDistances::InPlaneDistances(const ActionOptions&ao):
      60             :   Action(ao),
      61           1 :   ActionShortcut(ao)
      62             : {
      63           2 :   std::vector<std::string> str_atomsA; parseVector("VECTORSTART",str_atomsA); Tools::interpretRanges( str_atomsA );
      64           2 :   std::vector<std::string> str_atomsB; parseVector("VECTOREND",str_atomsB); Tools::interpretRanges( str_atomsB );
      65           2 :   std::vector<std::string> str_atomsC; parseVector("GROUP",str_atomsC); Tools::interpretRanges( str_atomsC );
      66           1 :   unsigned n=1; std::string dinput= getShortcutLabel() + "_dis: DISTANCE", ainput = getShortcutLabel() + "_ang: ANGLE";
      67           2 :   for(unsigned i=0; i<str_atomsA.size(); ++i ) {
      68           2 :     for(unsigned j=0; j<str_atomsB.size(); ++j ) {
      69           9 :       for(unsigned k=0; k<str_atomsC.size(); ++k) {
      70           8 :         std::string str_n; Tools::convert( n, str_n ); n++;
      71          16 :         dinput += " ATOMS" + str_n + "=" + str_atomsA[j] + "," + str_atomsC[k];
      72          16 :         ainput += " ATOMS" + str_n + "=" + str_atomsB[j] + "," + str_atomsA[i] + "," + str_atomsC[k];
      73             :       }
      74             :     }
      75             :   }
      76           1 :   readInputLine( dinput ); readInputLine( ainput );
      77           2 :   readInputLine( getShortcutLabel() + ": CUSTOM PERIODIC=NO FUNC=x*sin(y) ARG=" + getShortcutLabel() + "_dis," + getShortcutLabel() + "_ang");
      78           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
      79           1 : }
      80             : 
      81             : }
      82             : }

Generated by: LCOV version 1.16