GasConstant.h

Go to the documentation of this file.
00001 
00008 /* Copyright (C) 2002 - 2009, Bernd Speiser */
00009 
00010 /* This file is part of Quantities.
00011 
00012 PhysicalQuantities is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU General Public License
00014 as published by the Free Software Foundation; either version 2
00015 of the License, or (at your option) any later version.
00016 
00017 PhysicalQuantities is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021   
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00025 02111-1307, USA.
00026 */
00027 
00028 #ifndef _GasConstant_h
00029 #define _GasConstant_h
00030 
00031 // Quantity includes
00032 #include "Quantity/UniqueConstant.h"
00033 #include "PhysicalQuantities/AmountOfSubstance.h"
00034 #include "PhysicalQuantities/Energy.h"
00035 #include "PhysicalQuantities/ThermodynamicTemperature.h"
00036 
00037 namespace quantity {
00038   namespace gasConstant {
00039 
00041 class Class;
00042 
00044 class Unit;
00045 
00046 /* the JoulePerKelvinMole and prefixed variants */
00047 
00048 typedef LOKI_TYPELIST_1(energy::Joule) EnergyList;
00049 
00051 typedef unit::ComposeElement<Unit, EnergyList,
00052                                BSUtilities::Rational<1> > EnergyElement;
00053 
00054 typedef LOKI_TYPELIST_2(amountOfSubstance::Mole,
00055                     amountOfSubstance::MilliMole) AmountOfSubstanceList;
00056 
00058 typedef unit::ComposeElement<Unit, AmountOfSubstanceList,
00059                    BSUtilities::Rational<-1> > AmountOfSubstanceElement;
00060 
00061 typedef LOKI_TYPELIST_1(thermodynamicTemperature::Kelvin) 
00062                                            ThermodynamicTemperatureList;
00063 
00065 typedef 
00066   unit::ComposeElement<Unit, ThermodynamicTemperatureList,
00067             BSUtilities::Rational<-1> > ThermodynamicTemperatureElement;
00068 
00069 typedef unit::ComposeBase<Unit, 
00070   LOKI_TYPELIST_3(EnergyElement, AmountOfSubstanceElement, 
00071               ThermodynamicTemperatureElement)> GasConstantComposedUnit;
00072 
00073 typedef unit::Composed<GasConstantComposedUnit, 
00074   LOKI_TYPELIST_3(energy::Joule, amountOfSubstance::Mole, 
00075                   thermodynamicTemperature::Kelvin)> JoulePerKelvinMole;
00076 
00078 typedef LOKI_TYPELIST_1(JoulePerKelvinMole) Units;
00079 
00080 /* GasConstant quantity */
00081 
00082 typedef Quantity<Class> Quantity;
00083 
00084 class DerivedGasConstant;
00085 
00086   } // end namespace gasConstant
00087 
00089 
00091   template<typename ST>
00092     struct Standard<gasConstant::GasConstantComposedUnit, ST>
00093     {
00094       static const ST ratio;
00095       static const bool exact;
00096     };
00097 
00099 template<typename ST> const ST Standard<gasConstant::GasConstantComposedUnit, ST>::ratio
00100                                                                                        = 1.0;
00101 
00103 template<typename ST> const bool Standard<gasConstant::GasConstantComposedUnit, ST>::exact
00104                                                                                        = true;
00105 
00107 template<>
00108   struct QuantityTraits<gasConstant::Class>
00109   {
00110     typedef
00111       dimension::Dimension<BSUtilities::Rational<2>,
00112         BSUtilities::Rational<1>, BSUtilities::Rational<-2>,
00113           BSUtilities::Rational<0>, BSUtilities::Rational<-1>,
00114             BSUtilities::Rational<-1>, BSUtilities::Rational<0> > Dimension;
00115     typedef gasConstant::Unit UnitType;
00116     typedef gasConstant::Units UnitList;
00117     typedef gasConstant::JoulePerKelvinMole DefaultUnit;
00118 
00119     typedef gasConstant::DerivedGasConstant DefaultDerivedQuantityType;
00120 
00121     static const std::string NameString;
00122     static const std::string SymbolString;
00123 
00124   };
00125 
00126 // the derived quantity traits template for joule per Kelvin mole gas constant
00127 template<>
00128   struct DerivedQuantityTraits<gasConstant::Class, gasConstant::DerivedGasConstant>
00129   {
00130     static const bool OverwriteName = false;
00131     static const bool OverwriteSymbol = false;
00132 
00133     static const std::string NameString;
00134     static const std::string SymbolString;
00135 
00136   };
00137 
00138 
00140 typedef Loki::SingletonHolder<UniqueConstant <gasConstant::Quantity> > GasConstant;
00141 
00143 #define GASCONSTANT GasConstant::Instance()
00144 
00145 } // end namespace quantity
00146 
00147 #endif /* _GasConstant_h */

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