LCOV - code coverage report
Current view: top level - multicolvar - InPlaneDistances.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 24 24 100.0 %
Date: 2024-10-18 14:00:25 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           3 :   MultiColvarShortcuts::shortcutKeywords( keys );
      55           6 :   keys.needsAction("DISTANCE"); keys.needsAction("ANGLE");
      56           3 : }
      57             : 
      58           1 : InPlaneDistances::InPlaneDistances(const ActionOptions&ao):
      59             :   Action(ao),
      60           1 :   ActionShortcut(ao)
      61             : {
      62           2 :   std::vector<std::string> str_atomsA; parseVector("VECTORSTART",str_atomsA); Tools::interpretRanges( str_atomsA );
      63           2 :   std::vector<std::string> str_atomsB; parseVector("VECTOREND",str_atomsB); Tools::interpretRanges( str_atomsB );
      64           2 :   std::vector<std::string> str_atomsC; parseVector("GROUP",str_atomsC); Tools::interpretRanges( str_atomsC );
      65           1 :   unsigned n=1; std::string dinput= getShortcutLabel() + "_dis: DISTANCE", ainput = getShortcutLabel() + "_ang: ANGLE";
      66           2 :   for(unsigned i=0; i<str_atomsA.size(); ++i ) {
      67           2 :     for(unsigned j=0; j<str_atomsB.size(); ++j ) {
      68           9 :       for(unsigned k=0; k<str_atomsC.size(); ++k) {
      69           8 :         std::string str_n; Tools::convert( n, str_n ); n++;
      70          16 :         dinput += " ATOMS" + str_n + "=" + str_atomsA[j] + "," + str_atomsC[k];
      71          16 :         ainput += " ATOMS" + str_n + "=" + str_atomsB[j] + "," + str_atomsA[i] + "," + str_atomsC[k];
      72             :       }
      73             :     }
      74             :   }
      75           1 :   readInputLine( dinput ); readInputLine( ainput );
      76           2 :   readInputLine( getShortcutLabel() + ": CUSTOM PERIODIC=NO FUNC=x*sin(y) ARG=" + getShortcutLabel() + "_dis," + getShortcutLabel() + "_ang");
      77           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
      78           1 : }
      79             : 
      80             : }
      81             : }

Generated by: LCOV version 1.16