LCOV - code coverage report
Current view: top level - multicolvar - Torsions.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 6 32 18.8 %
Date: 2018-12-19 07:49:13 Functions: 5 13 38.5 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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 "MultiColvar.h"
      23             : #include "tools/Torsion.h"
      24             : #include "core/ActionRegister.h"
      25             : 
      26             : #include <string>
      27             : #include <cmath>
      28             : 
      29             : using namespace std;
      30             : 
      31             : namespace PLMD {
      32             : namespace multicolvar {
      33             : 
      34             : //+PLUMEDOC MCOLVAR TORSIONS
      35             : /*
      36             : Calculate whether or not a set of torsional angles are within a particular range.
      37             : 
      38             : \par Examples
      39             : 
      40             : The following provides an example of the input for the torsions command
      41             : 
      42             : \verbatim
      43             : TORSIONS ...
      44             : ATOMS1=168,170,172,188
      45             : ATOMS2=170,172,188,190
      46             : ATOMS3=188,190,192,230
      47             : LABEL=ab
      48             : ... TORSIONS
      49             : PRINT ARG=ab.* FILE=colvar STRIDE=10
      50             : \endverbatim
      51             : 
      52             : Writing out the atoms involved in all the torsions in this way can be rather tedious. Thankfully if you are working with protein you
      53             : can avoid this by using the \ref MOLINFO command.  PLUMED uses the pdb file that you provide to this command to learn
      54             : about the topology of the protein molecule.  This means that you can specify torsion angles using the following syntax:
      55             : 
      56             : \verbatim
      57             : MOLINFO MOLTYPE=protein STRUCTURE=myprotein.pdb
      58             : TORSIONS ...
      59             : ATOMS1=@phi-3
      60             : ATOMS2=@psi-3
      61             : ATOMS3=@phi-4
      62             : LABEL=ab
      63             : ... TORSIONS
      64             : PRINT ARG=ab FILE=colvar STRIDE=10
      65             : \endverbatim
      66             : 
      67             : Here, \@phi-3 tells plumed that you would like to calculate the \f$\phi\f$ angle in the third residue of the protein.
      68             : Similarly \@psi-4 tells plumed that you want to calculate the \f$\psi\f$ angle of the 4th residue of the protein.
      69             : 
      70             : 
      71             : */
      72             : //+ENDPLUMEDOC
      73             : 
      74           0 : class Torsions : public MultiColvar {
      75             : public:
      76             :   static void registerKeywords( Keywords& keys );
      77             :   explicit Torsions(const ActionOptions&);
      78             :   virtual double compute( const unsigned& tindex, AtomValuePack& myatoms ) const ;
      79           0 :   bool isPeriodic() { return true; }
      80           0 :   void retrieveDomain( std::string& min, std::string& max ) { min="-pi"; max="pi"; }
      81             : };
      82             : 
      83        2523 : PLUMED_REGISTER_ACTION(Torsions,"TORSIONS")
      84             : 
      85           1 : void Torsions::registerKeywords( Keywords& keys ) {
      86           1 :   MultiColvar::registerKeywords( keys );
      87           1 :   keys.use("ATOMS"); keys.use("BETWEEN"); keys.use("HISTOGRAM");
      88           1 : }
      89             : 
      90           0 : Torsions::Torsions(const ActionOptions&ao):
      91           0 :   PLUMED_MULTICOLVAR_INIT(ao)
      92             : {
      93             :   // Read in the atoms
      94           0 :   int natoms=4; std::vector<AtomNumber> all_atoms;
      95           0 :   readAtoms( natoms, all_atoms );
      96           0 :   std::vector<bool> catom_ind(4, false);
      97           0 :   catom_ind[1]=catom_ind[2]=true;
      98           0 :   setAtomsForCentralAtom( catom_ind );
      99             :   // Read in the vessels
     100           0 :   readVesselKeywords();
     101             :   // And check everything has been read in correctly
     102           0 :   checkRead();
     103           0 : }
     104             : 
     105           0 : double Torsions::compute( const unsigned& tindex, AtomValuePack& myatoms ) const {
     106           0 :   Vector d0,d1,d2;
     107           0 :   d0=getSeparation(myatoms.getPosition(1),myatoms.getPosition(0));
     108           0 :   d1=getSeparation(myatoms.getPosition(2),myatoms.getPosition(1));
     109           0 :   d2=getSeparation(myatoms.getPosition(3),myatoms.getPosition(2));
     110             : 
     111           0 :   Vector dd0,dd1,dd2; PLMD::Torsion t;
     112           0 :   double value  = t.compute(d0,d1,d2,dd0,dd1,dd2);
     113             : 
     114           0 :   addAtomDerivatives(1,0,dd0,myatoms);
     115           0 :   addAtomDerivatives(1,1,dd1-dd0,myatoms);
     116           0 :   addAtomDerivatives(1,2,dd2-dd1,myatoms);
     117           0 :   addAtomDerivatives(1,3,-dd2,myatoms);
     118             : 
     119           0 :   myatoms.addBoxDerivatives  (1, -(extProduct(d0,dd0)+extProduct(d1,dd1)+extProduct(d2,dd2)));
     120             : 
     121           0 :   return value;
     122             : }
     123             : 
     124             : }
     125        2523 : }

Generated by: LCOV version 1.13