LCOV - code coverage report
Current view: top level - vesselbase - Between.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 31 31 100.0 %
Date: 2020-11-18 11:20:57 Functions: 11 11 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2013-2019 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        6515 : PLUMED_REGISTER_VESSEL(Between,"BETWEEN")
      30             : 
      31          63 : void Between::registerKeywords( Keywords& keys ) {
      32          63 :   FunctionVessel::registerKeywords( keys );
      33          63 :   HistogramBead::registerKeywords( keys );
      34         189 :   keys.addFlag("NORM",false,"calculate the fraction of values rather than the number");
      35          63 : }
      36             : 
      37        1613 : void Between::reserveKeyword( Keywords& keys ) {
      38        6452 :   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        6452 :   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        1613 : }
      45             : 
      46          63 : Between::Between( const VesselOptions& da ) :
      47          63 :   FunctionVessel(da)
      48             : {
      49          63 :   usetol=true;
      50          63 :   bool isPeriodic=getAction()->isPeriodic();
      51             :   double min, max; std::string str_min, str_max;
      52          63 :   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         126 :   parseFlag("NORM",norm); std::string errormsg;
      58             : 
      59         126 :   hist.set( getAllInput(),errormsg );
      60          63 :   if( !isPeriodic ) hist.isNotPeriodic();
      61           1 :   else hist.isPeriodic( min, max );
      62          63 :   if( errormsg.size()!=0 ) error( errormsg );
      63          63 : }
      64             : 
      65          63 : std::string Between::value_descriptor() {
      66          64 :   if(norm) return "the fraction of values " + hist.description();
      67         124 :   return "the number of values " + hist.description();
      68             : }
      69             : 
      70        8188 : double Between::calcTransform( const double& val, double& dv ) const {
      71        8188 :   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        4839 : }

Generated by: LCOV version 1.13