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:
38 SteamPropertiesOutput(const double temperature, const double pressure, const double quality,
39 const double specificVolume, const double density, const double specificEnthalpy,
40 const double specificEntropy, const double internalEnergy = 0,
41 const double specificIsobaricHeatCapacity_cp = 0, const double specificIsochoricHeatCapacity_cv = 0,
42 const double speedOfSound_w = 0, const double isentropicExponent = 0)
43 : temperature(temperature), pressure(pressure), quality(quality), specificVolume(specificVolume),
44 density(density), specificEnthalpy(specificEnthalpy), specificEntropy(specificEntropy),
45 internalEnergy(internalEnergy),
46 specificIsobaricHeatCapacity_cp(specificIsobaricHeatCapacity_cp), specificIsochoricHeatCapacity_cv(specificIsochoricHeatCapacity_cv),
47 speedOfSound_w(speedOfSound_w), isentropicExponent(isentropicExponent){}
48
49 friend std::ostream& operator<<(std::ostream& stream, const SteamPropertiesOutput& props);
50
51 SteamPropertiesOutput() = default;
52
53 double temperature = 0, pressure = 0, quality = 0, specificVolume = 0, density = 0;
54 double specificEnthalpy = 0, specificEntropy = 0, internalEnergy = 0;
55 double specificIsobaricHeatCapacity_cp = 0, specificIsochoricHeatCapacity_cv = 0, speedOfSound_w = 0, isentropicExponent = 0;
56 };
57
73 SaturatedPropertiesOutput(const double temperature, const double pressure, const double gasSpecificVolume,
74 const double gasSpecificEnthalpy, const double gasSpecificEntropy,
75 const double liquidSpecificVolume, const double liquidSpecificEnthalpy,
76 const double liquidSpecificEntropy, const double evaporationSpecificVolume,
77 const double evaporationSpecificEnthalpy, const double evaporationSpecificEntropy)
78 : temperature(temperature), pressure(pressure), gasSpecificVolume(gasSpecificVolume),
79 gasSpecificEnthalpy(gasSpecificEnthalpy), gasSpecificEntropy(gasSpecificEntropy),
80 liquidSpecificVolume(liquidSpecificVolume), liquidSpecificEnthalpy(liquidSpecificEnthalpy),
81 liquidSpecificEntropy(liquidSpecificEntropy), evaporationSpecificVolume(evaporationSpecificVolume),
82 evaporationSpecificEnthalpy(evaporationSpecificEnthalpy),
83 evaporationSpecificEntropy(evaporationSpecificEntropy) {}
84
85 SaturatedPropertiesOutput() = default;
86
87 double temperature = 0, pressure = 0;
88 double gasSpecificVolume = 0, gasSpecificEnthalpy = 0, gasSpecificEntropy = 0;
89 double liquidSpecificVolume = 0, liquidSpecificEnthalpy = 0, liquidSpecificEntropy = 0;
90 double evaporationSpecificVolume = 0, evaporationSpecificEnthalpy = 0, evaporationSpecificEntropy = 0;
91 };
92
107 FluidProperties(const double massFlow, const double energyFlow, const double temperature, const double pressure,
108 const double quality, const double specificVolume, const double density,
109 const double specificEnthalpy, const double specificEntropy, const double internalEnergy = 0)
110 : SteamPropertiesOutput(temperature, pressure, quality, specificVolume, density, specificEnthalpy,
111 specificEntropy, internalEnergy),
112 massFlow(massFlow), energyFlow(energyFlow) {}
113
114 FluidProperties(const double massFlow, const double energyFlow, SteamPropertiesOutput const& sp)
115 : SteamPropertiesOutput(sp.temperature, sp.pressure, sp.quality, sp.specificVolume, sp.density,
116 sp.specificEnthalpy, sp.specificEntropy, sp.internalEnergy),
117 massFlow(massFlow), energyFlow(energyFlow) {}
118
119 friend std::ostream& operator<<(std::ostream& stream, const FluidProperties& props);
120 friend std::ostream& operator<<(std::ostream& stream, const std::shared_ptr<FluidProperties>& props);
121
122 FluidProperties() = default;
123
124 double massFlow = 0, energyFlow = 0;
125 };
126
127 enum class Key { ENTHALPY, ENTROPY };
128
129 enum class Region { REGION1, REGION2A, REGION2B, REGION2C };
130
131 private:
132 static void checkIsentropicExponentLimits(double& k);
133
140 static int regionSelect(double pressure, double temperature);
141
150 static SteamPropertiesOutput region1(double temperature, double pressure);
151
160 static SteamPropertiesOutput region2(double temperature, double pressure);
161
170 static SteamPropertiesOutput region3(double temperature, double pressure);
171
172 static SteamPropertiesOutput region3Density(double density, double temperature);
173
182 static double region4(double temperature);
183
192 static double backwardPressureEnthalpyRegion1(double pressure, double enthalpy);
193
202 static double backwardPressureEnthalpyRegion2A(double pressure, double enthalpy);
203
212 static double backwardPressureEnthalpyRegion2B(double pressure, double enthalpy);
213
222 static double backwardPressureEnthalpyRegion2C(double pressure, double enthalpy);
223
232 static double backwardPressureEntropyRegion2A(double pressure, double entropy);
233
242 static double backwardPressureEntropyRegion2B(double pressure, double entropy);
243
252 static double backwardPressureEntropyRegion2C(double pressure, double entropy);
253
262 static double backwardPressureEntropyRegion1(double pressure, double entropy);
263
274 static Point generatePoint(int region, SteamSystemModelerTool::Key key, double var1, double var2);
275
285 static double linearTestPoint(double X, Point point1, Point point2);
286
287 static double backwardRegion3Exact(double pressure, double X, SteamSystemModelerTool::Key key);
288
295 static double backwardPressureEnthalpyRegion3(double pressure, double enthalpy);
296
304 static double backwardPressureEntropyRegion3(double pressure, double entropy);
305
306 static double backwardPressureEnthalpyRegion1Exact(double pressure, double enthalpy);
307
308 static double backwardPressureEntropyRegion1Exact(double pressure, double entropy);
309
316 static double backwardPressureEnthalpyRegion2AExact(double pressure, double enthalpy);
317
324 static double backwardPressureEntropyRegion2AExact(double pressure, double entropy);
325
332 static double backwardPressureEnthalpyRegion2BExact(double pressure, double enthalpy);
333
340 static double backwardPressureEntropyRegion2BExact(double pressure, double entropy);
341
348 static double backwardPressureEnthalpyRegion2CExact(double pressure, double enthalpy);
349
356 static double backwardPressureEntropyRegion2CExact(double pressure, double entropy);
357
367 static double backwardExact(int region, SteamSystemModelerTool::Key key,
368 SteamSystemModelerTool::Region regionFunction, double pressure, double var2);
369
370 // constants
371
375 static constexpr double PRESSURE_MIN = 0.01;
379 static constexpr double TEMPERATURE_MIN = 273.15;
383 static constexpr double PRESSURE_Tp = 16.5291643;
384
388 static constexpr double TEMPERATURE_Tp = 623.15;
389
393 static constexpr double PRESSURE_CRIT = 22.064;
394
398 static constexpr double TEMPERATURE_CRIT = 647.096;
399
403 static constexpr double PRESSURE_MAX = 100;
404
408 static constexpr double TEMPERATURE_MAX = 1073.15;
409
413 static constexpr double TEMPERATURE_REGION3_MAX = 863.15;
414
421 static inline double boundaryByTemperatureRegion3to2(const double t) {
422 return 0.34805185628969E+03 - 0.11671859879975E+01 * t + 0.10192970039326E-02 * std::pow(t, 2.0);
423 }
424
432 static inline double boundaryByPressureRegion3to2(const double p) {
433 return 0.57254459862746E+03 + std::pow((p - 0.13918839778870E+02) / 0.10192970039326E-02, 0.5);
434 }
435
436 friend class SteamProperties;
437 friend class SaturatedProperties;
438};
439
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)