AMO-Tools-Suite  v.0.9.0
Set of tools for calculating energy efficiency in industrial equipment
All Classes Namespaces Files Functions Variables Enumerations Friends Macros Pages
SteamSystemModelerTool.h
1 #ifndef AMO_TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H
2 #define AMO_TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H
3 
4 #include <cmath>
5 #include <memory>
6 #include <iostream>
7 #include <string>
8 
9 class Point {
10 public:
11  Point(double x, double y)
12  : x_(x), y_(y) {}
13 
14  double getX() const { return x_; }
15 
16  double getY() const { return y_; }
17 
18 private:
19  double x_, y_;
20 };
21 
22 
24 public:
36  struct SteamPropertiesOutput {
37  SteamPropertiesOutput(const double temperature, const double pressure, const double quality,
38  const double specificVolume, const double density, const double specificEnthalpy,
39  const double specificEntropy, const double internalEnergy = 0):
40  temperature(temperature), pressure(pressure), quality(quality), specificVolume(specificVolume),
41  density(density), specificEnthalpy(specificEnthalpy), specificEntropy(specificEntropy),
42  internalEnergy(internalEnergy)
43  {}
44 
45  friend std::ostream &operator<<(std::ostream &stream, const SteamPropertiesOutput &props);
46 
47  SteamPropertiesOutput() = default;
48 
49  double temperature = 0, pressure = 0, quality = 0, specificVolume = 0, density = 0;
50  double specificEnthalpy = 0, specificEntropy = 0, internalEnergy = 0;
51  };
52 
67  struct SaturatedPropertiesOutput {
68  SaturatedPropertiesOutput(const double temperature, const double pressure,
69  const double gasSpecificVolume, const double gasSpecificEnthalpy, const double gasSpecificEntropy,
70  const double liquidSpecificVolume, const double liquidSpecificEnthalpy, const double liquidSpecificEntropy,
71  const double evaporationSpecificVolume, const double evaporationSpecificEnthalpy, const double evaporationSpecificEntropy):
72  temperature(temperature), pressure(pressure),
73  gasSpecificVolume(gasSpecificVolume), gasSpecificEnthalpy(gasSpecificEnthalpy), gasSpecificEntropy(gasSpecificEntropy),
74  liquidSpecificVolume(liquidSpecificVolume), liquidSpecificEnthalpy(liquidSpecificEnthalpy), liquidSpecificEntropy(liquidSpecificEntropy),
75  evaporationSpecificVolume(evaporationSpecificVolume), evaporationSpecificEnthalpy(evaporationSpecificEnthalpy), evaporationSpecificEntropy(evaporationSpecificEntropy)
76  {}
77 
78  SaturatedPropertiesOutput() = default;
79 
80  double temperature = 0, pressure = 0;
81  double gasSpecificVolume = 0, gasSpecificEnthalpy = 0, gasSpecificEntropy = 0;
82  double liquidSpecificVolume = 0, liquidSpecificEnthalpy = 0, liquidSpecificEntropy = 0;
83  double evaporationSpecificVolume = 0, evaporationSpecificEnthalpy = 0, evaporationSpecificEntropy = 0;
84  };
85 
99  struct FluidProperties: public SteamPropertiesOutput {
100  FluidProperties(const double massFlow, const double energyFlow, const double temperature, const double pressure,
101  const double quality, const double specificVolume, const double density, const double specificEnthalpy,
102  const double specificEntropy, const double internalEnergy = 0):
103  SteamPropertiesOutput(temperature, pressure, quality, specificVolume, density, specificEnthalpy,
104  specificEntropy, internalEnergy),
105  massFlow(massFlow), energyFlow(energyFlow)
106  {}
107 
108  FluidProperties(const double massFlow, const double energyFlow, SteamPropertiesOutput const & sp):
109  SteamPropertiesOutput(sp.temperature, sp.pressure, sp.quality, sp.specificVolume, sp.density,
110  sp.specificEnthalpy, sp.specificEntropy, sp.internalEnergy),
111  massFlow(massFlow), energyFlow(energyFlow)
112  {}
113 
114  friend std::ostream &operator<<(std::ostream &stream, const FluidProperties &props);
115  friend std::ostream &operator<<(std::ostream &stream, const std::shared_ptr<FluidProperties> &props);
116 
117  FluidProperties() = default;
118 
119  double massFlow = 0, energyFlow = 0;
120  };
121 
122  enum class Key{
123  ENTHALPY,
124  ENTROPY
125  };
126 
127  enum class Region{
128  REGION1,
129  REGION2A,
130  REGION2B,
131  REGION2C
132  };
133 
134 private:
135 
142  static int regionSelect(double pressure, double temperature);
143 
152  static SteamPropertiesOutput region1(double temperature, double pressure);
153 
162  static SteamPropertiesOutput region2(double temperature, double pressure);
163 
172  static SteamPropertiesOutput region3(double temperature, double pressure);
173 
174  static SteamPropertiesOutput region3Density(double density, double temperature);
175 
184  static double region4(double temperature);
185 
194  static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy);
195 
204  static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy);
205 
214  static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy);
215 
224  static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy);
225 
234  static double backwardPressureEntropyRegion2A(double pressure, double entropy);
235 
244  static double backwardPressureEntropyRegion2B(double pressure, double entropy);
245 
254  static double backwardPressureEntropyRegion2C(double pressure, double entropy);
255 
264  static double backwardPressureEntropyRegion1(double pressure, double entropy);
265 
276  static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2);
277 
287  static double linearTestPoint(double X, Point point1, Point point2);
288 
289 
290  static double backwardRegion3Exact(double pressure, double X, SteamSystemModelerTool::Key key);
291 
298  static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy);
299 
307  static double backwardPressureEntropyRegion3(double pressure, double entropy);
308 
309  static double backwardPressureEnthalpyRegion1Exact(double pressure, double enthalpy);
310 
311  static double backwardPressureEntropyRegion1Exact(double pressure, double entropy);
312 
319  static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy);
320 
327  static double backwardPressureEntropyRegion2AExact(double pressure, double entropy);
328 
335  static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy);
336 
343  static double backwardPressureEntropyRegion2BExact(double pressure, double entropy);
344 
351  static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy);
352 
359  static double backwardPressureEntropyRegion2CExact(double pressure, double entropy);
360 
370  static double backwardExact(int region, SteamSystemModelerTool::Key key, SteamSystemModelerTool::Region regionFunction , double pressure, double var2);
371 
372  // constants
373 
377  static constexpr double PRESSURE_MIN = 0.01;
381  static constexpr double TEMPERATURE_MIN = 273.15;
385  static constexpr double PRESSURE_Tp = 16.5291643;
386 
390  static constexpr double TEMPERATURE_Tp = 623.15;
391 
395  static constexpr double PRESSURE_CRIT = 22.064;
396 
400  static constexpr double TEMPERATURE_CRIT = 647.096;
401 
405  static constexpr double PRESSURE_MAX = 100;
406 
410  static constexpr double TEMPERATURE_MAX = 1073.15;
411 
415  static constexpr double TEMPERATURE_REGION3_MAX = 863.15;
416 
423  static inline double boundaryByTemperatureRegion3to2(const double t) {
424  return 0.34805185628969E+03 - 0.11671859879975E+01 * t + 0.10192970039326E-02 * std::pow(t, 2.0);
425  }
426 
434  static inline double boundaryByPressureRegion3to2(const double p) {
435  return 0.57254459862746E+03 + std::pow((p - 0.13918839778870E+02) / 0.10192970039326E-02, 0.5);
436  }
437 
438  friend class SteamProperties;
439  friend class SaturatedProperties;
440 };
441 
442 
443 #endif //AMO_TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H