setSystemOfUnits.cc

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

Generated on Mon May 27 17:50:34 2013 for Geant4 by  doxygen 1.4.7