GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.6% 112 / 0 / 134
Functions: 80.0% 24 / 0 / 30
Branches: 54.1% 105 / 0 / 194

src/model/CoilSystemCoolingDXHeatExchangerAssisted.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 "CoilSystemCoolingDXHeatExchangerAssisted.hpp"
7 #include "CoilSystemCoolingDXHeatExchangerAssisted_Impl.hpp"
8 #include "CoilCoolingDXSingleSpeed.hpp"
9 #include "CoilCoolingDXSingleSpeed_Impl.hpp"
10 #include "Node.hpp"
11 #include "Node_Impl.hpp"
12 #include "Model.hpp"
13 #include "Model_Impl.hpp"
14 #include "AirLoopHVAC.hpp"
15 #include "AirLoopHVAC_Impl.hpp"
16 #include "AirLoopHVACOutdoorAirSystem.hpp"
17 #include "AirLoopHVACOutdoorAirSystem_Impl.hpp"
18 #include "HeatExchangerAirToAirSensibleAndLatent.hpp"
19 #include "HeatExchangerAirToAirSensibleAndLatent_Impl.hpp"
20 #include "HeatExchangerDesiccantBalancedFlow.hpp"
21 #include "HeatExchangerDesiccantBalancedFlow_Impl.hpp"
22
23 #include "ZoneHVACPackagedTerminalHeatPump.hpp"
24 #include "ZoneHVACPackagedTerminalHeatPump_Impl.hpp"
25 #include "AirLoopHVACUnitarySystem.hpp"
26 #include "AirLoopHVACUnitarySystem_Impl.hpp"
27 #include "AirLoopHVACUnitaryHeatPumpAirToAir.hpp"
28 #include "AirLoopHVACUnitaryHeatPumpAirToAir_Impl.hpp"
29 #include "AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass.hpp"
30 #include "AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass_Impl.hpp"
31
32 #include <utilities/idd/OS_CoilSystem_Cooling_DX_HeatExchangerAssisted_FieldEnums.hxx>
33 #include <utilities/idd/IddFactory.hxx>
34
35 #include "../utilities/core/Assert.hpp"
36 #include "../utilities/data/DataEnums.hpp"
37
38 namespace openstudio {
39 namespace model {
40
41 namespace detail {
42
43 20 CoilSystemCoolingDXHeatExchangerAssisted_Impl::CoilSystemCoolingDXHeatExchangerAssisted_Impl(const IdfObject& idfObject, Model_Impl* model,
44 20 bool keepHandle)
45 20 : StraightComponent_Impl(idfObject, model, keepHandle) {
46
4/6
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 20 times.
✗ Branch 13 not taken.
20 OS_ASSERT(idfObject.iddObject().type() == CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType());
47 20 }
48
49 ✗ CoilSystemCoolingDXHeatExchangerAssisted_Impl::CoilSystemCoolingDXHeatExchangerAssisted_Impl(
50 ✗ const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
51 ✗ : StraightComponent_Impl(other, model, keepHandle) {
52 ✗ OS_ASSERT(other.iddObject().type() == CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType());
53 ✗ }
54
55 7 CoilSystemCoolingDXHeatExchangerAssisted_Impl::CoilSystemCoolingDXHeatExchangerAssisted_Impl(
56 7 const CoilSystemCoolingDXHeatExchangerAssisted_Impl& other, Model_Impl* model, bool keepHandle)
57 7 : StraightComponent_Impl(other, model, keepHandle) {}
58
59 ✗ const std::vector<std::string>& CoilSystemCoolingDXHeatExchangerAssisted_Impl::outputVariableNames() const {
60 ✗ static const std::vector<std::string> result;
61 // Not appropriate: no specific output, there are at the coil and HX level
62 ✗ return result;
63 }
64
65 17 IddObjectType CoilSystemCoolingDXHeatExchangerAssisted_Impl::iddObjectType() const {
66 17 return CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType();
67 }
68
69 5 std::vector<ModelObject> CoilSystemCoolingDXHeatExchangerAssisted_Impl::children() const {
70 5 std::vector<ModelObject> result;
71
72
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 result.push_back(coolingCoil());
73
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 result.push_back(heatExchanger());
74
75 5 return result;
76 ✗ }
77
78 1 ModelObject CoilSystemCoolingDXHeatExchangerAssisted_Impl::clone(Model model) const {
79
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 auto newCoilSystem = StraightComponent_Impl::clone(model).cast<CoilSystemCoolingDXHeatExchangerAssisted>();
80
81 {
82
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 auto mo = coolingCoil().clone(model).cast<StraightComponent>();
83
1/1
✓ Branch 1 taken 1 time.
1 newCoilSystem.setCoolingCoil(mo);
84 1 }
85
86 {
87
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 auto mo = heatExchanger().clone(model).cast<AirToAirComponent>();
88
1/1
✓ Branch 1 taken 1 time.
1 newCoilSystem.setHeatExchanger(mo);
89 1 }
90
91 2 return std::move(newCoilSystem);
92 1 }
93
94 3 boost::optional<HVACComponent> CoilSystemCoolingDXHeatExchangerAssisted_Impl::containingHVACComponent() const {
95 // AirLoopHVACUnitarySystem
96
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 std::vector<AirLoopHVACUnitarySystem> airLoopHVACUnitarySystems = this->model().getConcreteModelObjects<AirLoopHVACUnitarySystem>();
97
98
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
5 for (const auto& airLoopHVACUnitarySystem : airLoopHVACUnitarySystems) {
99
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<HVACComponent> coolingCoil = airLoopHVACUnitarySystem.coolingCoil()) {
100
6/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 2 times.
3 if (coolingCoil->handle() == this->handle()) {
101
1/1
✓ Branch 1 taken 1 time.
1 return airLoopHVACUnitarySystem;
102 }
103 3 }
104 }
105
106 // AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass
107 std::vector<AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass> bypassSystems =
108
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 this->model().getConcreteModelObjects<AirLoopHVACUnitaryHeatCoolVAVChangeoverBypass>();
109
110
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
2 for (const auto& bypassSystem : bypassSystems) {
111
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (boost::optional<HVACComponent> coolingCoil = bypassSystem.coolingCoil()) {
112
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
1 if (coolingCoil->handle() == this->handle()) {
113
1/1
✓ Branch 1 taken 1 time.
1 return bypassSystem;
114 }
115 1 }
116 }
117
118 // AirLoopHVACUnitaryHeatPumpAirToAir
119
120 1 std::vector<AirLoopHVACUnitaryHeatPumpAirToAir> airLoopHVACUnitaryHeatPumpAirToAirs;
121
122
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 airLoopHVACUnitaryHeatPumpAirToAirs = this->model().getConcreteModelObjects<AirLoopHVACUnitaryHeatPumpAirToAir>();
123
124
1/2
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
1 for (const auto& airLoopHVACUnitaryHeatPumpAirToAir : airLoopHVACUnitaryHeatPumpAirToAirs) {
125
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (boost::optional<HVACComponent> coil = airLoopHVACUnitaryHeatPumpAirToAir.coolingCoil()) {
126
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
1 if (coil->handle() == this->handle()) {
127
1/1
✓ Branch 1 taken 1 time.
1 return airLoopHVACUnitaryHeatPumpAirToAir;
128 }
129 1 }
130 }
131 ✗ return boost::none;
132 3 }
133
134 1 boost::optional<ZoneHVACComponent> CoilSystemCoolingDXHeatExchangerAssisted_Impl::containingZoneHVACComponent() const {
135
136 // ZoneHVACPackagedTerminalHeatPump
137
138 1 std::vector<ZoneHVACPackagedTerminalHeatPump> zoneHVACPackagedTerminalHeatPumps;
139
140
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 zoneHVACPackagedTerminalHeatPumps = this->model().getConcreteModelObjects<ZoneHVACPackagedTerminalHeatPump>();
141
142
1/2
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
1 for (const auto& zoneHVACPackagedTerminalHeatPump : zoneHVACPackagedTerminalHeatPumps) {
143
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (boost::optional<HVACComponent> coil = zoneHVACPackagedTerminalHeatPump.coolingCoil()) {
144
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
1 if (coil->handle() == this->handle()) {
145
1/1
✓ Branch 1 taken 1 time.
1 return zoneHVACPackagedTerminalHeatPump;
146 }
147 1 }
148 }
149
150 // ZoneHVAC:WindowAirConditioner not wrapped
151
152 ✗ return boost::none;
153 1 }
154
155 27 AirToAirComponent CoilSystemCoolingDXHeatExchangerAssisted_Impl::heatExchanger() const {
156
1/1
✓ Branch 1 taken 27 times.
27 boost::optional<AirToAirComponent> value = optionalHeatExchanger();
157
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
27 if (!value) {
158 ✗ LOG_AND_THROW(briefDescription() << " does not have an Heat Exchanger attached.");
159 }
160
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
54 return value.get();
161 27 }
162
163 34 StraightComponent CoilSystemCoolingDXHeatExchangerAssisted_Impl::coolingCoil() const {
164
1/1
✓ Branch 1 taken 34 times.
34 boost::optional<StraightComponent> value = optionalCoolingCoil();
165
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
34 if (!value) {
166 ✗ LOG_AND_THROW(briefDescription() << " does not have an Cooling Coil attached.");
167 }
168
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
68 return value.get();
169 34 }
170
171 24 bool CoilSystemCoolingDXHeatExchangerAssisted_Impl::setHeatExchanger(const AirToAirComponent& heatExchanger) {
172
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 bool result = setPointer(OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::HeatExchanger, heatExchanger.handle());
173 24 return result;
174 }
175
176 24 bool CoilSystemCoolingDXHeatExchangerAssisted_Impl::setCoolingCoil(const StraightComponent& coolingCoil) {
177
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 bool result = setPointer(OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::CoolingCoil, coolingCoil.handle());
178 24 return result;
179 }
180
181 27 boost::optional<AirToAirComponent> CoilSystemCoolingDXHeatExchangerAssisted_Impl::optionalHeatExchanger() const {
182
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 return getObject<ModelObject>().getModelObjectTarget<AirToAirComponent>(OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::HeatExchanger);
183 }
184
185 34 boost::optional<StraightComponent> CoilSystemCoolingDXHeatExchangerAssisted_Impl::optionalCoolingCoil() const {
186
2/2
✓ Branch 1 taken 34 times.
✓ Branch 4 taken 34 times.
34 return getObject<ModelObject>().getModelObjectTarget<StraightComponent>(OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::CoolingCoil);
187 }
188
189 7 unsigned CoilSystemCoolingDXHeatExchangerAssisted_Impl::inletPort() const {
190 7 return OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::AirInletNodeName;
191 }
192
193 7 unsigned CoilSystemCoolingDXHeatExchangerAssisted_Impl::outletPort() const {
194 7 return OS_CoilSystem_Cooling_DX_HeatExchangerAssistedFields::AirOutletNodeName;
195 }
196
197 4 bool CoilSystemCoolingDXHeatExchangerAssisted_Impl::addToNode(Node& /*node*/) {
198
199 /**
200 * Note JM 2019-03-13: At this point in time
201 * CoilSystemCoolingDXHeatExchangerAssisted is **NOT** allowed on a Branch directly and should be placed inside one of the Unitary systems
202 * cf https://github.com/NREL/EnergyPlus/issues/7222
203 * This method returns false and does nothing as a result
204 */
205
206 // TODO: uncomment this if it becomes allowed
207 //if( boost::optional<AirLoopHVAC> airLoop = node.airLoopHVAC() ) {
208 //if( ! airLoop->demandComponent(node.handle()) ) {
209 //return StraightComponent_Impl::addToNode( node );
210 //}
211 //}
212
213 //if ( auto oa = node.airLoopHVACOutdoorAirSystem() ) {
214 //return StraightComponent_Impl::addToNode( node );
215 //}
216
217 4 return false;
218 }
219
220 ✗ ComponentType CoilSystemCoolingDXHeatExchangerAssisted_Impl::componentType() const {
221 ✗ return ComponentType::Cooling;
222 }
223
224 ✗ std::vector<FuelType> CoilSystemCoolingDXHeatExchangerAssisted_Impl::coolingFuelTypes() const {
225 ✗ return {FuelType::Electricity};
226 }
227
228 ✗ std::vector<FuelType> CoilSystemCoolingDXHeatExchangerAssisted_Impl::heatingFuelTypes() const {
229 ✗ return {};
230 }
231
232 ✗ std::vector<AppGFuelType> CoilSystemCoolingDXHeatExchangerAssisted_Impl::appGHeatingFuelTypes() const {
233 ✗ return {};
234 }
235
236 } // namespace detail
237
238 18 CoilSystemCoolingDXHeatExchangerAssisted::CoilSystemCoolingDXHeatExchangerAssisted(const Model& model)
239 18 : StraightComponent(CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType(), model) {
240
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✗ Branch 5 not taken.
18 OS_ASSERT(getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>());
241
242
1/1
✓ Branch 1 taken 18 times.
18 CoilCoolingDXSingleSpeed coolingCoil(model);
243
1/1
✓ Branch 1 taken 18 times.
18 setCoolingCoil(coolingCoil);
244
245
1/1
✓ Branch 1 taken 18 times.
18 HeatExchangerAirToAirSensibleAndLatent heatExchanger(model);
246
1/1
✓ Branch 1 taken 18 times.
18 heatExchanger.setSupplyAirOutletTemperatureControl(false);
247
1/1
✓ Branch 1 taken 18 times.
18 setHeatExchanger(heatExchanger);
248 18 }
249
250 2 CoilSystemCoolingDXHeatExchangerAssisted::CoilSystemCoolingDXHeatExchangerAssisted(const Model& model, const AirToAirComponent& heatExchanger)
251 2 : StraightComponent(CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType(), model) {
252
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 5 not taken.
2 OS_ASSERT(getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>());
253
254
1/1
✓ Branch 1 taken 2 times.
2 bool ok = setHeatExchanger(heatExchanger);
255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (!ok) {
256 ✗ LOG_AND_THROW("Unable to set " << briefDescription() << "'s Heat Exchanger " << heatExchanger.briefDescription() << ".");
257 }
258
259
1/1
✓ Branch 1 taken 2 times.
2 CoilCoolingDXSingleSpeed coolingCoil(model);
260
1/1
✓ Branch 1 taken 2 times.
2 setCoolingCoil(coolingCoil);
261
262
1/1
✓ Branch 1 taken 2 times.
2 setHeatExchanger(heatExchanger);
263 2 }
264
265 8138 IddObjectType CoilSystemCoolingDXHeatExchangerAssisted::iddObjectType() {
266
1/1
✓ Branch 1 taken 8138 times.
8138 return {IddObjectType::OS_CoilSystem_Cooling_DX_HeatExchangerAssisted};
267 }
268
269 21 AirToAirComponent CoilSystemCoolingDXHeatExchangerAssisted::heatExchanger() const {
270
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>()->heatExchanger();
271 }
272
273 28 StraightComponent CoilSystemCoolingDXHeatExchangerAssisted::coolingCoil() const {
274
1/1
✓ Branch 3 taken 28 times.
28 return getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>()->coolingCoil();
275 }
276
277 24 bool CoilSystemCoolingDXHeatExchangerAssisted::setHeatExchanger(const AirToAirComponent& heatExchanger) {
278
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>()->setHeatExchanger(heatExchanger);
279 }
280
281 24 bool CoilSystemCoolingDXHeatExchangerAssisted::setCoolingCoil(const StraightComponent& coolingCoil) {
282
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl>()->setCoolingCoil(coolingCoil);
283 }
284
285 /// @cond
286 40 CoilSystemCoolingDXHeatExchangerAssisted::CoilSystemCoolingDXHeatExchangerAssisted(
287 40 std::shared_ptr<detail::CoilSystemCoolingDXHeatExchangerAssisted_Impl> impl)
288
1/1
✓ Branch 3 taken 40 times.
40 : StraightComponent(std::move(impl)) {}
289 /// @endcond
290
291 } // namespace model
292 } // namespace openstudio
293