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: 2020-11-18 11:20:57 Functions: 7 8 87.5 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2019 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        1038 : SingleDomainRMSD::SingleDomainRMSD( const ReferenceConfigurationOptions& ro ):
      29             :   ReferenceConfiguration(ro),
      30        1038 :   ReferenceAtoms(ro)
      31             : {
      32        1038 : }
      33             : 
      34         427 : void SingleDomainRMSD::readReference( const PDB& pdb ) {
      35         427 :   readAtomsFromPDB( pdb );
      36             :   double wa=0, wd=0;
      37       23245 :   for(unsigned i=0; i<pdb.size(); ++i) { wa+=align[i]; wd+=displace[i]; }
      38         433 :   plumed_massert(wa>epsilon,"It looks like weights used for alignment are zero. Check your reference PDB file.");
      39         431 :   plumed_massert(wd>epsilon,"It looks like weights used for displacement are zero. Check your reference PDB file.");
      40             : 
      41         423 :   Vector center;
      42       15595 :   for(unsigned i=0; i<pdb.size(); ++i) {
      43       22758 :     align[i]=align[i] / wa; displace[i]=displace[i] / wd;
      44       15172 :     center+=reference_atoms[i]*align[i];
      45             :   }
      46       15595 :   for(unsigned i=0; i<pdb.size(); ++i) reference_atoms[i]-=center;
      47         423 : }
      48             : 
      49         613 : void SingleDomainRMSD::setReferenceAtoms( const std::vector<Vector>& conf, const std::vector<double>& align_in, const std::vector<double>& displace_in ) {
      50        1839 :   reference_atoms.resize( conf.size() ); align.resize( conf.size() );
      51        1839 :   displace.resize( conf.size() ); atom_der_index.resize( conf.size() );
      52             :   double wa=0, wd=0;
      53       54738 :   for(unsigned i=0; i<conf.size(); ++i) { wa+=align_in[i]; wd+=displace_in[i]; }
      54             : 
      55         613 :   Vector center;
      56       41360 :   for(unsigned i=0; i<conf.size(); ++i) {
      57       53512 :     align[i]=align_in[i] / wa; displace[i]=displace_in[i] / wd;
      58       40134 :     center+=conf[i]*align[i]; atom_der_index[i]=i;
      59             :   }
      60       41360 :   for(unsigned i=0; i<conf.size(); ++i) reference_atoms[i]=conf[i]-center;
      61         613 :   setupRMSDObject();
      62         613 : }
      63             : 
      64       58046 : double SingleDomainRMSD::calculate( const std::vector<Vector>& pos, const Pbc& pbc, ReferenceValuePack& myder, const bool& squared ) const {
      65       58046 :   return calc( pos, pbc, myder, squared );
      66             : }
      67             : 
      68      140925 : double SingleDomainRMSD::calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& arg,
      69             :                                ReferenceValuePack& myder, const bool& squared ) const {
      70             :   plumed_dbg_assert( vals.size()==0 && pos.size()==getNumberOfAtoms() && arg.size()==0 );
      71      140925 :   return calc( pos, pbc, myder, squared );
      72             : }
      73             : 
      74        4839 : }

Generated by: LCOV version 1.13