GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 59.9% 106 / 0 / 177
Functions: 65.9% 27 / 0 / 41
Branches: 33.3% 83 / 0 / 249

src/model/HeatExchangerDesiccantBalancedFlow.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 "HeatExchangerDesiccantBalancedFlow.hpp"
7 #include "HeatExchangerDesiccantBalancedFlow_Impl.hpp"
8
9 #include "CoilSystemCoolingWaterHeatExchangerAssisted.hpp"
10 #include "CoilSystemCoolingWaterHeatExchangerAssisted_Impl.hpp"
11 #include "CoilSystemCoolingDXHeatExchangerAssisted.hpp"
12 #include "CoilSystemCoolingDXHeatExchangerAssisted_Impl.hpp"
13 #include "Schedule.hpp"
14 #include "Schedule_Impl.hpp"
15 #include "Model.hpp"
16 #include "Model_Impl.hpp"
17 #include "ScheduleTypeLimits.hpp"
18 #include "ScheduleTypeRegistry.hpp"
19 #include "AirflowNetworkEquivalentDuct.hpp"
20 #include "AirflowNetworkEquivalentDuct_Impl.hpp"
21 #include "HeatExchangerDesiccantBalancedFlowPerformanceDataType1.hpp"
22 #include "HeatExchangerDesiccantBalancedFlowPerformanceDataType1_Impl.hpp"
23
24 #include "../utilities/core/Assert.hpp"
25 #include "../utilities/data/DataEnums.hpp"
26
27 #include <utilities/idd/IddFactory.hxx>
28 #include <utilities/idd/OS_HeatExchanger_Desiccant_BalancedFlow_FieldEnums.hxx>
29 #include <utilities/idd/IddEnums.hxx>
30
31 namespace openstudio {
32
33 namespace model {
34
35 namespace detail {
36
37 22 HeatExchangerDesiccantBalancedFlow_Impl::HeatExchangerDesiccantBalancedFlow_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
38 22 : AirToAirComponent_Impl(idfObject, model, keepHandle) {
39
4/6
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22 times.
✗ Branch 13 not taken.
22 OS_ASSERT(idfObject.iddObject().type() == HeatExchangerDesiccantBalancedFlow::iddObjectType());
40 22 }
41
42 ✗ HeatExchangerDesiccantBalancedFlow_Impl::HeatExchangerDesiccantBalancedFlow_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
43 ✗ Model_Impl* model, bool keepHandle)
44 ✗ : AirToAirComponent_Impl(other, model, keepHandle) {
45 ✗ OS_ASSERT(other.iddObject().type() == HeatExchangerDesiccantBalancedFlow::iddObjectType());
46 ✗ }
47
48 5 HeatExchangerDesiccantBalancedFlow_Impl::HeatExchangerDesiccantBalancedFlow_Impl(const HeatExchangerDesiccantBalancedFlow_Impl& other,
49 5 Model_Impl* model, bool keepHandle)
50 5 : AirToAirComponent_Impl(other, model, keepHandle) {}
51
52 ✗ const std::vector<std::string>& HeatExchangerDesiccantBalancedFlow_Impl::outputVariableNames() const {
53 static const std::vector<std::string> result{
54 "Heat Exchanger Sensible Heating Rate", "Heat Exchanger Sensible Heating Energy", "Heat Exchanger Latent Gain Rate",
55 "Heat Exchanger Latent Gain Energy", "Heat Exchanger Total Heating Rate", "Heat Exchanger Total Heating Energy",
56 "Heat Exchanger Sensible Cooling Rate", "Heat Exchanger Sensible Cooling Energy", "Heat Exchanger Latent Cooling Rate",
57 "Heat Exchanger Latent Cooling Energy", "Heat Exchanger Total Cooling Rate", "Heat Exchanger Total Cooling Energy",
58 ✗ "Heat Exchanger Electricity Rate", "Heat Exchanger Electricity Energy"};
59 ✗ return result;
60 ✗ }
61
62 ✗ IddObjectType HeatExchangerDesiccantBalancedFlow_Impl::iddObjectType() const {
63 ✗ return HeatExchangerDesiccantBalancedFlow::iddObjectType();
64 }
65
66 9 std::vector<ModelObject> HeatExchangerDesiccantBalancedFlow_Impl::children() const {
67 9 std::vector<ModelObject> result;
68
69 // This is a ResourceObject, so it shouldn't really be a child except for OS App / IG
70
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 result.push_back(heatExchangerPerformance());
71
72 std::vector<AirflowNetworkEquivalentDuct> myAFNItems =
73
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 getObject<ModelObject>().getModelObjectSources<AirflowNetworkEquivalentDuct>(AirflowNetworkEquivalentDuct::iddObjectType());
74
1/1
✓ Branch 5 taken 9 times.
9 result.insert(result.end(), myAFNItems.begin(), myAFNItems.end());
75 18 return result;
76 9 }
77
78 ✗ std::vector<ScheduleTypeKey> HeatExchangerDesiccantBalancedFlow_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
79 ✗ std::vector<ScheduleTypeKey> result;
80 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
81 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
82 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
83 ✗ if (std::find(b, e, OS_HeatExchanger_Desiccant_BalancedFlowFields::AvailabilitySchedule) != e) {
84 ✗ result.push_back(ScheduleTypeKey("HeatExchangerDesiccantBalancedFlow", "Availability"));
85 }
86 ✗ return result;
87 ✗ }
88
89 18 boost::optional<HVACComponent> HeatExchangerDesiccantBalancedFlow_Impl::containingHVACComponent() const {
90 // CoilSystemCoolingWaterHeatExchangerAssisted
91 {
92
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 auto coilSystems = model().getConcreteModelObjects<CoilSystemCoolingWaterHeatExchangerAssisted>();
93
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
18 for (const auto& coilSystem : coilSystems) {
94 ✗ if (coilSystem.heatExchanger().handle() == handle()) {
95 ✗ return coilSystem;
96 }
97 }
98 18 }
99
100 // CoilSystemCoolingDXHeatExchangerAssisted
101 {
102
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
18 auto coilSystems = model().getConcreteModelObjects<CoilSystemCoolingDXHeatExchangerAssisted>();
103
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 16 times.
18 for (const auto& coilSystem : coilSystems) {
104
5/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
2 if (coilSystem.heatExchanger().handle() == handle()) {
105
1/1
✓ Branch 1 taken 2 times.
2 return coilSystem;
106 }
107 }
108 18 }
109
110 16 return boost::none;
111 }
112
113 11 bool HeatExchangerDesiccantBalancedFlow_Impl::addToNode(Node& node) {
114 11 bool success(false);
115
116
1/1
✓ Branch 1 taken 11 times.
11 auto t_containingHVACComponent = containingHVACComponent();
117
118
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 10 times.
11 if (t_containingHVACComponent) {
119
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
2 if (t_containingHVACComponent->optionalCast<CoilSystemCoolingWaterHeatExchangerAssisted>()) {
120 ✗ LOG(Warn,
121 this->briefDescription() << " cannot be connected directly when it's part of a parent CoilSystemCoolingWaterHeatExchangerAssisted. "
122 "Please call CoilSystemCoolingWaterHeatExchangerAssisted::addToNode instead");
123
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
2 } else if (t_containingHVACComponent->optionalCast<CoilSystemCoolingDXHeatExchangerAssisted>()) {
124
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 14 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
1 LOG(Warn, this->briefDescription() << " cannot be connected directly when it's part of a parent CoilSystemCoolingDXHeatExchangerAssisted. "
125 "Please call CoilSystemCoolingDXHeatExchangerAssisted::addToNode instead");
126 } else {
127 // Shouldn't happen
128 ✗ OS_ASSERT(false);
129 }
130 } else {
131
1/1
✓ Branch 1 taken 10 times.
10 success = AirToAirComponent_Impl::addToNode(node);
132 }
133
134 11 return success;
135 11 }
136
137 7 Schedule HeatExchangerDesiccantBalancedFlow_Impl::availabilitySchedule() const {
138
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<Schedule> value = optionalAvailabilitySchedule();
139
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 if (!value) {
140 ✗ LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached.");
141 }
142
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 return value.get();
143 7 }
144
145 boost::optional<HeatExchangerDesiccantBalancedFlowPerformanceDataType1>
146 24 HeatExchangerDesiccantBalancedFlow_Impl::optionalHeatExchangerPerformance() const {
147
1/1
✓ Branch 1 taken 24 times.
48 return getObject<ModelObject>().getModelObjectTarget<HeatExchangerDesiccantBalancedFlowPerformanceDataType1>(
148
1/1
✓ Branch 1 taken 24 times.
48 OS_HeatExchanger_Desiccant_BalancedFlowFields::HeatExchangerPerformance);
149 }
150
151 24 HeatExchangerDesiccantBalancedFlowPerformanceDataType1 HeatExchangerDesiccantBalancedFlow_Impl::heatExchangerPerformance() const {
152
1/1
✓ Branch 1 taken 24 times.
24 boost::optional<HeatExchangerDesiccantBalancedFlowPerformanceDataType1> value = optionalHeatExchangerPerformance();
153
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 if (!value) {
154 ✗ LOG_AND_THROW(briefDescription() << " does not have a Heat Exchanger Performance attached.");
155 }
156
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
48 return value.get();
157 24 }
158
159 5 bool HeatExchangerDesiccantBalancedFlow_Impl::economizerLockout() const {
160
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<std::string> value = getString(OS_HeatExchanger_Desiccant_BalancedFlowFields::EconomizerLockout, true);
161
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(value);
162
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
10 return openstudio::istringEqual(value.get(), "Yes");
163 5 }
164
165 23 bool HeatExchangerDesiccantBalancedFlow_Impl::setAvailabilitySchedule(Schedule& schedule) {
166
3/3
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 23 times.
92 bool result = setSchedule(OS_HeatExchanger_Desiccant_BalancedFlowFields::AvailabilitySchedule, "HeatExchangerDesiccantBalancedFlow",
167 "Availability", schedule);
168 23 return result;
169 }
170
171 24 bool HeatExchangerDesiccantBalancedFlow_Impl::setHeatExchangerPerformance(
172 const HeatExchangerDesiccantBalancedFlowPerformanceDataType1& heatExchangerPerformance) {
173
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 bool result = setPointer(OS_HeatExchanger_Desiccant_BalancedFlowFields::HeatExchangerPerformance, heatExchangerPerformance.handle());
174 24 return result;
175 }
176
177 22 bool HeatExchangerDesiccantBalancedFlow_Impl::setEconomizerLockout(bool economizerLockout) {
178 22 return setBooleanFieldValue(OS_HeatExchanger_Desiccant_BalancedFlowFields::EconomizerLockout, economizerLockout);
179 }
180
181 7 boost::optional<Schedule> HeatExchangerDesiccantBalancedFlow_Impl::optionalAvailabilitySchedule() const {
182
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_HeatExchanger_Desiccant_BalancedFlowFields::AvailabilitySchedule);
183 }
184
185 ✗ boost::optional<ModelObject> HeatExchangerDesiccantBalancedFlow_Impl::availabilityScheduleAsModelObject() const {
186 ✗ OptionalModelObject result = availabilitySchedule();
187 ✗ return result;
188 }
189
190 ✗ bool HeatExchangerDesiccantBalancedFlow_Impl::setAvailabilityScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
191 ✗ if (modelObject) {
192 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
193 ✗ if (intermediate) {
194 ✗ Schedule schedule(*intermediate);
195 ✗ return setAvailabilitySchedule(schedule);
196 ✗ }
197 ✗ }
198 ✗ return false;
199 }
200
201 112 unsigned HeatExchangerDesiccantBalancedFlow_Impl::primaryAirInletPort() const {
202 112 return OS_HeatExchanger_Desiccant_BalancedFlowFields::RegenerationAirInletNode;
203 }
204
205 25 unsigned HeatExchangerDesiccantBalancedFlow_Impl::primaryAirOutletPort() const {
206 25 return OS_HeatExchanger_Desiccant_BalancedFlowFields::RegenerationAirOutletNode;
207 }
208
209 25 unsigned HeatExchangerDesiccantBalancedFlow_Impl::secondaryAirInletPort() const {
210 25 return OS_HeatExchanger_Desiccant_BalancedFlowFields::ProcessAirInletNode;
211 }
212
213 108 unsigned HeatExchangerDesiccantBalancedFlow_Impl::secondaryAirOutletPort() const {
214 108 return OS_HeatExchanger_Desiccant_BalancedFlowFields::ProcessAirOutletNode;
215 }
216
217 ✗ AirflowNetworkEquivalentDuct HeatExchangerDesiccantBalancedFlow_Impl::getAirflowNetworkEquivalentDuct(double length, double diameter) {
218 ✗ boost::optional<AirflowNetworkEquivalentDuct> opt = airflowNetworkEquivalentDuct();
219 ✗ if (opt) {
220 ✗ if (opt->airPathLength() != length) {
221 ✗ opt->setAirPathLength(length);
222 }
223 ✗ if (opt->airPathHydraulicDiameter() != diameter) {
224 ✗ opt->setAirPathHydraulicDiameter(diameter);
225 }
226 }
227 ✗ return AirflowNetworkEquivalentDuct(model(), length, diameter, handle());
228 ✗ }
229
230 ✗ boost::optional<AirflowNetworkEquivalentDuct> HeatExchangerDesiccantBalancedFlow_Impl::airflowNetworkEquivalentDuct() const {
231 std::vector<AirflowNetworkEquivalentDuct> myAFN =
232 ✗ getObject<ModelObject>().getModelObjectSources<AirflowNetworkEquivalentDuct>(AirflowNetworkEquivalentDuct::iddObjectType());
233 ✗ auto count = myAFN.size();
234 ✗ if (count == 1) {
235 ✗ return myAFN[0];
236 ✗ } else if (count > 1) {
237 ✗ LOG(Warn, briefDescription() << " has more than one AirflowNetwork EquivalentDuct attached, returning first.");
238 ✗ return myAFN[0];
239 }
240 ✗ return boost::none;
241 ✗ }
242
243 ✗ ComponentType HeatExchangerDesiccantBalancedFlow_Impl::componentType() const {
244 ✗ return ComponentType::None;
245 }
246
247 ✗ std::vector<FuelType> HeatExchangerDesiccantBalancedFlow_Impl::coolingFuelTypes() const {
248 ✗ return {};
249 }
250
251 ✗ std::vector<FuelType> HeatExchangerDesiccantBalancedFlow_Impl::heatingFuelTypes() const {
252 ✗ return {};
253 }
254
255 ✗ std::vector<AppGFuelType> HeatExchangerDesiccantBalancedFlow_Impl::appGHeatingFuelTypes() const {
256 ✗ return {};
257 }
258
259 } // namespace detail
260
261 6 HeatExchangerDesiccantBalancedFlow::HeatExchangerDesiccantBalancedFlow(const Model& model)
262 6 : AirToAirComponent(HeatExchangerDesiccantBalancedFlow::iddObjectType(), model) {
263
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 5 not taken.
6 OS_ASSERT(getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>());
264
265
1/1
✓ Branch 1 taken 6 times.
6 Schedule schedule = model.alwaysOnDiscreteSchedule();
266
1/1
✓ Branch 1 taken 6 times.
6 setAvailabilitySchedule(schedule);
267
268
1/1
✓ Branch 1 taken 6 times.
6 HeatExchangerDesiccantBalancedFlowPerformanceDataType1 heatExchangerPerformance(model);
269
1/1
✓ Branch 1 taken 6 times.
6 bool ok = setHeatExchangerPerformance(heatExchangerPerformance);
270
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
6 OS_ASSERT(ok);
271
272
1/1
✓ Branch 1 taken 6 times.
6 setEconomizerLockout(true);
273 6 }
274
275 16 HeatExchangerDesiccantBalancedFlow::HeatExchangerDesiccantBalancedFlow(
276 16 const Model& model, const HeatExchangerDesiccantBalancedFlowPerformanceDataType1& heatExchangerPerformance)
277 16 : AirToAirComponent(HeatExchangerDesiccantBalancedFlow::iddObjectType(), model) {
278
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 5 not taken.
16 OS_ASSERT(getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>());
279
280
1/1
✓ Branch 1 taken 16 times.
16 Schedule schedule = model.alwaysOnDiscreteSchedule();
281
1/1
✓ Branch 1 taken 16 times.
16 setAvailabilitySchedule(schedule);
282
283
1/1
✓ Branch 1 taken 16 times.
16 bool ok = setHeatExchangerPerformance(heatExchangerPerformance);
284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (!ok) {
285 ✗ remove();
286 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s heatExchangerDesiccantBalancedFlowPerformanceDataType1 to "
287 << heatExchangerPerformance.briefDescription() << ".");
288 }
289
290
1/1
✓ Branch 1 taken 16 times.
16 setEconomizerLockout(true);
291 16 }
292
293 7784 IddObjectType HeatExchangerDesiccantBalancedFlow::iddObjectType() {
294
1/1
✓ Branch 1 taken 7784 times.
7784 return {IddObjectType::OS_HeatExchanger_Desiccant_BalancedFlow};
295 }
296
297 7 Schedule HeatExchangerDesiccantBalancedFlow::availabilitySchedule() const {
298
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->availabilitySchedule();
299 }
300
301 15 HeatExchangerDesiccantBalancedFlowPerformanceDataType1 HeatExchangerDesiccantBalancedFlow::heatExchangerPerformance() const {
302
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->heatExchangerPerformance();
303 }
304
305 5 bool HeatExchangerDesiccantBalancedFlow::economizerLockout() const {
306
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->economizerLockout();
307 }
308
309 23 bool HeatExchangerDesiccantBalancedFlow::setAvailabilitySchedule(Schedule& schedule) {
310
1/1
✓ Branch 3 taken 23 times.
23 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->setAvailabilitySchedule(schedule);
311 }
312
313 24 bool HeatExchangerDesiccantBalancedFlow::setHeatExchangerPerformance(
314 const HeatExchangerDesiccantBalancedFlowPerformanceDataType1& heatExchangerPerformance) {
315
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->setHeatExchangerPerformance(heatExchangerPerformance);
316 }
317
318 22 bool HeatExchangerDesiccantBalancedFlow::setEconomizerLockout(bool economizerLockout) {
319
1/1
✓ Branch 3 taken 22 times.
22 return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->setEconomizerLockout(economizerLockout);
320 }
321
322 ✗ AirflowNetworkEquivalentDuct HeatExchangerDesiccantBalancedFlow::getAirflowNetworkEquivalentDuct(double length, double diameter) {
323 ✗ return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->getAirflowNetworkEquivalentDuct(length, diameter);
324 }
325
326 ✗ boost::optional<AirflowNetworkEquivalentDuct> HeatExchangerDesiccantBalancedFlow::airflowNetworkEquivalentDuct() const {
327 ✗ return getImpl<detail::HeatExchangerDesiccantBalancedFlow_Impl>()->airflowNetworkEquivalentDuct();
328 }
329
330 /// @cond
331 14 HeatExchangerDesiccantBalancedFlow::HeatExchangerDesiccantBalancedFlow(std::shared_ptr<detail::HeatExchangerDesiccantBalancedFlow_Impl> impl)
332
1/1
✓ Branch 3 taken 14 times.
14 : AirToAirComponent(std::move(impl)) {}
333 /// @endcond
334
335 } // namespace model
336 } // namespace openstudio
337