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 498 : SingleDomainRMSD::SingleDomainRMSD( const ReferenceConfigurationOptions& ro ): 29 : ReferenceConfiguration(ro), 30 498 : ReferenceAtoms(ro) 31 : { 32 498 : } 33 : 34 456 : void SingleDomainRMSD::readReference( const PDB& pdb ) { 35 456 : readAtomsFromPDB( pdb ); 36 : double wa=0, wd=0; 37 23685 : for(unsigned i=0; i<pdb.size(); ++i) { wa+=align[i]; wd+=displace[i]; } 38 460 : plumed_massert(wa>epsilon,"It looks like weights used for alignment are zero. Check your reference PDB file."); 39 458 : plumed_massert(wd>epsilon,"It looks like weights used for displacement are zero. Check your reference PDB file."); 40 : 41 452 : Vector center; 42 8327 : for(unsigned i=0; i<pdb.size(); ++i) { 43 23625 : align[i]=align[i] / wa; displace[i]=displace[i] / wd; 44 15750 : center+=reference_atoms[i]*align[i]; 45 : } 46 15750 : for(unsigned i=0; i<pdb.size(); ++i) reference_atoms[i]-=center; 47 452 : } 48 : 49 45 : void SingleDomainRMSD::setReferenceAtoms( const std::vector<Vector>& conf, const std::vector<double>& align_in, const std::vector<double>& displace_in ) { 50 90 : reference_atoms.resize( conf.size() ); align.resize( conf.size() ); 51 90 : displace.resize( conf.size() ); atom_der_index.resize( conf.size() ); 52 : double wa=0, wd=0; 53 3372 : for(unsigned i=0; i<conf.size(); ++i) { wa+=align_in[i]; wd+=displace_in[i]; } 54 : 55 45 : Vector center; 56 2308 : for(unsigned i=0; i<conf.size(); ++i) { 57 2218 : align[i]=align_in[i] / wa; displace[i]=displace_in[i] / wd; 58 3327 : center+=conf[i]*align[i]; atom_der_index[i]=i; 59 : } 60 2263 : for(unsigned i=0; i<conf.size(); ++i) reference_atoms[i]=conf[i]-center; 61 45 : setupRMSDObject(); 62 45 : } 63 : 64 58033 : double SingleDomainRMSD::calculate( const std::vector<Vector>& pos, const Pbc& pbc, ReferenceValuePack& myder, const bool& squared ) const { 65 58033 : return calc( pos, pbc, myder, squared ); 66 : } 67 : 68 140818 : 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 140818 : return calc( pos, pbc, myder, squared ); 72 : } 73 : 74 5874 : }