LCOV - code coverage report
Current view: top level - reference - ReferenceAtoms.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 15 17 88.2 %
Date: 2018-12-19 07:49:13 Functions: 8 11 72.7 %

          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             : #ifndef __PLUMED_reference_ReferenceAtoms_h
      23             : #define __PLUMED_reference_ReferenceAtoms_h
      24             : 
      25             : #include "ReferenceConfiguration.h"
      26             : 
      27             : namespace PLMD {
      28             : 
      29             : class Pbc;
      30             : 
      31             : /// \ingroup TOOLBOX
      32             : /// In many applications (e.g. paths, fields, property maps) it is necessary to calculate
      33             : /// the distance between two configurations.  These distances can be calculated in a variety of
      34             : /// different ways.  For instance, one can assert that the distance between the two configuration
      35             : /// is the distance one would have to move all the atoms to transform configuration 1 into configuration
      36             : /// 2. Alternatively, one could calculate the values of a large set of collective coordinates in the two
      37             : /// configurations and then calculate the Euclidean distances between these two points in the resulting
      38             : /// high-dimensional vector space.  Lastly, one can combine these two forms of distance calculation to calculate
      39             : /// a hybrid distance.  Plumed allows one to use all these forms of distance calculations and also to implement
      40             : /// new forms of distance.  You should inherit from this class if your distance involves reference atomic positions.
      41             : /// This class and \ref PLMD::ReferenceArguments mirror the functionalities in and \ref PLMD::ActionAtomistic
      42             : /// and \ref PLMD::ActionWithArguments respectively but for distances.
      43             : 
      44         992 : class ReferenceAtoms :
      45             :   virtual public ReferenceConfiguration
      46             : {
      47             :   friend class Direction;
      48             :   friend class SingleDomainRMSD;
      49             : private:
      50             : /// This flag tells us if the user has disabled checking of the input in order to
      51             : /// do fancy paths with weird inputs
      52             :   bool checks_were_disabled;
      53             : /// The atoms to be used to align the instantaneous atomic positions
      54             : /// to the reference configuration
      55             :   std::vector<double> align;
      56             : /// The atoms to be used to calculate the distance the atoms have moved
      57             : /// from the reference configuration
      58             :   std::vector<double> displace;
      59             : /// The positions of the atoms in the reference configuration
      60             :   std::vector<Vector> reference_atoms;
      61             : /// The indices of the atoms in the pdb file
      62             :   std::vector<AtomNumber> indices;
      63             : /// The indeces for setting derivatives
      64             :   std::vector<unsigned> atom_der_index;
      65             : protected:
      66             : /// Read in the atoms from the pdb file
      67             :   void readAtomsFromPDB( const PDB&, const bool allowblocks=false );
      68             : /// Add atom indices to list
      69             :   void setAtomIndices( const std::vector<AtomNumber>& atomnumbers );
      70             : /// Read a list of atoms from the pdb input file
      71             :   bool parseAtomList( const std::string&, std::vector<unsigned>& );
      72             : /// Get the vector of alignment weights
      73             :   const std::vector<double> & getAlign() const ;
      74             : /// Get the vector of displacement weights
      75             :   const std::vector<double> & getDisplace() const ;
      76             : /// Get the position of the ith atom
      77             :   Vector getReferencePosition( const unsigned& iatom ) const ;
      78             : /// Get the reference positions
      79             :   const std::vector<Vector> & getReferencePositions() const ;
      80             : /// Add derivatives to iatom th atom in list
      81             : //  void addAtomicDerivatives( const unsigned& , const Vector& );
      82             : /// Get the atomic derivatives on the ith atom in the list
      83             : //  Vector retrieveAtomicDerivatives( const unsigned& ) const ;
      84             : /// Add derivatives to the viral
      85             : //  void addBoxDerivatives( const Tensor& );
      86             : /// This does the checks that are always required
      87             :   void singleDomainRequests( std::vector<AtomNumber>&, bool disable_checks );
      88             : public:
      89             :   explicit ReferenceAtoms( const ReferenceConfigurationOptions& ro );
      90             : /// This returns the number of reference atom positions
      91             :   unsigned getNumberOfReferencePositions() const ;
      92             : /// This allows us to use a single pos array with RMSD objects using different atom indexes
      93             :   unsigned getAtomIndex( const unsigned& ) const ;
      94             : /// Get the atoms required (additional checks are required when we have multiple domains)
      95             :   virtual void getAtomRequests( std::vector<AtomNumber>&, bool disable_checks=false );
      96             : /// Set the indices of the reference atoms
      97             :   void setAtomNumbers( const std::vector<AtomNumber>& numbers );
      98             : /// Set the positions of the reference atoms
      99             :   virtual void setReferenceAtoms( const std::vector<Vector>& conf, const std::vector<double>& align_in, const std::vector<double>& displace_in )=0;
     100             : /// Print the atomic positions
     101             :   void printAtoms( OFile& ofile, const double& lunits ) const ;
     102             : /// Return all atom indexes
     103             :   const std::vector<AtomNumber>& getAbsoluteIndexes();
     104             : /// This returns how many atoms there should be
     105             :   unsigned getNumberOfAtoms() const ;
     106             : };
     107             : 
     108             : inline
     109      386216 : const std::vector<double> & ReferenceAtoms::getAlign() const {
     110      386216 :   return align;
     111             : }
     112             : 
     113             : inline
     114      384223 : const std::vector<double> & ReferenceAtoms::getDisplace() const {
     115      384223 :   return displace;
     116             : }
     117             : 
     118             : inline
     119      113049 : unsigned ReferenceAtoms::getNumberOfReferencePositions() const {
     120             :   plumed_dbg_assert( atom_der_index.size()==reference_atoms.size() );
     121      113049 :   return reference_atoms.size();
     122             : }
     123             : 
     124             : inline
     125      423959 : unsigned ReferenceAtoms::getNumberOfAtoms() const {
     126      423959 :   return reference_atoms.size();
     127             : }
     128             : 
     129             : inline
     130    17683618 : unsigned ReferenceAtoms::getAtomIndex( const unsigned& iatom ) const {
     131             :   plumed_dbg_assert( iatom<atom_der_index.size() );
     132             :   plumed_dbg_assert( atom_der_index[iatom]<reference_atoms.size() );
     133    17683618 :   return atom_der_index[iatom];
     134             : }
     135             : 
     136             : inline
     137       38726 : Vector ReferenceAtoms::getReferencePosition( const unsigned& iatom ) const {
     138             :   plumed_dbg_assert( iatom<reference_atoms.size() );
     139       38726 :   return reference_atoms[iatom];
     140             : }
     141             : 
     142             : inline
     143     2608963 : const std::vector<Vector> & ReferenceAtoms::getReferencePositions() const {
     144     2608963 :   return reference_atoms;
     145             : }
     146             : 
     147             : // inline
     148             : // void ReferenceAtoms::addAtomicDerivatives( const unsigned& iatom, const Vector& der ){
     149             : //   atom_ders[ getAtomIndex(iatom) ]+=der;
     150             : // }
     151             : 
     152             : // inline
     153             : // Vector ReferenceAtoms::retrieveAtomicDerivatives( const unsigned& iatom ) const {
     154             : //   return atom_ders[ getAtomIndex(iatom) ];
     155             : // }
     156             : 
     157             : // inline
     158             : // void ReferenceAtoms::addBoxDerivatives( const Tensor& vir ){
     159             : //   virialWasSet=true; virial+=vir;
     160             : // }
     161             : 
     162             : inline
     163           0 : const std::vector<AtomNumber>& ReferenceAtoms::getAbsoluteIndexes() {
     164           0 :   return indices;
     165             : }
     166             : 
     167             : 
     168             : }
     169             : #endif
     170             : 

Generated by: LCOV version 1.13