GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 30.5% 152 / 0 / 499
Functions: 42.9% 45 / 0 / 105
Branches: 11.6% 84 / 0 / 723

src/model/GasMixture.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 "GasMixture.hpp"
7 #include "GasMixture_Impl.hpp"
8
9 #include "../utilities/idf/ValidityReport.hpp"
10
11 #include <utilities/idd/IddFactory.hxx>
12
13 #include <utilities/idd/OS_WindowMaterial_GasMixture_FieldEnums.hxx>
14 #include <utilities/idd/IddEnums.hxx>
15
16 #include "../utilities/math/FloatCompare.hpp"
17
18 #include "../utilities/units/Unit.hpp"
19
20 #include "../utilities/core/Assert.hpp"
21 #include <cmath>
22
23 namespace openstudio {
24 namespace model {
25
26 namespace detail {
27
28 4 GasMixture_Impl::GasMixture_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : GasLayer_Impl(idfObject, model, keepHandle) {
29
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() == GasMixture::iddObjectType());
30 4 }
31
32 ✗ GasMixture_Impl::GasMixture_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
33 ✗ : GasLayer_Impl(other, model, keepHandle) {
34 ✗ OS_ASSERT(other.iddObject().type() == GasMixture::iddObjectType());
35 ✗ }
36
37 1 GasMixture_Impl::GasMixture_Impl(const GasMixture_Impl& other, Model_Impl* model, bool keepHandle) : GasLayer_Impl(other, model, keepHandle) {}
38
39 ✗ IddObjectType GasMixture_Impl::iddObjectType() const {
40 ✗ return GasMixture::iddObjectType();
41 }
42
43 ✗ std::string GasMixture_Impl::getGasType(unsigned index) const {
44 ✗ if (index >= numGases()) {
45 ✗ LOG_AND_THROW("This GasMixture " << briefDescription() << " only has " << numGases()
46 << " gases in it, and so the type of gas cannot be returned for index " << index << ".");
47 }
48 ✗ OptionalString os = getString(mf_getGasTypeFieldIndex(index), true);
49 ✗ if (!os) {
50 ✗ LOG_AND_THROW("gasType is not yet set for the gas at index " << index << " of " << briefDescription() << ".");
51 }
52 ✗ return *os;
53 ✗ }
54
55 ✗ double GasMixture_Impl::getGasFraction(unsigned index) const {
56 ✗ if (index >= numGases()) {
57 ✗ LOG_AND_THROW("This GasMixture " << briefDescription() << " only has " << numGases()
58 << " gases in it, and so the gas fraction cannot be returned for index " << index << ".");
59 }
60 ✗ OptionalDouble od = getDouble(mf_getGasFractionFieldIndex(index), true);
61 ✗ if (!od) {
62 ✗ LOG_AND_THROW("gasFraction is not yet set for the gas at index " << index << " of " << briefDescription() << ".");
63 }
64 ✗ return *od;
65 }
66
67 ✗ double GasMixture_Impl::getThermalConductivity(double temperature) const {
68 ✗ double molecularWeight(0.0); // cumulative sum of fraction * molecular weight
69 ✗ double result(0.0); // cumulative sum of conductivity * fraction * molecular weight
70 ✗ for (unsigned i = 0, n = numGases(); i < n; ++i) {
71 ✗ std::string type = getGasType(i);
72 ✗ double fraction = getGasFraction(i);
73 ✗ double weight(0.0);
74 ✗ std::vector<double> coeffs;
75 ✗ if (openstudio::istringEqual(type, "Air")) {
76 ✗ weight = FenestrationMaterial::airMolecularWeight();
77 ✗ coeffs = FenestrationMaterial::airThermalConductivityCoefficients();
78 ✗ } else if (openstudio::istringEqual(type, "Argon")) {
79 ✗ weight = FenestrationMaterial::argonMolecularWeight();
80 ✗ coeffs = FenestrationMaterial::argonThermalConductivityCoefficients();
81 ✗ } else if (openstudio::istringEqual(type, "Krypton")) {
82 ✗ weight = FenestrationMaterial::kryptonMolecularWeight();
83 ✗ coeffs = FenestrationMaterial::kryptonThermalConductivityCoefficients();
84 ✗ } else if (openstudio::istringEqual(type, "Xenon")) {
85 ✗ weight = FenestrationMaterial::xenonMolecularWeight();
86 ✗ coeffs = FenestrationMaterial::xenonThermalConductivityCoefficients();
87 } else {
88 ✗ LOG_AND_THROW("Unknown gasType listed in " << briefDescription() << ".");
89 }
90 ✗ molecularWeight += weight * fraction;
91 ✗ result += (coeffs[0] + (coeffs[1] * temperature) + (coeffs[2] * ::pow(temperature, 2.0))) * fraction * weight;
92 ✗ }
93 ✗ result /= molecularWeight;
94 ✗ return result;
95 }
96
97 ✗ double GasMixture_Impl::getThermalConductance(double temperature) const {
98 ✗ return getThermalConductivity(temperature) / thickness();
99 }
100
101 ✗ double GasMixture_Impl::getThermalResistivity(double temperature) const {
102 ✗ return 1.0 / getThermalConductivity(temperature);
103 }
104
105 ✗ double GasMixture_Impl::getThermalResistance(double temperature) const {
106 ✗ return 1.0 / getThermalConductance(temperature);
107 }
108
109 ✗ double GasMixture_Impl::getViscosity(double temperature) const {
110 ✗ double molecularWeight(0.0); // cumulative sum of fraction * molecular weight
111 ✗ double result(0.0); // cumulative sum of viscosity * fraction * molecular weight
112 ✗ for (unsigned i = 0, n = numGases(); i < n; ++i) {
113 ✗ std::string type = getGasType(i);
114 ✗ double fraction = getGasFraction(i);
115 ✗ double weight(0.0);
116 ✗ std::vector<double> coeffs;
117 ✗ if (openstudio::istringEqual(type, "Air")) {
118 ✗ weight = FenestrationMaterial::airMolecularWeight();
119 ✗ coeffs = FenestrationMaterial::airViscosityCoefficients();
120 ✗ } else if (openstudio::istringEqual(type, "Argon")) {
121 ✗ weight = FenestrationMaterial::argonMolecularWeight();
122 ✗ coeffs = FenestrationMaterial::argonViscosityCoefficients();
123 ✗ } else if (openstudio::istringEqual(type, "Krypton")) {
124 ✗ weight = FenestrationMaterial::kryptonMolecularWeight();
125 ✗ coeffs = FenestrationMaterial::kryptonViscosityCoefficients();
126 ✗ } else if (openstudio::istringEqual(type, "Xenon")) {
127 ✗ weight = FenestrationMaterial::xenonMolecularWeight();
128 ✗ coeffs = FenestrationMaterial::xenonViscosityCoefficients();
129 } else {
130 ✗ LOG_AND_THROW("Unknown gasType listed in " << briefDescription() << ".");
131 }
132 ✗ molecularWeight += weight * fraction;
133 ✗ result += (coeffs[0] + (coeffs[1] * temperature) + (coeffs[2] * ::pow(temperature, 2))) * fraction * weight;
134 ✗ }
135 ✗ result /= molecularWeight;
136 ✗ return result;
137 }
138
139 ✗ double GasMixture_Impl::getSpecificHeat(double temperature) const {
140 ✗ double molecularWeight(0.0); // cumulative sum of fraction * molecular weight
141 ✗ double result(0.0); // cumulative sum of specific heat * fraction * molecular weight
142 ✗ for (unsigned i = 0, n = numGases(); i < n; ++i) {
143 ✗ std::string type = getGasType(i);
144 ✗ double fraction = getGasFraction(i);
145 ✗ double weight(0.0);
146 ✗ std::vector<double> coeffs;
147 ✗ if (openstudio::istringEqual(type, "Air")) {
148 ✗ weight = FenestrationMaterial::airMolecularWeight();
149 ✗ coeffs = FenestrationMaterial::airSpecificHeatCoefficients();
150 ✗ } else if (openstudio::istringEqual(type, "Argon")) {
151 ✗ weight = FenestrationMaterial::argonMolecularWeight();
152 ✗ coeffs = FenestrationMaterial::argonSpecificHeatCoefficients();
153 ✗ } else if (openstudio::istringEqual(type, "Krypton")) {
154 ✗ weight = FenestrationMaterial::kryptonMolecularWeight();
155 ✗ coeffs = FenestrationMaterial::kryptonSpecificHeatCoefficients();
156 ✗ } else if (openstudio::istringEqual(type, "Xenon")) {
157 ✗ weight = FenestrationMaterial::xenonMolecularWeight();
158 ✗ coeffs = FenestrationMaterial::xenonSpecificHeatCoefficients();
159 } else {
160 ✗ LOG_AND_THROW("Unknown gasType listed in " << briefDescription() << ".");
161 }
162 ✗ molecularWeight += weight * fraction;
163 ✗ result += (coeffs[0] + (coeffs[1] * temperature) + (coeffs[2] * ::pow(temperature, 2))) * fraction * weight;
164 ✗ }
165 ✗ result /= molecularWeight;
166 ✗ return result;
167 }
168
169 ✗ const std::vector<std::string>& GasMixture_Impl::outputVariableNames() const {
170 ✗ static const std::vector<std::string> result;
171 ✗ return result;
172 }
173
174 ✗ bool GasMixture_Impl::setGas(unsigned index, const std::string& type, double fraction) {
175 ✗ if ((index > numGases()) || (index >= 4)) {
176 ✗ LOG(Info, "Cannot set the gas at index " << index << " in GasMixture " << briefDescription() << ". The current number of gases is "
177 << numGases() << ", and the maximum is 4.");
178 ✗ return false;
179 }
180 ✗ if (index == numGases() && index < 4) {
181 ✗ return addGas(type, fraction);
182 }
183
184 ✗ unsigned typeIndex = mf_getGasTypeFieldIndex(index);
185 ✗ unsigned fractionIndex = mf_getGasFractionFieldIndex(index);
186
187 ✗ OptionalString oldType = getString(typeIndex, true);
188 ✗ bool result = setString(typeIndex, type);
189 ✗ if (!result) {
190 ✗ return false;
191 }
192 ✗ result = setDouble(fractionIndex, fraction);
193 ✗ if (!result) {
194 ✗ if (oldType) {
195 ✗ setString(typeIndex, *oldType);
196 } else {
197 ✗ setString(typeIndex, "");
198 }
199 }
200
201 ✗ return result;
202 ✗ }
203
204 ✗ bool GasMixture_Impl::setGasType(unsigned index, const std::string& type) {
205 ✗ if (index >= numGases()) {
206 ✗ LOG(Info, "Cannot set the gas type at index " << index << " in GasMixture " << briefDescription() << ". The current number of gases is "
207 << numGases() << ".");
208 ✗ return false;
209 }
210 ✗ return setString(mf_getGasTypeFieldIndex(index), type);
211 }
212
213 ✗ bool GasMixture_Impl::setGasFraction(unsigned index, double fraction) {
214 ✗ if (index >= numGases()) {
215 ✗ LOG(Info, "Cannot set the gas fraction at index " << index << " in GasMixture " << briefDescription() << ". The current number of gases is "
216 << numGases() << ".");
217 ✗ return false;
218 }
219 ✗ return setDouble(mf_getGasFractionFieldIndex(index), fraction);
220 }
221
222 ✗ bool GasMixture_Impl::addGas(const std::string& type, double fraction) {
223 ✗ if (numGases() == 4) {
224 ✗ LOG(Info, "Cannot add any more gases to GasMixture " << briefDescription() << ".");
225 ✗ return false;
226 }
227
228 ✗ unsigned index = numGases();
229 ✗ bool ok = setUnsigned(OS_WindowMaterial_GasMixtureFields::NumberofGasesinMixture, index + 1);
230 ✗ OS_ASSERT(ok);
231
232 ✗ bool result = setGas(index, type, fraction);
233
234 ✗ if (!result) {
235 ✗ ok = setUnsigned(OS_WindowMaterial_GasMixtureFields::NumberofGasesinMixture, index);
236 ✗ OS_ASSERT(ok);
237 }
238
239 ✗ return result;
240 }
241
242 ✗ bool GasMixture_Impl::setFractions(const std::vector<double>& fractions) {
243 ✗ if (fractions.size() != numGases()) {
244 ✗ LOG(Info, "Cannot set GasMixture " << briefDescription() << " fractions using vector " << "of length " << fractions.size()
245 << ", because the object currently lists " << numGases() << " gases.");
246 ✗ return false;
247 }
248 ✗ bool result = true;
249 ✗ double fullSum(0.0);
250 ✗ std::vector<std::string> rollbackValues;
251 ✗ for (unsigned i = 0, n = numGases(); i < n; ++i) {
252 // be able to rollback previously set values if necessary
253 ✗ unsigned index = mf_getGasFractionFieldIndex(i);
254 ✗ rollbackValues.push_back(getString(index, true).get());
255
256 // determine where we are with respect to adding up to 1.0
257 ✗ double value = fractions[i];
258 ✗ double minusOneSum = fullSum;
259 ✗ fullSum += value;
260 ✗ if (openstudio::greaterThanOrEqual(minusOneSum, 1.0)) {
261 ✗ LOG(Warn, "Unable to set gas fractions for GasMixture " << briefDescription() << " because the partial sum has met or exceeded 1.0");
262 ✗ result = false;
263 ✗ break;
264 }
265 ✗ if ((i == n - 1) && (!openstudio::equal(fullSum, 1.0))) {
266 ✗ LOG(Warn, "The sum of the fractions entered for GasMixture " << briefDescription() << " equal " << fullSum
267 << ", rather than 1.0, so the last entry will be adjusted " << "accordingly.");
268 ✗ value = 1.0 - minusOneSum;
269 }
270 ✗ result = setDouble(index, value);
271 ✗ if (!result) {
272 ✗ break;
273 }
274 ✗ index += 2;
275 }
276 ✗ if (!result) {
277 ✗ for (unsigned j = 0, nr = rollbackValues.size(); j < nr; ++j) {
278 ✗ setString(mf_getGasFractionFieldIndex(j), rollbackValues[j]);
279 }
280 }
281 ✗ return result;
282 ✗ }
283
284 ✗ bool GasMixture_Impl::balanceFractions(unsigned index) {
285 ✗ if (index >= numGases()) {
286 ✗ return false;
287 }
288 ✗ double partialSum(0.0);
289 ✗ for (unsigned i = 0, n = numGases(); i < n; ++i) {
290 ✗ if (i != index) {
291 ✗ partialSum += getGasFraction(i);
292 }
293 }
294 ✗ if (openstudio::greaterThanOrEqual(partialSum, 1.0)) {
295 ✗ LOG(Warn, "Cannot balance gas fractions for GasMixture " << briefDescription() << " because the partial sum has met or exceeded 1.0");
296 ✗ return false;
297 }
298 ✗ return setGasFraction(index, 1.0 - partialSum);
299 }
300
301 ✗ unsigned GasMixture_Impl::numGases() const {
302 ✗ OptionalUnsigned ou = getUnsigned(OS_WindowMaterial_GasMixtureFields::NumberofGasesinMixture, true);
303 ✗ OS_ASSERT(ou);
304 ✗ return *ou;
305 }
306
307 ✗ unsigned GasMixture_Impl::mf_getGasTypeFieldIndex(unsigned gasIndex) const {
308 ✗ unsigned result(0);
309 ✗ switch (gasIndex) {
310 ✗ case 0:
311 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas1Type;
312 ✗ break;
313 ✗ case 1:
314 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas2Type;
315 ✗ break;
316 ✗ case 2:
317 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas3Type;
318 ✗ break;
319 ✗ case 3:
320 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas4Type;
321 ✗ break;
322 ✗ default:
323 ✗ LOG_AND_THROW("GasMixture only supports four gases, and is indexed starting with 0. Cannot " << "return the gas type at index " << gasIndex
324 << ".");
325 };
326 ✗ OS_ASSERT(result > 0);
327 ✗ return result;
328 }
329
330 ✗ unsigned GasMixture_Impl::mf_getGasFractionFieldIndex(unsigned gasIndex) const {
331 ✗ unsigned result(0);
332 ✗ switch (gasIndex) {
333 ✗ case 0:
334 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas1Fraction;
335 ✗ break;
336 ✗ case 1:
337 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas2Fraction;
338 ✗ break;
339 ✗ case 2:
340 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas3Fraction;
341 ✗ break;
342 ✗ case 3:
343 ✗ result = OS_WindowMaterial_GasMixtureFields::Gas4Fraction;
344 ✗ break;
345 ✗ default:
346 ✗ LOG_AND_THROW("GasMixture only supports four gases, and is indexed starting with 0. Cannot " << "return the gas fraction at index "
347 << gasIndex << ".");
348 };
349 ✗ OS_ASSERT(result > 0);
350 ✗ return result;
351 }
352
353 2 double GasMixture_Impl::thickness() const {
354
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_WindowMaterial_GasMixtureFields::Thickness, true);
355
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
356
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
357 }
358
359 5 bool GasMixture_Impl::setThickness(double thickness) {
360 5 bool result = setDouble(OS_WindowMaterial_GasMixtureFields::Thickness, thickness);
361 5 return result;
362 }
363
364 3 int GasMixture_Impl::numberofGasesinMixture() const {
365
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<int> value = getInt(OS_WindowMaterial_GasMixtureFields::NumberofGasesinMixture, true);
366
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(value);
367
1/1
✓ Branch 1 taken 3 times.
6 return value.get();
368 }
369
370 6 bool GasMixture_Impl::setNumberofGasesinMixture(int numberofGasesinMixture) {
371 6 bool result = setInt(OS_WindowMaterial_GasMixtureFields::NumberofGasesinMixture, numberofGasesinMixture);
372 6 return result;
373 }
374
375 3 std::string GasMixture_Impl::gas1Type() const {
376
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_WindowMaterial_GasMixtureFields::Gas1Type, true);
377
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(value);
378
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 return value.get();
379 3 }
380
381 2 double GasMixture_Impl::gas1Fraction() const {
382
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_WindowMaterial_GasMixtureFields::Gas1Fraction, true);
383
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
384
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
385 }
386
387 3 std::string GasMixture_Impl::gas2Type() const {
388
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_WindowMaterial_GasMixtureFields::Gas2Type, true);
389
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(value);
390
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 return value.get();
391 3 }
392
393 2 double GasMixture_Impl::gas2Fraction() const {
394
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_WindowMaterial_GasMixtureFields::Gas2Fraction, true);
395
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
396
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
397 }
398
399 3 std::string GasMixture_Impl::gas3Type() const {
400
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_WindowMaterial_GasMixtureFields::Gas3Type, true);
401
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
402
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return *value;
403 } else {
404 ✗ return {};
405 }
406 3 }
407
408 4 boost::optional<double> GasMixture_Impl::gas3Fraction() const {
409 4 return getDouble(OS_WindowMaterial_GasMixtureFields::Gas3Fraction, true);
410 }
411
412 3 std::string GasMixture_Impl::gas4Type() const {
413
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_WindowMaterial_GasMixtureFields::Gas4Type, true);
414
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
415
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return *value;
416 } else {
417 ✗ return {};
418 }
419 3 }
420
421 4 boost::optional<double> GasMixture_Impl::gas4Fraction() const {
422 4 return getDouble(OS_WindowMaterial_GasMixtureFields::Gas4Fraction, true);
423 }
424
425 6 bool GasMixture_Impl::setGas1Type(const std::string& gas1Type) {
426 6 bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas1Type, gas1Type);
427 6 return result;
428 }
429
430 5 bool GasMixture_Impl::setGas1Fraction(double gas1Fraction) {
431 5 bool result = setDouble(OS_WindowMaterial_GasMixtureFields::Gas1Fraction, gas1Fraction);
432 5 return result;
433 }
434
435 6 bool GasMixture_Impl::setGas2Type(const std::string& gas2Type) {
436 6 bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas2Type, gas2Type);
437 6 return result;
438 }
439
440 5 bool GasMixture_Impl::setGas2Fraction(double gas2Fraction) {
441 5 bool result = setDouble(OS_WindowMaterial_GasMixtureFields::Gas2Fraction, gas2Fraction);
442 5 return result;
443 }
444
445 6 bool GasMixture_Impl::setGas3Type(boost::optional<std::string> gas3Type) {
446 6 bool result(false);
447
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (gas3Type) {
448 6 result = setString(OS_WindowMaterial_GasMixtureFields::Gas3Type, gas3Type.get());
449 } else {
450 ✗ resetGas3Type();
451 ✗ result = true;
452 }
453 6 return result;
454 }
455
456 ✗ void GasMixture_Impl::resetGas1Type() {
457 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas1Type, "");
458 ✗ OS_ASSERT(result);
459 ✗ }
460
461 ✗ void GasMixture_Impl::resetGas2Type() {
462 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas2Type, "");
463 ✗ OS_ASSERT(result);
464 ✗ }
465
466 ✗ void GasMixture_Impl::resetGas3Type() {
467 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas3Type, "");
468 ✗ OS_ASSERT(result);
469 ✗ }
470
471 5 bool GasMixture_Impl::setGas3Fraction(boost::optional<double> gas3Fraction) {
472 5 bool result(false);
473
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (gas3Fraction) {
474 5 result = setDouble(OS_WindowMaterial_GasMixtureFields::Gas3Fraction, gas3Fraction.get());
475 } else {
476 ✗ resetGas3Fraction();
477 ✗ result = true;
478 }
479 5 return result;
480 }
481
482 ✗ void GasMixture_Impl::resetGas1Fraction() {
483 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas1Fraction, "");
484 ✗ OS_ASSERT(result);
485 ✗ }
486
487 ✗ void GasMixture_Impl::resetGas2Fraction() {
488 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas2Fraction, "");
489 ✗ OS_ASSERT(result);
490 ✗ }
491
492 ✗ void GasMixture_Impl::resetGas3Fraction() {
493 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas3Fraction, "");
494 ✗ OS_ASSERT(result);
495 ✗ }
496
497 6 bool GasMixture_Impl::setGas4Type(boost::optional<std::string> gas4Type) {
498 6 bool result(false);
499
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (gas4Type) {
500 6 result = setString(OS_WindowMaterial_GasMixtureFields::Gas4Type, gas4Type.get());
501 } else {
502 ✗ resetGas4Type();
503 ✗ result = true;
504 }
505 6 return result;
506 }
507
508 ✗ void GasMixture_Impl::resetGas4Type() {
509 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas4Type, "");
510 ✗ OS_ASSERT(result);
511 ✗ }
512
513 5 bool GasMixture_Impl::setGas4Fraction(boost::optional<double> gas4Fraction) {
514 5 bool result(false);
515
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (gas4Fraction) {
516 5 result = setDouble(OS_WindowMaterial_GasMixtureFields::Gas4Fraction, gas4Fraction.get());
517 } else {
518 ✗ resetGas4Fraction();
519 ✗ result = true;
520 }
521 5 return result;
522 }
523
524 ✗ void GasMixture_Impl::resetGas4Fraction() {
525 ✗ bool result = setString(OS_WindowMaterial_GasMixtureFields::Gas4Fraction, "");
526 ✗ OS_ASSERT(result);
527 ✗ }
528
529 ✗ std::vector<std::string> GasMixture_Impl::gas1TypeValues() const {
530 ✗ return GasMixture::gas1TypeValues();
531 }
532
533 ✗ std::vector<std::string> GasMixture_Impl::gas2TypeValues() const {
534 ✗ return GasMixture::gas2TypeValues();
535 }
536
537 ✗ std::vector<std::string> GasMixture_Impl::gas3TypeValues() const {
538 ✗ return GasMixture::gas3TypeValues();
539 }
540
541 ✗ std::vector<std::string> GasMixture_Impl::gas4TypeValues() const {
542 ✗ return GasMixture::gas4TypeValues();
543 }
544
545 } // namespace detail
546
547 4 GasMixture::GasMixture(const Model& model, int numberofGasesinMixture, double thickness, std::string gas1Type, double gas1Fraction,
548 std::string gas2Type, double gas2Fraction, std::string gas3Type, double gas3Fraction, std::string gas4Type,
549 4 double gas4Fraction)
550 4 : GasLayer(GasMixture::iddObjectType(), model) {
551
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
4 OS_ASSERT(getImpl<detail::GasMixture_Impl>());
552
553 // TODO: Appropriately handle the following required object-list fields.
554 4 bool ok = true;
555 // ok = setHandle();
556
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
557
1/1
✓ Branch 1 taken 4 times.
4 ok = setThickness(thickness);
558
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
559
1/1
✓ Branch 1 taken 4 times.
4 ok = setNumberofGasesinMixture(numberofGasesinMixture);
560
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
561
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas1Type(gas1Type);
562
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
563
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas1Fraction(gas1Fraction);
564
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
565
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas2Type(gas2Type);
566
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
567
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas2Fraction(gas2Fraction);
568
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
569
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas3Type(gas3Type);
570
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
571
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas3Fraction(gas3Fraction);
572
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
573
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas4Type(gas4Type);
574
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
575
1/1
✓ Branch 1 taken 4 times.
4 ok = setGas4Fraction(gas4Fraction);
576
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
577 4 }
578
579 7738 IddObjectType GasMixture::iddObjectType() {
580
1/1
✓ Branch 1 taken 7738 times.
7738 return {IddObjectType::OS_WindowMaterial_GasMixture};
581 }
582
583 ✗ std::vector<std::string> GasMixture::validGasTypes() {
584 static const StringVector result =
585 ✗ getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WindowMaterial_GasMixtureFields::Gas1Type);
586 ✗ OS_ASSERT(!result.empty());
587 ✗ return result;
588 }
589
590 ✗ std::string GasMixture::getGasType(unsigned index) const {
591 ✗ return getImpl<detail::GasMixture_Impl>()->getGasType(index);
592 }
593
594 ✗ double GasMixture::getGasFraction(unsigned index) const {
595 ✗ return getImpl<detail::GasMixture_Impl>()->getGasFraction(index);
596 }
597
598 ✗ double GasMixture::getThermalConductivity(double temperature) const {
599 ✗ return getImpl<detail::GasMixture_Impl>()->getThermalConductivity(temperature);
600 }
601
602 ✗ double GasMixture::getThermalConductance(double temperature) const {
603 ✗ return getImpl<detail::GasMixture_Impl>()->getThermalConductance(temperature);
604 }
605
606 ✗ double GasMixture::getThermalResistivity(double temperature) const {
607 ✗ return getImpl<detail::GasMixture_Impl>()->getThermalResistivity(temperature);
608 }
609
610 ✗ double GasMixture::getThermalResistance(double temperature) const {
611 ✗ return getImpl<detail::GasMixture_Impl>()->getThermalResistance(temperature);
612 }
613
614 ✗ double GasMixture::getViscosity(double temperature) const {
615 ✗ return getImpl<detail::GasMixture_Impl>()->getViscosity(temperature);
616 }
617
618 ✗ double GasMixture::getSpecificHeat(double temperature) const {
619 ✗ return getImpl<detail::GasMixture_Impl>()->getSpecificHeat(temperature);
620 }
621
622 ✗ bool GasMixture::setGas(unsigned index, const std::string& type, double fraction) {
623 ✗ return getImpl<detail::GasMixture_Impl>()->setGas(index, type, fraction);
624 }
625
626 ✗ bool GasMixture::setGasType(unsigned index, const std::string& type) {
627 ✗ return getImpl<detail::GasMixture_Impl>()->setGasType(index, type);
628 }
629
630 ✗ bool GasMixture::setGasFraction(unsigned index, double fraction) {
631 ✗ return getImpl<detail::GasMixture_Impl>()->setGasFraction(index, fraction);
632 }
633
634 ✗ bool GasMixture::addGas(const std::string& type, double fraction) {
635 ✗ return getImpl<detail::GasMixture_Impl>()->addGas(type, fraction);
636 }
637
638 ✗ bool GasMixture::setFractions(const std::vector<double>& fractions) {
639 ✗ return getImpl<detail::GasMixture_Impl>()->setFractions(fractions);
640 }
641
642 ✗ bool GasMixture::balanceFractions(unsigned index) {
643 ✗ return getImpl<detail::GasMixture_Impl>()->balanceFractions(index);
644 }
645
646 ✗ unsigned GasMixture::numGases() const {
647 ✗ return getImpl<detail::GasMixture_Impl>()->numGases();
648 }
649
650 ✗ std::vector<std::string> GasMixture::gas1TypeValues() {
651 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WindowMaterial_GasMixtureFields::Gas1Type);
652 }
653
654 ✗ std::vector<std::string> GasMixture::gas2TypeValues() {
655 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WindowMaterial_GasMixtureFields::Gas2Type);
656 }
657
658 ✗ std::vector<std::string> GasMixture::gas3TypeValues() {
659 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WindowMaterial_GasMixtureFields::Gas3Type);
660 }
661
662 ✗ std::vector<std::string> GasMixture::gas4TypeValues() {
663 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_WindowMaterial_GasMixtureFields::Gas4Type);
664 }
665
666 2 double GasMixture::thickness() const {
667
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::GasMixture_Impl>()->thickness();
668 }
669
670 5 bool GasMixture::setThickness(double thickness) {
671
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::GasMixture_Impl>()->setThickness(thickness);
672 }
673
674 3 int GasMixture::numberofGasesinMixture() const {
675
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::GasMixture_Impl>()->numberofGasesinMixture();
676 }
677
678 6 bool GasMixture::setNumberofGasesinMixture(int numberofGasesinMixture) {
679
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::GasMixture_Impl>()->setNumberofGasesinMixture(numberofGasesinMixture);
680 }
681
682 3 std::string GasMixture::gas1Type() const {
683
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::GasMixture_Impl>()->gas1Type();
684 }
685
686 2 double GasMixture::gas1Fraction() const {
687
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::GasMixture_Impl>()->gas1Fraction();
688 }
689
690 3 std::string GasMixture::gas2Type() const {
691
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::GasMixture_Impl>()->gas2Type();
692 }
693
694 2 double GasMixture::gas2Fraction() const {
695
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::GasMixture_Impl>()->gas2Fraction();
696 }
697
698 3 std::string GasMixture::gas3Type() const {
699
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::GasMixture_Impl>()->gas3Type();
700 }
701
702 4 boost::optional<double> GasMixture::gas3Fraction() const {
703
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GasMixture_Impl>()->gas3Fraction();
704 }
705
706 3 std::string GasMixture::gas4Type() const {
707
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::GasMixture_Impl>()->gas4Type();
708 }
709
710 4 boost::optional<double> GasMixture::gas4Fraction() const {
711
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::GasMixture_Impl>()->gas4Fraction();
712 }
713
714 6 bool GasMixture::setGas1Type(const std::string& gas1Type) {
715
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::GasMixture_Impl>()->setGas1Type(gas1Type);
716 }
717
718 ✗ void GasMixture::resetGas1Type() {
719 ✗ getImpl<detail::GasMixture_Impl>()->resetGas1Type();
720 ✗ }
721
722 5 bool GasMixture::setGas1Fraction(double gas1Fraction) {
723
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::GasMixture_Impl>()->setGas1Fraction(gas1Fraction);
724 }
725
726 ✗ void GasMixture::resetGas1Fraction() {
727 ✗ getImpl<detail::GasMixture_Impl>()->resetGas1Fraction();
728 ✗ }
729
730 6 bool GasMixture::setGas2Type(const std::string& gas2Type) {
731
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::GasMixture_Impl>()->setGas2Type(gas2Type);
732 }
733
734 ✗ void GasMixture::resetGas2Type() {
735 ✗ getImpl<detail::GasMixture_Impl>()->resetGas2Type();
736 ✗ }
737
738 5 bool GasMixture::setGas2Fraction(double gas2Fraction) {
739
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::GasMixture_Impl>()->setGas2Fraction(gas2Fraction);
740 }
741
742 ✗ void GasMixture::resetGas2Fraction() {
743 ✗ getImpl<detail::GasMixture_Impl>()->resetGas2Fraction();
744 ✗ }
745
746 6 bool GasMixture::setGas3Type(const std::string& gas3Type) {
747
2/2
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
6 return getImpl<detail::GasMixture_Impl>()->setGas3Type(gas3Type);
748 }
749
750 ✗ void GasMixture::resetGas3Type() {
751 ✗ getImpl<detail::GasMixture_Impl>()->resetGas3Type();
752 ✗ }
753
754 5 bool GasMixture::setGas3Fraction(double gas3Fraction) {
755
2/2
✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
5 return getImpl<detail::GasMixture_Impl>()->setGas3Fraction(gas3Fraction);
756 }
757
758 ✗ void GasMixture::resetGas3Fraction() {
759 ✗ getImpl<detail::GasMixture_Impl>()->resetGas3Fraction();
760 ✗ }
761
762 6 bool GasMixture::setGas4Type(const std::string& gas4Type) {
763
2/2
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
6 return getImpl<detail::GasMixture_Impl>()->setGas4Type(gas4Type);
764 }
765
766 ✗ void GasMixture::resetGas4Type() {
767 ✗ getImpl<detail::GasMixture_Impl>()->resetGas4Type();
768 ✗ }
769
770 5 bool GasMixture::setGas4Fraction(double gas4Fraction) {
771
2/2
✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
5 return getImpl<detail::GasMixture_Impl>()->setGas4Fraction(gas4Fraction);
772 }
773
774 ✗ void GasMixture::resetGas4Fraction() {
775 ✗ getImpl<detail::GasMixture_Impl>()->resetGas4Fraction();
776 ✗ }
777
778 /// @cond
779
1/1
✓ Branch 3 taken 2 times.
2 GasMixture::GasMixture(std::shared_ptr<detail::GasMixture_Impl> impl) : GasLayer(std::move(impl)) {}
780 /// @endcond
781
782 } // namespace model
783 } // namespace openstudio
784