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#ifndef TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H
2#define TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H
3
4#include <cmath>
5#include <iostream>
6#include <memory>
7#include <string>
8
9class Point {
10 public:
11 Point(double x, double y) : x_(x), y_(y) {}
12
13 double getX() const { return x_; }
14
15 double getY() const { return y_; }
16
17 private:
18 double x_, y_;
19};
20
22 public:
35 SteamPropertiesOutput(const double temperature, const double pressure, const double quality,
36 const double specificVolume, const double density, const double specificEnthalpy,
37 const double specificEntropy, const double internalEnergy = 0)
38 : temperature(temperature), pressure(pressure), quality(quality), specificVolume(specificVolume),
39 density(density), specificEnthalpy(specificEnthalpy), specificEntropy(specificEntropy),
40 internalEnergy(internalEnergy) {}
41
42 friend std::ostream& operator<<(std::ostream& stream, const SteamPropertiesOutput& props);
43
44 SteamPropertiesOutput() = default;
45
46 double temperature = 0, pressure = 0, quality = 0, specificVolume = 0, density = 0;
47 double specificEnthalpy = 0, specificEntropy = 0, internalEnergy = 0;
48 };
49
65 SaturatedPropertiesOutput(const double temperature, const double pressure, const double gasSpecificVolume,
66 const double gasSpecificEnthalpy, const double gasSpecificEntropy,
67 const double liquidSpecificVolume, const double liquidSpecificEnthalpy,
68 const double liquidSpecificEntropy, const double evaporationSpecificVolume,
69 const double evaporationSpecificEnthalpy, const double evaporationSpecificEntropy)
70 : temperature(temperature), pressure(pressure), gasSpecificVolume(gasSpecificVolume),
71 gasSpecificEnthalpy(gasSpecificEnthalpy), gasSpecificEntropy(gasSpecificEntropy),
72 liquidSpecificVolume(liquidSpecificVolume), liquidSpecificEnthalpy(liquidSpecificEnthalpy),
73 liquidSpecificEntropy(liquidSpecificEntropy), evaporationSpecificVolume(evaporationSpecificVolume),
74 evaporationSpecificEnthalpy(evaporationSpecificEnthalpy),
75 evaporationSpecificEntropy(evaporationSpecificEntropy) {}
76
77 SaturatedPropertiesOutput() = default;
78
79 double temperature = 0, pressure = 0;
80 double gasSpecificVolume = 0, gasSpecificEnthalpy = 0, gasSpecificEntropy = 0;
81 double liquidSpecificVolume = 0, liquidSpecificEnthalpy = 0, liquidSpecificEntropy = 0;
82 double evaporationSpecificVolume = 0, evaporationSpecificEnthalpy = 0, evaporationSpecificEntropy = 0;
83 };
84
99 FluidProperties(const double massFlow, const double energyFlow, const double temperature, const double pressure,
100 const double quality, const double specificVolume, const double density,
101 const double specificEnthalpy, const double specificEntropy, const double internalEnergy = 0)
102 : SteamPropertiesOutput(temperature, pressure, quality, specificVolume, density, specificEnthalpy,
103 specificEntropy, internalEnergy),
104 massFlow(massFlow), energyFlow(energyFlow) {}
105
106 FluidProperties(const double massFlow, const double energyFlow, SteamPropertiesOutput const& sp)
107 : SteamPropertiesOutput(sp.temperature, sp.pressure, sp.quality, sp.specificVolume, sp.density,
108 sp.specificEnthalpy, sp.specificEntropy, sp.internalEnergy),
109 massFlow(massFlow), energyFlow(energyFlow) {}
110
111 friend std::ostream& operator<<(std::ostream& stream, const FluidProperties& props);
112 friend std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<FluidProperties>& props);
113
114 FluidProperties() = default;
115
116 double massFlow = 0, energyFlow = 0;
117 };
118
119 enum class Key { ENTHALPY, ENTROPY };
120
121 enum class Region { REGION1, REGION2A, REGION2B, REGION2C };
122
123 private:
130 static int regionSelect(double pressure, double temperature);
131
140 static SteamPropertiesOutput region1(double temperature, double pressure);
141
150 static SteamPropertiesOutput region2(double temperature, double pressure);
151
160 static SteamPropertiesOutput region3(double temperature, double pressure);
161
162 static SteamPropertiesOutput region3Density(double density, double temperature);
163
172 static double region4(double temperature);
173
182 static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy);
183
192 static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy);
193
202 static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy);
203
212 static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy);
213
222 static double backwardPressureEntropyRegion2A(double pressure, double entropy);
223
232 static double backwardPressureEntropyRegion2B(double pressure, double entropy);
233
242 static double backwardPressureEntropyRegion2C(double pressure, double entropy);
243
252 static double backwardPressureEntropyRegion1(double pressure, double entropy);
253
264 static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2);
265
275 static double linearTestPoint(double X, Point point1, Point point2);
276
277 static double backwardRegion3Exact(double pressure, double X, SteamSystemModelerTool::Key key);
278
285 static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy);
286
294 static double backwardPressureEntropyRegion3(double pressure, double entropy);
295
296 static double backwardPressureEnthalpyRegion1Exact(double pressure, double enthalpy);
297
298 static double backwardPressureEntropyRegion1Exact(double pressure, double entropy);
299
306 static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy);
307
314 static double backwardPressureEntropyRegion2AExact(double pressure, double entropy);
315
322 static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy);
323
330 static double backwardPressureEntropyRegion2BExact(double pressure, double entropy);
331
338 static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy);
339
346 static double backwardPressureEntropyRegion2CExact(double pressure, double entropy);
347
357 static double backwardExact(int region, SteamSystemModelerTool::Key key,
358 SteamSystemModelerTool::Region regionFunction, double pressure, double var2);
359
360 // constants
361
365 static constexpr double PRESSURE_MIN = 0.01;
369 static constexpr double TEMPERATURE_MIN = 273.15;
373 static constexpr double PRESSURE_Tp = 16.5291643;
374
378 static constexpr double TEMPERATURE_Tp = 623.15;
379
383 static constexpr double PRESSURE_CRIT = 22.064;
384
388 static constexpr double TEMPERATURE_CRIT = 647.096;
389
393 static constexpr double PRESSURE_MAX = 100;
394
398 static constexpr double TEMPERATURE_MAX = 1073.15;
399
403 static constexpr double TEMPERATURE_REGION3_MAX = 863.15;
404
411 static inline double boundaryByTemperatureRegion3to2(const double t) {
412 return 0.34805185628969E+03 - 0.11671859879975E+01 * t + 0.10192970039326E-02 * std::pow(t, 2.0);
413 }
414
422 static inline double boundaryByPressureRegion3to2(const double p) {
423 return 0.57254459862746E+03 + std::pow((p - 0.13918839778870E+02) / 0.10192970039326E-02, 0.5);
424 }
425
426 friend class SteamProperties;
427 friend class SaturatedProperties;
428};
429
430#endif // TOOLS_SUITE_STEAMSYSTEMMODELERTOOL_H
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)