8 #include "./NanDataConverters.h" 9 #include "calculator/util/CompressedAir.h" 10 #include "calculator/util/CompressedAirCentrifugal.h" 15 void compressedAirCentrifugal()
17 int controlType = getInteger(
"controlType");
18 int computeFrom = getInteger(
"computeFrom");
19 bool adjustForDischargePressure = getBool(
"adjustForDischargePressure");
21 const double powerAtFullLoad = getDouble(
"powerAtFullLoad", inp);
22 const double capacityAtFullLoad = getDouble(
"capacityAtFullLoad", inp);
24 const double capacityAtMinFullLoadPressure = getDouble(
"capacityAtMinFullLoadPressure", inp);
25 const double capacityAtMaxFullLoadPressure = getDouble(
"capacityAtMaxFullLoadPressure", inp);
26 const double fullLoadPressure = getDouble(
"fullLoadPressure", inp);
27 const double minFullLoadPressure = getDouble(
"minFullLoadPressure", inp);
28 const double maxFullLoadPressure = getDouble(
"maxFullLoadPressure", inp);
30 const double computeFromVal = getDouble(
"computeFromVal", inp);
31 const double computeFromPFVoltage = getDouble(
"computeFromPFVoltage", inp);
32 const double computeFromPFAmps = getDouble(
"computeFromPFAmps", inp);
34 if(controlType == CompressedAirCentrifugal::ControlType::LoadUnload) {
35 const double powerAtNoLoad = getDouble(
"powerAtNoLoad", inp);
38 if(adjustForDischargePressure) {
39 const double fullLoadPressure = getDouble(
"fullLoadPressure", inp);
40 cacLUL.AdjustDischargePressure(
41 {capacityAtFullLoad, capacityAtMinFullLoadPressure, capacityAtMaxFullLoadPressure},
42 {fullLoadPressure, minFullLoadPressure, maxFullLoadPressure}, fullLoadPressure);
44 setR(
"capacityAtFullLoadAdjusted", cacLUL.C_fl_Adjusted);
48 if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentagePower)
49 output = cacLUL.calculateFromPerkW(computeFromVal);
50 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentageCapacity)
51 output = cacLUL.calculateFromPerC(computeFromVal);
52 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerMeasured)
53 output = cacLUL.calculateFromkWMeasured(computeFromVal);
54 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::CapacityMeasured)
55 output = cacLUL.calculateFromCMeasured(computeFromVal);
56 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerFactor)
57 output = cacLUL.calculateFromVIPFMeasured(computeFromVal, computeFromPFVoltage, computeFromPFAmps);
58 else ThrowTypeError(std::string(
"CompressedAirCentrifugal: calculator : Invalid Compute Method in input").c_str());
60 setR(
"powerCalculated", output.kW_Calc);
61 setR(
"capacityCalculated", output.C_Calc);
62 setR(
"percentagePower", output.PerkW);
63 setR(
"percentageCapacity", output.C_Per);
65 else if(controlType == CompressedAirCentrifugal::ControlType::ModulationUnload) {
66 const double powerAtNoLoad = getDouble(
"powerAtNoLoad", inp);
67 const double capacityAtMaxFullFlow = getDouble(
"capacityAtMaxFullFlow", inp);
68 const double powerAtUnload = getDouble(
"powerAtUnload", inp);
69 const double capacityAtUnload = getDouble(
"capacityAtUnload", inp);
72 if(adjustForDischargePressure) {
73 const double fullLoadPressure = getDouble(
"fullLoadPressure", inp);
74 const double maxPressure = getDouble(
"maxPressure", inp);
75 cacMUL.AdjustDischargePressure(
76 {capacityAtFullLoad, capacityAtMinFullLoadPressure, capacityAtMaxFullLoadPressure},
77 {fullLoadPressure, minFullLoadPressure, maxFullLoadPressure}, fullLoadPressure, maxPressure);
79 setR(
"capacityAtFullLoadAdjusted", cacMUL.C_fl_Adjusted);
80 setR(
"capacityAtMaxFullFlowAdjusted", cacMUL.C_max_Adjusted);
84 if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentagePower)
85 output = cacMUL.calculateFromPerkW(computeFromVal);
86 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentageCapacity)
87 output = cacMUL.calculateFromPerC(computeFromVal);
88 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerMeasured)
89 output = cacMUL.calculateFromkWMeasured(computeFromVal);
90 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::CapacityMeasured)
91 output = cacMUL.calculateFromCMeasured(computeFromVal);
92 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerFactor)
93 output = cacMUL.calculateFromVIPFMeasured(computeFromVal, computeFromPFVoltage, computeFromPFAmps);
94 else ThrowTypeError(std::string(
"CompressedAirCentrifugal: calculator : Invalid Compute Method in input").c_str());
96 setR(
"powerCalculated", output.kW_Calc);
97 setR(
"capacityCalculated", output.C_Calc);
98 setR(
"percentagePower", output.PerkW);
99 setR(
"percentageCapacity", output.C_Per);
101 else if(controlType == CompressedAirCentrifugal::ControlType::BlowOff) {
102 const double powerAtBlowOff = getDouble(
"powerAtBlowOff", inp);
103 const double surgeFlow = getDouble(
"surgeFlow", inp);
104 const double percentageBlowOff = getDouble(
"percentageBlowOff", inp);
107 if(adjustForDischargePressure) {
108 const double fullLoadPressure = getDouble(
"fullLoadPressure", inp);
109 cacBO.AdjustDischargePressure(
110 {capacityAtFullLoad, capacityAtMinFullLoadPressure, capacityAtMaxFullLoadPressure},
111 {fullLoadPressure, minFullLoadPressure, maxFullLoadPressure}, fullLoadPressure);
113 setR(
"capacityAtFullLoadAdjusted", cacBO.C_fl_Adjusted);
117 if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentagePower)
118 output = cacBO.calculateFromPerkW_BlowOff(computeFromVal, percentageBlowOff);
119 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PercentageCapacity)
120 output = cacBO.calculateFromPerC_BlowOff(computeFromVal);
121 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerMeasured)
122 output = cacBO.calculateFromkWMeasured_BlowOff(computeFromVal, percentageBlowOff);
123 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::CapacityMeasured)
124 output = cacBO.calculateFromCMeasured_BlowOff(computeFromVal);
125 else if(computeFrom == CompressedAirCentrifugal::ComputeFrom::PowerFactor)
126 output = cacBO.calculateFromVIPFMeasured_BlowOff(computeFromVal, computeFromPFVoltage, computeFromPFAmps, percentageBlowOff);
127 else ThrowTypeError(std::string(
"CompressedAirCentrifugal: calculator : Invalid Compute Method in input").c_str());
129 setR(
"powerCalculated", output.kW_Calc);
130 setR(
"capacityCalculated", output.C_Calc);
131 setR(
"percentagePower", output.PerkW);
132 setR(
"percentageCapacity", output.C_Per);
133 setR(
"percentageBlowOff", output.blowPer);
134 setR(
"surgeFlow", output.C_blow);
136 else ThrowTypeError(std::string(
"CompressedAirCentrifugal: calculator : Invalid Control Type in input").c_str());
141 inp = Nan::To<Object>(info[0]).ToLocalChecked();
142 r = Nan::New<Object>();
146 int compressorType = getInteger(
"compressorType");
148 if(compressorType == CompressedAir::CompressorType::Centrifugal) compressedAirCentrifugal();
150 info.GetReturnValue().Set(r);
152 catch (std::runtime_error
const &e)
154 std::string
const what = e.what();
155 ThrowError(std::string(
"std::runtime_error thrown in CompressedAir - calculator: " + what).c_str());
Contains all the implementations of the various components of a compressed air system.