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 : #include "LessThan.h"
23 : #include "VesselRegister.h"
24 :
25 : namespace PLMD {
26 : namespace vesselbase {
27 :
28 6511 : PLUMED_REGISTER_VESSEL(LessThan,"LESS_THAN")
29 :
30 59 : void LessThan::registerKeywords( Keywords& keys ) {
31 59 : FunctionVessel::registerKeywords( keys );
32 59 : SwitchingFunction::registerKeywords( keys );
33 59 : }
34 :
35 1613 : void LessThan::reserveKeyword( Keywords& keys ) {
36 6452 : 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 6452 : 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 1613 : }
43 :
44 59 : LessThan::LessThan( const VesselOptions& da ) :
45 59 : FunctionVessel(da)
46 : {
47 59 : usetol=true;
48 59 : if( getAction()->isPeriodic() ) error("LESS_THAN is not a meaningful option for periodic variables");
49 118 : std::string errormsg; sf.set( getAllInput(), errormsg );
50 59 : if( errormsg.size()!=0 ) error( errormsg );
51 59 : }
52 :
53 59 : std::string LessThan::value_descriptor() {
54 118 : return "the number of values less than " + sf.description();
55 : }
56 :
57 57355 : double LessThan::calcTransform( const double& val, double& dv ) const {
58 57355 : double f = sf.calculate(val, dv); dv*=val; return f;
59 : }
60 :
61 16 : double LessThan::getCutoff() {
62 16 : return sf.get_dmax();
63 : }
64 :
65 : }
66 4839 : }
|