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 { 59 0 : plumed_error(); 60 : } 61 : /// Get the number of data points 62 : unsigned getNumberOfDataPoints() const override; 63 : /// Get the index of the data point 64 : unsigned getDataPointIndexInBase( const unsigned& idata ) const override; 65 : /// Get the input arguments 66 : std::vector<Value*> getArgumentList() override; 67 : /// Have dissimilarities between thses objects been calculated 68 : bool dissimilaritiesWereSet() const override; 69 : /// How are dissimilarities calcualted is not known 70 : std::string getDissimilarityInstruction() const override; 71 : /// Get the weight of one of the objects 72 : double getWeight( const unsigned& idat ) override; 73 : /// Get the reference configuration 74 : DataCollectionObject & getStoredData( const unsigned& idata, const bool& calcdist ) override; 75 : /// Get the list of atoms that are being stored 76 : const std::vector<AtomNumber>& getAtomIndexes() const override; 77 : }; 78 : 79 : inline 80 37013 : unsigned ReadAnalysisFrames::getNumberOfDataPoints() const { 81 37013 : return my_data_stash.size(); 82 : } 83 : 84 : inline 85 125002 : unsigned ReadAnalysisFrames::getDataPointIndexInBase( const unsigned& idata ) const { 86 125002 : return idata; 87 : } 88 : 89 : inline 90 0 : bool ReadAnalysisFrames::dissimilaritiesWereSet() const { 91 0 : return false; 92 : } 93 : 94 : inline 95 7777606 : double ReadAnalysisFrames::getWeight( const unsigned& idat ) { 96 7777606 : if( !weights_calculated ) { 97 26 : calculateWeights(); 98 : } 99 7777606 : return weights[idat]; 100 : } 101 : 102 : inline 103 522672 : DataCollectionObject & ReadAnalysisFrames::getStoredData( const unsigned& idata, const bool& calcdist ) { 104 : plumed_dbg_assert( idata<my_data_stash.size() ); 105 522672 : return my_data_stash[idata]; 106 : } 107 : 108 : } 109 : } 110 : #endif