LCOV - code coverage report
Current view: top level - reference - SimpleRMSD.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 30 30 100.0 %
Date: 2018-12-19 07:49:13 Functions: 13 14 92.9 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-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 "RMSDBase.h"
      23             : #include "MetricRegister.h"
      24             : #include "tools/RMSD.h"
      25             : 
      26             : namespace PLMD {
      27             : 
      28          58 : class SimpleRMSD : public RMSDBase {
      29             : private:
      30             :   RMSD myrmsd;
      31             : public:
      32             :   explicit SimpleRMSD( const ReferenceConfigurationOptions& ro );
      33             :   void read( const PDB& );
      34             :   double calc( const std::vector<Vector>& pos, ReferenceValuePack& myder, const bool& squared ) const ;
      35           3 :   bool pcaIsEnabledForThisReference() { return true; }
      36          67 :   void setupPCAStorage( ReferenceValuePack& mypack ) {
      37          67 :     mypack.switchOnPCAOption(); mypack.getAtomsDisplacementVector().resize( getNumberOfAtoms() );
      38          67 :   }
      39             :   double projectAtomicDisplacementOnVector( const unsigned& iv, const Matrix<Vector>& vecs, const std::vector<Vector>& pos, ReferenceValuePack& mypack ) const ;
      40             : };
      41             : 
      42        2552 : PLUMED_REGISTER_METRIC(SimpleRMSD,"SIMPLE")
      43             : 
      44          29 : SimpleRMSD::SimpleRMSD( const ReferenceConfigurationOptions& ro ):
      45             :   ReferenceConfiguration( ro ),
      46          29 :   RMSDBase( ro )
      47             : {
      48          29 : }
      49             : 
      50          23 : void SimpleRMSD::read( const PDB& pdb ) {
      51          23 :   readReference( pdb );
      52          23 : }
      53             : 
      54         148 : double SimpleRMSD::calc( const std::vector<Vector>& pos, ReferenceValuePack& myder, const bool& squared ) const {
      55         148 :   if( myder.getAtomsDisplacementVector().size()!=pos.size() ) myder.getAtomsDisplacementVector().resize( pos.size() );
      56         148 :   double d=myrmsd.simpleAlignment( getAlign(), getDisplace(), pos, getReferencePositions(), myder.getAtomVector(), myder.getAtomsDisplacementVector(), squared );
      57         148 :   myder.clear(); for(unsigned i=0; i<pos.size(); ++i) myder.setAtomDerivatives( i, myder.getAtomVector()[i] );
      58         148 :   if( !myder.updateComplete() ) myder.updateDynamicLists();
      59         148 :   return d;
      60             : }
      61             : 
      62          66 : double SimpleRMSD::projectAtomicDisplacementOnVector( const unsigned& iv, const Matrix<Vector>& vecs, const std::vector<Vector>& pos, ReferenceValuePack& mypack ) const {
      63          66 :   plumed_dbg_assert( mypack.calcUsingPCAOption() ); Vector comder; comder.zero();
      64         374 :   for(unsigned j=0; j<pos.size(); ++j) {
      65         308 :     for(unsigned k=0; k<3; ++k) comder[k] += getAlign()[j]*vecs(iv,j)[k];
      66             :   }
      67             : 
      68          66 :   double proj=0; mypack.clear();
      69         374 :   for(unsigned j=0; j<pos.size(); ++j) {
      70        1232 :     for(unsigned k=0; k<3; ++k) {
      71         924 :       proj += vecs(iv,j)[k]*mypack.getAtomsDisplacementVector()[j][k];
      72             :     }
      73         308 :     mypack.setAtomDerivatives( j, vecs(iv,j) - comder );
      74             :   }
      75          66 :   if( !mypack.updateComplete() ) mypack.updateDynamicLists();
      76          66 :   return proj;
      77             : }
      78             : 
      79        2523 : }

Generated by: LCOV version 1.13