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: 75.6% 34 / 0 / 45
Branches: 43.8% 99 / 0 / 226

src/model/ZoneHVACBaseboardRadiantConvectiveWater.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 "ZoneHVACBaseboardRadiantConvectiveWater.hpp"
7 #include "ZoneHVACBaseboardRadiantConvectiveWater_Impl.hpp"
8
9 #include "Schedule.hpp"
10 #include "Schedule_Impl.hpp"
11 #include "Surface.hpp"
12 #include "Surface_Impl.hpp"
13 #include "ThermalZone.hpp"
14 #include "ThermalZone_Impl.hpp"
15 #include "HVACComponent.hpp"
16 #include "HVACComponent_Impl.hpp"
17 #include "CoilHeatingWaterBaseboardRadiant.hpp"
18 #include "CoilHeatingWaterBaseboardRadiant_Impl.hpp"
19 #include "Model.hpp"
20 #include "Space.hpp"
21 #include "ScheduleTypeLimits.hpp"
22 #include "ScheduleTypeRegistry.hpp"
23
24 #include <utilities/idd/IddFactory.hxx>
25 #include <utilities/idd/OS_ZoneHVAC_Baseboard_RadiantConvective_Water_FieldEnums.hxx>
26
27 #include "../utilities/core/Assert.hpp"
28 #include "../utilities/data/DataEnums.hpp"
29
30 namespace openstudio {
31 namespace model {
32
33 namespace detail {
34
35 4 ZoneHVACBaseboardRadiantConvectiveWater_Impl::ZoneHVACBaseboardRadiantConvectiveWater_Impl(const IdfObject& idfObject, Model_Impl* model,
36 4 bool keepHandle)
37 4 : ZoneHVACComponent_Impl(idfObject, model, keepHandle) {
38
4/6
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
4 OS_ASSERT(idfObject.iddObject().type() == ZoneHVACBaseboardRadiantConvectiveWater::iddObjectType());
39 4 }
40
41 ✗ ZoneHVACBaseboardRadiantConvectiveWater_Impl::ZoneHVACBaseboardRadiantConvectiveWater_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
42 ✗ Model_Impl* model, bool keepHandle)
43 ✗ : ZoneHVACComponent_Impl(other, model, keepHandle) {
44 ✗ OS_ASSERT(other.iddObject().type() == ZoneHVACBaseboardRadiantConvectiveWater::iddObjectType());
45 ✗ }
46
47 1 ZoneHVACBaseboardRadiantConvectiveWater_Impl::ZoneHVACBaseboardRadiantConvectiveWater_Impl(
48 1 const ZoneHVACBaseboardRadiantConvectiveWater_Impl& other, Model_Impl* model, bool keepHandle)
49 1 : ZoneHVACComponent_Impl(other, model, keepHandle) {}
50
51 ✗ const std::vector<std::string>& ZoneHVACBaseboardRadiantConvectiveWater_Impl::outputVariableNames() const {
52 static const std::vector<std::string> result{"Baseboard Total Heating Rate", "Baseboard Convective Heating Rate",
53 "Baseboard Radiant Heating Rate", "Baseboard Total Heating Energy",
54 ✗ "Baseboard Convective Heating Energy", "Baseboard Radiant Heating Energy"};
55 ✗ return result;
56 ✗ }
57
58 4 IddObjectType ZoneHVACBaseboardRadiantConvectiveWater_Impl::iddObjectType() const {
59 4 return ZoneHVACBaseboardRadiantConvectiveWater::iddObjectType();
60 }
61
62 ✗ std::vector<ScheduleTypeKey> ZoneHVACBaseboardRadiantConvectiveWater_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
63 ✗ std::vector<ScheduleTypeKey> result;
64 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
65 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
66 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
67 ✗ if (std::find(b, e, OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::AvailabilityScheduleName) != e) {
68 ✗ result.push_back(ScheduleTypeKey("ZoneHVACBaseboardRadiantConvectiveWater", "Availability"));
69 }
70 ✗ return result;
71 ✗ }
72
73 3 unsigned ZoneHVACBaseboardRadiantConvectiveWater_Impl::inletPort() const {
74 3 return 0; // this object has no inlet or outlet node
75 }
76
77 ✗ unsigned ZoneHVACBaseboardRadiantConvectiveWater_Impl::outletPort() const {
78 ✗ return 0; // this object has no inlet or outlet node
79 }
80
81 8 boost::optional<ThermalZone> ZoneHVACBaseboardRadiantConvectiveWater_Impl::thermalZone() const {
82
1/1
✓ Branch 1 taken 8 times.
8 auto thisObject = this->getObject<ModelObject>();
83
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 auto const thermalZones = this->model().getConcreteModelObjects<ThermalZone>();
84
2/2
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 3 times.
13 for (auto const& thermalZone : thermalZones) {
85
1/1
✓ Branch 1 taken 10 times.
10 std::vector<ModelObject> equipment = thermalZone.equipment();
86
87
3/3
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 5 times.
10 if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) {
88
1/1
✓ Branch 1 taken 5 times.
5 return thermalZone;
89 }
90 10 }
91 3 return boost::none;
92 8 }
93
94 3 bool ZoneHVACBaseboardRadiantConvectiveWater_Impl::addToThermalZone(ThermalZone& thermalZone) {
95
1/1
✓ Branch 1 taken 3 times.
3 Model m = this->model();
96
97
7/13
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
3 if (thermalZone.model() != m || thermalZone.isPlenum()) {
98 ✗ return false;
99 }
100
101
1/1
✓ Branch 1 taken 3 times.
3 removeFromThermalZone();
102
103
1/1
✓ Branch 1 taken 3 times.
3 thermalZone.setUseIdealAirLoads(false);
104
105
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());
106
107 3 return true;
108 3 }
109
110 5 void ZoneHVACBaseboardRadiantConvectiveWater_Impl::removeFromThermalZone() {
111
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
10 if (auto thermalZone = this->thermalZone()) {
112
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 thermalZone->removeEquipment(this->getObject<ZoneHVACComponent>());
113 5 }
114 5 }
115
116 1 std::vector<Surface> ZoneHVACBaseboardRadiantConvectiveWater_Impl::surfaces() const {
117
118 //vector to hold all of the surfaces that this radiant system is attached to
119 1 std::vector<Surface> surfaces;
120
121 //get the thermal zone this equipment belongs to
122
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (auto const thermalZone = this->thermalZone()) {
123
124 //loop through all the spaces in this zone
125
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 12 taken 1 time.
2 for (auto const& space : thermalZone->spaces()) {
126
127 //loop through all the surfaces in this space
128
3/3
✓ Branch 1 taken 1 time.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 1 time.
7 for (auto const& surface : space.surfaces()) {
129
1/1
✓ Branch 1 taken 6 times.
6 surfaces.push_back(surface);
130 1 }
131 1 }
132 1 }
133
134 1 return surfaces;
135 ✗ }
136
137 2 std::vector<ModelObject> ZoneHVACBaseboardRadiantConvectiveWater_Impl::children() const {
138 2 std::vector<ModelObject> result;
139
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (OptionalHVACComponent intermediate = optionalHeatingCoil()) {
140
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result.push_back(*intermediate);
141 2 }
142 2 return result;
143 ✗ }
144
145 ✗ ModelObject ZoneHVACBaseboardRadiantConvectiveWater_Impl::clone(Model model) const {
146 ✗ auto baseboardRadConvWaterClone = ZoneHVACComponent_Impl::clone(model).cast<ZoneHVACBaseboardRadiantConvectiveWater>();
147
148 ✗ auto t_heatingCoil = heatingCoil();
149 ✗ auto heatingCoilClone = t_heatingCoil.clone(model).cast<HVACComponent>();
150
151 ✗ baseboardRadConvWaterClone.setHeatingCoil(heatingCoilClone);
152
153 ✗ if (model == this->model()) {
154 ✗ if (auto plant = t_heatingCoil.plantLoop()) {
155 ✗ plant->addDemandBranchForComponent(heatingCoilClone);
156 ✗ }
157 }
158
159 ✗ return std::move(baseboardRadConvWaterClone);
160 ✗ }
161
162 1 std::vector<IdfObject> ZoneHVACBaseboardRadiantConvectiveWater_Impl::remove() {
163
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (auto waterHeatingCoil = heatingCoil().optionalCast<CoilHeatingWaterBaseboardRadiant>()) {
164
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
2 if (boost::optional<PlantLoop> plantLoop = waterHeatingCoil->plantLoop()) {
165 ✗ plantLoop->removeDemandBranchWithComponent(waterHeatingCoil.get());
166 1 }
167 1 }
168 1 return ZoneHVACComponent_Impl::remove();
169 }
170
171 2 Schedule ZoneHVACBaseboardRadiantConvectiveWater_Impl::availabilitySchedule() const {
172
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<Schedule> value = optionalAvailabilitySchedule();
173
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!value) {
174 ✗ LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached.");
175 }
176
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 return value.get();
177 2 }
178
179 2 double ZoneHVACBaseboardRadiantConvectiveWater_Impl::fractionRadiant() const {
180
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::FractionRadiant, true);
181
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
182
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
183 }
184
185 2 double ZoneHVACBaseboardRadiantConvectiveWater_Impl::fractionofRadiantEnergyIncidentonPeople() const {
186
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::FractionofRadiantEnergyIncidentonPeople, true);
187
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
188
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
189 }
190
191 4 HVACComponent ZoneHVACBaseboardRadiantConvectiveWater_Impl::heatingCoil() const {
192
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<HVACComponent> value = optionalHeatingCoil();
193
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (!value) {
194 ✗ LOG_AND_THROW(briefDescription() << " does not have an Heating Coil attached.");
195 }
196
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return value.get();
197 4 }
198
199 4 bool ZoneHVACBaseboardRadiantConvectiveWater_Impl::setAvailabilitySchedule(Schedule& schedule) {
200
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
16 bool result = setSchedule(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::AvailabilityScheduleName,
201 "ZoneHVACBaseboardRadiantConvectiveWater", "Availability", schedule);
202 4 return result;
203 }
204
205 5 bool ZoneHVACBaseboardRadiantConvectiveWater_Impl::setFractionRadiant(double fractionRadiant) {
206 5 bool result = setDouble(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::FractionRadiant, fractionRadiant);
207 5 return result;
208 }
209
210 5 bool ZoneHVACBaseboardRadiantConvectiveWater_Impl::setFractionofRadiantEnergyIncidentonPeople(double fractionofRadiantEnergyIncidentonPeople) {
211 5 bool result = setDouble(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::FractionofRadiantEnergyIncidentonPeople,
212 fractionofRadiantEnergyIncidentonPeople);
213 5 return result;
214 }
215
216 4 bool ZoneHVACBaseboardRadiantConvectiveWater_Impl::setHeatingCoil(const HVACComponent& radBaseboardHeatingCoil) {
217
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 bool result = setPointer(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::HeatingCoilName, radBaseboardHeatingCoil.handle());
218 4 return result;
219 }
220
221 2 boost::optional<Schedule> ZoneHVACBaseboardRadiantConvectiveWater_Impl::optionalAvailabilitySchedule() const {
222
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::AvailabilityScheduleName);
223 }
224
225 6 boost::optional<HVACComponent> ZoneHVACBaseboardRadiantConvectiveWater_Impl::optionalHeatingCoil() const {
226
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return getObject<ModelObject>().getModelObjectTarget<HVACComponent>(OS_ZoneHVAC_Baseboard_RadiantConvective_WaterFields::HeatingCoilName);
227 }
228
229 ✗ std::vector<EMSActuatorNames> ZoneHVACBaseboardRadiantConvectiveWater_Impl::emsActuatorNames() const {
230 ✗ std::vector<EMSActuatorNames> actuators{{"ZoneBaseboard:OutdoorTemperatureControlled", "Power Level"}};
231 ✗ return actuators;
232 ✗ }
233
234 ✗ std::vector<std::string> ZoneHVACBaseboardRadiantConvectiveWater_Impl::emsInternalVariableNames() const {
235 ✗ std::vector<std::string> types{"Simple Zone Baseboard Capacity At Low Temperature", "Simple Zone Baseboard Capacity At High Temperature"};
236 ✗ return types;
237 ✗ }
238
239 ✗ ComponentType ZoneHVACBaseboardRadiantConvectiveWater_Impl::componentType() const {
240 ✗ return ComponentType::Heating;
241 }
242
243 ✗ std::vector<FuelType> ZoneHVACBaseboardRadiantConvectiveWater_Impl::coolingFuelTypes() const {
244 ✗ return {};
245 }
246
247 ✗ std::vector<FuelType> ZoneHVACBaseboardRadiantConvectiveWater_Impl::heatingFuelTypes() const {
248 ✗ return heatingCoil().heatingFuelTypes();
249 }
250
251 ✗ std::vector<AppGFuelType> ZoneHVACBaseboardRadiantConvectiveWater_Impl::appGHeatingFuelTypes() const {
252 ✗ return heatingCoil().appGHeatingFuelTypes();
253 }
254
255 } // namespace detail
256
257 4 ZoneHVACBaseboardRadiantConvectiveWater::ZoneHVACBaseboardRadiantConvectiveWater(const Model& model)
258 4 : ZoneHVACComponent(ZoneHVACBaseboardRadiantConvectiveWater::iddObjectType(), model) {
259
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
4 OS_ASSERT(getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>());
260
261 4 bool ok = true;
262
1/1
✓ Branch 1 taken 4 times.
4 auto alwaysOn = model.alwaysOnDiscreteSchedule();
263
1/1
✓ Branch 1 taken 4 times.
4 ok = setAvailabilitySchedule(alwaysOn);
264
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
265
1/1
✓ Branch 1 taken 4 times.
4 ok = setFractionRadiant(0.3);
266
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
267
1/1
✓ Branch 1 taken 4 times.
4 ok = setFractionofRadiantEnergyIncidentonPeople(0.3);
268
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
269
1/1
✓ Branch 1 taken 4 times.
4 CoilHeatingWaterBaseboardRadiant coil(model);
270
1/1
✓ Branch 1 taken 4 times.
4 ok = setHeatingCoil(coil);
271
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
272 4 }
273
274 7741 IddObjectType ZoneHVACBaseboardRadiantConvectiveWater::iddObjectType() {
275
1/1
✓ Branch 1 taken 7741 times.
7741 return {IddObjectType::OS_ZoneHVAC_Baseboard_RadiantConvective_Water};
276 }
277
278 2 Schedule ZoneHVACBaseboardRadiantConvectiveWater::availabilitySchedule() const {
279
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->availabilitySchedule();
280 }
281
282 2 double ZoneHVACBaseboardRadiantConvectiveWater::fractionRadiant() const {
283
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->fractionRadiant();
284 }
285
286 2 double ZoneHVACBaseboardRadiantConvectiveWater::fractionofRadiantEnergyIncidentonPeople() const {
287
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->fractionofRadiantEnergyIncidentonPeople();
288 }
289
290 3 HVACComponent ZoneHVACBaseboardRadiantConvectiveWater::heatingCoil() const {
291
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->heatingCoil();
292 }
293
294 4 bool ZoneHVACBaseboardRadiantConvectiveWater::setAvailabilitySchedule(Schedule& schedule) {
295
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->setAvailabilitySchedule(schedule);
296 }
297
298 5 bool ZoneHVACBaseboardRadiantConvectiveWater::setFractionRadiant(double fractionRadiant) {
299
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->setFractionRadiant(fractionRadiant);
300 }
301
302 5 bool ZoneHVACBaseboardRadiantConvectiveWater::setFractionofRadiantEnergyIncidentonPeople(double fractionofRadiantEnergyIncidentonPeople) {
303
1/1
✓ Branch 3 taken 5 times.
10 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->setFractionofRadiantEnergyIncidentonPeople(
304 10 fractionofRadiantEnergyIncidentonPeople);
305 }
306
307 4 bool ZoneHVACBaseboardRadiantConvectiveWater::setHeatingCoil(const HVACComponent& radBaseboardHeatingCoil) {
308
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->setHeatingCoil(radBaseboardHeatingCoil);
309 }
310
311 2 boost::optional<ThermalZone> ZoneHVACBaseboardRadiantConvectiveWater::thermalZone() const {
312
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->thermalZone();
313 }
314
315 3 bool ZoneHVACBaseboardRadiantConvectiveWater::addToThermalZone(ThermalZone& thermalZone) {
316
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->addToThermalZone(thermalZone);
317 }
318
319 1 void ZoneHVACBaseboardRadiantConvectiveWater::removeFromThermalZone() {
320
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl>()->removeFromThermalZone();
321 }
322
323 /// @cond
324 2 ZoneHVACBaseboardRadiantConvectiveWater::ZoneHVACBaseboardRadiantConvectiveWater(
325 2 std::shared_ptr<detail::ZoneHVACBaseboardRadiantConvectiveWater_Impl> impl)
326
1/1
✓ Branch 3 taken 2 times.
2 : ZoneHVACComponent(std::move(impl)) {}
327 /// @endcond
328
329 } // namespace model
330 } // namespace openstudio
331