GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 57.1% 104 / 0 / 182
Functions: 58.0% 29 / 0 / 50
Branches: 41.8% 71 / 0 / 170

src/model/ZoneHVACBaseboardConvectiveElectric.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 "ZoneHVACBaseboardConvectiveElectric.hpp"
7 #include "ZoneHVACBaseboardConvectiveElectric_Impl.hpp"
8 #include "Schedule.hpp"
9 #include "Schedule_Impl.hpp"
10 #include "ThermalZone.hpp"
11 #include "ThermalZone_Impl.hpp"
12 #include "Model.hpp"
13 #include "ScheduleTypeLimits.hpp"
14 #include "ScheduleTypeRegistry.hpp"
15 #include <utilities/idd/OS_ZoneHVAC_Baseboard_Convective_Electric_FieldEnums.hxx>
16 #include <utilities/idd/IddEnums.hxx>
17 #include "../utilities/core/Assert.hpp"
18 #include "../utilities/data/DataEnums.hpp"
19
20 namespace openstudio {
21 namespace model {
22
23 namespace detail {
24
25 30 ZoneHVACBaseboardConvectiveElectric_Impl::ZoneHVACBaseboardConvectiveElectric_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 30 : ZoneHVACComponent_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 30 times.
✗ Branch 13 not taken.
30 OS_ASSERT(idfObject.iddObject().type() == ZoneHVACBaseboardConvectiveElectric::iddObjectType());
28 30 }
29
30 13 ZoneHVACBaseboardConvectiveElectric_Impl::ZoneHVACBaseboardConvectiveElectric_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
31 13 Model_Impl* model, bool keepHandle)
32 13 : ZoneHVACComponent_Impl(other, model, keepHandle) {
33
4/6
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 13 times.
✗ Branch 13 not taken.
13 OS_ASSERT(other.iddObject().type() == ZoneHVACBaseboardConvectiveElectric::iddObjectType());
34 13 }
35
36 45 ZoneHVACBaseboardConvectiveElectric_Impl::ZoneHVACBaseboardConvectiveElectric_Impl(const ZoneHVACBaseboardConvectiveElectric_Impl& other,
37 45 Model_Impl* model, bool keepHandle)
38 45 : ZoneHVACComponent_Impl(other, model, keepHandle) {}
39
40 ✗ const std::vector<std::string>& ZoneHVACBaseboardConvectiveElectric_Impl::outputVariableNames() const {
41 static const std::vector<std::string> result{"Baseboard Total Heating Rate", "Baseboard Total Heating Energy", "Baseboard Electricity Energy",
42 ✗ "Baseboard Electricity Rate"};
43 ✗ return result;
44 ✗ }
45
46 40 IddObjectType ZoneHVACBaseboardConvectiveElectric_Impl::iddObjectType() const {
47 40 return ZoneHVACBaseboardConvectiveElectric::iddObjectType();
48 }
49
50 ✗ std::vector<ScheduleTypeKey> ZoneHVACBaseboardConvectiveElectric_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
51 ✗ std::vector<ScheduleTypeKey> result;
52 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
53 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
54 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
55 ✗ if (std::find(b, e, OS_ZoneHVAC_Baseboard_Convective_ElectricFields::AvailabilitySchedule) != e) {
56 ✗ result.push_back(ScheduleTypeKey("ZoneHVACBaseboardConvectiveElectric", "Availability"));
57 }
58 ✗ return result;
59 ✗ }
60
61 11 Schedule ZoneHVACBaseboardConvectiveElectric_Impl::availabilitySchedule() const {
62
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<Schedule> value = optionalAvailabilitySchedule();
63
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if (!value) {
64 ✗ LOG_AND_THROW(briefDescription() << " does not have an Availability Schedule attached.");
65 }
66
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
22 return value.get();
67 11 }
68
69 10 boost::optional<double> ZoneHVACBaseboardConvectiveElectric_Impl::nominalCapacity() const {
70 10 return getDouble(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::NominalCapacity, true);
71 }
72
73 10 bool ZoneHVACBaseboardConvectiveElectric_Impl::isNominalCapacityAutosized() const {
74 10 bool result = false;
75
1/1
✓ Branch 1 taken 10 times.
10 boost::optional<std::string> value = getString(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::NominalCapacity, true);
76
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (value) {
77
3/3
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
20 result = openstudio::istringEqual(value.get(), "autosize");
78 }
79 10 return result;
80 10 }
81
82 10 double ZoneHVACBaseboardConvectiveElectric_Impl::efficiency() const {
83
1/1
✓ Branch 1 taken 10 times.
10 boost::optional<double> value = getDouble(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::Efficiency, true);
84
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 4 not taken.
10 OS_ASSERT(value);
85
1/1
✓ Branch 1 taken 10 times.
20 return value.get();
86 }
87
88 ✗ bool ZoneHVACBaseboardConvectiveElectric_Impl::isEfficiencyDefaulted() const {
89 ✗ return isEmpty(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::Efficiency);
90 }
91
92 22 bool ZoneHVACBaseboardConvectiveElectric_Impl::setAvailabilitySchedule(Schedule& schedule) {
93
3/3
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
88 bool result = setSchedule(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::AvailabilitySchedule, "ZoneHVACBaseboardConvectiveElectric",
94 "Availability", schedule);
95 22 return result;
96 }
97
98 ✗ bool ZoneHVACBaseboardConvectiveElectric_Impl::setNominalCapacity(boost::optional<double> nominalCapacity) {
99 ✗ bool result(false);
100 ✗ if (nominalCapacity) {
101 ✗ result = setDouble(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::NominalCapacity, nominalCapacity.get());
102 }
103 ✗ OS_ASSERT(result);
104 ✗ return result;
105 }
106
107 17 void ZoneHVACBaseboardConvectiveElectric_Impl::autosizeNominalCapacity() {
108
2/2
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
34 bool result = setString(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::NominalCapacity, "autosize");
109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 OS_ASSERT(result);
110 17 }
111
112 17 bool ZoneHVACBaseboardConvectiveElectric_Impl::setEfficiency(double efficiency) {
113 17 bool result = setDouble(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::Efficiency, efficiency);
114 17 return result;
115 }
116
117 ✗ void ZoneHVACBaseboardConvectiveElectric_Impl::resetEfficiency() {
118 ✗ bool result = setString(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::Efficiency, "");
119 ✗ OS_ASSERT(result);
120 ✗ }
121
122 11 boost::optional<Schedule> ZoneHVACBaseboardConvectiveElectric_Impl::optionalAvailabilitySchedule() const {
123
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_ZoneHVAC_Baseboard_Convective_ElectricFields::AvailabilitySchedule);
124 }
125
126 ✗ boost::optional<ModelObject> ZoneHVACBaseboardConvectiveElectric_Impl::availabilityScheduleAsModelObject() const {
127 ✗ OptionalModelObject result = availabilitySchedule();
128 ✗ return result;
129 }
130
131 ✗ bool ZoneHVACBaseboardConvectiveElectric_Impl::setAvailabilityScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) {
132 ✗ if (modelObject) {
133 ✗ OptionalSchedule intermediate = modelObject->optionalCast<Schedule>();
134 ✗ if (intermediate) {
135 ✗ Schedule schedule(*intermediate);
136 ✗ return setAvailabilitySchedule(schedule);
137 ✗ }
138 ✗ }
139 ✗ return false;
140 }
141
142 14 unsigned ZoneHVACBaseboardConvectiveElectric_Impl::inletPort() const {
143 14 return 0; // this object has no inlet or outlet node
144 }
145
146 ✗ unsigned ZoneHVACBaseboardConvectiveElectric_Impl::outletPort() const {
147 ✗ return 0; // this object has no inlet or outlet node
148 }
149
150 21 boost::optional<ThermalZone> ZoneHVACBaseboardConvectiveElectric_Impl::thermalZone() const {
151
1/1
✓ Branch 1 taken 21 times.
21 auto thisObject = this->getObject<ModelObject>();
152
2/2
✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
21 std::vector<ThermalZone> thermalZones = this->model().getConcreteModelObjects<ThermalZone>();
153
2/2
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 16 times.
36 for (const auto& thermalZone : thermalZones) {
154
1/1
✓ Branch 1 taken 20 times.
20 std::vector<ModelObject> equipment = thermalZone.equipment();
155
156
3/3
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 15 times.
20 if (std::find(equipment.begin(), equipment.end(), thisObject) != equipment.end()) {
157
1/1
✓ Branch 1 taken 5 times.
5 return thermalZone;
158 }
159 20 }
160 16 return boost::none;
161 21 }
162
163 14 bool ZoneHVACBaseboardConvectiveElectric_Impl::addToThermalZone(ThermalZone& thermalZone) {
164
1/1
✓ Branch 1 taken 14 times.
14 Model m = this->model();
165
166
3/4
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
14 if (thermalZone.model() != m) {
167 ✗ return false;
168 }
169
170
2/3
✓ Branch 1 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
14 if (thermalZone.isPlenum()) {
171 ✗ return false;
172 }
173
174
1/1
✓ Branch 1 taken 14 times.
14 removeFromThermalZone();
175
176
1/1
✓ Branch 1 taken 14 times.
14 thermalZone.setUseIdealAirLoads(false);
177
178
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 thermalZone.addEquipment(this->getObject<ZoneHVACComponent>());
179
180 14 return true;
181 14 }
182
183 17 void ZoneHVACBaseboardConvectiveElectric_Impl::removeFromThermalZone() {
184
3/3
✓ Branch 1 taken 17 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 14 times.
34 if (boost::optional<ThermalZone> thermalZone = this->thermalZone()) {
185
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 thermalZone->removeEquipment(this->getObject<ZoneHVACComponent>());
186 17 }
187 17 }
188
189 ✗ boost::optional<double> ZoneHVACBaseboardConvectiveElectric_Impl::autosizedNominalCapacity() const {
190 // EPLUS-SQL-INCONSISTENCY
191 ✗ return getAutosizedValue("Design Size Heating Design Capacity", "W", "ZONEHVAC:BASEBOARD:CONVECTIVE:ELECTRIC");
192 }
193
194 ✗ void ZoneHVACBaseboardConvectiveElectric_Impl::autosize() {
195 ✗ autosizeNominalCapacity();
196 ✗ }
197
198 ✗ void ZoneHVACBaseboardConvectiveElectric_Impl::applySizingValues() {
199 ✗ boost::optional<double> val;
200 ✗ val = autosizedNominalCapacity();
201 ✗ if (val) {
202 ✗ setNominalCapacity(val.get());
203 }
204 ✗ }
205
206 ✗ std::vector<EMSActuatorNames> ZoneHVACBaseboardConvectiveElectric_Impl::emsActuatorNames() const {
207 ✗ std::vector<EMSActuatorNames> actuators{{"ZoneBaseboard:OutdoorTemperatureControlled", "Power Level"}};
208 ✗ return actuators;
209 ✗ }
210
211 ✗ std::vector<std::string> ZoneHVACBaseboardConvectiveElectric_Impl::emsInternalVariableNames() const {
212 ✗ std::vector<std::string> types{"Simple Zone Baseboard Capacity At Low Temperature", "Simple Zone Baseboard Capacity At High Temperature"};
213 ✗ return types;
214 ✗ }
215
216 ✗ ComponentType ZoneHVACBaseboardConvectiveElectric_Impl::componentType() const {
217 ✗ return ComponentType::Heating;
218 }
219
220 ✗ std::vector<FuelType> ZoneHVACBaseboardConvectiveElectric_Impl::coolingFuelTypes() const {
221 ✗ return {};
222 }
223
224 ✗ std::vector<FuelType> ZoneHVACBaseboardConvectiveElectric_Impl::heatingFuelTypes() const {
225 ✗ return {FuelType::Electricity};
226 }
227
228 ✗ std::vector<AppGFuelType> ZoneHVACBaseboardConvectiveElectric_Impl::appGHeatingFuelTypes() const {
229 ✗ return {AppGFuelType::Electric};
230 }
231
232 } // namespace detail
233
234 17 ZoneHVACBaseboardConvectiveElectric::ZoneHVACBaseboardConvectiveElectric(const Model& model)
235 17 : ZoneHVACComponent(ZoneHVACBaseboardConvectiveElectric::iddObjectType(), model) {
236
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
✗ Branch 5 not taken.
17 OS_ASSERT(getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>());
237
238
1/1
✓ Branch 1 taken 17 times.
17 autosizeNominalCapacity();
239
240
1/1
✓ Branch 1 taken 17 times.
17 Schedule schedule = model.alwaysOnDiscreteSchedule();
241
242
1/1
✓ Branch 1 taken 17 times.
17 setAvailabilitySchedule(schedule);
243
244
1/1
✓ Branch 1 taken 17 times.
17 setEfficiency(1.0);
245 17 }
246
247 7828 IddObjectType ZoneHVACBaseboardConvectiveElectric::iddObjectType() {
248
1/1
✓ Branch 1 taken 7828 times.
7828 return {IddObjectType::OS_ZoneHVAC_Baseboard_Convective_Electric};
249 }
250
251 11 Schedule ZoneHVACBaseboardConvectiveElectric::availabilitySchedule() const {
252
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->availabilitySchedule();
253 }
254
255 10 boost::optional<double> ZoneHVACBaseboardConvectiveElectric::nominalCapacity() const {
256
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->nominalCapacity();
257 }
258
259 10 bool ZoneHVACBaseboardConvectiveElectric::isNominalCapacityAutosized() const {
260
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->isNominalCapacityAutosized();
261 }
262
263 10 double ZoneHVACBaseboardConvectiveElectric::efficiency() const {
264
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->efficiency();
265 }
266
267 ✗ bool ZoneHVACBaseboardConvectiveElectric::isEfficiencyDefaulted() const {
268 ✗ return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->isEfficiencyDefaulted();
269 }
270
271 22 bool ZoneHVACBaseboardConvectiveElectric::setAvailabilitySchedule(Schedule& schedule) {
272
1/1
✓ Branch 3 taken 22 times.
22 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->setAvailabilitySchedule(schedule);
273 }
274
275 ✗ bool ZoneHVACBaseboardConvectiveElectric::setNominalCapacity(double nominalCapacity) {
276 ✗ return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->setNominalCapacity(nominalCapacity);
277 }
278
279 17 void ZoneHVACBaseboardConvectiveElectric::autosizeNominalCapacity() {
280
1/1
✓ Branch 3 taken 17 times.
17 getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->autosizeNominalCapacity();
281 17 }
282
283 17 bool ZoneHVACBaseboardConvectiveElectric::setEfficiency(double efficiency) {
284
1/1
✓ Branch 3 taken 17 times.
17 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->setEfficiency(efficiency);
285 }
286
287 ✗ void ZoneHVACBaseboardConvectiveElectric::resetEfficiency() {
288 ✗ getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->resetEfficiency();
289 ✗ }
290
291 4 boost::optional<ThermalZone> ZoneHVACBaseboardConvectiveElectric::thermalZone() const {
292
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->thermalZone();
293 }
294
295 14 bool ZoneHVACBaseboardConvectiveElectric::addToThermalZone(ThermalZone& thermalZone) {
296
1/1
✓ Branch 3 taken 14 times.
14 return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->addToThermalZone(thermalZone);
297 }
298
299 1 void ZoneHVACBaseboardConvectiveElectric::removeFromThermalZone() {
300
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->removeFromThermalZone();
301 1 }
302
303 /// @cond
304 10 ZoneHVACBaseboardConvectiveElectric::ZoneHVACBaseboardConvectiveElectric(std::shared_ptr<detail::ZoneHVACBaseboardConvectiveElectric_Impl> impl)
305
1/1
✓ Branch 3 taken 10 times.
10 : ZoneHVACComponent(std::move(impl)) {}
306 /// @endcond
307
308 ✗ boost::optional<double> ZoneHVACBaseboardConvectiveElectric::autosizedNominalCapacity() const {
309 ✗ return getImpl<detail::ZoneHVACBaseboardConvectiveElectric_Impl>()->autosizedNominalCapacity();
310 }
311
312 } // namespace model
313 } // namespace openstudio
314