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