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

          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 "SingleDomainRMSD.h"
      23             : #include "tools/PDB.h"
      24             : #include "DRMSD.h"
      25             : 
      26             : namespace PLMD {
      27             : 
      28         975 : SingleDomainRMSD::SingleDomainRMSD( const ReferenceConfigurationOptions& ro ):
      29             :   ReferenceConfiguration(ro),
      30         975 :   ReferenceAtoms(ro)
      31             : {
      32         975 : }
      33             : 
      34         367 : void SingleDomainRMSD::readReference( const PDB& pdb ) {
      35         367 :   readAtomsFromPDB( pdb );
      36         367 :   double wa=0, wd=0;
      37         367 :   for(unsigned i=0; i<pdb.size(); ++i) { wa+=align[i]; wd+=displace[i]; }
      38             : 
      39         367 :   Vector center;
      40        7233 :   for(unsigned i=0; i<pdb.size(); ++i) {
      41        6866 :     align[i]=align[i] / wa; displace[i]=displace[i] / wd;
      42        6866 :     center+=reference_atoms[i]*align[i];
      43             :   }
      44         367 :   for(unsigned i=0; i<pdb.size(); ++i) reference_atoms[i]-=center;
      45         367 : }
      46             : 
      47         596 : void SingleDomainRMSD::setReferenceAtoms( const std::vector<Vector>& conf, const std::vector<double>& align_in, const std::vector<double>& displace_in ) {
      48         596 :   reference_atoms.resize( conf.size() ); align.resize( conf.size() );
      49         596 :   displace.resize( conf.size() ); atom_der_index.resize( conf.size() );
      50         596 :   double wa=0, wd=0;
      51         596 :   for(unsigned i=0; i<conf.size(); ++i) { wa+=align_in[i]; wd+=displace_in[i]; }
      52             : 
      53         596 :   Vector center;
      54       13753 :   for(unsigned i=0; i<conf.size(); ++i) {
      55       13157 :     align[i]=align_in[i] / wa; displace[i]=displace_in[i] / wd;
      56       13157 :     center+=conf[i]*align[i]; atom_der_index[i]=i;
      57             :   }
      58         596 :   for(unsigned i=0; i<conf.size(); ++i) reference_atoms[i]=conf[i]-center;
      59         596 :   setupRMSDObject();
      60         596 : }
      61             : 
      62       58026 : double SingleDomainRMSD::calculate( const std::vector<Vector>& pos, const Pbc& pbc, ReferenceValuePack& myder, const bool& squared ) const {
      63       58026 :   return calc( pos, pbc, myder, squared );
      64             : }
      65             : 
      66      113840 : double SingleDomainRMSD::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& arg,
      67             :                                ReferenceValuePack& myder, const bool& squared ) const {
      68             :   plumed_dbg_assert( vals.size()==0 && pos.size()==getNumberOfAtoms() && arg.size()==0 );
      69      113840 :   return calc( pos, pbc, myder, squared );
      70             : }
      71             : 
      72        2523 : }

Generated by: LCOV version 1.13