Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

steamcalculator.h

00001 /* 00002 00003 freesteam - IAPWS-IF97 steam tables library 00004 Copyright (C) 2004-2005 John Pye 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 */ 00021 #ifndef STEAMCALCULATOR_H 00022 #define STEAMCALCULATOR_H 00023 00024 #include "designbycontract.h" 00025 #include "common.h" 00026 #include "steamcalculatorexception.h" 00027 #include "boundaries.h" 00028 #include "state.h" 00029 #include "zeroin.h" 00030 00031 typedef enum { STEAM_SUBCOOLED = 00032 0, STEAM_SUPERHEATED, STEAM_SATURATED, STEAM_SUPERCRITICAL, 00033 STEAM_STATE_UNKNOWN = -1 } SteamStateCode; 00034 00035 typedef enum { STEAM_TEMPERATURE = 00036 0, STEAM_PRESSURE, STEAM_VOLUME, STEAM_INTERNAL_ENERGY, 00037 STEAM_ENTHALPY, STEAM_ENTROPY } SteamPropertyCode; 00038 00082 00083 00093 class SteamCalculator:public DesignByContract { 00094 00095 public: 00096 00098 SteamCalculator(); 00099 00101 SteamCalculator(const SteamCalculator & original); 00102 00104 SteamCalculator const &operator=(SteamCalculator const &original); 00105 00106 // Destructor 00107 virtual ~SteamCalculator(); 00108 00109 // Defining state, simple methods 00110 00111 void set_pT(const Pressure &p, const Temperature &T, double x = 1.0); // pressure [MPa] 00112 00113 template<class F,class S> 00114 inline void set(const F &f, const S &s); 00115 00116 void setSatSteam_p(const Pressure &p); // p Pressure [MPa] 00117 void setSatWater_p(const Pressure &p); // p Pressure [MPa] 00118 void setSatWater_T(const Temperature &T); // T Temperature [K] 00119 void setSatSteam_T(const Temperature &T); // T Temperature [K] 00120 00121 void setB23_T(const Temperature &T); 00122 void setB23_p(const Pressure &p); 00123 00124 void setRegion1_pT(const Pressure &p, const Temperature &T); 00125 void setRegion2_pT(const Pressure &p, const Temperature &T); 00126 void setRegion4_Tx(const Temperature &T, const Num &x); 00127 void setRegion3_rhoT(const Density &rho, const Temperature &T); 00128 00129 bool isSet(void) const; 00130 00131 // Methods to return properties and state 00132 00133 int whichRegion(void) const; 00134 00135 SteamStateCode whichState(void); 00136 const char *SteamCalculator::whichStateStr(void); 00137 00138 Temperature temp() const; // Temperature 00139 Pressure pres() const; // Pressure 00140 Density dens() const; // Density 00141 00142 SpecificVolume specvol() const; // Specific volume 00143 SpecificEnergy specienergy() const; // Specific internal energy 00144 SpecificEntropy specentropy() const; // Specific entropy 00145 SpecificEnergy specenthalpy() const; // Specific entropy 00146 SpecHeatCap speccp() const; // Specific isobaric heat capacity [kJ/kgK] 00147 SpecHeatCap speccv() const; // Specific isochoric heat capacity [kJ/kgK] 00148 Num quality() const; // Steam quality 00149 DynamicViscosity dynvisc() const; // Dynamic viscosity, mu [Pa.s] 00150 Conductivity conductivity() const; // Conductivity 00151 00152 // Design by contract stuff... 00153 virtual bool isValid(void) const; 00154 00156 virtual void copy(const SteamCalculator & original); 00157 00158 protected: 00159 00160 Num tau_iaps85() const; 00161 Num del_iaps85() const; 00162 Num pi_iaps85() const; 00163 Num delpi_iaps85() const; 00164 Num pitau_iaps85() const; 00165 00166 Num lam() const; // for thermal conductivity. 00167 Num lam0() const; 00168 Num lam1() const; 00169 Num lam2() const; 00170 00171 Num mu() const; 00172 Num mu0() const; 00173 Num mu1() const; 00174 Num mu2() const; 00175 00176 Pressure getRegion3PressureError(const Density &test_rho); 00177 00178 // All the intrinsic properties must be stored here because the states are singletons to save memory. 00179 00180 Temperature T; 00181 Pressure p; 00182 Density rho; 00183 Num x; 00184 00185 Num tau; 00186 Num pi; 00187 Num del; 00188 Pressure reg3_target_pressure; 00189 00190 private: 00191 friend class SteamState; 00192 friend class Region1; 00193 friend class Region2; 00194 friend class Region3; 00195 friend class Region4; 00196 friend class ZeroIn<SteamCalculator, Pressure, Density>; 00197 00198 bool isset; 00199 00200 void changeState(SteamState * state); 00201 00202 void destroy(); 00203 00204 SteamState *_state; 00205 00206 SteamCalculator *gas; // for use in two-phase calcs 00207 SteamCalculator *liq; // for use in two-phase calcs 00208 00209 }; 00210 00211 template<> 00212 inline void 00213 SteamCalculator::set<Pressure,Temperature>(const Pressure &p, const Temperature &T){ 00214 set_pT(p,T); 00215 } 00216 00217 template<> 00218 inline void 00219 SteamCalculator::set<Temperature,Pressure>(const Temperature &T, const Pressure &p){ 00220 set_pT(p,T); 00221 } 00222 00223 #endif

Generated on Tue Mar 22 19:07:05 2005 for freesteam by doxygen 1.3.8