00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef STEAMPROPERTY_H
00023 #define STEAMPROPERTY_H
00024
00025 #include "steamcalculator.h"
00026
00027 #ifndef NDEBUG
00028 #include <sstream>
00029 #include <stdexcept>
00030 #endif
00031
00033
00038 template<class Property,int PropertyAlternative=0>
00039 class SteamProperty{
00040 public:
00041 static inline Property get(const SteamCalculator &S);
00042 static const char *name();
00043
00044 static inline const bool plotOnLogAxis(){
00045 return false;
00046 }
00047 };
00048
00049
00050
00051
00052 template<>
00053 const char *
00054 SteamProperty<SpecificEnergy,SOLVE_IENERGY>::name();
00055
00056 template<>
00057 const char *
00058 SteamProperty<SpecificEnergy,SOLVE_ENTHALPY>::name();
00059
00060 template<>
00061 const char *
00062 SteamProperty<Density,0>::name();
00063
00064 template<>
00065 const char *
00066 SteamProperty<SpecificVolume,0>::name();
00067
00068 template<>
00069 const char *
00070 SteamProperty<Temperature,0>::name();
00071
00072 template<>
00073 const char *
00074 SteamProperty<Pressure,0>::name();
00075
00076 template<>
00077 const char *
00078 SteamProperty<SpecificEntropy,SOLVE_ENTROPY>::name();
00079
00080 template<>
00081 const char *
00082 SteamProperty<SpecHeatCap,SOLVE_CP>::name();
00083
00084 template<>
00085 const char *
00086 SteamProperty<SpecHeatCap,SOLVE_CV>::name();
00087
00088 template<>
00089 const char *
00090 SteamProperty<Num,0>::name();
00091
00092
00093
00094
00095
00096
00097
00098 template<>
00099 inline SpecificEnergy
00100 SteamProperty<SpecificEnergy,SOLVE_IENERGY>::get(const SteamCalculator &S){
00101 return S.specienergy();
00102 }
00103
00104 template<>
00105 inline SpecificEnergy
00106 SteamProperty<SpecificEnergy,SOLVE_ENTHALPY>::get(const SteamCalculator &S){
00107 return S.specenthalpy();
00108 }
00109
00110 template<>
00111 inline Density
00112 SteamProperty<Density,0>::get(const SteamCalculator &S){
00113 return S.dens();
00114 }
00115
00116 template<>
00117 inline SpecificVolume
00118 SteamProperty<SpecificVolume,0>::get(const SteamCalculator &S){
00119 return S.specvol();
00120 }
00121
00122 template<>
00123 inline Temperature
00124 SteamProperty<Temperature,0>::get(const SteamCalculator &S){
00125 return S.temp();
00126 }
00127
00128 template<>
00129 inline Pressure
00130 SteamProperty<Pressure,0>::get(const SteamCalculator &S){
00131 return S.pres();
00132 }
00133
00134 template<>
00135 inline SpecificEntropy
00136 SteamProperty<SpecificEntropy,SOLVE_ENTROPY>::get(const SteamCalculator &S){
00137 #ifndef NDEBUG
00138 try{
00139 #endif
00140
00141 return S.specentropy();
00142
00143 #ifndef NDEBUG
00144 }catch(std::exception &E){
00145 std::stringstream s;
00146 s << "SteamProperty<s>::get: " << E.what();
00147 throw std::runtime_error(s.str());
00148 }
00149 #endif
00150 }
00151
00152 template<>
00153 inline SpecHeatCap
00154 SteamProperty<SpecHeatCap,SOLVE_CP>::get(const SteamCalculator &S){
00155 return S.speccp();
00156 }
00157
00158 template<>
00159 inline SpecHeatCap
00160 SteamProperty<SpecHeatCap,SOLVE_CV>::get(const SteamCalculator &S){
00161 return S.speccv();
00162 }
00163
00164 template<>
00165 inline Num
00166 SteamProperty<Num,0>::get(const SteamCalculator &S){
00167 return S.quality();
00168 }
00169
00170 template<>
00171 inline
00172 const bool
00173 SteamProperty<SpecificVolume,0>::plotOnLogAxis(){
00174 return true;
00175 }
00176
00177 template<>
00178 inline
00179 const bool
00180 SteamProperty<Pressure,0>::plotOnLogAxis(){
00181 return true;
00182 }
00183
00184 #endif