LCOV - code coverage report
Current view: top level - multicolvar - XYTorsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 30 40 75.0 %
Date: 2024-10-18 13:59:31 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             : \par Examples
      31             : 
      32             : */
      33             : //+ENDPLUMEDOC
      34             : 
      35             : //+PLUMEDOC COLVAR XZTORSIONS
      36             : /*
      37             : Calculate the torsional angle around the x axis between an arbitrary vector and the positive z direction
      38             : 
      39             : \par Examples
      40             : 
      41             : */
      42             : //+ENDPLUMEDOC
      43             : 
      44             : //+PLUMEDOC COLVAR YXTORSIONS
      45             : /*
      46             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive x direction
      47             : 
      48             : \par Examples
      49             : 
      50             : */
      51             : //+ENDPLUMEDOC
      52             : 
      53             : //+PLUMEDOC COLVAR YZTORSIONS
      54             : /*
      55             : Calculate the torsional angle around the y axis between an arbitrary vector and the positive z direction
      56             : 
      57             : \par Examples
      58             : 
      59             : */
      60             : //+ENDPLUMEDOC
      61             : 
      62             : //+PLUMEDOC COLVAR ZXTORSIONS
      63             : /*
      64             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive x direction
      65             : 
      66             : \par Examples
      67             : 
      68             : */
      69             : //+ENDPLUMEDOC
      70             : 
      71             : //+PLUMEDOC COLVAR ZYTORSIONS
      72             : /*
      73             : Calculate the torsional angle around the z axis between an arbitrary vector and the positive y direction
      74             : 
      75             : \par Examples
      76             : 
      77             : */
      78             : //+ENDPLUMEDOC
      79             : 
      80             : namespace PLMD {
      81             : namespace multicolvar {
      82             : 
      83             : class XYTorsions : public ActionShortcut {
      84             : public:
      85             :   static void registerKeywords(Keywords& keys);
      86             :   explicit XYTorsions(const ActionOptions&);
      87             : };
      88             : 
      89             : PLUMED_REGISTER_ACTION(XYTorsions,"XYTORSIONS")
      90             : PLUMED_REGISTER_ACTION(XYTorsions,"XZTORSIONS")
      91             : PLUMED_REGISTER_ACTION(XYTorsions,"YXTORSIONS")
      92             : PLUMED_REGISTER_ACTION(XYTorsions,"YZTORSIONS")
      93             : PLUMED_REGISTER_ACTION(XYTorsions,"ZXTORSIONS")
      94             : PLUMED_REGISTER_ACTION(XYTorsions,"ZYTORSIONS")
      95             : 
      96          15 : void XYTorsions::registerKeywords(Keywords& keys) {
      97          15 :   ActionShortcut::registerKeywords( keys );
      98          30 :   keys.add("numbered","ATOMS","the pairs of atoms that you would like to calculate the angles for");
      99          30 :   keys.reset_style("ATOMS","atoms"); MultiColvarShortcuts::shortcutKeywords( keys );
     100          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");
     101          30 :   keys.needsAction("FIXEDATOM"); keys.needsAction("TORSION");
     102          15 : }
     103             : 
     104           1 : XYTorsions::XYTorsions(const ActionOptions& ao):
     105             :   Action(ao),
     106           1 :   ActionShortcut(ao)
     107             : {
     108           2 :   std::string vdir = getShortcutLabel() + "_vec2," + getShortcutLabel() + "_origin";
     109           2 :   std::string adir = getShortcutLabel() + "_axis," + getShortcutLabel() + "_origin";
     110             :   // Create action for position of origin
     111           2 :   readInputLine( getShortcutLabel() + "_origin: FIXEDATOM AT=0,0,0");
     112           1 :   if( getName()=="XYTORSIONS" ) {
     113           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     114           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     115             :   }
     116           1 :   if( getName()=="XZTORSIONS" ) {
     117           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     118           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     119             :   }
     120           1 :   if( getName()=="YXTORSIONS" ) {
     121           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     122           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     123             :   }
     124           1 :   if( getName()=="YZTORSIONS" ) {
     125           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     126           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     127             :   }
     128           1 :   if( getName()=="ZXTORSIONS" ) {
     129           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     130           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     131             :   }
     132           1 :   if( getName()=="ZYTORSIONS" ) {
     133           1 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     134           2 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     135             :   }
     136             : 
     137             :   // Now create action to compute all torsions
     138           1 :   std::string torsions_str = getShortcutLabel() + ": TORSION";
     139           1 :   for(unsigned i=1;; ++i) {
     140           6 :     std::string atstring; parseNumbered("ATOMS",i,atstring);
     141           3 :     if( atstring.length()==0 ) break;
     142           2 :     std::string num; Tools::convert( i, num );
     143           4 :     torsions_str += " VECTORA" + num + "=" + atstring + " VECTORB" + num + "=" + vdir + " AXIS" + num + "=" + adir;
     144           2 :   }
     145           1 :   readInputLine( torsions_str );
     146             :   // Add shortcuts to label
     147           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
     148           1 : }
     149             : 
     150             : }
     151             : }

Generated by: LCOV version 1.16