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 : 23 : #include "Between.h" 24 : #include "VesselRegister.h" 25 : 26 : namespace PLMD { 27 : namespace vesselbase { 28 : 29 10484 : PLUMED_REGISTER_VESSEL(Between,"BETWEEN") 30 : 31 65 : void Between::registerKeywords( Keywords& keys ) { 32 65 : FunctionVessel::registerKeywords( keys ); 33 65 : HistogramBead::registerKeywords( keys ); 34 130 : keys.addFlag("NORM",false,"calculate the fraction of values rather than the number"); 35 65 : } 36 : 37 3473 : void Between::reserveKeyword( Keywords& keys ) { 38 6946 : keys.reserve("vessel","BETWEEN","calculate the number of values that are within a certain range. " 39 : "These quantities are calculated using kernel density estimation as described on " 40 : "\\ref histogrambead."); 41 6946 : keys.addOutputComponent("between","BETWEEN","the number/fraction of values within a certain range. This is calculated using one of the " 42 : "formula described in the description of the keyword so as to make it continuous. " 43 : "You can calculate this quantity multiple times using different parameters."); 44 3473 : } 45 : 46 65 : Between::Between( const VesselOptions& da ) : 47 65 : FunctionVessel(da) 48 : { 49 65 : usetol=true; 50 65 : bool isPeriodic=getAction()->isPeriodic(); 51 : double min, max; std::string str_min, str_max; 52 65 : if( isPeriodic ) { 53 1 : getAction()->retrieveDomain( str_min, str_max ); 54 1 : Tools::convert(str_min,min); Tools::convert(str_max,max); 55 : } 56 : 57 130 : parseFlag("NORM",norm); std::string errormsg; 58 : 59 65 : hist.set( getAllInput(),errormsg ); 60 65 : if( !isPeriodic ) hist.isNotPeriodic(); 61 1 : else hist.isPeriodic( min, max ); 62 65 : if( errormsg.size()!=0 ) error( errormsg ); 63 65 : } 64 : 65 65 : std::string Between::value_descriptor() { 66 66 : if(norm) return "the fraction of values " + hist.description(); 67 128 : return "the number of values " + hist.description(); 68 : } 69 : 70 8224 : double Between::calcTransform( const double& val, double& dv ) const { 71 8224 : double f = hist.calculate(val, dv); return f; 72 : } 73 : 74 60 : double Between::getCutoff() { 75 60 : return std::numeric_limits<double>::max(); 76 : } 77 : 78 : } 79 : }