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
ReceiverTank.h
Go to the documentation of this file.
1
10#ifndef TOOLS_SUITE_RECEIVERTANK_H
11#define TOOLS_SUITE_RECEIVERTANK_H
12
13#include <cmath>
14#include <functional>
15#include <stdexcept>
16#include <vector>
17
19 public:
20 enum class Method { General, DedicatedStorage, MeteredStorage, BridgingCompressorReactionDelay };
21
22 ReceiverTank() = default;
23
36 ReceiverTank(Method method, double airDemand, double allowablePressureDrop, double atmosphericPressure)
37 : method(method), airDemand(airDemand), allowablePressureDrop(allowablePressureDrop),
38 atmosphericPressure(atmosphericPressure) {
39 if (method != ReceiverTank::Method::General) {
40 throw std::runtime_error("Calculation method must be set to General to use this constructor");
41 }
42 }
43
62 ReceiverTank(Method method, double lengthOfDemandOrDistanceToCompressorRoom, double airFlowRequirementOrSpeedOfAir,
63 double atmosphericPressure, double initialTankPressureOrAirDemand,
64 double finalTankPressureOrAllowablePressureDrop)
65 : method(method), atmosphericPressure(atmosphericPressure),
66 lengthOfDemandOrDistanceToCompressorRoom(lengthOfDemandOrDistanceToCompressorRoom),
67 airFlowRequirementOrSpeedOfAir(airFlowRequirementOrSpeedOfAir),
68 initialTankPressureOrAirDemand(initialTankPressureOrAirDemand),
69 finalTankPressureOrAllowablePressureDrop(finalTankPressureOrAllowablePressureDrop) {
70 if (method != ReceiverTank::Method::DedicatedStorage &&
71 method != ReceiverTank::Method::BridgingCompressorReactionDelay) {
72 throw std::runtime_error("Calculation method must be set to DedicatedStorage or "
73 "BridgingCompressorReactionDelay to use this constructor");
74 }
75 }
76
91 ReceiverTank(Method method, double lengthOfDemand, double airFlowRequirement, double atmosphericPressure,
92 double initialTankPressure, double finalTankPressure, double meteredFlowControl)
93 : method(method), atmosphericPressure(atmosphericPressure),
94 lengthOfDemandOrDistanceToCompressorRoom(lengthOfDemand), airFlowRequirementOrSpeedOfAir(airFlowRequirement),
95 initialTankPressureOrAirDemand(initialTankPressure),
96 finalTankPressureOrAllowablePressureDrop(finalTankPressure), meteredFlowControl(meteredFlowControl) {
97 if (method != ReceiverTank::Method::MeteredStorage) {
98 throw std::runtime_error("Calculation method must be set to MeteredStorage to use this constructor");
99 }
100 }
101
109 double calculateUsableCapacity(const double tankSize, const double airPressureIn, const double airPressureOut) {
110 return (tankSize / 7.48) * (airPressureIn - airPressureOut) / 14.7;
111 }
112
117 double calculateSize() {
118 if (method == ReceiverTank::Method::General) {
119 return airDemand * (atmosphericPressure / allowablePressureDrop) * 7.48;
120 }
121 else if (method == ReceiverTank::Method::DedicatedStorage) {
122 return 7.48 *
123 (lengthOfDemandOrDistanceToCompressorRoom * airFlowRequirementOrSpeedOfAir * atmosphericPressure) /
124 (initialTankPressureOrAirDemand - finalTankPressureOrAllowablePressureDrop);
125 }
126 else if (method == ReceiverTank::Method::MeteredStorage) {
127 return (7.48 * lengthOfDemandOrDistanceToCompressorRoom *
128 (airFlowRequirementOrSpeedOfAir - meteredFlowControl) * atmosphericPressure) /
129 (initialTankPressureOrAirDemand - finalTankPressureOrAllowablePressureDrop);
130 }
131 // method must be BridgingCompressorReactionDelay
132 return (lengthOfDemandOrDistanceToCompressorRoom / airFlowRequirementOrSpeedOfAir) *
133 (initialTankPressureOrAirDemand / 60) *
134 (atmosphericPressure / finalTankPressureOrAllowablePressureDrop) * 7.48;
135 }
136
143 double volumeGal = calculateSize();
144 // * convert gal to ft3
145 double volumeCf = volumeGal * 0.133681;
146 double T = (volumeCf * (initialTankPressureOrAirDemand - finalTankPressureOrAllowablePressureDrop)) /
147 (meteredFlowControl * atmosphericPressure);
148 return T * 60;
149 }
150
151 private:
152 Method method;
153 double airDemand, allowablePressureDrop, atmosphericPressure;
154
155 double lengthOfDemandOrDistanceToCompressorRoom, airFlowRequirementOrSpeedOfAir, initialTankPressureOrAirDemand;
156 double finalTankPressureOrAllowablePressureDrop;
157
158 double meteredFlowControl;
159};
160
161#endif
ReceiverTank(Method method, double lengthOfDemandOrDistanceToCompressorRoom, double airFlowRequirementOrSpeedOfAir, double atmosphericPressure, double initialTankPressureOrAirDemand, double finalTankPressureOrAllowablePressureDrop)
double calculateSize()
ReceiverTank(Method method, double lengthOfDemand, double airFlowRequirement, double atmosphericPressure, double initialTankPressure, double finalTankPressure, double meteredFlowControl)
ReceiverTank(Method method, double airDemand, double allowablePressureDrop, double atmosphericPressure)
double calculateUsableCapacity(const double tankSize, const double airPressureIn, const double airPressureOut)
double calculateRefillTime()