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