GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 71.7% 134 / 0 / 187
Functions: 77.2% 44 / 0 / 57
Branches: 51.1% 70 / 0 / 137

src/model/HumidifierSteamElectric.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 "HumidifierSteamElectric.hpp"
7 #include "HumidifierSteamElectric_Impl.hpp"
8
9 #include "Schedule.hpp"
10 #include "Schedule_Impl.hpp"
11 #include "ScheduleTypeLimits.hpp"
12 #include "ScheduleTypeRegistry.hpp"
13
14 #include "../utilities/core/Assert.hpp"
15 #include "../utilities/data/DataEnums.hpp"
16
17 #include <utilities/idd/OS_Humidifier_Steam_Electric_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19
20 namespace openstudio {
21 namespace model {
22
23 namespace detail {
24
25 7 HumidifierSteamElectric_Impl::HumidifierSteamElectric_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 7 : StraightComponent_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
7 OS_ASSERT(idfObject.iddObject().type() == HumidifierSteamElectric::iddObjectType());
28 7 }
29
30 ✗ HumidifierSteamElectric_Impl::HumidifierSteamElectric_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
31 ✗ bool keepHandle)
32 ✗ : StraightComponent_Impl(other, model, keepHandle) {
33 ✗ OS_ASSERT(other.iddObject().type() == HumidifierSteamElectric::iddObjectType());
34 ✗ }
35
36 3 HumidifierSteamElectric_Impl::HumidifierSteamElectric_Impl(const HumidifierSteamElectric_Impl& other, Model_Impl* model, bool keepHandle)
37 3 : StraightComponent_Impl(other, model, keepHandle) {}
38
39 ✗ const std::vector<std::string>& HumidifierSteamElectric_Impl::outputVariableNames() const {
40 static const std::vector<std::string> result{
41 "Humidifier Water Volume Flow Rate", "Humidifier Water Volume", "Humidifier Electricity Rate", "Humidifier Electricity Energy",
42 "Humidifier Mains Water Volume"
43
44 // Water Storage Tank Name isn't implemented
45 // https://github.com/NREL/EnergyPlus/blob/a5b04d73ecfef706cda7d0543ccad31e7c27087a/src/EnergyPlus/Humidifiers.cc#L471
46 //"Humidifier Storage Tank Water Volume Flow Rate",
47 //"Humidifier Storage Tank Water Volume",
48 //"Humidifier Starved Storage Tank Water Volume Flow Rate",
49 //"Humidifier Starved Storage Tank Water Volume"
50 ✗ };
51 ✗ return result;
52 ✗ }
53
54 3 IddObjectType HumidifierSteamElectric_Impl::iddObjectType() const {
55 3 return HumidifierSteamElectric::iddObjectType();
56 }
57
58 ✗ std::vector<ScheduleTypeKey> HumidifierSteamElectric_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
59 ✗ std::vector<ScheduleTypeKey> result;
60 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
61 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
62 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
63 ✗ if (std::find(b, e, OS_Humidifier_Steam_ElectricFields::AvailabilityScheduleName) != e) {
64 ✗ result.push_back(ScheduleTypeKey("HumidifierSteamElectric", "Availability"));
65 }
66 ✗ return result;
67 ✗ }
68
69 35 unsigned HumidifierSteamElectric_Impl::inletPort() const {
70 35 return OS_Humidifier_Steam_ElectricFields::AirInletNodeName;
71 }
72
73 61 unsigned HumidifierSteamElectric_Impl::outletPort() const {
74 61 return OS_Humidifier_Steam_ElectricFields::AirOutletNodeName;
75 }
76
77 4 boost::optional<Schedule> HumidifierSteamElectric_Impl::availabilitySchedule() const {
78
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_Humidifier_Steam_ElectricFields::AvailabilityScheduleName);
79 }
80
81 5 boost::optional<double> HumidifierSteamElectric_Impl::ratedPower() const {
82 5 return getDouble(OS_Humidifier_Steam_ElectricFields::RatedPower, true);
83 }
84
85 3 bool HumidifierSteamElectric_Impl::isRatedPowerAutosized() const {
86 3 bool result = false;
87
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_Humidifier_Steam_ElectricFields::RatedPower, true);
88
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
89
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 result = openstudio::istringEqual(value.get(), "autosize");
90 }
91 3 return result;
92 3 }
93
94 4 boost::optional<double> HumidifierSteamElectric_Impl::ratedFanPower() const {
95 4 return getDouble(OS_Humidifier_Steam_ElectricFields::RatedFanPower, true);
96 }
97
98 4 boost::optional<double> HumidifierSteamElectric_Impl::standbyPower() const {
99 4 return getDouble(OS_Humidifier_Steam_ElectricFields::StandbyPower, true);
100 }
101
102 // boost::optional<WaterStorageTank> HumidifierSteamElectric_Impl::waterStorageTank() const {
103 // return getObject<ModelObject>().getModelObjectTarget<WaterStorageTank>(OS_Humidifier_Steam_ElectricFields::WaterStorageTankName);
104 // }
105
106 1 bool HumidifierSteamElectric_Impl::setAvailabilitySchedule(Schedule& schedule) {
107
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
4 bool result = setSchedule(OS_Humidifier_Steam_ElectricFields::AvailabilityScheduleName, "HumidifierSteamElectric", "Availability", schedule);
108 1 return result;
109 }
110
111 1 void HumidifierSteamElectric_Impl::resetAvailabilitySchedule() {
112
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Humidifier_Steam_ElectricFields::AvailabilityScheduleName, "");
113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
114 1 }
115
116 7 bool HumidifierSteamElectric_Impl::setRatedPower(boost::optional<double> ratedPower) {
117 7 bool result(false);
118
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (ratedPower) {
119 7 result = setDouble(OS_Humidifier_Steam_ElectricFields::RatedPower, ratedPower.get());
120 } else {
121 ✗ resetRatedPower();
122 ✗ result = true;
123 }
124 7 return result;
125 }
126
127 1 void HumidifierSteamElectric_Impl::resetRatedPower() {
128
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Humidifier_Steam_ElectricFields::RatedPower, "");
129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
130 1 }
131
132 1 void HumidifierSteamElectric_Impl::autosizeRatedPower() {
133
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Humidifier_Steam_ElectricFields::RatedPower, "autosize");
134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
135 1 }
136
137 1 bool HumidifierSteamElectric_Impl::setRatedFanPower(boost::optional<double> ratedFanPower) {
138 1 bool result(false);
139
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (ratedFanPower) {
140 1 result = setDouble(OS_Humidifier_Steam_ElectricFields::RatedFanPower, ratedFanPower.get());
141 } else {
142 ✗ resetRatedFanPower();
143 ✗ result = true;
144 }
145 1 return result;
146 }
147
148 1 void HumidifierSteamElectric_Impl::resetRatedFanPower() {
149
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Humidifier_Steam_ElectricFields::RatedFanPower, "");
150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
151 1 }
152
153 1 bool HumidifierSteamElectric_Impl::setStandbyPower(boost::optional<double> standbyPower) {
154 1 bool result(false);
155
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (standbyPower) {
156 1 result = setDouble(OS_Humidifier_Steam_ElectricFields::StandbyPower, standbyPower.get());
157 } else {
158 ✗ resetStandbyPower();
159 ✗ result = true;
160 }
161 1 return result;
162 }
163
164 1 void HumidifierSteamElectric_Impl::resetStandbyPower() {
165
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Humidifier_Steam_ElectricFields::StandbyPower, "");
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
167 1 }
168
169 // bool HumidifierSteamElectric_Impl::setWaterStorageTank(const boost::optional<WaterStorageTank>& waterStorageTank) {
170 // bool result(false);
171 // if (waterStorageTank) {
172 // result = setPointer(OS_Humidifier_Steam_ElectricFields::WaterStorageTankName, waterStorageTank.get().handle());
173 // }
174 // else {
175 // resetWaterStorageTank();
176 // result = true;
177 // }
178 // return result;
179 // }
180
181 // void HumidifierSteamElectric_Impl::resetWaterStorageTank() {
182 // bool result = setString(OS_Humidifier_Steam_ElectricFields::WaterStorageTankName, "");
183 // OS_ASSERT(result);
184 // }
185
186 4 boost::optional<double> HumidifierSteamElectric_Impl::ratedCapacity() const {
187 4 return getDouble(OS_Humidifier_Steam_ElectricFields::RatedCapacity, true);
188 }
189
190 4 bool HumidifierSteamElectric_Impl::isRatedCapacityAutosized() const {
191 4 bool result = false;
192
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<std::string> value = getString(OS_Humidifier_Steam_ElectricFields::RatedCapacity, true);
193
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (value) {
194
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
8 result = openstudio::istringEqual(value.get(), "autosize");
195 }
196 4 return result;
197 4 }
198
199 1 bool HumidifierSteamElectric_Impl::setRatedCapacity(boost::optional<double> ratedCapacity) {
200 1 bool result(false);
201
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (ratedCapacity) {
202 1 result = setDouble(OS_Humidifier_Steam_ElectricFields::RatedCapacity, ratedCapacity.get());
203 }
204 1 return result;
205 }
206
207 8 void HumidifierSteamElectric_Impl::autosizeRatedCapacity() {
208
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 bool result = setString(OS_Humidifier_Steam_ElectricFields::RatedCapacity, "autosize");
209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
210 8 }
211
212 ✗ boost::optional<double> HumidifierSteamElectric_Impl::autosizedRatedCapacity() const {
213 ✗ return getAutosizedValue("Design Size Nominal Capacity Volume", "m3/s");
214 }
215
216 ✗ boost::optional<double> HumidifierSteamElectric_Impl::autosizedRatedPower() const {
217 ✗ return getAutosizedValue("Design Size Rated Power", "W");
218 }
219
220 ✗ void HumidifierSteamElectric_Impl::autosize() {
221 ✗ autosizeRatedCapacity();
222 ✗ autosizeRatedPower();
223 ✗ }
224
225 ✗ void HumidifierSteamElectric_Impl::applySizingValues() {
226 ✗ boost::optional<double> val;
227 ✗ val = autosizedRatedCapacity();
228 ✗ if (val) {
229 ✗ setRatedCapacity(val.get());
230 }
231
232 ✗ val = autosizedRatedPower();
233 ✗ if (val) {
234 ✗ setRatedPower(val.get());
235 }
236 ✗ }
237
238 ✗ ComponentType HumidifierSteamElectric_Impl::componentType() const {
239 ✗ return ComponentType::Heating; // TODO: is that right?
240 }
241
242 ✗ std::vector<FuelType> HumidifierSteamElectric_Impl::coolingFuelTypes() const {
243 ✗ return {};
244 }
245
246 ✗ std::vector<FuelType> HumidifierSteamElectric_Impl::heatingFuelTypes() const {
247 ✗ return {FuelType::Electricity}; // TODO: is that right?
248 }
249
250 ✗ std::vector<AppGFuelType> HumidifierSteamElectric_Impl::appGHeatingFuelTypes() const {
251 ✗ return {AppGFuelType::Electric}; // TODO: is that right?
252 }
253
254 } // namespace detail
255
256 7 HumidifierSteamElectric::HumidifierSteamElectric(const Model& model) : StraightComponent(HumidifierSteamElectric::iddObjectType(), model) {
257
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
7 OS_ASSERT(getImpl<detail::HumidifierSteamElectric_Impl>());
258
1/1
✓ Branch 1 taken 7 times.
7 autosizeRatedCapacity();
259
1/1
✓ Branch 1 taken 7 times.
7 setRatedPower(10200); // JJR: per idf example in docs
260
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 setString(OS_Humidifier_Steam_ElectricFields::WaterStorageTankName, "");
261 7 }
262
263 7615 IddObjectType HumidifierSteamElectric::iddObjectType() {
264
1/1
✓ Branch 1 taken 7615 times.
7615 return {IddObjectType::OS_Humidifier_Steam_Electric};
265 }
266
267 4 boost::optional<Schedule> HumidifierSteamElectric::availabilitySchedule() const {
268
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HumidifierSteamElectric_Impl>()->availabilitySchedule();
269 }
270
271 5 boost::optional<double> HumidifierSteamElectric::ratedPower() const {
272
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::HumidifierSteamElectric_Impl>()->ratedPower();
273 }
274
275 3 bool HumidifierSteamElectric::isRatedPowerAutosized() const {
276
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::HumidifierSteamElectric_Impl>()->isRatedPowerAutosized();
277 }
278
279 4 boost::optional<double> HumidifierSteamElectric::ratedFanPower() const {
280
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HumidifierSteamElectric_Impl>()->ratedFanPower();
281 }
282
283 4 boost::optional<double> HumidifierSteamElectric::standbyPower() const {
284
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HumidifierSteamElectric_Impl>()->standbyPower();
285 }
286
287 // boost::optional<WaterStorageTank> HumidifierSteamElectric::waterStorageTank() const {
288 // return getImpl<detail::HumidifierSteamElectric_Impl>()->waterStorageTank();
289 // }
290
291 1 bool HumidifierSteamElectric::setAvailabilitySchedule(Schedule& schedule) {
292
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::HumidifierSteamElectric_Impl>()->setAvailabilitySchedule(schedule);
293 }
294
295 1 void HumidifierSteamElectric::resetAvailabilitySchedule() {
296
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::HumidifierSteamElectric_Impl>()->resetAvailabilitySchedule();
297 1 }
298
299 7 bool HumidifierSteamElectric::setRatedPower(double ratedPower) {
300
2/2
✓ Branch 3 taken 7 times.
✓ Branch 6 taken 7 times.
7 return getImpl<detail::HumidifierSteamElectric_Impl>()->setRatedPower(ratedPower);
301 }
302
303 1 void HumidifierSteamElectric::resetRatedPower() {
304
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::HumidifierSteamElectric_Impl>()->resetRatedPower();
305 1 }
306
307 1 void HumidifierSteamElectric::autosizeRatedPower() {
308
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::HumidifierSteamElectric_Impl>()->autosizeRatedPower();
309 1 }
310
311 1 bool HumidifierSteamElectric::setRatedFanPower(double ratedFanPower) {
312
2/2
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
1 return getImpl<detail::HumidifierSteamElectric_Impl>()->setRatedFanPower(ratedFanPower);
313 }
314
315 1 void HumidifierSteamElectric::resetRatedFanPower() {
316
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::HumidifierSteamElectric_Impl>()->resetRatedFanPower();
317 1 }
318
319 1 bool HumidifierSteamElectric::setStandbyPower(double standbyPower) {
320
2/2
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
1 return getImpl<detail::HumidifierSteamElectric_Impl>()->setStandbyPower(standbyPower);
321 }
322
323 1 void HumidifierSteamElectric::resetStandbyPower() {
324
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::HumidifierSteamElectric_Impl>()->resetStandbyPower();
325 1 }
326
327 4 boost::optional<double> HumidifierSteamElectric::ratedCapacity() const {
328
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HumidifierSteamElectric_Impl>()->ratedCapacity();
329 }
330
331 4 bool HumidifierSteamElectric::isRatedCapacityAutosized() const {
332
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::HumidifierSteamElectric_Impl>()->isRatedCapacityAutosized();
333 }
334
335 1 bool HumidifierSteamElectric::setRatedCapacity(double ratedCapacity) {
336
2/2
✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
1 return getImpl<detail::HumidifierSteamElectric_Impl>()->setRatedCapacity(ratedCapacity);
337 }
338
339 8 void HumidifierSteamElectric::autosizeRatedCapacity() {
340
1/1
✓ Branch 3 taken 8 times.
8 getImpl<detail::HumidifierSteamElectric_Impl>()->autosizeRatedCapacity();
341 8 }
342
343 // bool HumidifierSteamElectric::setWaterStorageTank(const WaterStorageTank& waterStorageTank) {
344 // return getImpl<detail::HumidifierSteamElectric_Impl>()->setWaterStorageTank(waterStorageTank);
345 // }
346
347 // void HumidifierSteamElectric::resetWaterStorageTank() {
348 // getImpl<detail::HumidifierSteamElectric_Impl>()->resetWaterStorageTank();
349 // }
350
351 /// @cond
352
1/1
✓ Branch 3 taken 2 times.
2 HumidifierSteamElectric::HumidifierSteamElectric(std::shared_ptr<detail::HumidifierSteamElectric_Impl> impl) : StraightComponent(std::move(impl)) {}
353 /// @endcond
354
355 ✗ boost::optional<double> HumidifierSteamElectric::autosizedRatedCapacity() const {
356 ✗ return getImpl<detail::HumidifierSteamElectric_Impl>()->autosizedRatedCapacity();
357 }
358
359 ✗ boost::optional<double> HumidifierSteamElectric::autosizedRatedPower() const {
360 ✗ return getImpl<detail::HumidifierSteamElectric_Impl>()->autosizedRatedPower();
361 }
362
363 } // namespace model
364 } // namespace openstudio
365