LCOV - code coverage report
Current view: top level - reference - ReferenceConfiguration.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 15 20 75.0 %
Date: 2024-10-11 08:09:47 Functions: 8 12 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2023 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_ReferenceConfiguration_h
      23             : #define __PLUMED_reference_ReferenceConfiguration_h
      24             : 
      25             : #include <vector>
      26             : #include <string>
      27             : #include "tools/Vector.h"
      28             : #include "tools/Tensor.h"
      29             : #include "tools/Tools.h"
      30             : #include "tools/Exception.h"
      31             : #include "ReferenceValuePack.h"
      32             : #include "tools/Matrix.h"
      33             : 
      34             : namespace PLMD {
      35             : 
      36             : class Value;
      37             : class Pbc;
      38             : class OFile;
      39             : class PDB;
      40             : class GenericMolInfo;
      41             : 
      42             : /// \ingroup TOOLBOX
      43             : /// Abstract base class for calculating the distance from a reference configuration.
      44             : /// A reference configuration can either have a particular set of atoms in a particular
      45             : /// given configuration or it can be that a particular set of colvars have a particular
      46             : /// set of values.  It could also be a combination of both.  To allow all the posible
      47             : /// permutations and in order make it easy to add new ways of calculating the distance
      48             : /// we have implemented this using polymorphism and multiple inheritance.
      49             : 
      50             : class Direction;
      51             : 
      52      519082 : class ReferenceConfigurationOptions {
      53             :   friend class ReferenceConfiguration;
      54             : private:
      55             :   std::string tt;
      56             : public:
      57             :   explicit ReferenceConfigurationOptions( const std::string& type );
      58             :   bool usingFastOption() const ;
      59             :   std::string getMultiRMSDType() const ;
      60             : };
      61             : 
      62             : /// \ingroup INHERIT
      63             : /// Abstract base class for calculating the distance from a reference configuration.
      64             : /// A reference configuration can either have a particular set of atoms in a particular
      65             : /// given configuration or it can be that a particular set of colvars have a particular
      66             : /// set of values.  It could also be a combination of both.  To allow all the posible
      67             : /// permutations and in order make it easy to add new ways of calculating the distance
      68             : /// we have implemented this using polymorphism and multiple inheritance.  The following
      69             : /// provides \ref AddingAMetric "information" on how to implement a new method for
      70             : /// calculating the distance between a pair of configurations
      71             : 
      72             : class ReferenceConfiguration {
      73             :   friend class SingleDomainRMSD;
      74             :   friend double distance( const Pbc& pbc, const std::vector<Value*> & vals, ReferenceConfiguration*, ReferenceConfiguration*, const bool& squared );
      75             : private:
      76             : /// The name of this particular config
      77             :   std::string name;
      78             : /// A vector containing all the remarks from the pdb input
      79             :   std::vector<std::string> line;
      80             : /// These are used to do fake things when we copy frames
      81             :   std::vector<AtomNumber> fake_atom_numbers;
      82             :   std::vector<std::string> fake_arg_names;
      83             : /// These are use by the distance function above
      84             :   std::vector<Vector> fake_refatoms;
      85             :   std::vector<double> fake_refargs;
      86             :   std::vector<double> fake_metric;
      87             : protected:
      88             : /// Crash with an error
      89             :   [[noreturn]] void error(const std::string& msg);
      90             : public:
      91             :   explicit ReferenceConfiguration( const ReferenceConfigurationOptions& ro );
      92             : /// Destructor
      93             :   virtual ~ReferenceConfiguration();
      94             : /// Return the name of this metric
      95             :   std::string getName() const ;
      96             : ///
      97             :   virtual unsigned getNumberOfReferencePositions() const ;
      98             :   virtual unsigned getNumberOfReferenceArguments() const ;
      99             : /// Retrieve the atoms that are required for this guy
     100         177 :   virtual void getAtomRequests( std::vector<AtomNumber>&, bool disable_checks=false ) {}
     101             : /// Retrieve the arguments that are required for this guy
     102         354 :   virtual void getArgumentRequests( std::vector<std::string>&, bool disable_checks=false ) {}
     103             : /// Do all local business for setting the configuration
     104             :   virtual void read( const PDB& )=0;
     105             : /// Calculate the distance from the reference configuration
     106             :   double calculate( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, ReferenceValuePack& myder, const bool& squared=false ) const ;
     107             : /// Calculate the distance from the reference configuration
     108             :   virtual double calc( const std::vector<Vector>& pos, const Pbc& pbc, const std::vector<Value*>& vals, const std::vector<double>& args,
     109             :                        ReferenceValuePack& myder, const bool& squared ) const=0;
     110             : /// Parse something from the pdb remarks
     111             : /// Copy derivatives from one frame to this frame
     112             :   void copyDerivatives( const ReferenceConfiguration* );
     113             : /// Get one of the referene arguments
     114           0 :   virtual double getReferenceArgument( const unsigned& i ) const { plumed_error(); }
     115             : /// These are overwritten in ReferenceArguments and ReferenceAtoms but are required here
     116             : /// to make PLMD::distance work
     117             :   virtual const std::vector<Vector>& getReferencePositions() const ;
     118             :   virtual const std::vector<double>& getReferenceArguments() const ;
     119             :   virtual const std::vector<double>& getReferenceMetric();
     120             : /// These are overwritten in ReferenceArguments and ReferenceAtoms to make frame copying work
     121             :   virtual const std::vector<AtomNumber>& getAbsoluteIndexes();
     122             :   virtual const std::vector<std::string>& getArgumentNames();
     123             : /// Extract a Direction giving you the displacement from some position
     124             :   void extractDisplacementVector( const std::vector<Vector>& pos, const std::vector<Value*>& vals,
     125             :                                   const std::vector<double>& arg, const bool& nflag,
     126             :                                   Direction& mydir ) const ;
     127             : /// Stuff for pca
     128           0 :   virtual bool pcaIsEnabledForThisReference() { return false; }
     129             :   double projectDisplacementOnVector( const Direction& mydir, const std::vector<Value*>& vals,
     130             :                                       const std::vector<double>& arg, ReferenceValuePack& mypack ) const ;
     131             : /// Stuff to setup pca
     132           0 :   virtual void setupPCAStorage( ReferenceValuePack& mypack ) { plumed_error(); }
     133             : /// Move the reference configuration by an amount specified using a Direction
     134             :   void displaceReferenceConfiguration( const double& weight, Direction& dir );
     135             : };
     136             : 
     137             : inline
     138      781533 : const std::vector<Vector>& ReferenceConfiguration::getReferencePositions() const {
     139      781533 :   return fake_refatoms;
     140             : }
     141             : 
     142             : inline
     143        2281 : const std::vector<double>& ReferenceConfiguration::getReferenceArguments() const {
     144        2281 :   return fake_refargs;
     145             : }
     146             : 
     147             : inline
     148           0 : const std::vector<double>& ReferenceConfiguration::getReferenceMetric() {
     149           0 :   return fake_metric;
     150             : }
     151             : 
     152             : inline
     153           8 : const std::vector<AtomNumber>& ReferenceConfiguration::getAbsoluteIndexes() {
     154           8 :   return fake_atom_numbers;
     155             : }
     156             : 
     157             : inline
     158           2 : const std::vector<std::string>& ReferenceConfiguration::getArgumentNames() {
     159           2 :   return fake_arg_names;
     160             : }
     161             : 
     162             : inline
     163       35978 : unsigned ReferenceConfiguration::getNumberOfReferencePositions() const {
     164       35978 :   return 0;
     165             : }
     166             : 
     167             : inline
     168      138192 : unsigned ReferenceConfiguration::getNumberOfReferenceArguments() const {
     169      138192 :   return 0;
     170             : }
     171             : 
     172             : }
     173             : #endif

Generated by: LCOV version 1.15