LCOV - code coverage report
Current view: top level - multicolvar - XYTorsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 29 39 74.4 %
Date: 2024-10-18 14:00:25 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.needsAction("FIXEDATOM"); keys.needsAction("TORSION");
     101          15 : }
     102             : 
     103           1 : XYTorsions::XYTorsions(const ActionOptions& ao):
     104             :   Action(ao),
     105           1 :   ActionShortcut(ao)
     106             : {
     107           2 :   std::string vdir = getShortcutLabel() + "_vec2," + getShortcutLabel() + "_origin";
     108           2 :   std::string adir = getShortcutLabel() + "_axis," + getShortcutLabel() + "_origin";
     109             :   // Create action for position of origin
     110           2 :   readInputLine( getShortcutLabel() + "_origin: FIXEDATOM AT=0,0,0");
     111           1 :   if( getName()=="XYTORSIONS" ) {
     112           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     113           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     114             :   }
     115           1 :   if( getName()=="XZTORSIONS" ) {
     116           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=1,0,0");
     117           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     118             :   }
     119           1 :   if( getName()=="YXTORSIONS" ) {
     120           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     121           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     122             :   }
     123           1 :   if( getName()=="YZTORSIONS" ) {
     124           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,1,0");
     125           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,0,1");
     126             :   }
     127           1 :   if( getName()=="ZXTORSIONS" ) {
     128           0 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     129           0 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=1,0,0");
     130             :   }
     131           1 :   if( getName()=="ZYTORSIONS" ) {
     132           1 :     readInputLine( getShortcutLabel() + "_axis: FIXEDATOM AT=0,0,1");
     133           2 :     readInputLine( getShortcutLabel() + "_vec2: FIXEDATOM AT=0,1,0");
     134             :   }
     135             : 
     136             :   // Now create action to compute all torsions
     137           1 :   std::string torsions_str = getShortcutLabel() + ": TORSION";
     138           1 :   for(unsigned i=1;; ++i) {
     139           6 :     std::string atstring; parseNumbered("ATOMS",i,atstring);
     140           3 :     if( atstring.length()==0 ) break;
     141           2 :     std::string num; Tools::convert( i, num );
     142           4 :     torsions_str += " VECTORA" + num + "=" + atstring + " VECTORB" + num + "=" + vdir + " AXIS" + num + "=" + adir;
     143           2 :   }
     144           1 :   readInputLine( torsions_str );
     145             :   // Add shortcuts to label
     146           2 :   MultiColvarShortcuts::expandFunctions( getShortcutLabel(), getShortcutLabel(), "", this );
     147           1 : }
     148             : 
     149             : }
     150             : }

Generated by: LCOV version 1.16