All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HistogramBead.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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_tools_HistogramBead_h
23 #define __PLUMED_tools_HistogramBead_h
24 
25 #include <cmath>
26 #include <string>
27 #include <vector>
28 #include "Exception.h"
29 #include "Tools.h"
30 
31 namespace PLMD {
32 
33 class Keywords;
34 class Log;
35 
36 /**
37 \ingroup TOOLBOX
38 A class for calculating whether or not values are within a given range using : \f$ \sum_i \int_a^b G( s_i, \sigma*(b-a) ) \f$
39 */
40 
42 private:
43  bool init;
44  double lowb;
45  double highb;
46  double width;
50  double difference( const double& d1, const double& d2 ) const ;
51 public:
52  static void registerKeywords( Keywords& keys );
53  static void generateBins( const std::string& params, const std::string& dd, std::vector<std::string>& bins );
54  HistogramBead();
55  std::string description() const ;
56  bool hasBeenSet() const;
57  void isNotPeriodic();
58  void isPeriodic( const double& mlow, const double& mhigh );
59  void setKernelType( const std::string& ktype );
60  void set(const std::string& params, const std::string& dd, std::string& errormsg);
61  void set(double l, double h, double w);
62  double calculate(double x, double&df) const;
63  double getlowb() const ;
64  double getbigb() const ;
65 };
66 
67 inline
69  return init;
70 }
71 
72 inline
75 }
76 
77 inline
78 void HistogramBead::isPeriodic( const double& mlow, const double& mhigh ){
79  periodicity=periodic; min=mlow; max=mhigh;
81  plumed_massert(max_minus_min>0, "your function has a very strange domain?");
83 }
84 
85 inline
86 double HistogramBead::getlowb() const { return lowb; }
87 
88 inline
89 double HistogramBead::getbigb() const { return highb; }
90 
91 inline
92 double HistogramBead::difference( const double& d1, const double& d2 ) const {
94  return d2-d1;
95  } else if(periodicity==periodic){
96  // Make sure the point is in the target range
97  double newx=d1*inv_max_minus_min;
98  newx=Tools::pbc(newx);
99  newx*=max_minus_min;
100  return d2-newx;
101  } else plumed_merror("periodicty was not set");
102  return 0;
103 }
104 
105 }
106 
107 #endif
double getbigb() const
Definition: HistogramBead.h:89
void setKernelType(const std::string &ktype)
enum PLMD::HistogramBead::@3 periodicity
static void registerKeywords(Keywords &keys)
static double pbc(double)
Apply pbc for a unitary cell.
Definition: Tools.h:170
static void generateBins(const std::string &params, const std::string &dd, std::vector< std::string > &bins)
void isPeriodic(const double &mlow, const double &mhigh)
Definition: HistogramBead.h:78
double getlowb() const
Definition: HistogramBead.h:86
This class holds the keywords and their documentation.
Definition: Keywords.h:36
A class for calculating whether or not values are within a given range using : .
Definition: HistogramBead.h:41
std::string description() const
void const char const char int double int double double int int double int double * w
Definition: Matrix.h:42
enum PLMD::HistogramBead::@2 type
void set(const std::string &params, const std::string &dd, std::string &errormsg)
bool hasBeenSet() const
Definition: HistogramBead.h:68
double calculate(double x, double &df) const
double difference(const double &d1, const double &d2) const
Definition: HistogramBead.h:92