GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.9% 48 / 0 / 54
Functions: 100.0% 1 / 0 / 1
Branches: 61.5% 56 / 0 / 91

src/energyplus/ForwardTranslator/ForwardTranslateGeneratorFuelSupply.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "../ForwardTranslator.hpp"
7
8 #include "../../model/Model.hpp"
9 #include "../../model/GeneratorFuelSupply.hpp"
10 #include "../../model/GeneratorFuelSupply_Impl.hpp"
11
12 #include "../../model/Node.hpp"
13 #include "../../model/Node_Impl.hpp"
14 #include "../../model/Schedule.hpp"
15 #include "../../model/Schedule_Impl.hpp"
16 #include "../../model/ScheduleConstant.hpp"
17 #include "../../model/ScheduleConstant_Impl.hpp"
18 #include "../../model/CurveCubic.hpp"
19 #include "../../model/CurveCubic_Impl.hpp"
20 #include "../../model/CurveQuadratic.hpp"
21 #include "../../model/CurveQuadratic_Impl.hpp"
22 #include "../../model/ScheduleTypeLimits.hpp"
23 #include "../../model/ScheduleTypeRegistry.hpp"
24
25 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
26
27 #include <utilities/idd/Generator_FuelSupply_FieldEnums.hxx>
28 #include "../../utilities/idd/IddEnums.hpp"
29 #include <utilities/idd/IddEnums.hxx>
30 #include <utilities/idd/IddFactory.hxx>
31
32 using namespace openstudio::model;
33
34 using namespace std;
35
36 namespace openstudio {
37
38 namespace energyplus {
39
40 3 boost::optional<IdfObject> ForwardTranslator::translateGeneratorFuelSupply(GeneratorFuelSupply& modelObject) {
41 3 boost::optional<std::string> s;
42 3 boost::optional<double> d;
43 3 boost::optional<int> i;
44 3 boost::optional<Node> node;
45 3 boost::optional<Schedule> schedule;
46 3 boost::optional<CurveCubic> curve;
47
48
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject idf_fS = createAndRegisterIdfObject(openstudio::IddObjectType::Generator_FuelSupply, modelObject);
49 //Name
50
1/1
✓ Branch 1 taken 3 times.
3 s = modelObject.name();
51
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
52
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_fS.setName(*s);
53 }
54
55 //fuelTemperatureModelingMode
56
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.fuelTemperatureModelingMode();
57
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
58
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_fS.setString(Generator_FuelSupplyFields::FuelTemperatureModelingMode, s.get());
59 }
60
61 //FuelTemperatureReferenceNodeName
62
1/1
✓ Branch 1 taken 3 times.
3 node = modelObject.fuelTemperatureReferenceNode();
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (node) {
64 ✗ idf_fS.setString(Generator_FuelSupplyFields::FuelTemperatureReferenceNodeName, node.get().nameString());
65 }
66
67 //FuelTemperatureScheduleName
68
1/1
✓ Branch 1 taken 3 times.
3 schedule = modelObject.fuelTemperatureSchedule();
69
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (schedule) {
70
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idf_fS.setString(Generator_FuelSupplyFields::FuelTemperatureScheduleName, schedule.get().nameString());
71 }
72
73 //CompressorPowerMultiplierFunctionofFuelRateCurveName
74
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 curve = modelObject.compressorPowerMultiplierFunctionofFuelRateCurve();
75
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (curve) {
76
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idf_fS.setString(Generator_FuelSupplyFields::CompressorPowerMultiplierFunctionofFuelRateCurveName, curve.get().nameString());
77 }
78
79 //CompressorHeatLossFactor
80
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 d = modelObject.compressorHeatLossFactor();
81
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (d) {
82
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_fS.setDouble(Generator_FuelSupplyFields::CompressorHeatLossFactor, d.get());
83 }
84
85 //FuelType
86
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.fuelType();
87
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
88
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_fS.setString(Generator_FuelSupplyFields::FuelType, s.get());
89 }
90
91 //LiquidGenericFuelLowerHeatingValue
92
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.liquidGenericFuelLowerHeatingValue();
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (d) {
94 ✗ idf_fS.setDouble(Generator_FuelSupplyFields::LiquidGenericFuelLowerHeatingValue, d.get());
95 }
96
97 //LiquidGenericFuelHigherHeatingValue
98
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.liquidGenericFuelHigherHeatingValue();
99
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (d) {
100 ✗ idf_fS.setDouble(Generator_FuelSupplyFields::LiquidGenericFuelHigherHeatingValue, d.get());
101 }
102
103 //LiquidGenericFuelMolecularWeight
104
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.liquidGenericFuelMolecularWeight();
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (d) {
106 ✗ idf_fS.setDouble(Generator_FuelSupplyFields::LiquidGenericFuelMolecularWeight, d.get());
107 }
108
109 //LiquidGenericFuelCO2EmissionFactor
110
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.liquidGenericFuelCO2EmissionFactor();
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (d) {
112 ✗ idf_fS.setDouble(Generator_FuelSupplyFields::LiquidGenericFuelCO2EmissionFactor, d.get());
113 }
114
115 //UserDefinedConstituents
116
1/1
✓ Branch 1 taken 3 times.
3 std::vector<FuelSupplyConstituent> constituents = modelObject.constituents();
117
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 if (!constituents.empty()) {
118 // E+ expects the sum of the molar fractions to be 1
119
1/1
✓ Branch 1 taken 3 times.
3 double sumFractions = modelObject.sumofConstituentsMolarFractions();
120
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if ((sumFractions < 0.98) || (sumFractions > 1.02)) {
121 ✗ LOG(Warn, "For " << modelObject.briefDescription() << ", the sum of molar fractions of the constituent isn't equal to 1, but " << sumFractions
122 << ".");
123 }
124
2/2
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3 times.
27 for (const FuelSupplyConstituent& constituent : constituents) {
125
1/1
✓ Branch 1 taken 24 times.
24 auto eg = idf_fS.pushExtensibleGroup();
126
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 eg.setString(Generator_FuelSupplyExtensibleFields::ConstituentName, constituent.constituentName());
127
2/2
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
24 eg.setDouble(Generator_FuelSupplyExtensibleFields::ConstituentMolarFraction, constituent.molarFraction());
128 24 }
129 }
130
131 //NumberofUserDefinedConstituents
132
1/1
✓ Branch 2 taken 3 times.
3 idf_fS.setInt(Generator_FuelSupplyFields::NumberofConstituentsinGaseousConstituentFuelSupply, constituents.size());
133
134
1/1
✓ Branch 1 taken 3 times.
6 return idf_fS;
135 3 }
136
137 } // namespace energyplus
138
139 } // namespace openstudio
140