GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 85.0% 51 / 0 / 60
Functions: 100.0% 1 / 0 / 1
Branches: 62.6% 62 / 0 / 99

src/energyplus/ForwardTranslator/ForwardTranslateGeneratorFuelCellAirSupply.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/GeneratorFuelCellPowerModule.hpp"
10 #include "../../model/GeneratorFuelCellPowerModule_Impl.hpp"
11 #include "../../model/GeneratorFuelCellAirSupply.hpp"
12 #include "../../model/GeneratorFuelCellAirSupply_Impl.hpp"
13 #include "../../model/GeneratorFuelCellWaterSupply.hpp"
14 #include "../../model/GeneratorFuelCellWaterSupply_Impl.hpp"
15 #include "../../model/GeneratorFuelCellAuxiliaryHeater.hpp"
16 #include "../../model/GeneratorFuelCellAuxiliaryHeater_Impl.hpp"
17 #include "../../model/GeneratorFuelCellExhaustGasToWaterHeatExchanger.hpp"
18 #include "../../model/GeneratorFuelCellExhaustGasToWaterHeatExchanger_Impl.hpp"
19 #include "../../model/GeneratorFuelCellElectricalStorage.hpp"
20 #include "../../model/GeneratorFuelCellElectricalStorage_Impl.hpp"
21 #include "../../model/GeneratorFuelCellInverter.hpp"
22 #include "../../model/GeneratorFuelCellInverter_Impl.hpp"
23 #include "../../model/GeneratorFuelCellStackCooler.hpp"
24 #include "../../model/GeneratorFuelCellStackCooler_Impl.hpp"
25 #include "../../model/GeneratorFuelSupply.hpp"
26 #include "../../model/GeneratorFuelSupply_Impl.hpp"
27 #include "../../model/CurveQuadratic.hpp"
28 #include "../../model/CurveQuadratic_Impl.hpp"
29 #include "../../model/CurveCubic.hpp"
30 #include "../../model/CurveCubic_Impl.hpp"
31 #include "../../model/Node.hpp"
32 #include "../../model/Node_Impl.hpp"
33
34 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
35
36 #include <utilities/idd/Generator_FuelCell_AirSupply_FieldEnums.hxx>
37 #include "../../utilities/idd/IddEnums.hpp"
38 #include <utilities/idd/IddEnums.hxx>
39 #include <utilities/idd/IddFactory.hxx>
40
41 using namespace openstudio::model;
42
43 using namespace std;
44
45 namespace openstudio {
46
47 namespace energyplus {
48
49 3 boost::optional<IdfObject> ForwardTranslator::translateGeneratorFuelCellAirSupply(GeneratorFuelCellAirSupply& modelObject) {
50 3 boost::optional<std::string> s;
51 3 boost::optional<double> d;
52 3 boost::optional<int> i;
53 3 boost::optional<Node> node;
54 3 boost::optional<CurveCubic> curve;
55 3 boost::optional<CurveQuadratic> curvequad;
56
57
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject idf_aS = createAndRegisterIdfObject(openstudio::IddObjectType::Generator_FuelCell_AirSupply, modelObject);
58 //Name
59
1/1
✓ Branch 1 taken 3 times.
3 s = modelObject.name();
60
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
61
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setName(*s);
62 }
63
64 //AirInletNodeName
65
1/1
✓ Branch 1 taken 3 times.
3 node = modelObject.airInletNode();
66
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (node) {
67 ✗ idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirInletNodeName, node.get().nameString());
68 } else {
69
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 auto name = modelObject.nameString() + " OA Node";
70
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
71
1/1
✓ Branch 1 taken 3 times.
3 oaNodeListIdf.setString(0, name);
72
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(oaNodeListIdf);
73
74
1/1
✓ Branch 1 taken 3 times.
3 idf_aS.setString(openstudio::Generator_FuelCell_AirSupplyFields::AirInletNodeName, name);
75 3 }
76
77 //blowerPowerCurve
78
1/1
✓ Branch 1 taken 3 times.
3 curve = modelObject.blowerPowerCurve();
79
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (curve) {
80
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::BlowerPowerCurveName, curve.get().nameString());
81 }
82
83 //BlowerHeatLossFactor
84
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 d = modelObject.blowerHeatLossFactor();
85
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (d) {
86
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setDouble(Generator_FuelCell_AirSupplyFields::BlowerHeatLossFactor, d.get());
87 }
88
89 //AirSupplyRateCalculationMode
90
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.airSupplyRateCalculationMode();
91
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
92
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirSupplyRateCalculationMode, s.get());
93 }
94
95 //StoichiometricRatio
96
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.stoichiometricRatio();
97
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (d) {
98
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setDouble(Generator_FuelCell_AirSupplyFields::StoichiometricRatio, d.get());
99 }
100
101 //AirRateFunctionofElectricPowerCurveName
102
1/1
✓ Branch 1 taken 3 times.
3 curvequad = modelObject.airRateFunctionofElectricPowerCurve();
103
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (curvequad) {
104
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirRateFunctionofElectricPowerCurveName, curvequad.get().nameString());
105 }
106
107 //AirRateAirTemperatureCoefficient
108
1/1
✓ Branch 1 taken 3 times.
3 d = modelObject.airRateAirTemperatureCoefficient();
109
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (d) {
110
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setDouble(Generator_FuelCell_AirSupplyFields::AirRateAirTemperatureCoefficient, d.get());
111 }
112
113 //AirRateFunctionofElectricPowerCurveName
114
1/1
✓ Branch 1 taken 3 times.
3 curvequad = modelObject.airRateFunctionofElectricPowerCurve();
115
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (curvequad) {
116
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirRateFunctionofElectricPowerCurveName, curvequad.get().nameString());
117 }
118
119 //AirIntakeHeatRecoveryMode
120
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.airIntakeHeatRecoveryMode();
121
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
122
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirIntakeHeatRecoveryMode, s.get());
123 }
124
125 //AirSupplyConstituentMode
126
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.airSupplyConstituentMode();
127
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
128
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idf_aS.setString(Generator_FuelCell_AirSupplyFields::AirSupplyConstituentMode, s.get());
129 }
130
131 //UserDefinedConstituents
132
1/1
✓ Branch 1 taken 3 times.
3 std::vector<AirSupplyConstituent> constituents = modelObject.constituents();
133
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!constituents.empty()) {
134 // E+ expects the sum of the molar fractions to be 1
135 ✗ double sumFractions = modelObject.sumofConstituentsMolarFractions();
136 ✗ if ((sumFractions < 0.98) || (sumFractions > 1.02)) {
137 ✗ LOG(Warn, "For " << modelObject.briefDescription() << ", the sum of molar fractions of the constituent isn't equal to 1, but " << sumFractions
138 << ".");
139 }
140 ✗ for (const AirSupplyConstituent& constituent : constituents) {
141 ✗ auto eg = idf_aS.pushExtensibleGroup();
142 ✗ eg.setString(Generator_FuelCell_AirSupplyExtensibleFields::ConstituentName, constituent.constituentName());
143 ✗ eg.setDouble(Generator_FuelCell_AirSupplyExtensibleFields::MolarFraction, constituent.molarFraction());
144 ✗ }
145 }
146
147 //NumberofUserDefinedConstituents
148
1/1
✓ Branch 2 taken 3 times.
3 idf_aS.setInt(Generator_FuelCell_AirSupplyFields::NumberofUserDefinedConstituents, constituents.size());
149
150
1/1
✓ Branch 1 taken 3 times.
6 return idf_aS;
151 3 }
152
153 } // namespace energyplus
154
155 } // namespace openstudio
156