GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 73.6% 92 / 0 / 125
Functions: 100.0% 1 / 0 / 1
Branches: 50.2% 108 / 0 / 215

src/energyplus/ForwardTranslator/ForwardTranslateGeneratorMicroTurbine.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
10 #include "../../model/GeneratorMicroTurbine.hpp"
11 #include "../../model/GeneratorMicroTurbine_Impl.hpp"
12 #include "../../model/GeneratorMicroTurbineHeatRecovery.hpp"
13 #include "../../model/GeneratorMicroTurbineHeatRecovery_Impl.hpp"
14
15 #include "../../model/StraightComponent.hpp"
16 #include "../../model/StraightComponent_Impl.hpp"
17 #include "../../model/Node.hpp" // Is this needed?
18 #include "../../model/Node_Impl.hpp"
19 #include "../../model/Curve.hpp"
20 #include "../../model/Curve_Impl.hpp"
21
22 #include <utilities/idd/Generator_MicroTurbine_FieldEnums.hxx>
23 #include "../../utilities/idd/IddEnums.hpp"
24 #include <utilities/idd/IddEnums.hxx>
25
26 using namespace openstudio::model;
27
28 using namespace std;
29
30 namespace openstudio {
31
32 namespace energyplus {
33
34 /** This method forward translates the OS:Generator:MicroTurbine as well the optional attached OS:Generator:MicroTurbine:HeatRecovery
35 to the EnergyPlus Generator:MicroTurbine object */
36 2 boost::optional<IdfObject> ForwardTranslator::translateGeneratorMicroTurbine(GeneratorMicroTurbine& modelObject) {
37
38
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Generator_MicroTurbine, modelObject);
39
40
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<GeneratorMicroTurbineHeatRecovery> generatorOptionalMicroTurbineHeatRecovery = modelObject.generatorMicroTurbineHeatRecovery();
41 // If there is a Heat Recovery Object, we set the appropriate fields of the E+ object from the HR object
42
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (generatorOptionalMicroTurbineHeatRecovery) {
43
44 // Get it
45
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 GeneratorMicroTurbineHeatRecovery generatorMCHPHX = *generatorOptionalMicroTurbineHeatRecovery;
46
47 // HeatRecoveryWaterInletNodeName
48 // Inlet Node Name
49
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto temp = generatorMCHPHX.inletModelObject()) {
50
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 auto s = temp->name();
51
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
52
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryWaterInletNodeName, *s);
53 }
54 4 }
55
56 //HeatRecoveryWaterOutletNodeName
57
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto temp = generatorMCHPHX.outletModelObject()) {
58
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 auto s = temp->name();
59
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
60
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryWaterOutletNodeName, *s);
61 }
62 4 }
63
64 //ReferenceThermalEfficiencyUsingLowerHeatValue
65 {
66
1/1
✓ Branch 1 taken 2 times.
2 auto value = generatorMCHPHX.referenceThermalEfficiencyUsingLowerHeatValue();
67
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceThermalEfficiencyUsingLowerHeatValue, value);
68 }
69
70 //ReferenceInletWaterTemperature (double)
71
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceInletWaterTemperature, generatorMCHPHX.referenceInletWaterTemperature());
72
73 //HeatRecoveryWaterFlowOperatingMode
74 {
75
1/1
✓ Branch 1 taken 2 times.
2 auto value = generatorMCHPHX.heatRecoveryWaterFlowOperatingMode();
76
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryWaterFlowOperatingMode, value);
77 2 }
78
79 //ReferenceHeatRecoveryWaterFlowRate (double)
80
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceHeatRecoveryWaterFlowRate, generatorMCHPHX.referenceHeatRecoveryWaterFlowRate());
81
82 //HeatRecoveryWaterFlowRateFunctionofTemperatureandPowerCurve
83
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = generatorMCHPHX.heatRecoveryWaterFlowRateFunctionofTemperatureandPowerCurve()) {
84 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
85 ✗ idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryWaterFlowRateFunctionofTemperatureandPowerCurveName, _curve->name().get());
86 ✗ }
87 2 }
88
89 //ThermalEfficiencyFunctionofTemperatureandElevationCurve
90
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = generatorMCHPHX.thermalEfficiencyFunctionofTemperatureandElevationCurve()) {
91 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
92 ✗ idfObject.setString(Generator_MicroTurbineFields::ThermalEfficiencyFunctionofTemperatureandElevationCurveName, _curve->name().get());
93 ✗ }
94 2 }
95
96 //HeatRecoveryRateFunctionofPartLoadRatioCurve
97
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = generatorMCHPHX.heatRecoveryRateFunctionofPartLoadRatioCurve()) {
98 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
99 ✗ idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryRateFunctionofPartLoadRatioCurveName, _curve->name().get());
100 ✗ }
101 2 }
102
103 //HeatRecoveryRateFunctionofInletWaterTemperatureCurve
104
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = generatorMCHPHX.heatRecoveryRateFunctionofInletWaterTemperatureCurve()) {
105 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
106 ✗ idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryRateFunctionofInletWaterTemperatureCurveName, _curve->name().get());
107 ✗ }
108 2 }
109
110 //HeatRecoveryRateFunctionofWaterFlowRateCurve
111
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = generatorMCHPHX.heatRecoveryRateFunctionofWaterFlowRateCurve()) {
112 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
113 ✗ idfObject.setString(Generator_MicroTurbineFields::HeatRecoveryRateFunctionofWaterFlowRateCurveName, _curve->name().get());
114 ✗ }
115 2 }
116
117 //MinimumHeatRecoveryWaterFlowRate
118 {
119
1/1
✓ Branch 1 taken 2 times.
2 auto value = generatorMCHPHX.minimumHeatRecoveryWaterFlowRate();
120
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::MinimumHeatRecoveryWaterFlowRate, value);
121 }
122
123 //MaximumHeatRecoveryWaterFlowRate
124 {
125
1/1
✓ Branch 1 taken 2 times.
2 auto value = generatorMCHPHX.maximumHeatRecoveryWaterFlowRate();
126
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::MaximumHeatRecoveryWaterFlowRate, value);
127 }
128
129 //MaximumHeatRecoveryWaterTemperature
130
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto value = generatorMCHPHX.maximumHeatRecoveryWaterTemperature()) {
131 ✗ idfObject.setDouble(Generator_MicroTurbineFields::MaximumHeatRecoveryWaterTemperature, value.get());
132 }
133 2 }
134
135 /// Doubles, non optional
136 //ReferenceElectricalPowerOutput
137
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceElectricalPowerOutput, modelObject.referenceElectricalPowerOutput());
138
139 //ReferenceElectricalEfficiencyUsingLowerHeatingValue
140
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceElectricalEfficiencyUsingLowerHeatingValue,
141 modelObject.referenceElectricalEfficiencyUsingLowerHeatingValue());
142
143 /// Doubles, optional
144 //MinimumFullLoadElectricalPowerOutput
145 {
146
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.minimumFullLoadElectricalPowerOutput();
147
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::MinimumFullLoadElectricalPowerOutput, value);
148 }
149
150 //MaximumFullLoadElectricalPowerOutput
151 {
152
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.maximumFullLoadElectricalPowerOutput();
153
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::MaximumFullLoadElectricalPowerOutput, value);
154 }
155
156 //ReferenceCombustionAirInletTemperature
157 {
158
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.referenceCombustionAirInletTemperature();
159
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceCombustionAirInletTemperature, value);
160 }
161
162 //ReferenceCombustionAirInletHumidityRatio
163 {
164
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.referenceCombustionAirInletHumidityRatio();
165
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceCombustionAirInletHumidityRatio, value);
166 }
167
168 //ReferenceElevation
169 {
170
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.referenceElevation();
171
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::ReferenceElevation, value);
172 }
173
174 //FuelHigherHeatingValue
175 {
176
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.fuelHigherHeatingValue();
177
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::FuelHigherHeatingValue, value);
178 }
179
180 //FuelLowerHeatingValue
181 {
182
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.fuelLowerHeatingValue();
183
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::FuelLowerHeatingValue, value);
184 }
185
186 //StandbyPower
187 {
188
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.standbyPower();
189
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::StandbyPower, value);
190 }
191
192 //AncillaryPower
193 {
194
1/1
✓ Branch 1 taken 2 times.
2 auto value = modelObject.ancillaryPower();
195
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(Generator_MicroTurbineFields::AncillaryPower, value);
196 }
197
198 //ReferenceExhaustAirMassFlowRate
199
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto value = modelObject.referenceExhaustAirMassFlowRate()) {
200 ✗ idfObject.setDouble(Generator_MicroTurbineFields::ReferenceExhaustAirMassFlowRate, value.get());
201 }
202
203 //NominalExhaustAirOutletTemperature
204
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto value = modelObject.nominalExhaustAirOutletTemperature()) {
205 ✗ idfObject.setDouble(Generator_MicroTurbineFields::NominalExhaustAirOutletTemperature, value.get());
206 }
207
208 /// Choice
209 //FuelType
210 {
211
1/1
✓ Branch 1 taken 2 times.
2 auto s = modelObject.fuelType();
212
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::FuelType, s);
213 2 }
214
215 /// Nodes
216
217 // Will leave blank to assume outside air conditions
218 //CombustionAirInletNodeName
219
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 idfObject.setString(Generator_MicroTurbineFields::CombustionAirInletNodeName, "");
220
221 //CombustionAirOutletNodeName
222
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::CombustionAirOutletNodeName, "");
223
224 /// Curves, Not Optional
225 //ElectricalPowerFunctionofTemperatureandElevationCurve
226 {
227
1/1
✓ Branch 1 taken 2 times.
2 auto curve = modelObject.electricalPowerFunctionofTemperatureandElevationCurve();
228
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto _curve = translateAndMapModelObject(curve)) {
229
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::ElectricalPowerFunctionofTemperatureandElevationCurveName, _curve->name().get());
230 2 }
231 2 }
232
233 //ElectricalEfficiencyFunctionofTemperatureCurve
234 {
235
1/1
✓ Branch 1 taken 2 times.
2 auto curve = modelObject.electricalEfficiencyFunctionofTemperatureCurve();
236
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto _curve = translateAndMapModelObject(curve)) {
237
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::ElectricalEfficiencyFunctionofTemperatureCurveName, _curve->name().get());
238 2 }
239 2 }
240
241 //ElectricalEfficiencyFunctionofPartLoadRatioCurve
242 {
243
1/1
✓ Branch 1 taken 2 times.
2 auto curve = modelObject.electricalEfficiencyFunctionofPartLoadRatioCurve();
244
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto _curve = translateAndMapModelObject(curve)) {
245
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(Generator_MicroTurbineFields::ElectricalEfficiencyFunctionofPartLoadRatioCurveName, _curve->name().get());
246 2 }
247 2 }
248 /// Curves, Optional
249
250 //AncillaryPowerFunctionofFuelInputCurve
251
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = modelObject.ancillaryPowerFunctionofFuelInputCurve()) {
252 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
253 ✗ idfObject.setString(Generator_MicroTurbineFields::AncillaryPowerFunctionofFuelInputCurveName, _curve->name().get());
254 ✗ }
255 2 }
256
257 //ExhaustAirFlowRateFunctionofTemperatureCurve
258
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = modelObject.exhaustAirFlowRateFunctionofTemperatureCurve()) {
259 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
260 ✗ idfObject.setString(Generator_MicroTurbineFields::ExhaustAirFlowRateFunctionofTemperatureCurveName, _curve->name().get());
261 ✗ }
262 2 }
263
264 //ExhaustAirFlowRateFunctionofPartLoadRatioCurve
265
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = modelObject.exhaustAirFlowRateFunctionofPartLoadRatioCurve()) {
266 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
267 ✗ idfObject.setString(Generator_MicroTurbineFields::ExhaustAirFlowRateFunctionofPartLoadRatioCurveName, _curve->name().get());
268 ✗ }
269 2 }
270
271 //ExhaustAirTemperatureFunctionofTemperatureCurve
272
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = modelObject.exhaustAirTemperatureFunctionofTemperatureCurve()) {
273 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
274 ✗ idfObject.setString(Generator_MicroTurbineFields::ExhaustAirTemperatureFunctionofTemperatureCurveName, _curve->name().get());
275 ✗ }
276 2 }
277
278 //ExhaustAirTemperatureFunctionofPartLoadRatioCurve
279
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
4 if (auto curve = modelObject.exhaustAirTemperatureFunctionofPartLoadRatioCurve()) {
280 ✗ if (auto _curve = translateAndMapModelObject(curve.get())) {
281 ✗ idfObject.setString(Generator_MicroTurbineFields::ExhaustAirTemperatureFunctionofPartLoadRatioCurveName, _curve->name().get());
282 ✗ }
283 2 }
284
285
1/1
✓ Branch 1 taken 2 times.
4 return idfObject;
286 2 }
287
288 } // namespace energyplus
289
290 } // namespace openstudio
291