Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2014-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 "CLTool.h" 23 : #include "core/CLToolRegister.h" 24 : #include "tools/Tools.h" 25 : #include "config/Config.h" 26 : #include "tools/Units.h" 27 : #include "core/ActionRegister.h" 28 : #include <cstdio> 29 : #include <string> 30 : 31 : namespace PLMD { 32 : namespace cltools { 33 : 34 : //+PLUMEDOC TOOLS kt 35 : /* 36 : Print out the value of k_B T at a particular temperature 37 : 38 : \par Examples 39 : 40 : The following command will tell you the value of \f$k_BT\f$ when T is equal 41 : to 300 K in eV 42 : 43 : \verbatim 44 : plumed kt --temp 300 --units eV 45 : \endverbatim 46 : 47 : */ 48 : //+ENDPLUMEDOC 49 : 50 : class kt: 51 : public CLTool { 52 : public: 53 : static void registerKeywords( Keywords& keys ); 54 : explicit kt(const CLToolOptions& co ); 55 : int main(FILE* in, FILE*out,Communicator& pc) override; 56 5 : std::string description()const override { 57 5 : return "print out the value of kT at a particular temperature"; 58 : } 59 : }; 60 : 61 16265 : PLUMED_REGISTER_CLTOOL(kt,"kt") 62 : 63 5418 : void kt::registerKeywords( Keywords& keys ) { 64 5418 : CLTool::registerKeywords( keys ); 65 5418 : keys.add("compulsory","--temp","print the manual for this particular action"); 66 5418 : keys.add("compulsory","--units","kj/mol","the units of energy can be kj/mol, kcal/mol, j/mol, eV or the conversion factor from kj/mol"); 67 5418 : } 68 : 69 11 : kt::kt(const CLToolOptions& co ): 70 11 : CLTool(co) { 71 11 : inputdata=commandline; 72 11 : } 73 : 74 6 : int kt::main(FILE* in, FILE*out,Communicator& pc) { 75 : 76 : std::string unitname; 77 6 : parse("--units",unitname); 78 6 : Units units; 79 6 : units.setEnergy( unitname ); 80 : double temp; 81 6 : parse("--temp",temp); 82 6 : double kk=(kBoltzmann*temp)/units.getEnergy(); 83 : std::fprintf(out,"When the temperature is %f kelvin kT is equal to %f %s\n",temp,kk,unitname.c_str()); 84 6 : return 0; 85 6 : } 86 : 87 : } // End of namespace 88 : }