LCOV - code coverage report
Current view: top level - cltools - kT.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 7 20 35.0 %
Date: 2020-11-18 11:20:57 Functions: 5 11 45.5 %

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

Generated by: LCOV version 1.13