Energy.h

Go to the documentation of this file.
00001 
00007 /* Copyright (C) 2002 - 2009, Bernd Speiser */
00008 /* This file is part of Quantities.
00009 
00010 PhysicalQuantities is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 PhysicalQuantities is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019   
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00023 02111-1307, USA.
00024 */
00025 
00026 #ifndef _Energy_h
00027 #define _Energy_h
00028 
00029 // Quantity includes
00030 #include "Quantity/Variable.h"
00031 #include "Quantity/Constant.h"
00032 #include "Quantity/QuantityCluster.h"
00033 
00034 namespace quantity {
00035   namespace energy {
00036 
00038 class Class;
00039 
00041 class Unit;
00042 
00043 /* declaration of Energy units */
00044 class JouleUnits;
00045 class ErgUnit;
00046 class HartreeUnit;
00047 class RydbergUnit;
00048 class ElectronVoltUnit;
00049 class ThermochemicalCaloryUnit;
00050 class InternationalCaloryUnit;
00051 class FifteenDegreeCaloryUnit;
00052 class LitreAtmosphereUnit;
00053 class BritishThermalUnitUnit;
00054 
00056 typedef unit::Prefixable<Unit, JouleUnits> Joules;
00057 
00059 typedef unit::Prefixed<Joules> Joule;
00060 
00062 typedef unit::Prefixed<Joules, unit::Kilo> KiloJoule;
00063 
00065 typedef unit::NonPrefixable<Unit, ErgUnit> Erg;
00066 
00068 typedef unit::NonPrefixable<Unit, HartreeUnit> Hartree;
00069 
00071 typedef unit::NonPrefixable<Unit, RydbergUnit> Rydberg;
00072 
00074 typedef unit::Prefixable<Unit, ElectronVoltUnit> ElectronVolts;
00075 
00077 typedef unit::NonPrefixable<Unit, ThermochemicalCaloryUnit> 
00078                                                    ThermochemicalCalory;
00079 
00081 typedef unit::NonPrefixable<Unit, InternationalCaloryUnit> 
00082                                                    InternationalCalory;
00083 
00085 typedef unit::NonPrefixable<Unit, FifteenDegreeCaloryUnit> 
00086                                                    FifteenDegreeCalory;
00087 
00089 typedef unit::NonPrefixable<Unit, LitreAtmosphereUnit> LitreAtmosphere;
00090 
00092 typedef unit::NonPrefixable<Unit, BritishThermalUnitUnit> 
00093                                                      BritishThermalUnit;
00094 
00096 typedef Loki::TL::Append<Joules::Units,
00097   LOKI_TYPELIST_9(Erg, Hartree, Rydberg, ElectronVolts::Units, 
00098     ThermochemicalCalory,
00099              InternationalCalory, FifteenDegreeCalory, LitreAtmosphere,
00100                                      BritishThermalUnit)>::Result Units;
00101 
00102 /* declare some abbreviated energy units */
00103 typedef Joule J;
00104 
00105 /* Energy Quantity */
00106 
00107 typedef Quantity<Class> Quantity;
00108 
00109 class DerivedEnergy;
00110 
00111   } // end namespace energy
00112 
00114 
00116   template<typename ST>
00117     struct Standard<energy::Joules, ST>
00118     {
00119       static const ST ratio;
00120       static const bool exact;
00121     };
00122 
00124 template<typename ST> const ST Standard<energy::Joules, ST>::ratio = 1.0;
00125 
00127 template<typename ST> const bool Standard<energy::Joules, ST>::exact = true;
00128 
00130 
00132   template<typename ST>
00133     struct Standard<energy::Erg, ST>
00134     {
00135       static const ST ratio;
00136       static const bool exact;
00137     };
00138 
00140 template<typename ST> const ST Standard<energy::Erg, ST>::ratio = 1.0e-7;
00141 
00143 template<typename ST> const bool Standard<energy::Erg, ST>::exact = true;
00144 
00146 
00148   template<typename ST>
00149     struct Standard<energy::Hartree, ST>
00150     {
00151       static const ST ratio;
00152       static const bool exact;
00153     };
00154 
00156 template<typename ST> const ST Standard<energy::Hartree, ST>::ratio = 4.35975e-18;
00157 
00159 template<typename ST> const bool Standard<energy::Hartree, ST>::exact = false;
00160 
00162 
00164   template<typename ST>
00165     struct Standard<energy::Rydberg, ST>
00166     {
00167       static const ST ratio;
00168       static const bool exact;
00169     };
00170 
00172 template<typename ST> const ST Standard<energy::Rydberg, ST>::ratio = 2.17987e-18;
00173 
00175 template<typename ST> const bool Standard<energy::Rydberg, ST>::exact = false;
00176 
00178 
00180   template<typename ST>
00181     struct Standard<energy::ElectronVolts, ST>
00182     {
00183       static const ST ratio;
00184       static const bool exact;
00185     };
00186 
00188 template<typename ST> const ST Standard<energy::ElectronVolts, ST>::ratio = 1.60218e-19;
00189 
00191 template<typename ST> const bool Standard<energy::ElectronVolts, ST>::exact = false;
00192 
00194 
00196   template<typename ST>
00197     struct Standard<energy::ThermochemicalCalory, ST>
00198     {
00199       static const ST ratio;
00200       static const bool exact;
00201     };
00202 
00204 template<typename ST> const ST Standard<energy::ThermochemicalCalory, ST>::ratio = 4.184;
00205 
00207 template<typename ST> const bool Standard<energy::ThermochemicalCalory, ST>::exact = true;
00208 
00210 
00212   template<typename ST>
00213     struct Standard<energy::InternationalCalory, ST>
00214     {
00215       static const ST ratio;
00216       static const bool exact;
00217     };
00218 
00220 template<typename ST> const ST Standard<energy::InternationalCalory, ST>::ratio = 4.1868;
00221 
00223 template<typename ST> const bool Standard<energy::InternationalCalory, ST>::exact = true;
00224 
00226 
00228   template<typename ST>
00229     struct Standard<energy::FifteenDegreeCalory, ST>
00230     {
00231       static const ST ratio;
00232       static const bool exact;
00233     };
00234 
00236 template<typename ST> const ST Standard<energy::FifteenDegreeCalory, ST>::ratio = 4.1855;
00237 
00239 template<typename ST> const bool Standard<energy::FifteenDegreeCalory, ST>::exact = false;
00240 
00242 
00244   template<typename ST>
00245     struct Standard<energy::LitreAtmosphere, ST>
00246     {
00247       static const ST ratio;
00248       static const bool exact;
00249     };
00250 
00252 template<typename ST> const ST Standard<energy::LitreAtmosphere, ST>::ratio = 101.325;
00253 
00255 template<typename ST> const bool Standard<energy::LitreAtmosphere, ST>::exact = true;
00256 
00258 
00260   template<typename ST>
00261     struct Standard<energy::BritishThermalUnit, ST>
00262     {
00263       static const ST ratio;
00264       static const bool exact;
00265     };
00266 
00268 template<typename ST> const ST Standard<energy::BritishThermalUnit, ST>::ratio = 1055.06;
00269 
00271 template<typename ST> const bool Standard<energy::BritishThermalUnit, ST>::exact = true;
00272 
00274 template<>
00275   struct QuantityTraits<energy::Class>
00276   {
00277     typedef
00278       dimension::Dimension<BSUtilities::Rational<2>,
00279         BSUtilities::Rational<1>, BSUtilities::Rational<-2>,
00280           BSUtilities::Rational<0>, BSUtilities::Rational<0>,
00281             BSUtilities::Rational<0>, BSUtilities::Rational<0> > Dimension;
00282     typedef energy::Unit UnitType;
00283     typedef energy::Units UnitList;
00284     typedef energy::Joule DefaultUnit;
00285 
00286     typedef energy::DerivedEnergy DefaultDerivedQuantityType;
00287 
00288     static const std::string NameString;
00289     static const std::string SymbolString;
00290 
00291   };
00292 
00293 // the derived quantity traits template for Joule Energy
00294 template<>
00295   struct DerivedQuantityTraits<energy::Class, energy::DerivedEnergy>
00296   {
00297     static const bool OverwriteName = false;
00298     static const bool OverwriteSymbol = false;
00299 
00300     static const std::string NameString;
00301     static const std::string SymbolString;
00302 
00303   };
00304 
00306 typedef Variable<energy::Quantity> Energy;
00307 
00309 typedef Constant<energy::Quantity> EnergyConstant;
00310 
00312 typedef QuantityVector<Variable, energy::Quantity> EnergyVector;
00313 
00314 } // end namespace quantity
00315 
00316 #endif /* _Energy_h */

Generated on Mon Jul 27 15:55:44 2009 for Quantities by  doxygen 1.5.3