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 : #include "tools/HistogramBead.h" 23 : #include "VesselRegister.h" 24 : #include "ShortcutVessel.h" 25 : 26 : namespace PLMD { 27 : namespace vesselbase { 28 : 29 : class Histogram : public ShortcutVessel { 30 : public: 31 : static void registerKeywords( Keywords& keys ); 32 : static void reserveKeyword( Keywords& keys ); 33 : explicit Histogram( const VesselOptions& da ); 34 : }; 35 : 36 10430 : PLUMED_REGISTER_VESSEL(Histogram,"HISTOGRAM") 37 : 38 11 : void Histogram::registerKeywords( Keywords& keys ) { 39 11 : ShortcutVessel::registerKeywords( keys ); 40 11 : HistogramBead::registerKeywords( keys ); 41 22 : keys.add("compulsory","NBINS","The number of equal width bins you want to divide the range into"); 42 22 : keys.addFlag("NORM",false,"calculate the fraction of values rather than the number"); 43 22 : keys.add("compulsory","COMPONENT","1","the component of the vector for which to calculate this quantity"); 44 11 : } 45 : 46 3473 : void Histogram::reserveKeyword( Keywords& keys ) { 47 6946 : keys.reserve("vessel","HISTOGRAM","calculate how many of the values fall in each of the bins of a histogram. " 48 : "This shortcut allows you to calculates NBIN quantities like BETWEEN."); 49 3473 : } 50 : 51 11 : Histogram::Histogram( const VesselOptions& da ): 52 11 : ShortcutVessel(da) 53 : { 54 22 : bool norm; parseFlag("NORM",norm); std::string normstr=""; 55 11 : if(norm) normstr=" NORM"; 56 11 : std::string compstr; parse("COMPONENT",compstr); 57 22 : normstr+=" COMPONENT=" + compstr; 58 11 : std::vector<std::string> bins; HistogramBead::generateBins( getAllInput(), bins ); 59 75 : for(unsigned i=0; i<bins.size(); ++i) addVessel("BETWEEN",bins[i] + normstr); 60 22 : } 61 : 62 : } 63 : }