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
quantify_steam_leak_by_plume_length.h
Go to the documentation of this file.
1#pragma once
2
13#include <stdexcept>
14#include <array>
15#include <cmath>
16
18 public:
27 static double estimate(const double pressure, const double plumeLength, const double ambTemp) {
28 if (pressure < 115 || pressure > 415) {
29 throw std::runtime_error("Steam Leak with Plume length method, Header pressure / steam pressure has to be "
30 "in the range of 115 and 415 psig, provided value is " +
31 std::to_string(pressure));
32 }
33
34 if (plumeLength < 3 || plumeLength > 12) {
35 throw std::runtime_error("Steam Leak with Plume length method, Plume Length has to be in the range of 3 "
36 "and 12 ft, provided value is " +
37 std::to_string(plumeLength));
38 }
39
40 if (ambTemp < 45 || ambTemp > 90) {
41 throw std::runtime_error("Steam Leak with Plume length method, ambient temperature has to be in the range "
42 "of 45 and 90 F, provided value is " +
43 std::to_string(ambTemp));
44 }
45
46 constexpr int pressureSize = 2;
47 constexpr int lengthsSize = 4;
48 constexpr int tempsSize = 3;
49 constexpr std::array<int, pressureSize> pressures = { 115, 415 };
50 constexpr std::array<int, lengthsSize> lengths = { 3, 6, 9, 12 };
51 constexpr std::array<int, tempsSize> temps = { 45, 75, 90 };
52 constexpr std::array<std::array<std::array<int, tempsSize>, lengthsSize>, pressureSize> steamLossData = { {
53 {{ // 115
54 {{10, 30, 50}}, // 3
55 {{30, 170, 280}}, // 6
56 {{70, 420, 700}}, // 9
57 {{110, 650, 1100}} // 12
58 }},
59 {{ // 415
60 {{20, 35, 50}}, // 3
61 {{50, 170, 290}}, // 6
62 {{130, 500, 800}}, // 9
63 {{220, 870, 1400}} // 12
64 }}
65 } };
66
67 int lengthIndexL = 0, lengthIndexH = 1;
68 if (plumeLength <= 6) { lengthIndexL = 0; lengthIndexH = 1; }
69 else if (plumeLength <= 9) { lengthIndexL = 1; lengthIndexH = 2; }
70 else if (plumeLength <= 12) { lengthIndexL = 2; lengthIndexH = 3; }
71
72 int tempIndexL = 0, tempIndexH = 1;
73 if (ambTemp > 75) { tempIndexL = 1; tempIndexH = 2; }
74
75 std::array<std::array<double, 2>, 2> steamLossRange = { {
76 {{0, 0}},
77 {{0, 0}}
78 } };
79 int r2 = pressures[1], r1 = pressures[0], r = static_cast<int>(std::round(pressure));
80 steamLossRange[0][0] = interpolate(r2, r1, r, steamLossData[0][lengthIndexL][tempIndexL], steamLossData[1][lengthIndexL][tempIndexL]);
81 steamLossRange[0][1] = interpolate(r2, r1, r, steamLossData[0][lengthIndexH][tempIndexL], steamLossData[1][lengthIndexH][tempIndexL]);
82 steamLossRange[1][0] = interpolate(r2, r1, r, steamLossData[0][lengthIndexL][tempIndexH], steamLossData[1][lengthIndexL][tempIndexH]);
83 steamLossRange[1][1] = interpolate(r2, r1, r, steamLossData[0][lengthIndexH][tempIndexH], steamLossData[1][lengthIndexH][tempIndexH]);
84
85 r2 = temps[tempIndexH], r1 = temps[tempIndexL], r = static_cast<int>(std::round(ambTemp));
86 const double steamLossL = interpolate(r2, r1, r, steamLossRange[0][0], steamLossRange[1][0]);
87 const double steamLossH = interpolate(r2, r1, r, steamLossRange[0][1], steamLossRange[1][1]);
88
89 r2 = lengths[lengthIndexH], r1 = lengths[lengthIndexL], r = static_cast<int>(std::round(plumeLength));
90 return interpolate(r2, r1, r, steamLossL, steamLossH);
91 }
92
93 private:
94 static double interpolate(const int r2, const int r1, const int r, const double l, const double u) { return (u - l) / (r2 - r1) * (r - r1) + l; }
95};
static double estimate(const double pressure, const double plumeLength, const double ambTemp)