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  setVariable("kilobecquerel", kilo_ * Bq);
215  setVariable("kBq", kilo_ * Bq);
216  setVariable("megabecquerel", mega_ * Bq);
217  setVariable("MBq", mega_ * Bq);
218  setVariable("gigabecquerel", giga_ * Bq);
219  setVariable("GBq", giga_ * Bq);
220 
221  // --- honors Pierre Curie (1859-1906) of France
222  // and Marie Sklodowska Curie (1867-1934) of Poland
223  setVariable("curie", 3.7e+10 * Bq);
224  setVariable("Ci", 3.7e+10 * Bq);
225  setVariable("millicurie", milli_ * 3.7e+10 * Bq);
226  setVariable("mCi", milli_ * 3.7e+10 * Bq);
227  setVariable("microcurie", micro_ * 3.7e+10 * Bq);
228  setVariable("uCi", micro_ * 3.7e+10 * Bq);
229 
230  // Specific energy
231  // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England
232  const double Gy = J / kg;
233  setVariable("gray", Gy);
234  setVariable("Gy", Gy);
235  setVariable("kilogray", kilo_ * Gy);
236  setVariable("milligray", milli_ * Gy);
237  setVariable("microgray", micro_ * Gy);
238 
239  // Dose equivalent
240  const double Sv = J / kg;
241  setVariable("sievert", Sv);
242  setVariable("Sv", Sv);
243 
244  // ======================================================================
245  //
246  // Selected units:
247  //
248  // ======================================================================
249 
250  // Length
251 
252  const double mm = milli_ * m;
253  setVariable("millimeter", mm);
254  setVariable("mm", mm);
255 
256  const double cm = centi_ * m;
257  setVariable("centimeter", cm);
258  setVariable("cm", cm);
259 
260  setVariable("decimeter", deci_ * m);
261 
262  const double km = kilo_ * m;
263  setVariable("kilometer", km);
264  setVariable("km", km);
265 
266  setVariable("micrometer", micro_ * m);
267  setVariable("micron", micro_ * m);
268  setVariable("nanometer", nano_ * m);
269 
270  // --- honors Anders Jonas Angstrom (1814-1874) of Sweden
271  setVariable("angstrom", 1.e-10 * m);
272 
273  // --- honors Enrico Fermi (1901-1954) of Italy
274  setVariable("fermi", 1.e-15 * m);
275 
276  // Length^2
277 
278  setVariable("m2", m*m);
279  setVariable("mm2", mm*mm);
280  setVariable("cm2", cm*cm);
281  setVariable("km2", km*km);
282 
283  const double barn = 1.e-28 * m*m;
284  setVariable("barn", barn);
285  setVariable("millibarn", milli_ * barn);
286  setVariable("mbarn", milli_ * barn);
287  setVariable("microbarn", micro_ * barn);
288  setVariable("nanobarn", nano_ * barn);
289  setVariable("picobarn", pico_ * barn);
290 
291  // LengthL^3
292 
293  setVariable("m3", m*m*m);
294  setVariable("mm3", mm*mm*mm);
295  setVariable("cm3", cm*cm*cm);
296  setVariable("cc", cm*cm*cm);
297  setVariable("km3", km*km*km);
298 
299  const double L = 1.e-3*m*m*m;
300  setVariable("liter", L);
301  setVariable("litre", L);
302  setVariable("L", L);
303  setVariable("centiliter", centi_ * L);
304  setVariable("cL", centi_ * L);
305  setVariable("milliliter", milli_ * L);
306  setVariable("mL", milli_ * L);
307 
308  // Length^-1
309 
310  const double dpt = 1./m;
311  setVariable("diopter", dpt);
312  setVariable("dioptre", dpt);
313  setVariable("dpt", dpt);
314 
315  // Mass
316 
317  const double g = 0.001*kg;
318  setVariable("gram", g);
319  setVariable("g", g);
320  setVariable("milligram", milli_ * g);
321  setVariable("mg", milli_ * g);
322 
323  // Time
324 
325  setVariable("millisecond", milli_ * s);
326  setVariable("ms", milli_ * s);
327  setVariable("microsecond", micro_ * s);
328  setVariable("nanosecond", nano_ * s);
329  setVariable("ns", nano_ * s);
330  setVariable("picosecond", pico_ * s);
331 
332  // Current
333 
334  setVariable("milliampere", milli_ * A);
335  setVariable("mA", milli_ * A);
336  setVariable("microampere", micro_ * A);
337  setVariable("nanoampere", nano_ * A);
338 
339  // Frequency
340 
341  setVariable("kilohertz", kilo_ * Hz);
342  setVariable("kHz", kilo_ * Hz);
343  setVariable("megahertz", mega_ * Hz);
344  setVariable("MHz", mega_ * Hz);
345 
346  // Force
347  setVariable("kilonewton", kilo_ * N);
348  setVariable("kN", kilo_ * N);
349 
350  // Pressure
351  setVariable("kilobar", kilo_ * bar);
352  setVariable("kbar", kilo_ * bar);
353  setVariable("millibar", milli_ * bar);
354  setVariable("mbar", milli_ * bar);
355 
356  // Energy
357  setVariable("kilojoule", kilo_ * J);
358  setVariable("kJ", kilo_ * J);
359  setVariable("megajoule", mega_ * J);
360  setVariable("MJ", mega_ * J);
361  setVariable("gigajoule", giga_ * J);
362  setVariable("GJ", giga_ * J);
363 
364  const double e_SI = 1.60217733e-19; // positron charge in coulomb
365  const double ePlus = e_SI * C; // positron charge
366  const double eV = ePlus * V;
367  setVariable("electronvolt", eV);
368  setVariable("eV", eV);
369  setVariable("kiloelectronvolt", kilo_ * eV);
370  setVariable("keV", kilo_ * eV);
371  setVariable("megaelectronvolt", mega_ * eV);
372  setVariable("MeV", mega_ * eV);
373  setVariable("gigaelectronvolt", giga_ * eV);
374  setVariable("GeV", giga_ * eV);
375  setVariable("teraelectronvolt", tera_ * eV);
376  setVariable("TeV", tera_ * eV);
377  setVariable("petaelectronvolt", peta_ * eV);
378  setVariable("PeV", peta_ * eV);
379 
380  // Power
381  setVariable("kilowatt", kilo_ * W);
382  setVariable("kW", kilo_ * W);
383  setVariable("megawatt", mega_ * W);
384  setVariable("MW", mega_ * W);
385  setVariable("gigawatt", giga_ * W);
386  setVariable("GW", giga_ * W);
387 
388  // Electric potential
389  setVariable("kilovolt", kilo_ * V);
390  setVariable("kV", kilo_ * V);
391  setVariable("megavolt", mega_ * V);
392  setVariable("MV", mega_ * V);
393 
394  // Electric capacitance
395  setVariable("millifarad", milli_ * F);
396  setVariable("mF", milli_ * F);
397  setVariable("microfarad", micro_ * F);
398  setVariable("uF", micro_ * F);
399  setVariable("nanofarad", nano_ * F);
400  setVariable("nF", nano_ * F);
401  setVariable("picofarad", pico_ * F);
402  setVariable("pF", pico_ * F);
403 
404  // Magnetic flux density
405  setVariable("kilogauss", kilo_ * Gs);
406  setVariable("kGs", kilo_ * Gs);
407 }
408 
409 } // namespace HepTool
void setSystemOfUnits(double meter=1.0, double kilogram=1.0, double second=1.0, double ampere=1.0, double kelvin=1.0, double mole=1.0, double candela=1.0)
void setVariable(const char *name, double value)
Definition: Evaluator.cc:688
int g(shared_ptr< X >)