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 : The following command will tell you the value of $k_BT$ when T is equal to 300 K in eV 39 : 40 : ```plumed 41 : plumed kt --temp 300 --units eV 42 : ``` 43 : 44 : The value output depends on the unit of energy and the temperature. 45 : 46 : */ 47 : //+ENDPLUMEDOC 48 : 49 : class kt: 50 : public CLTool { 51 : public: 52 : static void registerKeywords( Keywords& keys ); 53 : explicit kt(const CLToolOptions& co ); 54 : int main(FILE* in, FILE*out,Communicator& pc) override; 55 7 : std::string description()const override { 56 7 : return "print out the value of kT at a particular temperature"; 57 : } 58 : }; 59 : 60 21980 : PLUMED_REGISTER_CLTOOL(kt,"kt") 61 : 62 7321 : void kt::registerKeywords( Keywords& keys ) { 63 7321 : CLTool::registerKeywords( keys ); 64 7321 : keys.add("compulsory","--temp","the temperature in kelvin"); 65 7321 : 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"); 66 7321 : } 67 : 68 17 : kt::kt(const CLToolOptions& co ): 69 17 : CLTool(co) { 70 17 : inputdata=inputType::commandline; 71 17 : } 72 : 73 10 : int kt::main(FILE* in, FILE*out,Communicator& pc) { 74 : 75 : std::string unitname; 76 10 : parse("--units",unitname); 77 10 : Units units; 78 10 : units.setEnergy( unitname ); 79 : double temp; 80 10 : parse("--temp",temp); 81 10 : double kk=(kBoltzmann*temp)/units.getEnergy(); 82 : std::fprintf(out,"When the temperature is %f kelvin kT is equal to %f %s\n",temp,kk,unitname.c_str()); 83 10 : return 0; 84 10 : } 85 : 86 : } // End of namespace 87 : }