LCOV - code coverage report
Current view: top level - cltools - kT.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 19 19 100.0 %
Date: 2024-10-18 14:00:25 Functions: 7 7 100.0 %

          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             : {
      53             : public:
      54             :   static void registerKeywords( Keywords& keys );
      55             :   explicit kt(const CLToolOptions& co );
      56             :   int main(FILE* in, FILE*out,Communicator& pc) override;
      57           4 :   std::string description()const override {
      58           4 :     return "print out the value of kT at a particular temperature";
      59             :   }
      60             : };
      61             : 
      62       15958 : PLUMED_REGISTER_CLTOOL(kt,"kt")
      63             : 
      64        5316 : void kt::registerKeywords( Keywords& keys ) {
      65        5316 :   CLTool::registerKeywords( keys );
      66       10632 :   keys.add("compulsory","--temp","print the manual for this particular action");
      67       10632 :   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");
      68        5316 : }
      69             : 
      70          10 : kt::kt(const CLToolOptions& co ):
      71          10 :   CLTool(co)
      72             : {
      73          10 :   inputdata=commandline;
      74          10 : }
      75             : 
      76           6 : int kt::main(FILE* in, FILE*out,Communicator& pc) {
      77             : 
      78           6 :   std::string unitname; parse("--units",unitname);
      79           6 :   Units units; units.setEnergy( unitname );
      80           6 :   double temp; parse("--temp",temp);
      81           6 :   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           6 :   return 0;
      84           6 : }
      85             : 
      86             : } // End of namespace
      87             : }

Generated by: LCOV version 1.16