LCOV - code coverage report
Current view: top level - analysis - ReadAnalysisFrames.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 9 13 69.2 %
Date: 2024-10-11 08:09:47 Functions: 4 7 57.1 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2015-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_analysis_ReadAnalysisFrames_h
      23             : #define __PLUMED_analysis_ReadAnalysisFrames_h
      24             : 
      25             : #include "AnalysisBase.h"
      26             : #include "bias/ReweightBase.h"
      27             : 
      28             : namespace PLMD {
      29             : namespace analysis {
      30             : 
      31             : class ReadAnalysisFrames : public AnalysisBase {
      32             : private:
      33             : /// The frequency with which to clear the data stash
      34             :   unsigned clearstride;
      35             :   bool clearonnextstep;
      36             : /// The list of argument names that we are storing
      37             :   std::vector<std::string> argument_names;
      38             : /// The list of atom numbers that we are storing
      39             :   std::vector<AtomNumber> atom_numbers;
      40             : /// The biases we are using in reweighting and the args we store them separately
      41             :   std::vector<Value*> weight_vals;
      42             : /// The object that calculates weights using WHAM
      43             :   bias::ReweightBase* wham_pointer;
      44             : /// The weights of all the data points
      45             :   bool weights_calculated;
      46             :   std::vector<double> logweights, weights;
      47             : /// The data that has been collected from the trajectory
      48             :   std::vector<DataCollectionObject> my_data_stash;
      49             : /// Calculate the weights of the various points from the logweights
      50             :   void calculateWeights();
      51             : public:
      52             :   static void registerKeywords( Keywords& keys );
      53             :   explicit ReadAnalysisFrames( const ActionOptions& ao );
      54             :   void update() override;
      55             : /// This does nothing
      56           0 :   void performAnalysis() override {}
      57             : /// This does nothing - it just ensures the final class is not abstract
      58           0 :   void performTask( const unsigned&, const unsigned&, MultiValue& ) const override { plumed_error(); }
      59             : /// Get the number of data points
      60             :   unsigned getNumberOfDataPoints() const override;
      61             : /// Get the index of the data point
      62             :   unsigned getDataPointIndexInBase( const unsigned& idata ) const override;
      63             : /// Get the input arguments
      64             :   std::vector<Value*> getArgumentList() override;
      65             : /// Have dissimilarities between thses objects been calculated
      66             :   bool dissimilaritiesWereSet() const override;
      67             : /// How are dissimilarities calcualted is not known
      68             :   std::string getDissimilarityInstruction() const override;
      69             : /// Get the weight of one of the objects
      70             :   double getWeight( const unsigned& idat ) override;
      71             : /// Get the reference configuration
      72             :   DataCollectionObject & getStoredData( const unsigned& idata, const bool& calcdist ) override;
      73             : /// Get the list of atoms that are being stored
      74             :   const std::vector<AtomNumber>& getAtomIndexes() const override;
      75             : };
      76             : 
      77             : inline
      78       37013 : unsigned ReadAnalysisFrames::getNumberOfDataPoints() const {
      79       37013 :   return my_data_stash.size();
      80             : }
      81             : 
      82             : inline
      83      125002 : unsigned ReadAnalysisFrames::getDataPointIndexInBase( const unsigned& idata ) const {
      84      125002 :   return idata;
      85             : }
      86             : 
      87             : inline
      88           0 : bool ReadAnalysisFrames::dissimilaritiesWereSet() const {
      89           0 :   return false;
      90             : }
      91             : 
      92             : inline
      93     7777606 : double ReadAnalysisFrames::getWeight( const unsigned& idat ) {
      94     7777606 :   if( !weights_calculated ) calculateWeights();
      95     7777606 :   return weights[idat];
      96             : }
      97             : 
      98             : inline
      99      522672 : DataCollectionObject & ReadAnalysisFrames::getStoredData( const unsigned& idata, const bool& calcdist ) {
     100             :   plumed_dbg_assert( idata<my_data_stash.size() );
     101      522672 :   return my_data_stash[idata];
     102             : }
     103             : 
     104             : }
     105             : }
     106             : #endif

Generated by: LCOV version 1.15