MEASUR-Tools-Suite v1.0.11
The MEASUR Tools Suite is a collection of industrial efficiency calculations written in C++ and with bindings for compilation to WebAssembly.
Loading...
Searching...
No Matches
SteamSystemModelerTool.h
1#pragma once
2
3#include <cmath>
4#include <iostream>
5#include <memory>
6#include <string>
7
8class Point {
9 public:
10 Point(double x, double y) : x_(x), y_(y) {}
11
12 double getX() const { return x_; }
13
14 double getY() const { return y_; }
15
16 private:
17 double x_, y_;
18};
19
21 public:
34 SteamPropertiesOutput(const double temperature, const double pressure, const double quality,
35 const double specificVolume, const double density, const double specificEnthalpy,
36 const double specificEntropy, const double internalEnergy = 0)
37 : temperature(temperature), pressure(pressure), quality(quality), specificVolume(specificVolume),
38 density(density), specificEnthalpy(specificEnthalpy), specificEntropy(specificEntropy),
39 internalEnergy(internalEnergy) {}
40
41 friend std::ostream& operator<<(std::ostream& stream, const SteamPropertiesOutput& props);
42
43 SteamPropertiesOutput() = default;
44
45 double temperature = 0, pressure = 0, quality = 0, specificVolume = 0, density = 0;
46 double specificEnthalpy = 0, specificEntropy = 0, internalEnergy = 0;
47 };
48
64 SaturatedPropertiesOutput(const double temperature, const double pressure, const double gasSpecificVolume,
65 const double gasSpecificEnthalpy, const double gasSpecificEntropy,
66 const double liquidSpecificVolume, const double liquidSpecificEnthalpy,
67 const double liquidSpecificEntropy, const double evaporationSpecificVolume,
68 const double evaporationSpecificEnthalpy, const double evaporationSpecificEntropy)
69 : temperature(temperature), pressure(pressure), gasSpecificVolume(gasSpecificVolume),
70 gasSpecificEnthalpy(gasSpecificEnthalpy), gasSpecificEntropy(gasSpecificEntropy),
71 liquidSpecificVolume(liquidSpecificVolume), liquidSpecificEnthalpy(liquidSpecificEnthalpy),
72 liquidSpecificEntropy(liquidSpecificEntropy), evaporationSpecificVolume(evaporationSpecificVolume),
73 evaporationSpecificEnthalpy(evaporationSpecificEnthalpy),
74 evaporationSpecificEntropy(evaporationSpecificEntropy) {}
75
76 SaturatedPropertiesOutput() = default;
77
78 double temperature = 0, pressure = 0;
79 double gasSpecificVolume = 0, gasSpecificEnthalpy = 0, gasSpecificEntropy = 0;
80 double liquidSpecificVolume = 0, liquidSpecificEnthalpy = 0, liquidSpecificEntropy = 0;
81 double evaporationSpecificVolume = 0, evaporationSpecificEnthalpy = 0, evaporationSpecificEntropy = 0;
82 };
83
98 FluidProperties(const double massFlow, const double energyFlow, const double temperature, const double pressure,
99 const double quality, const double specificVolume, const double density,
100 const double specificEnthalpy, const double specificEntropy, const double internalEnergy = 0)
101 : SteamPropertiesOutput(temperature, pressure, quality, specificVolume, density, specificEnthalpy,
102 specificEntropy, internalEnergy),
103 massFlow(massFlow), energyFlow(energyFlow) {}
104
105 FluidProperties(const double massFlow, const double energyFlow, SteamPropertiesOutput const& sp)
106 : SteamPropertiesOutput(sp.temperature, sp.pressure, sp.quality, sp.specificVolume, sp.density,
107 sp.specificEnthalpy, sp.specificEntropy, sp.internalEnergy),
108 massFlow(massFlow), energyFlow(energyFlow) {}
109
110 friend std::ostream& operator<<(std::ostream& stream, const FluidProperties& props);
111 friend std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<FluidProperties>& props);
112
113 FluidProperties() = default;
114
115 double massFlow = 0, energyFlow = 0;
116 };
117
118 enum class Key { ENTHALPY, ENTROPY };
119
120 enum class Region { REGION1, REGION2A, REGION2B, REGION2C };
121
122 private:
129 static int regionSelect(double pressure, double temperature);
130
139 static SteamPropertiesOutput region1(double temperature, double pressure);
140
149 static SteamPropertiesOutput region2(double temperature, double pressure);
150
159 static SteamPropertiesOutput region3(double temperature, double pressure);
160
161 static SteamPropertiesOutput region3Density(double density, double temperature);
162
171 static double region4(double temperature);
172
181 static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy);
182
191 static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy);
192
201 static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy);
202
211 static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy);
212
221 static double backwardPressureEntropyRegion2A(double pressure, double entropy);
222
231 static double backwardPressureEntropyRegion2B(double pressure, double entropy);
232
241 static double backwardPressureEntropyRegion2C(double pressure, double entropy);
242
251 static double backwardPressureEntropyRegion1(double pressure, double entropy);
252
263 static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2);
264
274 static double linearTestPoint(double X, Point point1, Point point2);
275
276 static double backwardRegion3Exact(double pressure, double X, SteamSystemModelerTool::Key key);
277
284 static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy);
285
293 static double backwardPressureEntropyRegion3(double pressure, double entropy);
294
295 static double backwardPressureEnthalpyRegion1Exact(double pressure, double enthalpy);
296
297 static double backwardPressureEntropyRegion1Exact(double pressure, double entropy);
298
305 static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy);
306
313 static double backwardPressureEntropyRegion2AExact(double pressure, double entropy);
314
321 static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy);
322
329 static double backwardPressureEntropyRegion2BExact(double pressure, double entropy);
330
337 static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy);
338
345 static double backwardPressureEntropyRegion2CExact(double pressure, double entropy);
346
356 static double backwardExact(int region, SteamSystemModelerTool::Key key,
357 SteamSystemModelerTool::Region regionFunction, double pressure, double var2);
358
359 // constants
360
364 static constexpr double PRESSURE_MIN = 0.01;
368 static constexpr double TEMPERATURE_MIN = 273.15;
372 static constexpr double PRESSURE_Tp = 16.5291643;
373
377 static constexpr double TEMPERATURE_Tp = 623.15;
378
382 static constexpr double PRESSURE_CRIT = 22.064;
383
387 static constexpr double TEMPERATURE_CRIT = 647.096;
388
392 static constexpr double PRESSURE_MAX = 100;
393
397 static constexpr double TEMPERATURE_MAX = 1073.15;
398
402 static constexpr double TEMPERATURE_REGION3_MAX = 863.15;
403
410 static inline double boundaryByTemperatureRegion3to2(const double t) {
411 return 0.34805185628969E+03 - 0.11671859879975E+01 * t + 0.10192970039326E-02 * std::pow(t, 2.0);
412 }
413
421 static inline double boundaryByPressureRegion3to2(const double p) {
422 return 0.57254459862746E+03 + std::pow((p - 0.13918839778870E+02) / 0.10192970039326E-02, 0.5);
423 }
424
425 friend class SteamProperties;
426 friend class SaturatedProperties;
427};
428
static double backwardPressureEntropyRegion2BExact(double pressure, double entropy)
static double backwardPressureEntropyRegion2A(double pressure, double entropy)
static SteamPropertiesOutput region2(double temperature, double pressure)
static SteamPropertiesOutput region3(double temperature, double pressure)
static constexpr double TEMPERATURE_REGION3_MAX
static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy)
static constexpr double TEMPERATURE_MIN
static SteamPropertiesOutput region1(double temperature, double pressure)
static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy)
static double backwardPressureEntropyRegion2CExact(double pressure, double entropy)
static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy)
static double linearTestPoint(double X, Point point1, Point point2)
static double boundaryByPressureRegion3to2(const double p)
static constexpr double TEMPERATURE_CRIT
static double backwardPressureEntropyRegion2AExact(double pressure, double entropy)
static double backwardPressureEntropyRegion3(double pressure, double entropy)
static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy)
static double region4(double temperature)
static constexpr double PRESSURE_CRIT
static double backwardPressureEntropyRegion1(double pressure, double entropy)
static constexpr double PRESSURE_MAX
static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy)
static int regionSelect(double pressure, double temperature)
static constexpr double PRESSURE_Tp
static constexpr double PRESSURE_MIN
static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2)
static double backwardPressureEntropyRegion2B(double pressure, double entropy)
static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy)
static constexpr double TEMPERATURE_Tp
static double backwardExact(int region, SteamSystemModelerTool::Key key, SteamSystemModelerTool::Region regionFunction, double pressure, double var2)
static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy)
static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy)
static constexpr double TEMPERATURE_MAX
static double boundaryByTemperatureRegion3to2(const double t)
static double backwardPressureEntropyRegion2C(double pressure, double entropy)