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 <memory>
5
6class Point {
7 public:
8 Point(double x, double y) : x_(x), y_(y) {}
9
10 double getX() const { return x_; }
11
12 double getY() const { return y_; }
13
14 private:
15 double x_, y_;
16};
17
19 public:
36 SteamPropertiesOutput(const double temperature, const double pressure, const double quality,
37 const double specificVolume, const double density, const double specificEnthalpy,
38 const double specificEntropy, const double internalEnergy = 0,
39 const double specificIsobaricHeatCapacity_cp = 0, const double specificIsochoricHeatCapacity_cv = 0,
40 const double speedOfSound_w = 0, const double isentropicExponent = 0)
41 : temperature(temperature), pressure(pressure), quality(quality), specificVolume(specificVolume),
42 density(density), specificEnthalpy(specificEnthalpy), specificEntropy(specificEntropy),
43 internalEnergy(internalEnergy),
44 specificIsobaricHeatCapacity_cp(specificIsobaricHeatCapacity_cp), specificIsochoricHeatCapacity_cv(specificIsochoricHeatCapacity_cv),
45 speedOfSound_w(speedOfSound_w), isentropicExponent(isentropicExponent){}
46
47 friend std::ostream& operator<<(std::ostream& stream, const SteamPropertiesOutput& props);
48
49 SteamPropertiesOutput() = default;
50
51 double temperature = 0, pressure = 0, quality = 0, specificVolume = 0, density = 0;
52 double specificEnthalpy = 0, specificEntropy = 0, internalEnergy = 0;
53 double specificIsobaricHeatCapacity_cp = 0, specificIsochoricHeatCapacity_cv = 0, speedOfSound_w = 0, isentropicExponent = 0;
54 };
55
71 SaturatedPropertiesOutput(const double temperature, const double pressure, const double gasSpecificVolume,
72 const double gasSpecificEnthalpy, const double gasSpecificEntropy,
73 const double liquidSpecificVolume, const double liquidSpecificEnthalpy,
74 const double liquidSpecificEntropy, const double evaporationSpecificVolume,
75 const double evaporationSpecificEnthalpy, const double evaporationSpecificEntropy)
76 : temperature(temperature), pressure(pressure), gasSpecificVolume(gasSpecificVolume),
77 gasSpecificEnthalpy(gasSpecificEnthalpy), gasSpecificEntropy(gasSpecificEntropy),
78 liquidSpecificVolume(liquidSpecificVolume), liquidSpecificEnthalpy(liquidSpecificEnthalpy),
79 liquidSpecificEntropy(liquidSpecificEntropy), evaporationSpecificVolume(evaporationSpecificVolume),
80 evaporationSpecificEnthalpy(evaporationSpecificEnthalpy),
81 evaporationSpecificEntropy(evaporationSpecificEntropy) {}
82
83 SaturatedPropertiesOutput() = default;
84
85 double temperature = 0, pressure = 0;
86 double gasSpecificVolume = 0, gasSpecificEnthalpy = 0, gasSpecificEntropy = 0;
87 double liquidSpecificVolume = 0, liquidSpecificEnthalpy = 0, liquidSpecificEntropy = 0;
88 double evaporationSpecificVolume = 0, evaporationSpecificEnthalpy = 0, evaporationSpecificEntropy = 0;
89 };
90
105 FluidProperties(const double massFlow, const double energyFlow, const double temperature, const double pressure,
106 const double quality, const double specificVolume, const double density,
107 const double specificEnthalpy, const double specificEntropy, const double internalEnergy = 0)
108 : SteamPropertiesOutput(temperature, pressure, quality, specificVolume, density, specificEnthalpy,
109 specificEntropy, internalEnergy),
110 massFlow(massFlow), energyFlow(energyFlow) {}
111
112 FluidProperties(const double massFlow, const double energyFlow, SteamPropertiesOutput const& sp)
113 : SteamPropertiesOutput(sp.temperature, sp.pressure, sp.quality, sp.specificVolume, sp.density,
114 sp.specificEnthalpy, sp.specificEntropy, sp.internalEnergy),
115 massFlow(massFlow), energyFlow(energyFlow) {}
116
117 friend std::ostream& operator<<(std::ostream& stream, const FluidProperties& props);
118 friend std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<FluidProperties>& props);
119
120 FluidProperties() = default;
121
122 double massFlow = 0, energyFlow = 0;
123 };
124
125 enum class Key { ENTHALPY, ENTROPY };
126
127 enum class Region { REGION1, REGION2A, REGION2B, REGION2C };
128
129 private:
130 static void checkIsentropicExponentLimits(double& k);
131
138 static int regionSelect(double pressure, double temperature);
139
148 static SteamPropertiesOutput region1(double temperature, double pressure);
149
158 static SteamPropertiesOutput region2(double temperature, double pressure);
159
168 static SteamPropertiesOutput region3(double temperature, double pressure);
169
170 static SteamPropertiesOutput region3Density(double density, double temperature);
171
179 static double region4(double temperature);
180
189 static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy);
190
199 static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy);
200
209 static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy);
210
219 static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy);
220
229 static double backwardPressureEntropyRegion2A(double pressure, double entropy);
230
239 static double backwardPressureEntropyRegion2B(double pressure, double entropy);
240
249 static double backwardPressureEntropyRegion2C(double pressure, double entropy);
250
259 static double backwardPressureEntropyRegion1(double pressure, double entropy);
260
271 static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2);
272
282 static double linearTestPoint(double X, Point point1, Point point2);
283
284 static double backwardRegion3Exact(double pressure, double X, SteamSystemModelerTool::Key key);
285
292 static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy);
293
300 static double backwardPressureEntropyRegion3(double pressure, double entropy);
301
302 static double backwardPressureEnthalpyRegion1Exact(double pressure, double enthalpy);
303
304 static double backwardPressureEntropyRegion1Exact(double pressure, double entropy);
305
312 static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy);
313
320 static double backwardPressureEntropyRegion2AExact(double pressure, double entropy);
321
328 static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy);
329
336 static double backwardPressureEntropyRegion2BExact(double pressure, double entropy);
337
344 static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy);
345
352 static double backwardPressureEntropyRegion2CExact(double pressure, double entropy);
353
363 static double backwardExact(int region, SteamSystemModelerTool::Key key,
364 SteamSystemModelerTool::Region regionFunction, double pressure, double var2);
365
366 // constants
367
371 static constexpr double PRESSURE_MIN = 0.00061;
375 static constexpr double TEMPERATURE_MIN = 273.15;
379 static constexpr double PRESSURE_Tp = 16.5291643;
380
384 static constexpr double TEMPERATURE_Tp = 623.15;
385
389 static constexpr double PRESSURE_CRIT = 22.064;
390
394 static constexpr double TEMPERATURE_CRIT = 647.096;
395
399 static constexpr double PRESSURE_MAX = 100;
400
404 static constexpr double TEMPERATURE_MAX = 1073.15;
405
409 static constexpr double TEMPERATURE_REGION3_MAX = 863.15;
410
414 static constexpr double TEMPERATURE_REGION5_MAX = 2273.15;
415
419 static constexpr double PRESSURE_REGION5_MAX = 50;
420
427 static inline double boundaryByTemperatureRegion3to2(const double t) {
428 return 0.34805185628969E+03 - 0.11671859879975E+01 * t + 0.10192970039326E-02 * std::pow(t, 2.0);
429 }
430
438 static inline double boundaryByPressureRegion3to2(const double p) {
439 return 0.57254459862746E+03 + std::pow((p - 0.13918839778870E+02) / 0.10192970039326E-02, 0.5);
440 }
441
442 friend class SteamProperties;
443 friend class SaturatedProperties;
444};
445
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 constexpr double TEMPERATURE_REGION5_MAX
static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2)
static constexpr double PRESSURE_REGION5_MAX
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)