GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 60.7% 71 / 0 / 117
Functions: 100.0% 1 / 0 / 1
Branches: 38.6% 88 / 0 / 228

src/energyplus/ForwardTranslator/ForwardTranslateZoneHVACEquipmentList.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 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
8 #include "../../model/ZoneHVACEquipmentList.hpp"
9 #include "../../model/ZoneHVACEquipmentList_Impl.hpp"
10 #include "../../model/ZoneHVACComponent.hpp"
11 #include "../../model/ZoneHVACComponent_Impl.hpp"
12 #include "../../model/Schedule.hpp"
13 #include "../../model/ThermalZone.hpp"
14 #include "../../model/RefrigerationAirChiller.hpp"
15 #include "../../model/RefrigerationAirChiller_Impl.hpp"
16 #include "../../model/ZoneVentilationDesignFlowRate.hpp"
17 #include "../../model/ZoneVentilationDesignFlowRate_Impl.hpp"
18 #include "../../model/ZoneVentilationWindandStackOpenArea.hpp"
19 #include "../../model/ZoneVentilationWindandStackOpenArea_Impl.hpp"
20 #include "../../model/AirLoopHVACReturnPlenum.hpp"
21 #include "../../model/AirLoopHVACReturnPlenum_Impl.hpp"
22 #include "../../utilities/idd/IddEnums.hpp"
23 #include <utilities/idd/IddEnums.hxx>
24 #include <utilities/idd/ZoneHVAC_EquipmentList_FieldEnums.hxx>
25 #include <utilities/idd/ZoneHVAC_RefrigerationChillerSet_FieldEnums.hxx>
26
27 using namespace openstudio::model;
28
29 namespace openstudio {
30
31 namespace energyplus {
32
33 127 boost::optional<IdfObject> ForwardTranslator::translateZoneHVACEquipmentList(ZoneHVACEquipmentList& modelObject) {
34 127 OptionalString s;
35 127 OptionalDouble d;
36 127 OptionalModelObject temp;
37
38
1/1
✓ Branch 1 taken 127 times.
127 std::vector<ModelObject> objects = modelObject.equipment();
39
40
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
127 if (objects.empty()) {
41 // do not write out this object
42 ✗ return boost::none;
43 }
44
45 // If there is nothing but ZoneVentilationDesignFlowRate or ZoneVentilationWindandStackOpenArea then stop
46 // We don't want a zone hvac equipment list in the idf (these are ZoneHVAC comp in OS but not in E+)
47
2/3
✓ Branch 1 taken 127 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 127 times.
254 if ((subsetCastVector<model::ZoneVentilationDesignFlowRate>(objects).size()
48
1/1
✓ Branch 1 taken 127 times.
254 + subsetCastVector<model::ZoneVentilationWindandStackOpenArea>(objects).size())
49 127 == objects.size()) {
50 ✗ return boost::none;
51 }
52
53
1/1
✓ Branch 1 taken 127 times.
127 std::vector<ModelObject> coolingVector = modelObject.equipmentInCoolingOrder();
54
1/1
✓ Branch 1 taken 127 times.
127 std::vector<ModelObject> heatingVector = modelObject.equipmentInHeatingOrder();
55
56 127 std::vector<ModelObject> airChillers;
57 127 std::vector<ModelObject> stdEquipment;
58
59
2/2
✓ Branch 5 taken 143 times.
✓ Branch 6 taken 127 times.
270 for (const auto& elem : objects) {
60
2/3
✓ Branch 1 taken 143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143 times.
286 if (boost::optional<RefrigerationAirChiller> airChiller = elem.optionalCast<RefrigerationAirChiller>()) {
61 ✗ airChillers.push_back(airChiller.get());
62
7/16
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 143 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 143 times.
✓ Branch 12 taken 143 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 143 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 143 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
429 } else if (elem.optionalCast<ZoneVentilationDesignFlowRate>() || elem.optionalCast<ZoneVentilationWindandStackOpenArea>()) {
63 ✗ continue;
64 } else {
65
1/1
✓ Branch 1 taken 143 times.
143 stdEquipment.push_back(elem);
66 143 }
67 }
68
69 127 boost::optional<RefrigerationAirChiller> airChiller;
70 127 std::map<ModelObject, unsigned> coolingMap;
71 127 unsigned chillerSetCoolingPriority = 0;
72 127 unsigned priority = 1;
73 127 int offset = 0;
74
2/2
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 127 times.
270 for (const auto& elem : coolingVector) {
75
3/11
✗ Branch 1 not taken.
✓ Branch 2 taken 143 times.
✗ Branch 4 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 143 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 143 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
143 if (!airChillers.empty() && (airChiller = elem.optionalCast<RefrigerationAirChiller>())) {
76 ✗ if (chillerSetCoolingPriority == 0) {
77 ✗ chillerSetCoolingPriority = priority;
78 } else {
79 ✗ offset++;
80 }
81
7/16
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 143 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 143 times.
✓ Branch 12 taken 143 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 143 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 143 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
429 } else if (elem.optionalCast<ZoneVentilationDesignFlowRate>() || elem.optionalCast<ZoneVentilationWindandStackOpenArea>()) {
82 // ZoneVentilationDesignFlowRate and ZoneVentilationWindandStackOpenArea are not ZoneHVAC from E+ perspective
83 ✗ offset++;
84 } else {
85
2/2
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
143 coolingMap.insert(std::pair<ModelObject, unsigned>(elem, priority - offset));
86 }
87 143 priority++;
88 }
89
90 127 std::map<ModelObject, unsigned> heatingMap;
91 127 unsigned chillerSetHeatingPriority = 0;
92 127 priority = 1;
93 127 offset = 0;
94
2/2
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 127 times.
270 for (const auto& elem : heatingVector) {
95
3/11
✗ Branch 1 not taken.
✓ Branch 2 taken 143 times.
✗ Branch 4 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 143 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 143 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
143 if (!airChillers.empty() && (airChiller = elem.optionalCast<RefrigerationAirChiller>())) {
96 ✗ if (chillerSetHeatingPriority == 0) {
97 ✗ chillerSetHeatingPriority = priority;
98 } else {
99 ✗ offset++;
100 }
101
7/16
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 143 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 143 times.
✓ Branch 12 taken 143 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 143 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 143 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
429 } else if (elem.optionalCast<ZoneVentilationDesignFlowRate>() || elem.optionalCast<ZoneVentilationWindandStackOpenArea>()) {
102 // ZoneVentilationDesignFlowRate and ZoneVentilationWindandStackOpenArea are not ZoneHVAC from E+ perspective
103 ✗ offset++;
104 } else {
105
2/2
✓ Branch 1 taken 143 times.
✓ Branch 4 taken 143 times.
143 heatingMap.insert(std::pair<ModelObject, unsigned>(elem, priority - offset));
106 }
107 143 priority++;
108 }
109
110
2/2
✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
127 IdfObject idfObject(IddObjectType::ZoneHVAC_EquipmentList);
111
112 // Name
113 127 std::string name;
114
2/2
✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
127 s = modelObject.thermalZone().name();
115
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if (s) {
116
2/2
✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
127 name = s.get() + " Equipment List";
117
1/1
✓ Branch 1 taken 127 times.
127 idfObject.setName(name);
118 }
119
120 // LoadDistributionScheme
121 {
122
1/1
✓ Branch 1 taken 127 times.
127 auto scheme = modelObject.loadDistributionScheme();
123
1/1
✓ Branch 1 taken 127 times.
127 idfObject.setString(ZoneHVAC_EquipmentListFields::LoadDistributionScheme, scheme);
124 127 }
125
126
2/2
✓ Branch 5 taken 143 times.
✓ Branch 6 taken 127 times.
270 for (auto& elem : stdEquipment) {
127
1/1
✓ Branch 1 taken 143 times.
143 unsigned coolingPriority = coolingMap[elem];
128
1/1
✓ Branch 1 taken 143 times.
143 unsigned heatingPriority = heatingMap[elem];
129
130 143 boost::optional<IdfObject> _equipment;
131
132
3/3
✓ Branch 1 taken 143 times.
✓ Branch 3 taken 135 times.
✓ Branch 4 taken 8 times.
286 if (auto _equipment = translateAndMapModelObject(elem)) {
133
1/1
✓ Branch 1 taken 135 times.
135 IdfExtensibleGroup eg = idfObject.pushExtensibleGroup();
134
4/4
✓ Branch 1 taken 135 times.
✓ Branch 4 taken 135 times.
✓ Branch 7 taken 135 times.
✓ Branch 10 taken 135 times.
135 eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentObjectType, _equipment->iddObject().name());
135
4/4
✓ Branch 1 taken 135 times.
✓ Branch 4 taken 135 times.
✓ Branch 7 taken 135 times.
✓ Branch 10 taken 135 times.
135 eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentName, _equipment->name().get());
136
1/1
✓ Branch 1 taken 135 times.
135 eg.setUnsigned(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence, coolingPriority);
137
1/1
✓ Branch 1 taken 135 times.
135 eg.setUnsigned(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentHeatingorNoLoadSequence, heatingPriority);
138
139 // Only translate the Sequential Load Fractions if appropriate (model checks for Load Distribution = SequentialLoad, and has heating/cooling
140 // Priority that isn't zero)
141
2/3
✓ Branch 1 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
270 if (boost::optional<Schedule> _schedule = modelObject.sequentialCoolingFractionSchedule(elem)) {
142 ✗ eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentSequentialCoolingFractionScheduleName, _schedule.get().name().get());
143 135 }
144
145
2/3
✓ Branch 1 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
270 if (boost::optional<Schedule> _schedule = modelObject.sequentialHeatingFractionSchedule(elem)) {
146 ✗ eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentSequentialHeatingFractionScheduleName, _schedule.get().name().get());
147 135 }
148 278 }
149
150
1/1
✓ Branch 1 taken 143 times.
143 auto zoneHVAC = elem.optionalCast<ZoneHVACComponent>();
151
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 76 times.
143 if (zoneHVAC) {
152
2/2
✓ Branch 1 taken 67 times.
✓ Branch 4 taken 67 times.
67 auto plenum = zoneHVAC->returnPlenum();
153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if (plenum) {
154 ✗ auto _plenum = translateAndMapModelObject(plenum.get());
155 ✗ }
156 67 }
157 143 }
158
159
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
127 if (!airChillers.empty()) {
160 // ZoneHVAC:RefrigerationChillerSet
161 // Name
162 ✗ IdfObject _chillerSet(IddObjectType::ZoneHVAC_RefrigerationChillerSet);
163
164 ✗ m_idfObjects.push_back(_chillerSet);
165
166 ✗ _chillerSet.setName(name + " Refrigeration Chiller Set");
167
168 // AvailabilityScheduleName
169 ✗ boost::optional<Schedule> availabilitySchedule = modelObject.model().alwaysOnDiscreteSchedule();
170
171 ✗ if (availabilitySchedule) {
172 ✗ boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get());
173
174 ✗ if (_availabilitySchedule && _availabilitySchedule->name()) {
175 ✗ _chillerSet.setString(ZoneHVAC_RefrigerationChillerSetFields::AvailabilityScheduleName, _availabilitySchedule->name().get());
176 }
177 ✗ }
178
179 // ZoneName
180 ✗ boost::optional<ThermalZone> thermalZone = modelObject.thermalZone();
181
182 ✗ if (thermalZone) {
183 ✗ boost::optional<IdfObject> _thermalZone = translateAndMapModelObject(thermalZone.get());
184
185 ✗ if (_thermalZone && _thermalZone->name()) {
186 ✗ _chillerSet.setString(ZoneHVAC_RefrigerationChillerSetFields::ZoneName, _thermalZone->name().get());
187 }
188 ✗ }
189
190 // AirInletNodeName
191 ✗ _chillerSet.setString(ZoneHVAC_RefrigerationChillerSetFields::AirInletNodeName, "");
192
193 // AirOutletNodeName
194 ✗ _chillerSet.setString(ZoneHVAC_RefrigerationChillerSetFields::AirOutletNodeName, "");
195
196 // AirChiller (extensible)
197 ✗ for (auto& elem : airChillers) {
198 ✗ boost::optional<IdfObject> _airChiller = translateAndMapModelObject(elem);
199
200 ✗ if (_airChiller) {
201 ✗ IdfExtensibleGroup eg = _chillerSet.pushExtensibleGroup();
202
203 ✗ eg.setString(ZoneHVAC_RefrigerationChillerSetExtensibleFields::AirChillerName, _airChiller->name().get());
204 ✗ }
205 ✗ }
206
207 ✗ IdfExtensibleGroup eg = idfObject.pushExtensibleGroup();
208
209 ✗ eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentObjectType, _chillerSet.iddObject().name());
210 ✗ eg.setString(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentName, _chillerSet.name().get());
211 ✗ eg.setUnsigned(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentCoolingSequence, chillerSetCoolingPriority);
212 ✗ eg.setUnsigned(ZoneHVAC_EquipmentListExtensibleFields::ZoneEquipmentHeatingorNoLoadSequence, chillerSetHeatingPriority);
213 ✗ }
214
215
1/1
✓ Branch 1 taken 127 times.
127 m_idfObjects.push_back(idfObject);
216
217
1/1
✓ Branch 1 taken 127 times.
127 return idfObject;
218 127 }
219
220 } // namespace energyplus
221
222 } // namespace openstudio
223