All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Units.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 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-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
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 #ifndef __PLUMED_tools_Units_h
23 #define __PLUMED_tools_Units_h
24 
25 #include <string>
26 
27 namespace PLMD{
28 
29 /**
30 \ingroup TOOLBOX
31 Small utility class that contains information about units.
32 
33 This class can be used to contain in a single place all the
34 information about units. Units are expressed in terms of
35 standard PLUMED units, i.e. kj/mol, nm, and ps.
36 Units can be set as double or as string. In the latter case,
37 one can also use strings such as kcal/mol.
38 
39 
40 */
41 class Units{
42 /// Units for energy, expressed in kj/mol (e.g. 4.184 means kcal/mol)
43  double energy;
44  std::string energyString;
45 /// Units for length, expressed in nm (e.g. 0.1 means A)
46  double length;
47  std::string lengthString;
48 /// Units for time, expressed in ps (e.g. 0.001 means fs)
49  double time;
50  std::string timeString;
51 public:
52 /// Constructor, setting default values (1.0)
53  Units();
54 /// Set energy units from string.
55 /// Also understands the following strings:
56 /// kj/mol, kcal/mol, j/mol, and eV.
57  void setEnergy(const std::string &);
58 /// Set time units from string.
59 /// Also understands the following strings:
60 /// ps, ns, fs.
61  void setTime(const std::string &);
62 /// Set lengh units from string.
63 /// Also understands the following strings:
64 /// nm, A, um.
65  void setLength(const std::string &);
66 /// Set energy units from double.
67 /// Should be specified in units of kj/mol (e.g. 4.184 means kcal/mol)
68  void setEnergy(double);
69 /// Set time units from double.
70 /// Should be specified in units of ps (e.g. 0.001 means fs)
71  void setTime(double);
72 /// Set lenght units from double.
73 /// Should be specified in units of nm (e.g. 0.1 means A)
74  void setLength(double);
75 /// Get energy units as double.
76  const double & getEnergy()const;
77 /// Get length units as double.
78  const double & getLength()const;
79 /// Get time units as double.
80  const double & getTime()const;
81 /// Get energy units as string.
82  const std::string & getEnergyString()const;
83 /// Get length units as string.
84  const std::string & getLengthString()const;
85 /// Get time units as string.
86  const std::string & getTimeString()const;
87 };
88 
89 inline
90 const double & Units::getEnergy()const{
91  return energy;
92 }
93 
94 inline
95 const double & Units::getLength()const{
96  return length;
97 }
98 
99 inline
100 const double & Units::getTime()const{
101  return time;
102 }
103 
104 inline
105 const std::string & Units::getEnergyString()const{
106  return energyString;
107 }
108 
109 inline
110 const std::string & Units::getLengthString()const{
111  return lengthString;
112 }
113 
114 inline
115 const std::string & Units::getTimeString()const{
116  return timeString;
117 }
118 
119 
120 }
121 
122 #endif
void setTime(const std::string &)
Set time units from string.
Definition: Units.cpp:73
const std::string & getTimeString() const
Get time units as string.
Definition: Units.h:115
const std::string & getLengthString() const
Get length units as string.
Definition: Units.h:110
Units()
Constructor, setting default values (1.0)
Definition: Units.cpp:29
void setLength(const std::string &)
Set lengh units from string.
Definition: Units.cpp:57
double length
Units for length, expressed in nm (e.g. 0.1 means A)
Definition: Units.h:46
std::string lengthString
Definition: Units.h:47
Small utility class that contains information about units.
Definition: Units.h:41
double energy
Units for energy, expressed in kj/mol (e.g. 4.184 means kcal/mol)
Definition: Units.h:43
const std::string & getEnergyString() const
Get energy units as string.
Definition: Units.h:105
void setEnergy(const std::string &)
Set energy units from string.
Definition: Units.cpp:39
const double & getEnergy() const
Get energy units as double.
Definition: Units.h:90
const double & getTime() const
Get time units as double.
Definition: Units.h:100
const double & getLength() const
Get length units as double.
Definition: Units.h:95
std::string timeString
Definition: Units.h:50
std::string energyString
Definition: Units.h:44
double time
Units for time, expressed in ps (e.g. 0.001 means fs)
Definition: Units.h:49