LCOV - code coverage report
Current view: top level - reference - ReferenceArguments.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 7 9 77.8 %
Date: 2020-11-18 11:20:57 Functions: 6 7 85.7 %

          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             : #ifndef __PLUMED_reference_ReferenceArguments_h
      23             : #define __PLUMED_reference_ReferenceArguments_h
      24             : 
      25             : #include "ReferenceConfiguration.h"
      26             : #include "tools/Matrix.h"
      27             : 
      28             : namespace PLMD {
      29             : 
      30             : /// \ingroup TOOLBOX
      31             : /// In many applications (e.g. paths, fields, property maps) it is necessary to calculate
      32             : /// the distance between two configurations.  These distances can be calculated in a variety of
      33             : /// different ways.  For instance, one can assert that the distance between the two configuration
      34             : /// is the distance one would have to move all the atoms to transform configuration 1 into configuration
      35             : /// 2. Alternatively, one could calculate the values of a large set of collective coordinates in the two
      36             : /// configurations and then calculate the Euclidean distances between these two points in the resulting
      37             : /// high-dimensional vector space.  Lastly, one can combine these two forms of distance calculation to calculate
      38             : /// a hybrid distance.  Plumed allows one to use all these forms of distance calculations and also to implement
      39             : /// new forms of distance.  You should inherit from this class if your distance involves reference colvar values.
      40             : /// This class and \ref PLMD::ReferenceAtoms mirror the functionalities in \ref PLMD::ActionWithArguments and
      41             : /// \ref PLMD::ActionAtomistic respectively but for distances.
      42             : 
      43        5831 : class ReferenceArguments :
      44             :   virtual public ReferenceConfiguration
      45             : {
      46             :   friend class Direction;
      47             :   friend class ReferenceConfiguration;
      48             : private:
      49             : /// The weights for normed euclidean distance
      50             :   std::vector<double> weights, sqrtweight;
      51             : /// The N X N matrix we are using to calculate our Malanobius distance
      52             :   Matrix<double> metric;
      53             :   std::vector<double> trig_metric;
      54             : /// The values of the colvars in the reference configuration
      55             :   std::vector<double> reference_args;
      56             : /// The names of the arguments
      57             :   std::vector<std::string> arg_names;
      58             : /// The indices for setting derivatives
      59             :   std::vector<unsigned> arg_der_index;
      60             : protected:
      61             : /// Are we reading weights from input
      62             :   bool hasweights;
      63             : /// Are we calculating a Malanobius distance
      64             :   bool hasmetric;
      65             : /// Read in the atoms from the pdb file
      66             :   void readArgumentsFromPDB( const PDB& pdb );
      67             : /// Set the values of the colvars based on their current instantanous values (used in Analysis)
      68             :   void setReferenceArguments();
      69             : public:
      70             :   explicit ReferenceArguments( const ReferenceConfigurationOptions& ro );
      71             : /// Get the number of reference arguments
      72             :   unsigned getNumberOfReferenceArguments() const ;
      73             : /// Get the arguments required
      74             :   void getArgumentRequests( std::vector<std::string>&, bool disable_checks=false );
      75             : /// Set the names of the arguments
      76             :   void setArgumentNames( const std::vector<std::string>& arg_vals );
      77             : /// Set the positions of the refernce arguments
      78             :   void setReferenceArguments( const std::vector<double>& arg_vals, const std::vector<double>& sigma );
      79             : /// Set the positions of the reference arguments
      80             :   void moveReferenceArguments( const std::vector<double>& arg_vals );
      81             : /// Get the value of the ith reference argument
      82             :   double getReferenceArgument( const unsigned& i ) const ;
      83             : /// Print the arguments out
      84             :   void printArguments( OFile& ofile, const std::string& fmt ) const ;
      85             : /// Return all the reference arguments
      86             :   const std::vector<double>& getReferenceArguments() const ;
      87             :   const std::vector<double>& getReferenceMetric();
      88             : /// Return names
      89             :   const std::vector<std::string>& getArgumentNames();
      90             : /// Calculate the euclidean/malanobius distance the atoms have moved from the reference
      91             : /// configuration in CV space
      92             :   virtual double calculateArgumentDistance( const std::vector<Value*> & vals, const std::vector<double>& arg, ReferenceValuePack& myder, const bool& squared ) const ;
      93             : /// Displace the positions of the reference atoms
      94             :   void displaceReferenceArguments( const double& weight, const std::vector<double>& displace );
      95             : /// Extract the displacement from a position in a space
      96             :   virtual void extractArgumentDisplacement( const std::vector<Value*>& vals, const std::vector<double>& arg, std::vector<double>& dirout ) const ;
      97             : /// Project the displacement of the arguments on a vector
      98             :   double projectArgDisplacementOnVector( const std::vector<double>& eigv, const std::vector<Value*>& vals, const std::vector<double>& arg, ReferenceValuePack& mypack ) const ;
      99             : };
     100             : 
     101             : inline
     102           0 : double ReferenceArguments::getReferenceArgument( const unsigned& i ) const {
     103             :   plumed_dbg_assert( i<reference_args.size() );
     104           0 :   return reference_args[i];
     105             : }
     106             : 
     107             : inline
     108       40775 : const std::vector<double>& ReferenceArguments::getReferenceArguments() const {
     109       40775 :   return reference_args;
     110             : }
     111             : 
     112             : inline
     113         345 : const std::vector<std::string>& ReferenceArguments::getArgumentNames() {
     114         345 :   return arg_names;
     115             : }
     116             : 
     117             : inline
     118       34884 : unsigned ReferenceArguments::getNumberOfReferenceArguments() const {
     119       34884 :   return reference_args.size();
     120             : }
     121             : 
     122             : }
     123             : #endif
     124             : 

Generated by: LCOV version 1.13