LCOV - code coverage report
Current view: top level - vesselbase - LessThan.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 24 26 92.3 %
Date: 2026-03-30 13:16:06 Functions: 9 9 100.0 %

          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 "LessThan.h"
      23             : #include "VesselRegister.h"
      24             : 
      25             : namespace PLMD {
      26             : namespace vesselbase {
      27             : 
      28       13862 : PLUMED_REGISTER_VESSEL(LessThan,"LESS_THAN")
      29             : 
      30          77 : void LessThan::registerKeywords( Keywords& keys ) {
      31          77 :   FunctionVessel::registerKeywords( keys );
      32          77 :   SwitchingFunction::registerKeywords( keys );
      33          77 : }
      34             : 
      35        4595 : void LessThan::reserveKeyword( Keywords& keys ) {
      36        9190 :   keys.reserve("vessel","LESS_THAN","calculate the number of variables less than a certain target value. "
      37             :                "This quantity is calculated using \\f$\\sum_i \\sigma(s_i)\\f$, where \\f$\\sigma(s)\\f$ "
      38             :                "is a \\ref switchingfunction.");
      39        9190 :   keys.addOutputComponent("lessthan","LESS_THAN","the number of values less than a target value. This is calculated using one of the "
      40             :                           "formula described in the description of the keyword so as to make it continuous. "
      41             :                           "You can calculate this quantity multiple times using different parameters.");
      42        4595 : }
      43             : 
      44          77 : LessThan::LessThan( const VesselOptions& da ) :
      45          77 :   FunctionVessel(da) {
      46          77 :   usetol=true;
      47          77 :   if( getAction()->isPeriodic() ) {
      48           0 :     error("LESS_THAN is not a meaningful option for periodic variables");
      49             :   }
      50             :   std::string errormsg;
      51         154 :   sf.set( getAllInput(), errormsg );
      52          77 :   if( errormsg.size()!=0 ) {
      53           0 :     error( errormsg );
      54             :   }
      55          77 : }
      56             : 
      57          77 : std::string LessThan::value_descriptor() {
      58         154 :   return "the number of values less than " + sf.description();
      59             : }
      60             : 
      61      105907 : double LessThan::calcTransform( const double& val, double& dv ) const {
      62      105907 :   double f = sf.calculate(val, dv);
      63      105907 :   dv*=val;
      64      105907 :   return f;
      65             : }
      66             : 
      67          16 : double LessThan::getCutoff() {
      68          16 :   return sf.get_dmax();
      69             : }
      70             : 
      71             : }
      72             : }

Generated by: LCOV version 1.16