GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 70.6% 243 / 0 / 344
Functions: 73.9% 65 / 0 / 88
Branches: 50.2% 217 / 0 / 432

src/model/PeopleDefinition.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 "PeopleDefinition.hpp"
7 #include "PeopleDefinition_Impl.hpp"
8
9 #include "../utilities/idf/IdfExtensibleGroup.hpp"
10
11 #include <utilities/idd/IddFactory.hxx>
12
13 #include <utilities/idd/OS_People_Definition_FieldEnums.hxx>
14 #include <utilities/idd/IddEnums.hxx>
15
16 #include "../utilities/math/FloatCompare.hpp"
17 #include "../utilities/core/Assert.hpp"
18
19 namespace openstudio {
20 namespace model {
21
22 namespace detail {
23
24 900 PeopleDefinition_Impl::PeopleDefinition_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
25 900 : SpaceLoadDefinition_Impl(idfObject, model, keepHandle) {
26
4/6
✓ Branch 1 taken 900 times.
✓ Branch 4 taken 900 times.
✓ Branch 7 taken 900 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 900 times.
✗ Branch 13 not taken.
900 OS_ASSERT(idfObject.iddObject().type() == PeopleDefinition::iddObjectType());
27 900 }
28
29 621 PeopleDefinition_Impl::PeopleDefinition_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
30 621 : SpaceLoadDefinition_Impl(other, model, keepHandle) {
31
4/6
✓ Branch 1 taken 621 times.
✓ Branch 4 taken 621 times.
✓ Branch 7 taken 621 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 621 times.
✗ Branch 13 not taken.
621 OS_ASSERT(other.iddObject().type() == PeopleDefinition::iddObjectType());
32 621 }
33
34 183 PeopleDefinition_Impl::PeopleDefinition_Impl(const PeopleDefinition_Impl& other, Model_Impl* model, bool keepHandle)
35 183 : SpaceLoadDefinition_Impl(other, model, keepHandle) {}
36
37 // TODO: remove
38 1 const std::vector<std::string>& PeopleDefinition_Impl::outputVariableNames() const {
39
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 static const std::vector<std::string> result;
40 // Not appropriate: output is listed in People instead
41 1 return result;
42 }
43
44 1 IddObjectType PeopleDefinition_Impl::iddObjectType() const {
45 1 return PeopleDefinition::iddObjectType();
46 }
47
48 1425 std::string PeopleDefinition_Impl::numberofPeopleCalculationMethod() const {
49
1/1
✓ Branch 1 taken 1425 times.
1425 boost::optional<std::string> value = getString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, true);
50
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1425 times.
✗ Branch 4 not taken.
1425 OS_ASSERT(value);
51
2/2
✓ Branch 1 taken 1425 times.
✓ Branch 4 taken 1425 times.
2850 return value.get();
52 1425 }
53
54 178 boost::optional<double> PeopleDefinition_Impl::numberofPeople() const {
55
1/1
✓ Branch 1 taken 178 times.
178 OptionalDouble value = getDouble(OS_People_DefinitionFields::NumberofPeople, true);
56
5/5
✓ Branch 1 taken 178 times.
✓ Branch 4 taken 178 times.
✓ Branch 7 taken 178 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 53 times.
534 if (istringEqual("People", this->numberofPeopleCalculationMethod())) {
57
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 4 not taken.
125 OS_ASSERT(value);
58 }
59 178 return value;
60 }
61
62 544 boost::optional<double> PeopleDefinition_Impl::peopleperSpaceFloorArea() const {
63
1/1
✓ Branch 1 taken 544 times.
544 OptionalDouble value = getDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea, true);
64
5/5
✓ Branch 1 taken 544 times.
✓ Branch 4 taken 544 times.
✓ Branch 7 taken 544 times.
✓ Branch 11 taken 498 times.
✓ Branch 12 taken 46 times.
1632 if (istringEqual("People/Area", this->numberofPeopleCalculationMethod())) {
65
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 498 times.
✗ Branch 4 not taken.
498 OS_ASSERT(value);
66 }
67 544 return value;
68 }
69
70 94 boost::optional<double> PeopleDefinition_Impl::spaceFloorAreaperPerson() const {
71
1/1
✓ Branch 1 taken 94 times.
94 OptionalDouble value = getDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson, true);
72
5/5
✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
✓ Branch 7 taken 94 times.
✓ Branch 11 taken 20 times.
✓ Branch 12 taken 74 times.
282 if (istringEqual("Area/Person", this->numberofPeopleCalculationMethod())) {
73
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 4 not taken.
20 OS_ASSERT(value);
74 }
75 94 return value;
76 }
77
78 79 double PeopleDefinition_Impl::fractionRadiant() const {
79
1/1
✓ Branch 1 taken 79 times.
79 OptionalDouble value = getDouble(OS_People_DefinitionFields::FractionRadiant, true);
80
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 4 not taken.
79 OS_ASSERT(value);
81
1/1
✓ Branch 1 taken 79 times.
158 return value.get();
82 }
83
84 80 boost::optional<double> PeopleDefinition_Impl::sensibleHeatFraction() const {
85
1/1
✓ Branch 1 taken 80 times.
80 OptionalDouble value = getDouble(OS_People_DefinitionFields::SensibleHeatFraction, true);
86 80 return value;
87 }
88
89 ✗ bool PeopleDefinition_Impl::isSensibleHeatFractionDefaulted() const {
90 ✗ return isEmpty(OS_People_DefinitionFields::SensibleHeatFraction);
91 }
92
93 ✗ bool PeopleDefinition_Impl::isSensibleHeatFractionAutocalculated() const {
94 ✗ bool result = false;
95 ✗ boost::optional<std::string> value = getString(OS_People_DefinitionFields::SensibleHeatFraction, true);
96 ✗ if (value) {
97 ✗ result = openstudio::istringEqual(value.get(), "Autocalculate");
98 }
99 ✗ return result;
100 ✗ }
101
102 8 double PeopleDefinition_Impl::carbonDioxideGenerationRate() const {
103
1/1
✓ Branch 1 taken 8 times.
8 OptionalDouble value = getDouble(OS_People_DefinitionFields::CarbonDioxideGenerationRate, true);
104
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(value);
105
1/1
✓ Branch 1 taken 8 times.
16 return value.get();
106 }
107
108 78 bool PeopleDefinition_Impl::isCarbonDioxideGenerationRateDefaulted() const {
109 78 return isEmpty(OS_People_DefinitionFields::CarbonDioxideGenerationRate);
110 }
111
112 8 bool PeopleDefinition_Impl::enableASHRAE55ComfortWarnings() const {
113
1/1
✓ Branch 1 taken 8 times.
8 boost::optional<std::string> value = getString(OS_People_DefinitionFields::EnableASHRAE55ComfortWarnings, true);
114
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(value);
115
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
16 return openstudio::istringEqual(value.get(), "Yes");
116 8 }
117
118 78 bool PeopleDefinition_Impl::isEnableASHRAE55ComfortWarningsDefaulted() const {
119 78 return isEmpty(OS_People_DefinitionFields::EnableASHRAE55ComfortWarnings);
120 }
121
122 141 std::string PeopleDefinition_Impl::meanRadiantTemperatureCalculationType() const {
123
1/1
✓ Branch 1 taken 141 times.
141 boost::optional<std::string> value = getString(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType, true);
124
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 141 times.
✗ Branch 4 not taken.
141 OS_ASSERT(value);
125
2/2
✓ Branch 1 taken 141 times.
✓ Branch 4 taken 141 times.
282 return value.get();
126 141 }
127
128 184 bool PeopleDefinition_Impl::isMeanRadiantTemperatureCalculationTypeDefaulted() const {
129 184 return isEmpty(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType);
130 }
131
132 13 boost::optional<std::string> PeopleDefinition_Impl::getThermalComfortModelType(int i) const {
133 13 OptionalString result;
134
2/3
✓ Branch 1 taken 13 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
13 if (i < numThermalComfortModelTypes()) {
135
1/1
✓ Branch 1 taken 13 times.
13 IdfExtensibleGroup eg = getExtensibleGroup(i);
136
2/4
✓ Branch 1 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 6 not taken.
13 OS_ASSERT(!eg.empty());
137
1/1
✓ Branch 1 taken 13 times.
13 result = eg.getString(OS_People_DefinitionExtensibleFields::ThermalComfortModelType, true);
138 13 }
139 13 return result;
140 ✗ }
141
142 162 int PeopleDefinition_Impl::numThermalComfortModelTypes() const {
143 162 return numExtensibleGroups();
144 }
145
146 307 bool PeopleDefinition_Impl::setNumberofPeople(boost::optional<double> numberofPeople) {
147 307 bool result = false;
148
1/2
✓ Branch 0 taken 307 times.
✗ Branch 1 not taken.
307 if (numberofPeople) {
149 307 result = setDouble(OS_People_DefinitionFields::NumberofPeople, numberofPeople.get());
150
1/2
✓ Branch 0 taken 307 times.
✗ Branch 1 not taken.
307 if (result) {
151
2/2
✓ Branch 1 taken 307 times.
✓ Branch 4 taken 307 times.
614 result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "People");
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307 times.
307 OS_ASSERT(result);
153
2/2
✓ Branch 1 taken 307 times.
✓ Branch 4 taken 307 times.
614 result = setString(OS_People_DefinitionFields::PeopleperSpaceFloorArea, "");
154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307 times.
307 OS_ASSERT(result);
155
2/2
✓ Branch 1 taken 307 times.
✓ Branch 4 taken 307 times.
614 result = setString(OS_People_DefinitionFields::SpaceFloorAreaperPerson, "");
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307 times.
307 OS_ASSERT(result);
157 }
158 } else {
159 ✗ if (istringEqual("People", this->numberofPeopleCalculationMethod())) {
160 ✗ result = setDouble(OS_People_DefinitionFields::NumberofPeople, 0.0);
161 }
162 }
163 307 return result;
164 }
165
166 205 bool PeopleDefinition_Impl::setPeopleperSpaceFloorArea(boost::optional<double> peopleperSpaceFloorArea) {
167 205 bool result = false;
168
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if (peopleperSpaceFloorArea) {
169 205 result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea, peopleperSpaceFloorArea.get());
170
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if (result) {
171
2/2
✓ Branch 1 taken 205 times.
✓ Branch 4 taken 205 times.
410 result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "People/Area");
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 OS_ASSERT(result);
173
2/2
✓ Branch 1 taken 205 times.
✓ Branch 4 taken 205 times.
410 result = setString(OS_People_DefinitionFields::NumberofPeople, "");
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 OS_ASSERT(result);
175
2/2
✓ Branch 1 taken 205 times.
✓ Branch 4 taken 205 times.
410 result = setString(OS_People_DefinitionFields::SpaceFloorAreaperPerson, "");
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 OS_ASSERT(result);
177 }
178 } else {
179 ✗ if (istringEqual("People/Area", this->numberofPeopleCalculationMethod())) {
180 ✗ result = setDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea, 0.0);
181 }
182 }
183 205 return result;
184 }
185
186 26 bool PeopleDefinition_Impl::setSpaceFloorAreaperPerson(boost::optional<double> spaceFloorAreaperPerson) {
187 26 bool result(false);
188
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if (spaceFloorAreaperPerson) {
189 26 result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson, spaceFloorAreaperPerson.get());
190
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if (result) {
191
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
52 result = setString(OS_People_DefinitionFields::NumberofPeopleCalculationMethod, "Area/Person");
192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 OS_ASSERT(result);
193
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
52 result = setString(OS_People_DefinitionFields::NumberofPeople, "");
194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 OS_ASSERT(result);
195
2/2
✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
52 result = setString(OS_People_DefinitionFields::PeopleperSpaceFloorArea, "");
196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 OS_ASSERT(result);
197 }
198 } else {
199 ✗ if (istringEqual("Area/Person", this->numberofPeopleCalculationMethod())) {
200 ✗ result = setDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson, 0.0);
201 }
202 }
203 26 return result;
204 }
205
206 314 bool PeopleDefinition_Impl::setFractionRadiant(double fractionRadiant) {
207 314 return setDouble(OS_People_DefinitionFields::FractionRadiant, fractionRadiant);
208 }
209
210 24 bool PeopleDefinition_Impl::setSensibleHeatFraction(double sensibleHeatFraction) {
211 24 return setDouble(OS_People_DefinitionFields::SensibleHeatFraction, sensibleHeatFraction);
212 }
213
214 ✗ void PeopleDefinition_Impl::resetSensibleHeatFraction() {
215 ✗ bool result = setString(OS_People_DefinitionFields::SensibleHeatFraction, "");
216 ✗ OS_ASSERT(result);
217 ✗ }
218
219 ✗ void PeopleDefinition_Impl::autocalculateSensibleHeatFraction() {
220 ✗ bool result = setString(OS_People_DefinitionFields::SensibleHeatFraction, "Autocalculate");
221 ✗ OS_ASSERT(result);
222 ✗ }
223
224 29 bool PeopleDefinition_Impl::setCarbonDioxideGenerationRate(double carbonDioxideGenerationRate) {
225 29 return setDouble(OS_People_DefinitionFields::CarbonDioxideGenerationRate, carbonDioxideGenerationRate);
226 }
227
228 ✗ void PeopleDefinition_Impl::resetCarbonDioxideGenerationRate() {
229 ✗ bool result = setString(OS_People_DefinitionFields::CarbonDioxideGenerationRate, "");
230 ✗ OS_ASSERT(result);
231 ✗ }
232
233 31 bool PeopleDefinition_Impl::setEnableASHRAE55ComfortWarnings(bool enableASHRAE55ComfortWarnings) {
234 31 bool result = false;
235
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if (enableASHRAE55ComfortWarnings) {
236
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
9 result = setString(OS_People_DefinitionFields::EnableASHRAE55ComfortWarnings, "Yes");
237 } else {
238
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
84 result = setString(OS_People_DefinitionFields::EnableASHRAE55ComfortWarnings, "No");
239 }
240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 OS_ASSERT(result);
241 31 return result;
242 }
243
244 ✗ void PeopleDefinition_Impl::resetEnableASHRAE55ComfortWarnings() {
245 ✗ bool result = setString(OS_People_DefinitionFields::EnableASHRAE55ComfortWarnings, "");
246 ✗ OS_ASSERT(result);
247 ✗ }
248
249 54 bool PeopleDefinition_Impl::setMeanRadiantTemperatureCalculationType(const std::string& meanRadiantTemperatureCalculationType) {
250 // Backward compat, starting at 3.8.0
251 const std::string mrtType =
252
8/10
✓ Branch 1 taken 54 times.
✓ Branch 4 taken 54 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 53 times.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 53 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 53 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
56 istringEqual("ZoneAveraged", meanRadiantTemperatureCalculationType) ? "EnclosureAveraged" : meanRadiantTemperatureCalculationType;
253
1/1
✓ Branch 1 taken 54 times.
54 bool result = setString(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType, mrtType);
254 54 return result;
255 54 }
256
257 2 void PeopleDefinition_Impl::resetMeanRadiantTemperatureCalculationType() {
258
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 bool result = setString(OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType, "");
259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
260 2 }
261
262 40 bool PeopleDefinition_Impl::pushThermalComfortModelType(const std::string& thermalComfortModelType) {
263
3/3
✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
✓ Branch 7 taken 40 times.
120 return !pushExtensibleGroup(StringVector(1u, thermalComfortModelType)).empty();
264 }
265
266 40 bool PeopleDefinition_Impl::setThermalComfortModelType(int i, const std::string& thermalComfortModelType) {
267 40 int n = numThermalComfortModelTypes();
268
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (i == n) {
269 40 return pushThermalComfortModelType(thermalComfortModelType);
270 }
271 ✗ if (i < n) {
272 ✗ IdfExtensibleGroup eg = getExtensibleGroup(i);
273 ✗ OS_ASSERT(!eg.empty());
274 ✗ return eg.setString(OS_People_DefinitionExtensibleFields::ThermalComfortModelType, thermalComfortModelType);
275 ✗ }
276 ✗ return false;
277 }
278
279 1 bool PeopleDefinition_Impl::eraseThermalComfortModelType(int i) {
280
1/1
✓ Branch 1 taken 1 time.
1 return !eraseExtensibleGroup(i).empty();
281 }
282
283 463 double PeopleDefinition_Impl::getNumberOfPeople(double floorArea) const {
284
1/1
✓ Branch 1 taken 463 times.
463 std::string method = numberofPeopleCalculationMethod();
285
286
3/3
✓ Branch 1 taken 463 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 408 times.
463 if (method == "People") {
287
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 return numberofPeople().get();
288
3/3
✓ Branch 1 taken 408 times.
✓ Branch 3 taken 405 times.
✓ Branch 4 taken 3 times.
408 } else if (method == "People/Area") {
289
2/2
✓ Branch 1 taken 405 times.
✓ Branch 4 taken 405 times.
405 return peopleperSpaceFloorArea().get() * floorArea;
290
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 } else if (method == "Area/Person") {
291
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 double areaPerPerson = spaceFloorAreaperPerson().get();
292
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (equal(areaPerPerson, 0.0)) {
293 ✗ LOG_AND_THROW("Calculation would require division by zero.");
294 }
295 3 return floorArea / areaPerPerson;
296 }
297
298 ✗ OS_ASSERT(false);
299 ✗ return 0.0;
300 463 }
301
302 56 double PeopleDefinition_Impl::getPeoplePerFloorArea(double floorArea) const {
303
1/1
✓ Branch 1 taken 56 times.
56 std::string method = numberofPeopleCalculationMethod();
304
305
3/3
✓ Branch 1 taken 56 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 52 times.
56 if (method == "People") {
306
2/2
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 3 times.
4 if (equal(floorArea, 0.0)) {
307
13/13
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
1 LOG_AND_THROW("Calculation would require division by zero.");
308 }
309
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return numberofPeople().get() / floorArea;
310
3/3
✓ Branch 1 taken 52 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 4 times.
52 } else if (method == "People/Area") {
311
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 return peopleperSpaceFloorArea().get();
312
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 } else if (method == "Area/Person") {
313
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 double areaPerPerson = spaceFloorAreaperPerson().get();
314
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if (equal(areaPerPerson, 0.0)) {
315 ✗ LOG_AND_THROW("Calculation would require division by zero.");
316 }
317 4 return 1.0 / areaPerPerson;
318 }
319
320 ✗ OS_ASSERT(false);
321 ✗ return 0.0;
322 56 }
323
324 6 double PeopleDefinition_Impl::getFloorAreaPerPerson(double floorArea) const {
325
1/1
✓ Branch 1 taken 6 times.
6 std::string method = numberofPeopleCalculationMethod();
326
327
3/3
✓ Branch 1 taken 6 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
6 if (method == "People") {
328
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 double numPeople = numberofPeople().get();
329
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (equal(numPeople, 0.0)) {
330 ✗ LOG_AND_THROW("Calculation would require division by zero.");
331 }
332 2 return floorArea / numPeople;
333
3/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
4 } else if (method == "People/Area") {
334
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 double peoplePerArea = peopleperSpaceFloorArea().get();
335
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (equal(peoplePerArea, 0.0)) {
336 ✗ LOG_AND_THROW("Calculation would require division by zero.");
337 }
338 2 return 1.0 / peoplePerArea;
339
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (method == "Area/Person") {
340
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return spaceFloorAreaperPerson().get();
341 }
342
343 ✗ OS_ASSERT(false);
344 ✗ return 0.0;
345 6 }
346
347 ✗ bool PeopleDefinition_Impl::setNumberOfPeopleCalculationMethod(const std::string& method, double floorArea) {
348 ✗ std::string wmethod(method);
349 ✗ boost::to_lower(wmethod);
350
351 ✗ if (wmethod == "people") {
352 ✗ return setNumberofPeople(getNumberOfPeople(floorArea));
353 ✗ } else if (wmethod == "people/area") {
354 ✗ return setPeopleperSpaceFloorArea(getPeoplePerFloorArea(floorArea));
355 ✗ } else if (wmethod == "area/person") {
356 ✗ return setSpaceFloorAreaperPerson(getFloorAreaPerPerson(floorArea));
357 }
358
359 ✗ return false;
360 ✗ }
361
362 ✗ std::vector<std::string> PeopleDefinition_Impl::numberofPeopleCalculationMethodValues() const {
363 ✗ return PeopleDefinition::numberofPeopleCalculationMethodValues();
364 }
365
366 ✗ std::vector<std::string> PeopleDefinition_Impl::meanRadiantTemperatureCalculationTypeValues() const {
367 ✗ return PeopleDefinition::meanRadiantTemperatureCalculationTypeValues();
368 }
369
370 ✗ std::vector<std::string> PeopleDefinition_Impl::thermalComfortModelTypeValues() const {
371 ✗ return PeopleDefinition::thermalComfortModelTypeValues();
372 }
373
374 ✗ std::vector<EMSActuatorNames> PeopleDefinition_Impl::emsActuatorNames() const {
375 ✗ std::vector<EMSActuatorNames> actuators{{"People", "Number of People"}};
376 ✗ return actuators;
377 ✗ }
378
379 ✗ std::vector<std::string> PeopleDefinition_Impl::emsInternalVariableNames() const {
380 ✗ std::vector<std::string> types{"People Count Design Level"};
381 ✗ return types;
382 ✗ }
383
384 } // namespace detail
385
386 278 PeopleDefinition::PeopleDefinition(const Model& model) : SpaceLoadDefinition(PeopleDefinition::iddObjectType(), model) {
387
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 5 not taken.
278 OS_ASSERT(getImpl<detail::PeopleDefinition_Impl>());
388
2/2
✓ Branch 3 taken 278 times.
✓ Branch 6 taken 278 times.
278 bool ok = getImpl<detail::PeopleDefinition_Impl>()->setNumberofPeople(0.0);
389
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 3 not taken.
278 OS_ASSERT(ok);
390
1/1
✓ Branch 3 taken 278 times.
278 ok = getImpl<detail::PeopleDefinition_Impl>()->setFractionRadiant(0.3);
391
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 3 not taken.
278 OS_ASSERT(ok);
392 278 }
393
394 9411 IddObjectType PeopleDefinition::iddObjectType() {
395
1/1
✓ Branch 1 taken 9411 times.
9411 IddObjectType result(IddObjectType::OS_People_Definition);
396 9411 return result;
397 }
398
399 ✗ std::vector<std::string> PeopleDefinition::numberofPeopleCalculationMethodValues() {
400 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_People_DefinitionFields::NumberofPeopleCalculationMethod);
401 }
402
403 ✗ std::vector<std::string> PeopleDefinition::meanRadiantTemperatureCalculationTypeValues() {
404 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_People_DefinitionFields::MeanRadiantTemperatureCalculationType);
405 }
406
407 ✗ std::vector<std::string> PeopleDefinition::thermalComfortModelTypeValues() {
408 ✗ IddObject obj = IddFactory::instance().getObject(iddObjectType()).get();
409 // Return IddKeyNames in extensible portion
410 ✗ return getIddKeyNames(obj, obj.numFields() + OS_People_DefinitionExtensibleFields::ThermalComfortModelType);
411 ✗ }
412
413 84 std::string PeopleDefinition::numberofPeopleCalculationMethod() const {
414
1/1
✓ Branch 3 taken 84 times.
84 return getImpl<detail::PeopleDefinition_Impl>()->numberofPeopleCalculationMethod();
415 }
416
417 118 boost::optional<double> PeopleDefinition::numberofPeople() const {
418
1/1
✓ Branch 3 taken 118 times.
118 return getImpl<detail::PeopleDefinition_Impl>()->numberofPeople();
419 }
420
421 89 boost::optional<double> PeopleDefinition::peopleperSpaceFloorArea() const {
422
1/1
✓ Branch 3 taken 89 times.
89 return getImpl<detail::PeopleDefinition_Impl>()->peopleperSpaceFloorArea();
423 }
424
425 85 boost::optional<double> PeopleDefinition::spaceFloorAreaperPerson() const {
426
1/1
✓ Branch 3 taken 85 times.
85 return getImpl<detail::PeopleDefinition_Impl>()->spaceFloorAreaperPerson();
427 }
428
429 79 double PeopleDefinition::fractionRadiant() const {
430
1/1
✓ Branch 3 taken 79 times.
79 return getImpl<detail::PeopleDefinition_Impl>()->fractionRadiant();
431 }
432
433 80 boost::optional<double> PeopleDefinition::sensibleHeatFraction() const {
434
1/1
✓ Branch 3 taken 80 times.
80 return getImpl<detail::PeopleDefinition_Impl>()->sensibleHeatFraction();
435 }
436
437 ✗ bool PeopleDefinition::isSensibleHeatFractionDefaulted() const {
438 ✗ return getImpl<detail::PeopleDefinition_Impl>()->isSensibleHeatFractionDefaulted();
439 }
440
441 ✗ bool PeopleDefinition::isSensibleHeatFractionAutocalculated() const {
442 ✗ return getImpl<detail::PeopleDefinition_Impl>()->isSensibleHeatFractionAutocalculated();
443 }
444
445 8 double PeopleDefinition::carbonDioxideGenerationRate() const {
446
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::PeopleDefinition_Impl>()->carbonDioxideGenerationRate();
447 }
448
449 78 bool PeopleDefinition::isCarbonDioxideGenerationRateDefaulted() const {
450
1/1
✓ Branch 3 taken 78 times.
78 return getImpl<detail::PeopleDefinition_Impl>()->isCarbonDioxideGenerationRateDefaulted();
451 }
452
453 8 bool PeopleDefinition::enableASHRAE55ComfortWarnings() const {
454
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::PeopleDefinition_Impl>()->enableASHRAE55ComfortWarnings();
455 }
456
457 78 bool PeopleDefinition::isEnableASHRAE55ComfortWarningsDefaulted() const {
458
1/1
✓ Branch 3 taken 78 times.
78 return getImpl<detail::PeopleDefinition_Impl>()->isEnableASHRAE55ComfortWarningsDefaulted();
459 }
460
461 141 std::string PeopleDefinition::meanRadiantTemperatureCalculationType() const {
462
1/1
✓ Branch 3 taken 141 times.
141 return getImpl<detail::PeopleDefinition_Impl>()->meanRadiantTemperatureCalculationType();
463 }
464
465 184 bool PeopleDefinition::isMeanRadiantTemperatureCalculationTypeDefaulted() const {
466
1/1
✓ Branch 3 taken 184 times.
184 return getImpl<detail::PeopleDefinition_Impl>()->isMeanRadiantTemperatureCalculationTypeDefaulted();
467 }
468
469 13 boost::optional<std::string> PeopleDefinition::getThermalComfortModelType(int i) const {
470
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::PeopleDefinition_Impl>()->getThermalComfortModelType(i);
471 }
472
473 109 int PeopleDefinition::numThermalComfortModelTypes() const {
474
1/1
✓ Branch 3 taken 109 times.
109 return getImpl<detail::PeopleDefinition_Impl>()->numThermalComfortModelTypes();
475 }
476
477 29 bool PeopleDefinition::setNumberofPeople(double numberofPeople) {
478
2/2
✓ Branch 3 taken 29 times.
✓ Branch 6 taken 29 times.
29 return getImpl<detail::PeopleDefinition_Impl>()->setNumberofPeople(numberofPeople);
479 }
480
481 205 bool PeopleDefinition::setPeopleperSpaceFloorArea(double peopleperSpaceFloorArea) {
482
2/2
✓ Branch 3 taken 205 times.
✓ Branch 6 taken 205 times.
205 return getImpl<detail::PeopleDefinition_Impl>()->setPeopleperSpaceFloorArea(peopleperSpaceFloorArea);
483 }
484
485 26 bool PeopleDefinition::setSpaceFloorAreaperPerson(double spaceFloorAreaperPerson) {
486
2/2
✓ Branch 3 taken 26 times.
✓ Branch 6 taken 26 times.
26 return getImpl<detail::PeopleDefinition_Impl>()->setSpaceFloorAreaperPerson(spaceFloorAreaperPerson);
487 }
488
489 36 bool PeopleDefinition::setFractionRadiant(double fractionRadiant) {
490
1/1
✓ Branch 3 taken 36 times.
36 return getImpl<detail::PeopleDefinition_Impl>()->setFractionRadiant(fractionRadiant);
491 }
492
493 24 bool PeopleDefinition::setSensibleHeatFraction(double sensibleHeatFraction) {
494
1/1
✓ Branch 3 taken 24 times.
24 return getImpl<detail::PeopleDefinition_Impl>()->setSensibleHeatFraction(sensibleHeatFraction);
495 }
496
497 ✗ void PeopleDefinition::resetSensibleHeatFraction() {
498 ✗ getImpl<detail::PeopleDefinition_Impl>()->resetSensibleHeatFraction();
499 ✗ }
500
501 ✗ void PeopleDefinition::autocalculateSensibleHeatFraction() {
502 ✗ getImpl<detail::PeopleDefinition_Impl>()->autocalculateSensibleHeatFraction();
503 ✗ }
504
505 29 bool PeopleDefinition::setCarbonDioxideGenerationRate(double carbonDioxideGenerationRate) {
506
1/1
✓ Branch 3 taken 29 times.
29 return getImpl<detail::PeopleDefinition_Impl>()->setCarbonDioxideGenerationRate(carbonDioxideGenerationRate);
507 }
508
509 ✗ void PeopleDefinition::resetCarbonDioxideGenerationRate() {
510 ✗ getImpl<detail::PeopleDefinition_Impl>()->resetCarbonDioxideGenerationRate();
511 ✗ }
512
513 31 bool PeopleDefinition::setEnableASHRAE55ComfortWarnings(bool enableASHRAE55ComfortWarnings) {
514
1/1
✓ Branch 3 taken 31 times.
31 return getImpl<detail::PeopleDefinition_Impl>()->setEnableASHRAE55ComfortWarnings(enableASHRAE55ComfortWarnings);
515 }
516
517 ✗ void PeopleDefinition::resetEnableASHRAE55ComfortWarnings() {
518 ✗ getImpl<detail::PeopleDefinition_Impl>()->resetEnableASHRAE55ComfortWarnings();
519 ✗ }
520
521 54 bool PeopleDefinition::setMeanRadiantTemperatureCalculationType(const std::string& meanRadiantTemperatureCalculationType) {
522
1/1
✓ Branch 3 taken 54 times.
54 return getImpl<detail::PeopleDefinition_Impl>()->setMeanRadiantTemperatureCalculationType(meanRadiantTemperatureCalculationType);
523 }
524
525 2 void PeopleDefinition::resetMeanRadiantTemperatureCalculationType() {
526
1/1
✓ Branch 3 taken 2 times.
2 getImpl<detail::PeopleDefinition_Impl>()->resetMeanRadiantTemperatureCalculationType();
527 2 }
528
529 ✗ bool PeopleDefinition::pushThermalComfortModelType(const std::string& thermalComfortModelType) {
530 ✗ return getImpl<detail::PeopleDefinition_Impl>()->pushThermalComfortModelType(thermalComfortModelType);
531 }
532
533 40 bool PeopleDefinition::setThermalComfortModelType(int i, const std::string& thermalComfortModelType) {
534
1/1
✓ Branch 3 taken 40 times.
40 return getImpl<detail::PeopleDefinition_Impl>()->setThermalComfortModelType(i, thermalComfortModelType);
535 }
536
537 1 bool PeopleDefinition::eraseThermalComfortModelType(int i) {
538
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::PeopleDefinition_Impl>()->eraseThermalComfortModelType(i);
539 }
540
541 463 double PeopleDefinition::getNumberOfPeople(double floorArea) const {
542
1/1
✓ Branch 3 taken 463 times.
463 return getImpl<detail::PeopleDefinition_Impl>()->getNumberOfPeople(floorArea);
543 }
544
545 56 double PeopleDefinition::getPeoplePerFloorArea(double floorArea) const {
546
1/1
✓ Branch 3 taken 55 times.
56 return getImpl<detail::PeopleDefinition_Impl>()->getPeoplePerFloorArea(floorArea);
547 }
548
549 6 double PeopleDefinition::getFloorAreaPerPerson(double floorArea) const {
550
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::PeopleDefinition_Impl>()->getFloorAreaPerPerson(floorArea);
551 }
552
553 ✗ bool PeopleDefinition::setNumberOfPeopleCalculationMethod(const std::string& method, double floorArea) {
554 ✗ return getImpl<detail::PeopleDefinition_Impl>()->setNumberOfPeopleCalculationMethod(method, floorArea);
555 }
556
557 /// @cond
558
1/1
✓ Branch 3 taken 774 times.
774 PeopleDefinition::PeopleDefinition(std::shared_ptr<detail::PeopleDefinition_Impl> impl) : SpaceLoadDefinition(std::move(impl)) {}
559 /// @endcond
560
561 } // namespace model
562 } // namespace openstudio
563