GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.4% 65 / 0 / 77
Functions: 100.0% 1 / 0 / 1
Branches: 64.9% 122 / 0 / 188

src/energyplus/ForwardTranslator/ForwardTranslatePumpVariableSpeed.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ForwardTranslator.hpp"
7
8 #include "../../model/PumpVariableSpeed.hpp"
9 #include "../../model/PumpVariableSpeed_Impl.hpp"
10 #include "../../model/Model.hpp"
11 #include "../../model/Schedule.hpp"
12 #include "../../model/Schedule_Impl.hpp"
13 #include "../../model/Node.hpp"
14 #include "../../model/Node_Impl.hpp"
15 #include "../../model/Curve.hpp"
16 #include "../../model/Curve_Impl.hpp"
17
18 #include "../../utilities/core/Assert.hpp"
19
20 #include <utilities/idd/Pump_VariableSpeed_FieldEnums.hxx>
21 #include <utilities/idd/IddEnums.hxx>
22
23 using namespace openstudio::model;
24
25 using namespace std;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 4 boost::optional<IdfObject> ForwardTranslator::translatePumpVariableSpeed(PumpVariableSpeed& modelObject) {
32 4 boost::optional<std::string> s;
33 4 boost::optional<double> value;
34 4 OptionalSchedule schedule;
35
36
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 IdfObject idfObject(IddObjectType::Pump_VariableSpeed);
37
38
1/1
✓ Branch 1 taken 4 times.
4 m_idfObjects.push_back(idfObject);
39
40 // Name
41
42
1/1
✓ Branch 1 taken 4 times.
4 s = modelObject.name();
43
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (s) {
44
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setName(*s);
45 }
46
47 // InletNodeName
48
49
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
8 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
50
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
8 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
51
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::InletNodeName, node->name().get());
52 4 }
53 4 }
54
55 // OutletNodeName
56
57
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
8 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
58
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
8 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
59
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::OutletNodeName, node->name().get());
60 4 }
61 4 }
62
63 // RatedFlowRate
64
65
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 if (modelObject.isRatedFlowRateAutosized()) {
66
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 idfObject.setString(Pump_VariableSpeedFields::DesignMaximumFlowRate, "Autosize");
67 ✗ } else if ((value = modelObject.ratedFlowRate())) {
68 ✗ idfObject.setDouble(Pump_VariableSpeedFields::DesignMaximumFlowRate, value.get());
69 }
70
71 // RatedPumpHead
72
73
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.ratedPumpHead())) {
74
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::DesignPumpHead, value.get());
75 }
76
77 // RatedPowerConsumption
78
79
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 if (modelObject.isRatedPowerConsumptionAutosized()) {
80
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 idfObject.setString(Pump_VariableSpeedFields::DesignPowerConsumption, "Autosize");
81 ✗ } else if ((value = modelObject.ratedPowerConsumption())) {
82 ✗ idfObject.setDouble(Pump_VariableSpeedFields::DesignPowerConsumption, value.get());
83 }
84
85 // MotorEfficiency
86
87
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.motorEfficiency())) {
88
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::MotorEfficiency, value.get());
89 }
90
91 // FractionofMotorInefficienciestoFluidStream
92
93
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.fractionofMotorInefficienciestoFluidStream())) {
94
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::FractionofMotorInefficienciestoFluidStream, value.get());
95 }
96
97 // Coefficient1ofthePartLoadPerformanceCurve
98
99
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.coefficient1ofthePartLoadPerformanceCurve())) {
100
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::Coefficient1ofthePartLoadPerformanceCurve, value.get());
101 }
102
103 // Coefficient2ofthePartLoadPerformanceCurve
104
105
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.coefficient2ofthePartLoadPerformanceCurve())) {
106
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::Coefficient2ofthePartLoadPerformanceCurve, value.get());
107 }
108
109 // Coefficient3ofthePartLoadPerformanceCurve
110
111
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.coefficient3ofthePartLoadPerformanceCurve())) {
112
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::Coefficient3ofthePartLoadPerformanceCurve, value.get());
113 }
114
115 // Coefficient4ofthePartLoadPerformanceCurve
116
117
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.coefficient4ofthePartLoadPerformanceCurve())) {
118
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::Coefficient4ofthePartLoadPerformanceCurve, value.get());
119 }
120
121 // MinimumFlowRate
122
123
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.minimumFlowRate())) {
124
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::DesignMinimumFlowRate, value.get());
125 }
126
127 // PumpControlType
128
129
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
8 if ((s = modelObject.pumpControlType())) {
130
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::PumpControlType, s.get());
131 }
132
133 // PumpFlowRateSchedule
134
135
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.pumpFlowRateSchedule())) {
136 ✗ idfObject.setString(Pump_VariableSpeedFields::PumpFlowRateScheduleName, schedule->name().get());
137 }
138
139 // PumpCurve
140
141
2/3
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
8 if (OptionalCurve curve = modelObject.pumpCurve()) {
142 ✗ idfObject.setString(Pump_VariableSpeedFields::PumpCurveName, curve->name().get());
143 4 }
144
145 // ImpellerDiameter
146
147
2/3
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
8 if ((value = modelObject.impellerDiameter())) {
148 ✗ idfObject.setDouble(Pump_VariableSpeedFields::ImpellerDiameter, value.get());
149 }
150
151 // VFDControlType
152
153
2/3
✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
8 if ((s = modelObject.vFDControlType())) {
154
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::VFDControlType, s.get());
155 }
156
157 // PumpRPMSchedule
158
159
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.pumpRPMSchedule())) {
160 ✗ idfObject.setString(Pump_VariableSpeedFields::PumpRPMScheduleName, schedule->name().get());
161 }
162
163 // MinimumPressureSchedule
164
165
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.minimumPressureSchedule())) {
166 ✗ idfObject.setString(Pump_VariableSpeedFields::MinimumPressureSchedule, schedule->name().get());
167 }
168
169 // MaximumPressureSchedule
170
171
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.maximumPressureSchedule())) {
172 ✗ idfObject.setString(Pump_VariableSpeedFields::MaximumPressureSchedule, schedule->name().get());
173 }
174
175 // MinimumRPMSchedule
176
177
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.minimumRPMSchedule())) {
178 ✗ idfObject.setString(Pump_VariableSpeedFields::MinimumRPMSchedule, schedule->name().get());
179 }
180
181 // MaximumRPMSchedule
182
183
2/3
✓ Branch 1 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
8 if ((schedule = modelObject.maximumRPMSchedule())) {
184 ✗ idfObject.setString(Pump_VariableSpeedFields::MaximumRPMSchedule, schedule->name().get());
185 }
186
187
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
8 if ((value = modelObject.skinLossRadiativeFraction())) {
188
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::SkinLossRadiativeFraction, value.get());
189 }
190
191 {
192
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 s = modelObject.designPowerSizingMethod();
193
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::DesignPowerSizingMethod, s.get());
194 }
195
196 {
197
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 value = modelObject.designElectricPowerPerUnitFlowRate();
198
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::DesignElectricPowerperUnitFlowRate, value.get());
199 }
200
201 {
202
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 value = modelObject.designShaftPowerPerUnitFlowRatePerUnitHead();
203
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::DesignShaftPowerperUnitFlowRateperUnitHead, value.get());
204 }
205
206 {
207
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 value = modelObject.designMinimumFlowRateFraction();
208
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setDouble(Pump_VariableSpeedFields::DesignMinimumFlowRateFraction, value.get());
209 }
210
211 // End Use Subcategory
212
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 idfObject.setString(Pump_VariableSpeedFields::EndUseSubcategory, modelObject.endUseSubcategory());
213
214
1/1
✓ Branch 1 taken 4 times.
8 return idfObject;
215 4 }
216
217 } // namespace energyplus
218 } // namespace openstudio
219