LCOV - code coverage report
Current view: top level - multicolvar - XYTorsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 32 42 76.2 %
Date: 2025-04-08 21:11:17 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             : #include "MultiColvarShortcuts.h"
      25             : 
      26             : //+PLUMEDOC COLVAR XYTORSIONS
      27             : /*
      28             : Calculate the torsional angle around the x axis between an arbitrary vector and the positive y direction
      29             : 
      30             : The following input tells plumed to calculate the angle around the x direction between the positive y-axis and the vector connecting atom 3 to atom 5 and
      31             : the angle around the x direction between the positive y axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
      32             : 
      33             : ```plumed
      34             : d1: XYTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      35             : PRINT ARG=d1_mean
      36             : ```
      37             : 
      38             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
      39             : 
      40             : */
      41             : //+ENDPLUMEDOC
      42             : 
      43             : //+PLUMEDOC COLVAR XZTORSIONS
      44             : /*
      45             : Calculate the torsional angle around the x axis between an arbitrary vector and the positive z direction
      46             : 
      47             : The following input tells plumed to calculate the angle around the x direction between the positive z-axis and the vector connecting atom 3 to atom 5 and
      48             : the angle around the x direction between the positive z axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
      49             : 
      50             : ```plumed
      51             : d1: XZTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      52             : PRINT ARG=d1_mean
      53             : ```
      54             : 
      55             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
      56             : 
      57             : */
      58             : //+ENDPLUMEDOC
      59             : 
      60             : //+PLUMEDOC COLVAR YXTORSIONS
      61             : /*
      62             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive x direction
      63             : 
      64             : The following input tells plumed to calculate the angle around the y direction between the positive x-axis and the vector connecting atom 3 to atom 5 and
      65             : the angle around the y direction between the positive x axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
      66             : 
      67             : ```plumed
      68             : d1: YXTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      69             : PRINT ARG=d1_mean
      70             : ```
      71             : 
      72             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
      73             : 
      74             : */
      75             : //+ENDPLUMEDOC
      76             : 
      77             : //+PLUMEDOC COLVAR YZTORSIONS
      78             : /*
      79             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive z direction
      80             : 
      81             : The following input tells plumed to calculate the angle around the y direction between the positive z-axis and the vector connecting atom 3 to atom 5 and
      82             : the angle around the y direction between the positive z axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
      83             : 
      84             : ```plumed
      85             : d1: YZTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      86             : PRINT ARG=d1_mean
      87             : ```
      88             : 
      89             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
      90             : 
      91             : */
      92             : //+ENDPLUMEDOC
      93             : 
      94             : //+PLUMEDOC COLVAR ZXTORSIONS
      95             : /*
      96             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive x direction
      97             : 
      98             : The following input tells plumed to calculate the angle around the z direction between the positive x-axis and the vector connecting atom 3 to atom 5 and
      99             : the angle around the z direction between the positive x axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
     100             : 
     101             : ```plumed
     102             : d1: ZXTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
     103             : PRINT ARG=d1_mean
     104             : ```
     105             : 
     106             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
     107             : 
     108             : */
     109             : //+ENDPLUMEDOC
     110             : 
     111             : //+PLUMEDOC COLVAR ZYTORSIONS
     112             : /*
     113             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive y direction
     114             : 
     115             : The following input tells plumed to calculate the angle around the z direction between the positive y-axis and the vector connecting atom 3 to atom 5 and
     116             : the angle around the z direction between the positive y-axis and the vector connecting atom 1 to atom 2.  The average of these two quantities is then output
     117             : 
     118             : ```plumed
     119             : d1: ZYTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
     120             : PRINT ARG=d1_mean
     121             : ```
     122             : 
     123             : Notice that this command is a shortcut. You can thus learn more about how to use PLUMED by examining the expanded version of the input above.
     124             : 
     125             : */
     126             : //+ENDPLUMEDOC
     127             : 
     128             : namespace PLMD {
     129             : namespace multicolvar {
     130             : 
     131             : class XYTorsions : public ActionShortcut {
     132             : public:
     133             :   static void registerKeywords(Keywords& keys);
     134             :   explicit XYTorsions(const ActionOptions&);
     135             : };
     136             : 
     137             : PLUMED_REGISTER_ACTION(XYTorsions,"XYTORSIONS")
     138             : PLUMED_REGISTER_ACTION(XYTorsions,"XZTORSIONS")
     139             : PLUMED_REGISTER_ACTION(XYTorsions,"YXTORSIONS")
     140             : PLUMED_REGISTER_ACTION(XYTorsions,"YZTORSIONS")
     141             : PLUMED_REGISTER_ACTION(XYTorsions,"ZXTORSIONS")
     142             : PLUMED_REGISTER_ACTION(XYTorsions,"ZYTORSIONS")
     143             : 
     144          15 : void XYTorsions::registerKeywords(Keywords& keys) {
     145          15 :   ActionShortcut::registerKeywords( keys );
     146          15 :   keys.add("numbered","ATOMS","the pairs of atoms that you would like to calculate the angles for");
     147          30 :   keys.reset_style("ATOMS","atoms");
     148          15 :   MultiColvarShortcuts::shortcutKeywords( keys );
     149          30 :   keys.setValueDescription("vector","the angle between the vector connecting each pair of atoms and the the positive X/Y/Z direction around the X/Y/Z axis");
     150          15 :   keys.needsAction("FIXEDATOM");
     151          15 :   keys.needsAction("TORSION");
     152          15 : }
     153             : 
     154           1 : XYTorsions::XYTorsions(const ActionOptions& ao):
     155             :   Action(ao),
     156           1 :   ActionShortcut(ao) {
     157           2 :   std::string vdir = getShortcutLabel() + "_vec2," + getShortcutLabel() + "_origin";
     158           2 :   std::string adir = getShortcutLabel() + "_axis," + getShortcutLabel() + "_origin";
     159             :   // Create action for position of origin
     160           2 :   readInputLine( getShortcutLabel() + "_origin: FIXEDATOM AT=0,0,0");
     161           1 :   if( getName()=="XYTORSIONS" ) {
     162           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     163           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     164             :   }
     165           1 :   if( getName()=="XZTORSIONS" ) {
     166           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     167           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     168             :   }
     169           1 :   if( getName()=="YXTORSIONS" ) {
     170           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     171           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     172             :   }
     173           1 :   if( getName()=="YZTORSIONS" ) {
     174           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     175           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     176             :   }
     177           1 :   if( getName()=="ZXTORSIONS" ) {
     178           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     179           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     180             :   }
     181           1 :   if( getName()=="ZYTORSIONS" ) {
     182           1 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     183           2 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     184             :   }
     185             : 
     186             :   // Now create action to compute all torsions
     187           1 :   std::string torsions_str = getShortcutLabel() + ": TORSION";
     188           1 :   for(unsigned i=1;; ++i) {
     189             :     std::string atstring;
     190           6 :     parseNumbered("ATOMS",i,atstring);
     191           3 :     if( atstring.length()==0 ) {
     192             :       break;
     193             :     }
     194             :     std::string num;
     195           2 :     Tools::convert( i, num );
     196           4 :     torsions_str += " VECTORA" + num + "=" + atstring + " VECTORB" + num + "=" + vdir + " AXIS" + num + "=" + adir;
     197           2 :   }
     198           1 :   readInputLine( torsions_str );
     199             :   // Add shortcuts to label
     200           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
     201           1 : }
     202             : 
     203             : }
     204             : }

Generated by: LCOV version 1.16