QMCPACK
qmcplusplus::Units Namespace Reference

Namespaces

 charge
 
 constants
 
 count
 
 distance
 
 energy
 
 force
 
 mass
 
 pressure
 
 time
 

Typedefs

using real = QMCTraits::RealType
 

Enumerations

enum  units {
  mol = 0, A, B, m,
  nm, pm, fm, s,
  ms, ns, ps, fs,
  kg, me, mp, amu,
  Da, J, eV, Ry,
  Ha, kJ_mol, K, C,
  e, Pa, bar, Mbar,
  GPa, atm, N, pN,
  mole, angstrom, bohr, meter,
  nanometer, picometer, femtometer, second,
  millisecond, nanosecond, picosecond, femtosecond,
  kilogram, electron_mass, proton_mass, atomic_mass_unit,
  dalton, joule, electron_volt, rydberg,
  hartree, kilojoule_per_mole, kelvin, coulomb,
  proton_charge, pascal, megabar, gigapascal,
  atmosphere, newton, piconewton, nunits
}
 

Functions

units count_unit (const std::string &su)
 convert from std::string to count unit More...
 
units distance_unit (const std::string &su)
 convert from std::string to distance unit More...
 
units time_unit (const std::string &su)
 convert from std::string to time unit More...
 
units mass_unit (const std::string &su)
 convert from std::string to mass unit More...
 
units energy_unit (const std::string &su)
 convert from std::string to energy unit More...
 
units charge_unit (const std::string &su)
 convert from std::string to charge unit More...
 
units pressure_unit (const std::string &su)
 convert from std::string to pressure unit More...
 
units force_unit (const std::string &su)
 convert from std::string to force unit More...
 
real convert (real value, units units_in, units units_out)
 
template<typename array >
void convert_array (array &values, units units_in, units units_out)
 

Variables

const real unit_values [nunits]
 

Typedef Documentation

◆ real

Definition at line 23 of file unit_conversion.h.

Enumeration Type Documentation

◆ units

enum units
Enumerator
mol 
nm 
pm 
fm 
ms 
ns 
ps 
fs 
kg 
me 
mp 
amu 
Da 
eV 
Ry 
Ha 
kJ_mol 
Pa 
bar 
Mbar 
GPa 
atm 
pN 
mole 
angstrom 
bohr 
meter 
nanometer 
picometer 
femtometer 
second 
millisecond 
nanosecond 
picosecond 
femtosecond 
kilogram 
electron_mass 
proton_mass 
atomic_mass_unit 
dalton 
joule 
electron_volt 
rydberg 
hartree 
kilojoule_per_mole 
kelvin 
coulomb 
proton_charge 
pascal 
megabar 
gigapascal 
atmosphere 
newton 
piconewton 
nunits 

Definition at line 97 of file unit_conversion.h.

98 {
99  mol = 0,
100  A,
101  B,
102  m,
103  nm,
104  pm,
105  fm,
106  s,
107  ms,
108  ns,
109  ps,
110  fs,
111  kg,
112  me,
113  mp,
114  amu,
115  Da,
116  J,
117  eV,
118  Ry,
119  Ha,
120  kJ_mol,
121  K,
122  C,
123  e,
124  Pa,
125  bar,
126  Mbar,
127  GPa,
128  atm,
129  N,
130  pN,
131  mole,
132  angstrom,
133  bohr,
134  meter,
135  nanometer,
136  picometer,
137  femtometer,
138  second,
139  millisecond,
140  nanosecond,
141  picosecond,
142  femtosecond,
143  kilogram,
145  proton_mass,
147  dalton,
148  joule,
150  rydberg,
151  hartree,
153  kelvin,
154  coulomb,
156  pascal,
157  megabar,
158  gigapascal,
159  atmosphere,
160  newton,
161  piconewton,
162  nunits
163 };
double B(double x, int k, int i, const std::vector< double > &t)

Function Documentation

◆ charge_unit()

units charge_unit ( const std::string &  su)

convert from std::string to charge unit

