CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: setSystemOfUnits.cc,v 1.2 2003/08/13 20:00:10 garren Exp $ 00003 // ---------------------------------------------------------------------- 00004 00005 #include "CLHEP/Evaluator/defs.h" 00006 #include "CLHEP/Evaluator/Evaluator.h" 00007 00008 namespace HepTool { 00009 00010 void Evaluator::setSystemOfUnits(double meter, 00011 double kilogram, 00012 double second, 00013 double ampere, 00014 double kelvin, 00015 double mole, 00016 double candela) 00017 { 00018 const double kilo_ = 1.e+03; // chilioi (Greek) "thousand" 00019 const double mega_ = 1.e+06; // megas (Greek) "large" 00020 const double giga_ = 1.e+09; // gigas (Greek) "giant" 00021 const double tera_ = 1.e+12; // teras (Greek) "monster" 00022 const double peta_ = 1.e+15; // pente (Greek) "five" 00023 00024 const double deci_ = 1.e-01; // decimus (Latin) "tenth" 00025 const double centi_ = 1.e-02; // centum (Latin) "hundred" 00026 const double milli_ = 1.e-03; // mille (Latin) "thousand" 00027 const double micro_ = 1.e-06; // micro (Latin) or mikros (Greek) "small" 00028 const double nano_ = 1.e-09; // nanus (Latin) or nanos (Greek) "dwarf" 00029 const double pico_ = 1.e-12; // pico (Spanish) "bit" 00030 00031 // ====================================================================== 00032 // 00033 // Base (default) SI units 00034 // for the basic measurable quantities (dimensions): 00035 // 00036 // ====================================================================== 00037 00038 // Length 00039 // metrum (Latin) and metron (Greek) "measure" 00040 const double m = meter; 00041 setVariable("meter", m); 00042 setVariable("metre", m); 00043 setVariable("m", m); 00044 00045 // Mass 00046 const double kg = kilogram; 00047 setVariable("kilogram", kg); 00048 setVariable("kg", kg); 00049 00050 // Time 00051 // minuta secundam (Latin) "second small one" 00052 const double s = second; 00053 setVariable("second", s); 00054 setVariable("s", s); 00055 00056 // Current 00057 // --- honors Andre-Marie Ampere (1775-1836) of France 00058 const double A = ampere; 00059 setVariable("ampere", A); 00060 setVariable("amp", A); 00061 setVariable("A", A); 00062 00063 // Temperature 00064 // --- honors William Thomson, 1st Baron Lord Kelvin (1824-1907) of England 00065 const double K = kelvin; 00066 setVariable("kelvin", K); 00067 setVariable("K", K); 00068 00069 // Amount of substance 00070 const double mol = mole; 00071 setVariable("mole", mol); 00072 setVariable("mol", mol); 00073 00074 // Luminous intensity 00075 const double cd = candela; 00076 setVariable("candela", cd); 00077 setVariable("cd", cd); 00078 00079 // ====================================================================== 00080 // 00081 // Supplementary SI units having special symbols: 00082 // 00083 // ====================================================================== 00084 00085 // Plane angle 00086 const double rad = 1.; 00087 setVariable("radian", rad); 00088 setVariable("rad", rad); 00089 setVariable("milliradian", milli_ * rad); 00090 setVariable("mrad", milli_ * rad); 00091 00092 const double pi = 3.14159265358979323846; 00093 const double deg = rad*pi/180.; 00094 setVariable("degree", deg); 00095 setVariable("deg", deg); 00096 00097 // Solid angle 00098 const double sr = 1.; 00099 setVariable("steradian", sr); 00100 setVariable("sr", sr); 00101 00102 // ====================================================================== 00103 // 00104 // Derived SI units having special symbols: 00105 // 00106 // ====================================================================== 00107 00108 // Frequency 00109 // --- honors Heinrich Rudolf Hertz (1857-1894) of Germany 00110 const double Hz = 1./s; 00111 setVariable("hertz", Hz); 00112 setVariable("Hz", Hz); 00113 00114 // Force 00115 // --- honors Sir Isaac Newton (1642-1727) of England 00116 const double N = m * kg / (s*s); 00117 setVariable("newton", N); 00118 setVariable("N", N); 00119 00120 // Pressure 00121 // --- honors Blaise Pascal (1623-1662) of France 00122 const double Pa = N / (m*m); 00123 setVariable("pascal", Pa); 00124 setVariable("Pa", Pa); 00125 00126 const double atm = 101325. * Pa; 00127 setVariable("atmosphere", atm); 00128 setVariable("atm", atm); 00129 00130 const double bar = 100000*Pa; 00131 setVariable("bar", bar); 00132 00133 // Energy 00134 // --- honors James Prescott Joule (1818-1889) of England 00135 const double J = N * m; 00136 setVariable("joule", J); 00137 setVariable("J", J); 00138 00139 // Power 00140 // --- honors James Watt (1736-1819) of Scotland 00141 const double W = J / s; 00142 setVariable("watt", W); 00143 setVariable("W", W); 00144 00145 // Electric charge 00146 // --- honors Charles-Augustin de Coulomb (1736-1806) of France 00147 const double C = A * s; 00148 setVariable("coulomb", C); 00149 setVariable("C", C); 00150 00151 // Electric potential 00152 // --- honors Count Alessandro Volta (1745-1827) of Italy 00153 const double V = J / C; 00154 setVariable("volt", V); 00155 setVariable("V", V); 00156 00157 // Electric resistance 00158 // --- honors Georg Simon Ohm (1787-1854) of Germany 00159 const double ohm = V / A; 00160 setVariable("ohm", ohm); 00161 00162 // Electric conductance 00163 // --- honors Ernst Werner von Siemens (1816-1892) or 00164 // his brother Sir William (Karl Wilhelm von) Siemens (1823-1883) 00165 // of Germany (England) 00166 const double S = 1./ ohm; 00167 setVariable("siemens", S); 00168 setVariable("S", S); 00169 00170 // Electric capacitance 00171 // --- honors Michael Faraday (1791-1867) of England 00172 const double F = C / V; 00173 setVariable("farad", F); 00174 setVariable("F", F); 00175 00176 // Magnetic flux density 00177 // --- honors Nikola Tesla (1856-1943) of Croatia (United States) 00178 const double T = V * s / (m*m); 00179 setVariable("tesla", T); 00180 setVariable("T", T); 00181 00182 // --- honors Karl Friedrich Gauss (1777-1855) of Germany 00183 const double Gs = 1.e-4*T; 00184 setVariable("gauss", Gs); 00185 setVariable("Gs", Gs); 00186 00187 // Magnetic flux 00188 // --- honors Wilhelm Eduard Weber (1804-1891) of Germany 00189 const double Wb = V * s; 00190 setVariable("weber", Wb); 00191 setVariable("Wb", Wb); 00192 00193 // Inductance 00194 // --- honors Joseph Henry (1797-1878) of the United States 00195 const double H = Wb / A; 00196 setVariable("henry", H); 00197 setVariable("H", H); 00198 00199 // Luminous flux 00200 const double lm = cd * sr; 00201 setVariable("lumen", lm); 00202 setVariable("lm", lm); 00203 00204 // Illuminace 00205 const double lx = lm / (m*m); 00206 setVariable("lux", lx); 00207 setVariable("lx", lx); 00208 00209 // Radioactivity 00210 // --- honors Antoine-Henri Becquerel (1852-1908) of France 00211 const double Bq = 1./s; 00212 setVariable("becquerel", Bq); 00213 setVariable("Bq", Bq); 00214 00215 // --- honors Pierre Curie (1859-1906) of France 00216 // and Marie Sklodowska Curie (1867-1934) of Poland 00217 setVariable("curie", 3.7e+10 * Bq); 00218 setVariable("Ci", 3.7e+10 * Bq); 00219 00220 // Specific energy 00221 // --- honors Louis Harold Gray, F.R.S. (1905-1965) of England 00222 const double Gy = J / kg; 00223 setVariable("gray", Gy); 00224 setVariable("Gy", Gy); 00225 00226 // Dose equivalent 00227 const double Sv = J / kg; 00228 setVariable("sievert", Sv); 00229 setVariable("Sv", Sv); 00230 00231 // ====================================================================== 00232 // 00233 // Selected units: 00234 // 00235 // ====================================================================== 00236 00237 // Length 00238 00239 const double mm = milli_ * m; 00240 setVariable("millimeter", mm); 00241 setVariable("mm", mm); 00242 00243 const double cm = centi_ * m; 00244 setVariable("centimeter", cm); 00245 setVariable("cm", cm); 00246 00247 setVariable("decimeter", deci_ * m); 00248 00249 const double km = kilo_ * m; 00250 setVariable("kilometer", km); 00251 setVariable("km", km); 00252 00253 setVariable("micrometer", micro_ * m); 00254 setVariable("micron", micro_ * m); 00255 setVariable("nanometer", nano_ * m); 00256 00257 // --- honors Anders Jonas Angstrom (1814-1874) of Sweden 00258 setVariable("angstrom", 1.e-10 * m); 00259 00260 // --- honors Enrico Fermi (1901-1954) of Italy 00261 setVariable("fermi", 1.e-15 * m); 00262 00263 // Length^2 00264 00265 setVariable("m2", m*m); 00266 setVariable("mm2", mm*mm); 00267 setVariable("cm2", cm*cm); 00268 setVariable("km2", km*km); 00269 00270 const double barn = 1.e-28 * m*m; 00271 setVariable("barn", barn); 00272 setVariable("millibarn", milli_ * barn); 00273 setVariable("mbarn", milli_ * barn); 00274 setVariable("microbarn", micro_ * barn); 00275 setVariable("nanobarn", nano_ * barn); 00276 setVariable("picobarn", pico_ * barn); 00277 00278 // LengthL^3 00279 00280 setVariable("m3", m*m*m); 00281 setVariable("mm3", mm*mm*mm); 00282 setVariable("cm3", cm*cm*cm); 00283 setVariable("cc", cm*cm*cm); 00284 setVariable("km3", km*km*km); 00285 00286 const double L = 1.e-3*m*m*m; 00287 setVariable("liter", L); 00288 setVariable("litre", L); 00289 setVariable("L", L); 00290 setVariable("centiliter", centi_ * L); 00291 setVariable("cL", centi_ * L); 00292 setVariable("milliliter", milli_ * L); 00293 setVariable("mL", milli_ * L); 00294 00295 // Length^-1 00296 00297 const double dpt = 1./m; 00298 setVariable("diopter", dpt); 00299 setVariable("dioptre", dpt); 00300 setVariable("dpt", dpt); 00301 00302 // Mass 00303 00304 const double g = 0.001*kg; 00305 setVariable("gram", g); 00306 setVariable("g", g); 00307 setVariable("milligram", milli_ * g); 00308 setVariable("mg", milli_ * g); 00309 00310 // Time 00311 00312 setVariable("millisecond", milli_ * s); 00313 setVariable("ms", milli_ * s); 00314 setVariable("microsecond", micro_ * s); 00315 setVariable("nanosecond", nano_ * s); 00316 setVariable("ns", nano_ * s); 00317 setVariable("picosecond", pico_ * s); 00318 00319 // Current 00320 00321 setVariable("milliampere", milli_ * A); 00322 setVariable("mA", milli_ * A); 00323 setVariable("microampere", micro_ * A); 00324 setVariable("nanoampere", nano_ * A); 00325 00326 // Frequency 00327 00328 setVariable("kilohertz", kilo_ * Hz); 00329 setVariable("kHz", kilo_ * Hz); 00330 setVariable("megahertz", mega_ * Hz); 00331 setVariable("MHz", mega_ * Hz); 00332 00333 // Force 00334 setVariable("kilonewton", kilo_ * N); 00335 setVariable("kN", kilo_ * N); 00336 00337 // Pressure 00338 setVariable("kilobar", kilo_ * bar); 00339 setVariable("kbar", kilo_ * bar); 00340 setVariable("millibar", milli_ * bar); 00341 setVariable("mbar", milli_ * bar); 00342 00343 // Energy 00344 setVariable("kilojoule", kilo_ * J); 00345 setVariable("kJ", kilo_ * J); 00346 setVariable("megajoule", mega_ * J); 00347 setVariable("MJ", mega_ * J); 00348 setVariable("gigajoule", giga_ * J); 00349 setVariable("GJ", giga_ * J); 00350 00351 const double e_SI = 1.60217733e-19; // positron charge in coulomb 00352 const double ePlus = e_SI * C; // positron charge 00353 const double eV = ePlus * V; 00354 setVariable("electronvolt", eV); 00355 setVariable("eV", eV); 00356 setVariable("kiloelectronvolt", kilo_ * eV); 00357 setVariable("keV", kilo_ * eV); 00358 setVariable("megaelectronvolt", mega_ * eV); 00359 setVariable("MeV", mega_ * eV); 00360 setVariable("gigaelectronvolt", giga_ * eV); 00361 setVariable("GeV", giga_ * eV); 00362 setVariable("teraelectronvolt", tera_ * eV); 00363 setVariable("TeV", tera_ * eV); 00364 setVariable("petaelectronvolt", peta_ * eV); 00365 setVariable("PeV", peta_ * eV); 00366 00367 // Power 00368 setVariable("kilowatt", kilo_ * W); 00369 setVariable("kW", kilo_ * W); 00370 setVariable("megawatt", mega_ * W); 00371 setVariable("MW", mega_ * W); 00372 setVariable("gigawatt", giga_ * W); 00373 setVariable("GW", giga_ * W); 00374 00375 // Electric potential 00376 setVariable("kilovolt", kilo_ * V); 00377 setVariable("kV", kilo_ * V); 00378 setVariable("megavolt", mega_ * V); 00379 setVariable("MV", mega_ * V); 00380 00381 // Electric capacitance 00382 setVariable("millifarad", milli_ * F); 00383 setVariable("mF", milli_ * F); 00384 setVariable("microfarad", micro_ * F); 00385 setVariable("uF", micro_ * F); 00386 setVariable("nanofarad", nano_ * F); 00387 setVariable("nF", nano_ * F); 00388 setVariable("picofarad", pico_ * F); 00389 setVariable("pF", pico_ * F); 00390 00391 // Magnetic flux density 00392 setVariable("kilogauss", kilo_ * Gs); 00393 setVariable("kGs", kilo_ * Gs); 00394 } 00395 00396 } // namespace HepTool