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 :
23 : #include "Between.h"
24 : #include "VesselRegister.h"
25 :
26 : namespace PLMD {
27 : namespace vesselbase {
28 :
29 2585 : PLUMED_REGISTER_VESSEL(Between,"BETWEEN")
30 :
31 62 : void Between::registerKeywords( Keywords& keys ) {
32 62 : FunctionVessel::registerKeywords( keys );
33 62 : HistogramBead::registerKeywords( keys );
34 62 : keys.addFlag("NORM",false,"calculate the fraction of values rather than the number");
35 62 : }
36 :
37 841 : void Between::reserveKeyword( Keywords& keys ) {
38 : 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 841 : "\\ref histogrambead.");
41 : 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 841 : "You can calculate this quantity multiple times using different parameters.");
44 841 : }
45 :
46 62 : Between::Between( const VesselOptions& da ) :
47 62 : FunctionVessel(da)
48 : {
49 62 : usetol=true;
50 62 : bool isPeriodic=getAction()->isPeriodic();
51 124 : double min, max; std::string str_min, str_max;
52 62 : if( isPeriodic ) {
53 0 : getAction()->retrieveDomain( str_min, str_max );
54 0 : Tools::convert(str_min,min); Tools::convert(str_max,max);
55 : }
56 :
57 124 : parseFlag("NORM",norm); std::string errormsg;
58 :
59 62 : hist.set( getAllInput(),errormsg );
60 62 : if( !isPeriodic ) hist.isNotPeriodic();
61 0 : else hist.isPeriodic( min, max );
62 124 : if( errormsg.size()!=0 ) error( errormsg );
63 62 : }
64 :
65 62 : std::string Between::value_descriptor() {
66 62 : if(norm) return "the fraction of values " + hist.description();
67 61 : return "the number of values " + hist.description();
68 : }
69 :
70 8173 : double Between::calcTransform( const double& val, double& dv ) const {
71 8173 : 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 2523 : }
|