LCOV - code coverage report
Current view: top level - multicolvar - XYTorsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 33 43 76.7 %
Date: 2025-12-04 11:19:34 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             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
      31             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
      32             : you with a clearer understanding of the equations you are using.__
      33             : 
      34             : 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
      35             : 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
      36             : 
      37             : ```plumed
      38             : d1: XYTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      39             : PRINT ARG=d1_mean
      40             : ```
      41             : 
      42             : 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.
      43             : 
      44             : */
      45             : //+ENDPLUMEDOC
      46             : 
      47             : //+PLUMEDOC COLVAR XZTORSIONS
      48             : /*
      49             : Calculate the torsional angle around the x axis between an arbitrary vector and the positive z direction
      50             : 
      51             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
      52             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
      53             : you with a clearer understanding of the equations you are using.__
      54             : 
      55             : 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
      56             : 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
      57             : 
      58             : ```plumed
      59             : d1: XZTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      60             : PRINT ARG=d1_mean
      61             : ```
      62             : 
      63             : 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.
      64             : 
      65             : */
      66             : //+ENDPLUMEDOC
      67             : 
      68             : //+PLUMEDOC COLVAR YXTORSIONS
      69             : /*
      70             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive x direction
      71             : 
      72             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
      73             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
      74             : you with a clearer understanding of the equations you are using.__
      75             : 
      76             : 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
      77             : 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
      78             : 
      79             : ```plumed
      80             : d1: YXTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
      81             : PRINT ARG=d1_mean
      82             : ```
      83             : 
      84             : 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.
      85             : 
      86             : */
      87             : //+ENDPLUMEDOC
      88             : 
      89             : //+PLUMEDOC COLVAR YZTORSIONS
      90             : /*
      91             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive z direction
      92             : 
      93             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
      94             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
      95             : you with a clearer understanding of the equations you are using.__
      96             : 
      97             : 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
      98             : 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
      99             : 
     100             : ```plumed
     101             : d1: YZTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
     102             : PRINT ARG=d1_mean
     103             : ```
     104             : 
     105             : 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.
     106             : 
     107             : */
     108             : //+ENDPLUMEDOC
     109             : 
     110             : //+PLUMEDOC COLVAR ZXTORSIONS
     111             : /*
     112             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive x direction
     113             : 
     114             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
     115             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
     116             : you with a clearer understanding of the equations you are using.__
     117             : 
     118             : 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
     119             : 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
     120             : 
     121             : ```plumed
     122             : d1: ZXTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
     123             : PRINT ARG=d1_mean
     124             : ```
     125             : 
     126             : 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.
     127             : 
     128             : */
     129             : //+ENDPLUMEDOC
     130             : 
     131             : //+PLUMEDOC COLVAR ZYTORSIONS
     132             : /*
     133             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive y direction
     134             : 
     135             : __As you can see if you expand the inputs below, you can achieve what this shortcut action does by using [TORSION](TORSION.md) together with [CUSTOM](CUSTOM.md),
     136             : [BETWEEN](BETWEEN.md), [LESS_THAN](LESS_THAN.md), [SUM](SUM.md) and [MEAN](MEAN.md).  We strongly encourage you to use these actions instead as using them will provide
     137             : you with a clearer understanding of the equations you are using.__
     138             : 
     139             : 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
     140             : 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
     141             : 
     142             : ```plumed
     143             : d1: ZYTORSIONS ATOMS1=3,5 ATOMS2=1,2 MEAN
     144             : PRINT ARG=d1_mean
     145             : ```
     146             : 
     147             : 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.
     148             : 
     149             : */
     150             : //+ENDPLUMEDOC
     151             : 
     152             : namespace PLMD {
     153             : namespace multicolvar {
     154             : 
     155             : class XYTorsions : public ActionShortcut {
     156             : public:
     157             :   static void registerKeywords(Keywords& keys);
     158             :   explicit XYTorsions(const ActionOptions&);
     159             : };
     160             : 
     161             : PLUMED_REGISTER_ACTION(XYTorsions,"XYTORSIONS")
     162             : PLUMED_REGISTER_ACTION(XYTorsions,"XZTORSIONS")
     163             : PLUMED_REGISTER_ACTION(XYTorsions,"YXTORSIONS")
     164             : PLUMED_REGISTER_ACTION(XYTorsions,"YZTORSIONS")
     165             : PLUMED_REGISTER_ACTION(XYTorsions,"ZXTORSIONS")
     166             : PLUMED_REGISTER_ACTION(XYTorsions,"ZYTORSIONS")
     167             : 
     168          15 : void XYTorsions::registerKeywords(Keywords& keys) {
     169          15 :   ActionShortcut::registerKeywords( keys );
     170          15 :   keys.add("numbered","ATOMS","the pairs of atoms that you would like to calculate the angles for");
     171          30 :   keys.reset_style("ATOMS","atoms");
     172          15 :   MultiColvarShortcuts::shortcutKeywords( keys );
     173          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");
     174          15 :   keys.needsAction("FIXEDATOM");
     175          15 :   keys.needsAction("TORSION");
     176          15 :   keys.setDeprecated("TORSION");
     177          15 : }
     178             : 
     179           1 : XYTorsions::XYTorsions(const ActionOptions& ao):
     180             :   Action(ao),
     181           1 :   ActionShortcut(ao) {
     182           2 :   std::string vdir = getShortcutLabel() + "_vec2," + getShortcutLabel() + "_origin";
     183           2 :   std::string adir = getShortcutLabel() + "_axis," + getShortcutLabel() + "_origin";
     184             :   // Create action for position of origin
     185           2 :   readInputLine( getShortcutLabel() + "_origin: FIXEDATOM AT=0,0,0");
     186           1 :   if( getName()=="XYTORSIONS" ) {
     187           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     188           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     189             :   }
     190           1 :   if( getName()=="XZTORSIONS" ) {
     191           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     192           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     193             :   }
     194           1 :   if( getName()=="YXTORSIONS" ) {
     195           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     196           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     197             :   }
     198           1 :   if( getName()=="YZTORSIONS" ) {
     199           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     200           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     201             :   }
     202           1 :   if( getName()=="ZXTORSIONS" ) {
     203           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     204           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     205             :   }
     206           1 :   if( getName()=="ZYTORSIONS" ) {
     207           1 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     208           2 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     209             :   }
     210             : 
     211             :   // Now create action to compute all torsions
     212           1 :   std::string torsions_str = getShortcutLabel() + ": TORSION";
     213           1 :   for(unsigned i=1;; ++i) {
     214             :     std::string atstring;
     215           6 :     parseNumbered("ATOMS",i,atstring);
     216           3 :     if( atstring.length()==0 ) {
     217             :       break;
     218             :     }
     219             :     std::string num;
     220           2 :     Tools::convert( i, num );
     221           4 :     torsions_str += " VECTORA" + num + "=" + atstring + " VECTORB" + num + "=" + vdir + " AXIS" + num + "=" + adir;
     222           2 :   }
     223           1 :   readInputLine( torsions_str );
     224             :   // Add shortcuts to label
     225           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
     226           1 : }
     227             : 
     228             : }
     229             : }

Generated by: LCOV version 1.16