LCOV - code coverage report
Current view: top level - reference - PointWiseMapping.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 20 20 100.0 %
Date: 2018-12-19 07:49:13 Functions: 10 10 100.0 %

          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_PointWiseMapping_h
      23             : #define __PLUMED_reference_PointWiseMapping_h
      24             : 
      25             : #include "MultiReferenceBase.h"
      26             : 
      27             : namespace PLMD {
      28             : 
      29          16 : class PointWiseMapping : public MultiReferenceBase {
      30             : private:
      31             : /// This is a path
      32             :   bool ispath;
      33             : /// The matrix of interframe distances
      34             :   Matrix<double> dmat;
      35             : /// The names of the projection coordinates
      36             :   std::vector<std::string> property;
      37             : /// These are where the reference configurations should be projected
      38             :   std::vector< std::vector<double> > low_dim;
      39             : public:
      40             :   PointWiseMapping( const std::string& type, const bool& checksoff );
      41             : /// Set the names of the low dimensional properties
      42             :   void setPropertyNames( const std::vector<std::string>& prop, const bool isp );
      43             : /// Check if setup was completed
      44             :   bool mappingNeedsSetup() const;
      45             : /// Delete the low dimensional projections
      46             :   void clearRestOfData();
      47             : /// Read in the data from a file
      48             :   void readRestOfFrame();
      49             : /// Resize everything else from a file
      50             :   void resizeRestOfFrame();
      51             : /// Make a second copy of the frame list
      52             :   void duplicateFrameList();
      53             : /// Get the number of points we are mapping into the lower dimensional space
      54             :   unsigned getNumberOfMappedPoints() const ;
      55             : /// Get the number of properties
      56             :   unsigned getNumberOfProperties() const ;
      57             : /// Get the name of the ith property
      58             :   std::string getPropertyName( const unsigned& i ) const ;
      59             : /// Get the index of the property with name
      60             :   unsigned getPropertyIndex( const std::string& name ) const ;
      61             : /// Get the value of the ith property for th jth frame
      62             :   double getPropertyValue( const unsigned& iframe, const unsigned& jprop ) const ;
      63             : /// Get the derivatives wrt to the position of an atom
      64             : //  Vector getAtomDerivatives( const unsigned& iframe, const unsigned& jatom );
      65             : /// Get the derivatives wrt to the box
      66             : //  bool getVirial( const unsigned& iframe, Tensor& vir );
      67             : /// Ge the derivatives wrt to one of the arguments
      68             : //  double getArgumentDerivative( const unsigned& iframe, const unsigned& jarg );
      69             : /// Copy derivative information from frame number from to frame number to
      70             :   void copyFrameDerivatives( const unsigned& from, const unsigned& to );
      71             : /// Get a pointer to the matrix of pairwise distances
      72             :   Matrix<double>& modifyDmat();
      73             : /// Print out the low dimensional mapping
      74             :   void print( const std::string& method, const double & time, OFile& afile,
      75             :               const std::string& fmt, const double& lunits );
      76             : /// Get the low dimensional embedding coordinate
      77             :   double getProjectionCoordinate( const unsigned& iframe, const unsigned& jcoord ) const ;
      78             : /// Set the value of the projection coordinate
      79             :   void setProjectionCoordinate( const unsigned& iframe, const unsigned& jcoord, const double& coord );
      80             : };
      81             : 
      82             : inline
      83           7 : bool PointWiseMapping::mappingNeedsSetup() const {
      84           7 :   bool didsetup=(frames.size()==2*low_dim.size());
      85           7 :   return !didsetup;
      86             : }
      87             : 
      88             : inline
      89             : void PointWiseMapping::copyFrameDerivatives( const unsigned& from, const unsigned& to ) {
      90             :   plumed_dbg_assert( to>=frames.size()/2 && from<frames.size()/2 );
      91             :   frames[to]->copyDerivatives( frames[from] );
      92             : }
      93             : 
      94             : inline
      95         301 : unsigned PointWiseMapping::getNumberOfMappedPoints() const {
      96         301 :   return low_dim.size();
      97             : }
      98             : 
      99             : inline
     100         613 : unsigned PointWiseMapping::getNumberOfProperties() const {
     101         613 :   return property.size();
     102             : }
     103             : 
     104             : inline
     105           6 : std::string PointWiseMapping::getPropertyName( const unsigned& i ) const {
     106             :   plumed_dbg_assert( i<property.size() );
     107           6 :   return property[i];
     108             : }
     109             : 
     110             : inline
     111       27071 : double PointWiseMapping::getPropertyValue( const unsigned& iframe, const unsigned& jprop ) const {
     112             :   plumed_dbg_assert( iframe<low_dim.size() && jprop<property.size() );
     113       27071 :   return low_dim[iframe][jprop];
     114             : }
     115             : 
     116             : // inline
     117             : // Vector PointWiseMapping::getAtomDerivatives( const unsigned& iframe, const unsigned& jatom ){
     118             : //   return frames[iframe]->getAtomDerivative(jatom);
     119             : // }
     120             : //
     121             : // inline
     122             : // bool PointWiseMapping::getVirial( const unsigned& iframe, Tensor& vir ){
     123             : //   return frames[iframe]->getVirial( vir );
     124             : // }
     125             : 
     126             : // inline
     127             : // double PointWiseMapping::getArgumentDerivative( const unsigned& iframe, const unsigned& jarg ){
     128             : //   return frames[iframe]->getArgumentDerivative(jarg);
     129             : // }
     130             : 
     131             : inline
     132           4 : Matrix<double>& PointWiseMapping::modifyDmat() {
     133           4 :   if( dmat.nrows()!=frames.size() || dmat.ncols()!=frames.size() ) dmat.resize( frames.size(), frames.size() );
     134           4 :   return dmat;
     135             : }
     136             : 
     137             : inline
     138         400 : double PointWiseMapping::getProjectionCoordinate( const unsigned& iframe, const unsigned& jcoord ) const {
     139             :   plumed_dbg_assert( iframe<frames.size() && jcoord<property.size() );
     140         400 :   return low_dim[iframe][jcoord];
     141             : }
     142             : 
     143             : inline
     144         400 : void PointWiseMapping::setProjectionCoordinate( const unsigned& iframe, const unsigned& jcoord, const double& coord ) {
     145             :   plumed_dbg_assert( iframe<frames.size() && jcoord<property.size() );
     146         400 :   low_dim[iframe][jcoord]=coord;
     147         400 : }
     148             : 
     149             : }
     150             : #endif

Generated by: LCOV version 1.13