Definition at line 169 of file unit_conversion.cpp.

References APP_ABORT, C, and e.

170 {
171  if (su == "C")
172  return C;
173  else if (su == "e")
174  return e;
175  else if (su == "coulomb")
176  return C;
177  else if (su == "proton_charge")
178  return e;
179  else
180  {
181  APP_ABORT("units::charge_unit\n invalid charge unit: " + su + "\n valid options are: C/coulomb, e/proton_charge");
182  return C;
183  }
184 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ convert()

real qmcplusplus::Units::convert ( real  value,
units  units_in,
units  units_out 
)
inline

Definition at line 177 of file unit_conversion.h.

References unit_values.

Referenced by OrbitalImages::write_orbital_xsf().

178 {
179  return value * unit_values[units_in] / unit_values[units_out];
180 }
const real unit_values[nunits]

◆ convert_array()

void qmcplusplus::Units::convert_array ( array &  values,
units  units_in,
units  units_out 
)
inline

Definition at line 184 of file unit_conversion.h.

References unit_values.

Referenced by SPOSetInputInfo::put().

185 {
186  real conv = unit_values[units_in] / unit_values[units_out];
187  typename array::iterator v;
188  for (v = values.begin(); v != values.end(); ++v)
189  (*v) *= conv;
190 }
QMCTraits::RealType real
const real unit_values[nunits]

◆ count_unit()

units count_unit ( const std::string &  su)

convert from std::string to count unit

Definition at line 22 of file unit_conversion.cpp.

References APP_ABORT, and mol.

23 {
24  if (su == "mol")
25  return mol;
26  else if (su == "mole")
27  return mol;
28  else
29  {
30  APP_ABORT("units::count_unit\n invalid count unit: " + su + "\n valid options are: mol");
31  return mol;
32  }
33 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ distance_unit()

units distance_unit ( const std::string &  su)

convert from std::string to distance unit

Definition at line 36 of file unit_conversion.cpp.

References A, APP_ABORT, B, fm, m, nm, and pm.

37 {
38  if (su == "m")
39  return m;
40  else if (su == "A")
41  return A;
42  else if (su == "B")
43  return B;
44  else if (su == "nm")
45  return nm;
46  else if (su == "pm")
47  return pm;
48  else if (su == "fm")
49  return fm;
50  else if (su == "meter")
51  return m;
52  else if (su == "angstrom")
53  return A;
54  else if (su == "bohr")
55  return B;
56  else if (su == "nanometer")
57  return nm;
58  else if (su == "picometer")
59  return pm;
60  else if (su == "femtometer")
61  return fm;
62  else
63  {
64  APP_ABORT("units::distance_unit\n invalid distance unit: " + su +
65  "\n valid options are: m/meter, A/angstrom, B/bohr, nm/nanometer, pm/picometer, fm/femtometer");
66  return m;
67  }
68 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27
double B(double x, int k, int i, const std::vector< double > &t)

◆ energy_unit()

units energy_unit ( const std::string &  su)

convert from std::string to energy unit

Definition at line 133 of file unit_conversion.cpp.

References APP_ABORT, eV, Ha, J, K, kJ_mol, and Ry.

Referenced by SPOSetInputInfo::put().

134 {
135  if (su == "J")
136  return J;
137  else if (su == "eV")
138  return eV;
139  else if (su == "Ry")
140  return Ry;
141  else if (su == "Ha")
142  return Ha;
143  else if (su == "kJ/mol")
144  return kJ_mol;
145  else if (su == "K")
146  return K;
147  else if (su == "joule")
148  return J;
149  else if (su == "electron_volt")
150  return eV;
151  else if (su == "rydberg")
152  return Ry;
153  else if (su == "hartree")
154  return Ha;
155  else if (su == "kilojoule_per_mole")
156  return kJ_mol;
157  else if (su == "kelvin")
158  return K;
159  else
160  {
161  APP_ABORT("units::energy_unit\n invalid energy unit: " + su +
162  "\n valid options are: J/joule, eV/electron_volt, Ry/rydberg, Ha/hartree, kJ/mol/kilo_joule_per_mole, "
163  "K/kelvin");
164  return J;
165  }
166 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ force_unit()

units force_unit ( const std::string &  su)

convert from std::string to force unit

Definition at line 216 of file unit_conversion.cpp.

References APP_ABORT, N, and pN.

217 {
218  if (su == "N")
219  return N;
220  else if (su == "pN")
221  return pN;
222  else if (su == "newton")
223  return N;
224  else if (su == "piconewton")
225  return pN;
226  else
227  {
228  APP_ABORT("units::force_unit\n invalid force unit: " + su + "\n valid options are: N/newton, pN/piconewton");
229  return N;
230  }
231 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ mass_unit()

units mass_unit ( const std::string &  su)

convert from std::string to mass unit

Definition at line 102 of file unit_conversion.cpp.

References amu, APP_ABORT, Da, kg, me, and mp.

103 {
104  if (su == "kg")
105  return kg;
106  else if (su == "me")
107  return me;
108  else if (su == "mp")
109  return mp;
110  else if (su == "amu")
111  return amu;
112  else if (su == "Da")
113  return Da;
114  else if (su == "kilogram")
115  return kg;
116  else if (su == "electron_mass")
117  return me;
118  else if (su == "proton_mass")
119  return mp;
120  else if (su == "atomic_mass_unit")
121  return amu;
122  else if (su == "dalton")
123  return Da;
124  else
125  {
126  APP_ABORT("units::mass_unit\n invalid mass unit: " + su +
127  "\n valid options are: kg/kilogram, me/electron_mass, mp/proton_mass, amu/atomic_mass_unit, Da/dalton");
128  return kg;
129  }
130 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ pressure_unit()

units pressure_unit ( const std::string &  su)

convert from std::string to pressure unit

Definition at line 187 of file unit_conversion.cpp.

References APP_ABORT, atm, bar, GPa, Mbar, and Pa.

188 {
189  if (su == "Pa")
190  return Pa;
191  else if (su == "bar")
192  return bar;
193  else if (su == "Mbar")
194  return Mbar;
195  else if (su == "GPa")
196  return GPa;
197  else if (su == "atm")
198  return atm;
199  else if (su == "pascal")
200  return Pa;
201  else if (su == "megabar")
202  return Mbar;
203  else if (su == "gigapascal")
204  return GPa;
205  else if (su == "atmosphere")
206  return atm;
207  else
208  {
209  APP_ABORT("units::pressure_unit\n invalid pressure unit: " + su +
210  "\n valid options are: Pa/pascal, bar/bar, Mbar/megabar, GPa/gigapascal, atm/atmosphere");
211  return Pa;
212  }
213 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

◆ time_unit()

units time_unit ( const std::string &  su)

convert from std::string to time unit

Definition at line 71 of file unit_conversion.cpp.

References APP_ABORT, fs, ms, ns, ps, and s.

72 {
73  if (su == "s")
74  return s;
75  else if (su == "ms")
76  return ms;
77  else if (su == "ns")
78  return ns;
79  else if (su == "ps")
80  return ps;
81  else if (su == "fs")
82  return fs;
83  else if (su == "second")
84  return s;
85  else if (su == "millisecond")
86  return ms;
87  else if (su == "nanosecond")
88  return ns;
89  else if (su == "picosecond")
90  return ps;
91  else if (su == "femtosecond")
92  return fs;
93  else
94  {
95  APP_ABORT("units::time_unit\n invalid time unit: " + su +
96  "\n valid options are: s/second, ms/millisecond, ns/nanosecond, ps/picosecond, fs/femtosecond");
97  return s;
98  }
99 }
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Definition: AppAbort.h:27

Variable Documentation

◆ unit_values

const real unit_values[nunits]
Initial value:
=
double B(double x, int k, int i, const std::vector< double > &t)

Definition at line 166 of file unit_conversion.h.

Referenced by convert(), and convert_array().