CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

setSystemOfUnits.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: setSystemOfUnits.cc,v 1.2 2003/08/13 20:00:10 garren Exp $
3 // ----------------------------------------------------------------------
4 
5 #include "CLHEP/Evaluator/defs.h"
7 
8 namespace HepTool {
9 
10 void Evaluator::setSystemOfUnits(double meter,
11  double kilogram,
12  double second,
13  double ampere,
14  double kelvin,
15  double mole,
16  double candela)
17 {
18  const double kilo_ = 1.e+03; // chilioi (Greek) "thousand"
19  const double mega_ = 1.e+06; // megas (Greek) "large"
20  const double giga_ = 1.e+09; // gigas (Greek) "giant"
21  const double tera_ = 1.e+12; // teras (Greek) "monster"
22  const double peta_ = 1.e+15; // pente (Greek) "five"
23 
24  const double deci_ = 1.e-01; // decimus (Latin) "tenth"
25  const double centi_ = 1.e-02; // centum (Latin) "hundred"
26  const double milli_ = 1.e-03; // mille (Latin) "thousand"
27  const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small"
28  const double nano_ = 1.e-09; // nanus (Latin) or nanos (Greek) "dwarf"
29  const double pico_ = 1.e-12; // pico (Spanish) "bit"
30 
31  // ======================================================================
32  //
33  // Base (default) SI units
34  // for the basic measurable quantities (dimensions):
35  //
36  // ======================================================================
37 
38  // Length
39  // metrum (Latin) and metron (Greek) "measure"
40  const double m = meter;
41  setVariable("meter", m);
42  setVariable("metre", m);
43  setVariable("m", m);
44 
45  // Mass
46  const double kg = kilogram;
47  setVariable("kilogram", kg);
48  setVariable("kg", kg);
49 
50  // Time
51  // minuta secundam (Latin) "second small one"
52  const double s = second;
53  setVariable("second", s);
54  setVariable("s", s);
55 
56  // Current
57  // --- honors Andre-Marie Ampere (1775-1836) of France
58  const double A = ampere;
59  setVariable("ampere", A);
60  setVariable("amp", A);
61  setVariable("A", A);
62 
63  // Temperature
64  // --- honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England
65  const double K = kelvin;
66  setVariable("kelvin", K);
67  setVariable("K", K);
68 
69  // Amount of substance
70  const double mol = mole;
71  setVariable("mole", mol);
72  setVariable("mol", mol);
73 
74  // Luminous intensity
75  const double cd = candela;
76  setVariable("candela", cd);
77  setVariable("cd", cd);
78 
79  // ======================================================================
80  //
81  // Supplementary SI units having special symbols:
82  //
83  // ======================================================================
84 
85  // Plane angle
86  const double rad = 1.;
87  setVariable("radian", rad);
88  setVariable("rad", rad);
89  setVariable("milliradian", milli_ * rad);
90  setVariable("mrad", milli_ * rad);
91 
92  const double pi = 3.14159265358979323846;
93  const double deg = rad*pi/180.;
94  setVariable("degree", deg);
95  setVariable("deg", deg);
96 
97  // Solid angle
98  const double sr = 1.;
99  setVariable("steradian", sr);
100  setVariable("sr", sr);
101 
102  // ======================================================================
103  //
104  // Derived SI units having special symbols:
105  //
106  // ======================================================================
107 
108  // Frequency
109  // --- honors Heinrich Rudolf Hertz (1857-1894) of Germany
110  const double Hz = 1./s;
111  setVariable("hertz", Hz);
112  setVariable("Hz", Hz);
113 
114  // Force
115  // --- honors Sir Isaac Newton (1642-1727) of England
116  const double N = m * kg / (s*s);
117  setVariable("newton", N);
118  setVariable("N", N);
119 
120  // Pressure
121  // --- honors Blaise Pascal (1623-1662) of France
122  const double Pa = N / (m*m);
123  setVariable("pascal", Pa);
124  setVariable("Pa", Pa);
125 
126  const double atm = 101325. * Pa;
127  setVariable("atmosphere", atm);
128  setVariable("atm", atm);
129 
130  const double bar = 100000*Pa;
131  setVariable("bar", bar);
132 
133  // Energy
134  // --- honors James Prescott Joule (1818-1889) of England
135  const double J = N * m;
136  setVariable("joule", J);
137  setVariable("J", J);
138 
139  // Power
140  // --- honors James Watt (1736-1819) of Scotland
141  const double W = J / s;
142  setVariable("watt", W);
143  setVariable("W", W);
144 
145  // Electric charge
146  // --- honors Charles-Augustin de Coulomb (1736-1806) of France
147  const double C = A * s;
148  setVariable("coulomb", C);
149  setVariable("C", C);
150 
151  // Electric potential
152  // --- honors Count Alessandro Volta (1745-1827) of Italy
153  const double V = J / C;
154  setVariable("volt", V);
155  setVariable("V", V);
156 
157  // Electric resistance
158  // --- honors Georg Simon Ohm (1787-1854) of Germany
159  const double ohm = V / A;
160  setVariable("ohm", ohm);
161 
162  // Electric conductance
163  // --- honors Ernst Werner von Siemens (1816-1892) or
164  // his brother Sir William (Karl Wilhelm von) Siemens (1823-1883)
165  // of Germany (England)
166  const double S = 1./ ohm;
167  setVariable("siemens", S);
168  setVariable("S", S);
169 
170  // Electric capacitance
171  // --- honors Michael Faraday (1791-1867) of England
172  const double F = C / V;
173  setVariable("farad", F);
174  setVariable("F", F);
175 
176  // Magnetic flux density
177  // --- honors Nikola Tesla (1856-1943) of Croatia (United States)
178  const double T = V * s / (m*m);
179  setVariable("tesla", T);
180  setVariable("T", T);
181 
182  // --- honors Karl Friedrich Gauss (1777-1855) of Germany
183  const double Gs = 1.e-4*T;
184  setVariable("gauss", Gs);
185  setVariable("Gs", Gs);
186 
187  // Magnetic flux
188  // --- honors Wilhelm Eduard Weber (1804-1891) of Germany
189  const double Wb = V * s;
190  setVariable("weber", Wb);
191  setVariable("Wb", Wb);
192 
193  // Inductance
194  // --- honors Joseph Henry (1797-1878) of the United States
195  const double H = Wb / A;
196  setVariable("henry", H);
197  setVariable("H", H);
198 
199  // Luminous flux
200  const double lm = cd * sr;
201  setVariable("lumen", lm);
202  setVariable("lm", lm);
203 
204  // Illuminace
205  const double lx = lm / (m*m);
206  setVariable("lux", lx);
207  setVariable("lx", lx);
208 
209  // Radioactivity
210  // --- honors Antoine-Henri Becquerel (1852-1908) of France
211  const double Bq = 1./s;
212  setVariable("becquerel", Bq);
213  setVariable("Bq", Bq);
214 
215  // --- honors Pierre Curie (1859-1906) of France
216  // and Marie Sklodowska Curie (1867-1934) of Poland
217  setVariable("curie", 3.7e+10 * Bq);
218  setVariable("Ci", 3.7e+10 * Bq);
219 
220  // Specific energy
221  // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England
222  const double Gy = J / kg;
223  setVariable("gray", Gy);
224  setVariable("Gy", Gy);
225 
226  // Dose equivalent
227  const double Sv = J / kg;
228  setVariable("sievert", Sv);
229  setVariable("Sv", Sv);
230 
231  // ======================================================================
232  //
233  // Selected units:
234  //
235  // ======================================================================
236 
237  // Length
238 
239  const double mm = milli_ * m;
240  setVariable("millimeter", mm);
241  setVariable("mm", mm);
242 
243  const double cm = centi_ * m;
244  setVariable("centimeter", cm);
245  setVariable("cm", cm);
246 
247  setVariable("decimeter", deci_ * m);
248 
249  const double km = kilo_ * m;
250  setVariable("kilometer", km);
251  setVariable("km", km);
252 
253  setVariable("micrometer", micro_ * m);
254  setVariable("micron", micro_ * m);
255  setVariable("nanometer", nano_ * m);
256 
257  // --- honors Anders Jonas Angstrom (1814-1874) of Sweden
258  setVariable("angstrom", 1.e-10 * m);
259 
260  // --- honors Enrico Fermi (1901-1954) of Italy
261  setVariable("fermi", 1.e-15 * m);
262 
263  // Length^2
264 
265  setVariable("m2", m*m);
266  setVariable("mm2", mm*mm);
267  setVariable("cm2", cm*cm);
268  setVariable("km2", km*km);
269 
270  const double barn = 1.e-28 * m*m;
271  setVariable("barn", barn);
272  setVariable("millibarn", milli_ * barn);
273  setVariable("mbarn", milli_ * barn);
274  setVariable("microbarn", micro_ * barn);
275  setVariable("nanobarn", nano_ * barn);
276  setVariable("picobarn", pico_ * barn);
277 
278  // LengthL^3
279 
280  setVariable("m3", m*m*m);
281  setVariable("mm3", mm*mm*mm);
282  setVariable("cm3", cm*cm*cm);
283  setVariable("cc", cm*cm*cm);
284  setVariable("km3", km*km*km);
285 
286  const double L = 1.e-3*m*m*m;
287  setVariable("liter", L);
288  setVariable("litre", L);
289  setVariable("L", L);
290  setVariable("centiliter", centi_ * L);
291  setVariable("cL", centi_ * L);
292  setVariable("milliliter", milli_ * L);
293  setVariable("mL", milli_ * L);
294 
295  // Length^-1
296 
297  const double dpt = 1./m;
298  setVariable("diopter", dpt);
299  setVariable("dioptre", dpt);
300  setVariable("dpt", dpt);
301 
302  // Mass
303 
304  const double g = 0.001*kg;
305  setVariable("gram", g);
306  setVariable("g", g);
307  setVariable("milligram", milli_ * g);
308  setVariable("mg", milli_ * g);
309 
310  // Time
311 
312  setVariable("millisecond", milli_ * s);
313  setVariable("ms", milli_ * s);
314  setVariable("microsecond", micro_ * s);
315  setVariable("nanosecond", nano_ * s);
316  setVariable("ns", nano_ * s);
317  setVariable("picosecond", pico_ * s);
318 
319  // Current
320 
321  setVariable("milliampere", milli_ * A);
322  setVariable("mA", milli_ * A);
323  setVariable("microampere", micro_ * A);
324  setVariable("nanoampere", nano_ * A);
325 
326  // Frequency
327 
328  setVariable("kilohertz", kilo_ * Hz);
329  setVariable("kHz", kilo_ * Hz);
330  setVariable("megahertz", mega_ * Hz);
331  setVariable("MHz", mega_ * Hz);
332 
333  // Force
334  setVariable("kilonewton", kilo_ * N);
335  setVariable("kN", kilo_ * N);
336 
337  // Pressure
338  setVariable("kilobar", kilo_ * bar);
339  setVariable("kbar", kilo_ * bar);
340  setVariable("millibar", milli_ * bar);
341  setVariable("mbar", milli_ * bar);
342 
343  // Energy
344  setVariable("kilojoule", kilo_ * J);
345  setVariable("kJ", kilo_ * J);
346  setVariable("megajoule", mega_ * J);
347  setVariable("MJ", mega_ * J);
348  setVariable("gigajoule", giga_ * J);
349  setVariable("GJ", giga_ * J);
350 
351  const double e_SI = 1.60217733e-19; // positron charge in coulomb
352  const double ePlus = e_SI * C; // positron charge
353  const double eV = ePlus * V;
354  setVariable("electronvolt", eV);
355  setVariable("eV", eV);
356  setVariable("kiloelectronvolt", kilo_ * eV);
357  setVariable("keV", kilo_ * eV);
358  setVariable("megaelectronvolt", mega_ * eV);
359  setVariable("MeV", mega_ * eV);
360  setVariable("gigaelectronvolt", giga_ * eV);
361  setVariable("GeV", giga_ * eV);
362  setVariable("teraelectronvolt", tera_ * eV);
363  setVariable("TeV", tera_ * eV);
364  setVariable("petaelectronvolt", peta_ * eV);
365  setVariable("PeV", peta_ * eV);
366 
367  // Power
368  setVariable("kilowatt", kilo_ * W);
369  setVariable("kW", kilo_ * W);
370  setVariable("megawatt", mega_ * W);
371  setVariable("MW", mega_ * W);
372  setVariable("gigawatt", giga_ * W);
373  setVariable("GW", giga_ * W);
374 
375  // Electric potential
376  setVariable("kilovolt", kilo_ * V);
377  setVariable("kV", kilo_ * V);
378  setVariable("megavolt", mega_ * V);
379  setVariable("MV", mega_ * V);
380 
381  // Electric capacitance
382  setVariable("millifarad", milli_ * F);
383  setVariable("mF", milli_ * F);
384  setVariable("microfarad", micro_ * F);
385  setVariable("uF", micro_ * F);
386  setVariable("nanofarad", nano_ * F);
387  setVariable("nF", nano_ * F);
388  setVariable("picofarad", pico_ * F);
389  setVariable("pF", pico_ * F);
390 
391  // Magnetic flux density
392  setVariable("kilogauss", kilo_ * Gs);
393  setVariable("kGs", kilo_ * Gs);
394 }
395 
396 } // namespace HepTool