GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 81.6% 71 / 0 / 87
Functions: 100.0% 1 / 0 / 1
Branches: 55.5% 121 / 0 / 218

src/energyplus/ForwardTranslator/ForwardTranslateCoilWaterHeatingDesuperheater.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 #include "../../model/Model.hpp"
8 #include "../../model/CoilWaterHeatingDesuperheater.hpp"
9
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Node.hpp"
12 #include "../../model/Node_Impl.hpp"
13 #include "../../model/CurveBiquadratic.hpp"
14
15 #include "../../utilities/core/Logger.hpp"
16 #include "../../utilities/core/Assert.hpp"
17 #include <utilities/idd/Coil_WaterHeating_Desuperheater_FieldEnums.hxx>
18 #include <utilities/idd/CoilSystem_Cooling_DX_FieldEnums.hxx>
19 #include "../../utilities/idd/IddEnums.hpp"
20 #include <utilities/idd/IddEnums.hxx>
21 #include <utilities/idd/IddFactory.hxx>
22
23 using namespace openstudio::model;
24
25 using namespace std;
26
27 namespace openstudio {
28
29 namespace energyplus {
30
31 11 boost::optional<IdfObject> ForwardTranslator::translateCoilWaterHeatingDesuperheater(CoilWaterHeatingDesuperheater& modelObject) {
32 11 boost::optional<std::string> s;
33 11 boost::optional<double> d;
34
35 // Name
36
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Coil_WaterHeating_Desuperheater, modelObject);
37
38 // AvailabilityScheduleName
39
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 boost::optional<Schedule> availabilitySchedule = modelObject.availabilitySchedule();
40
41
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (availabilitySchedule) {
42
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule.get());
43
44
6/12
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 11 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
33 if (_availabilitySchedule && _availabilitySchedule->name()) {
45
4/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
11 idfObject.setString(Coil_WaterHeating_DesuperheaterFields::AvailabilityScheduleName, _availabilitySchedule->name().get());
46 }
47 11 }
48
49 // SetpointTemperatureScheduleName
50
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 boost::optional<Schedule> setpointTemperatureSchedule = modelObject.setpointTemperatureSchedule();
51
52
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (setpointTemperatureSchedule) {
53
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 boost::optional<IdfObject> _setpointTemperatureSchedule = translateAndMapModelObject(setpointTemperatureSchedule.get());
54
55
6/12
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 11 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
33 if (_setpointTemperatureSchedule && _setpointTemperatureSchedule->name()) {
56
4/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
11 idfObject.setString(Coil_WaterHeating_DesuperheaterFields::SetpointTemperatureScheduleName, _setpointTemperatureSchedule->name().get());
57 }
58 11 }
59
60 // DeadBandTemperatureDifference
61
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.deadBandTemperatureDifference();
62
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
63
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::DeadBandTemperatureDifference, d.get());
64 }
65
66 // RatedHeatReclaimRecoveryEfficiency
67
1/1
✓ Branch 1 taken 11 times.
11 d = modelObject.ratedHeatReclaimRecoveryEfficiency();
68
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
69
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::RatedHeatReclaimRecoveryEfficiency, d.get());
70 }
71
72 // RatedInletWaterTemperature
73
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.ratedInletWaterTemperature();
74
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
75
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::RatedInletWaterTemperature, d.get());
76 }
77
78 // RatedOutdoorAirTemperature
79
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.ratedOutdoorAirTemperature();
80
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
81
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::RatedOutdoorAirTemperature, d.get());
82 }
83
84 // MaximumInletWaterTemperatureforHeatReclaim
85
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.maximumInletWaterTemperatureforHeatReclaim();
86
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
87
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::MaximumInletWaterTemperatureforHeatReclaim, d.get());
88 }
89
90 // HeatReclaimEfficiencyFunctionofTemperatureCurveName
91
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<CurveBiquadratic> heatReclaimCurve = modelObject.heatReclaimEfficiencyFunctionofTemperatureCurve();
92
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (heatReclaimCurve) {
94 ✗ boost::optional<IdfObject> _heatReclaimCurve = translateAndMapModelObject(heatReclaimCurve.get());
95
96 ✗ if (_heatReclaimCurve && _heatReclaimCurve->name()) {
97 ✗ idfObject.setString(Coil_WaterHeating_DesuperheaterFields::HeatReclaimEfficiencyFunctionofTemperatureCurveName,
98 ✗ _heatReclaimCurve->name().get());
99 }
100 ✗ }
101
102 // WaterInletNodeName
103
2/3
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
22 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
104 ✗ if (boost::optional<Node> node = mo->optionalCast<Node>()) {
105 ✗ idfObject.setString(Coil_WaterHeating_DesuperheaterFields::WaterInletNodeName, node->name().get());
106 ✗ }
107 11 }
108
109 // WaterOutletNodeName
110
2/3
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
22 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
111 ✗ if (boost::optional<Node> node = mo->optionalCast<Node>()) {
112 ✗ idfObject.setString(Coil_WaterHeating_DesuperheaterFields::WaterOutletNodeName, node->name().get());
113 ✗ }
114 11 }
115
116 // TankObjectType
117 // TankName
118
2/3
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
22 if (boost::optional<ModelObject> heatRejectionTarget = modelObject.heatRejectionTarget()) {
119 ✗ boost::optional<IdfObject> _heatRejectionTarget = translateAndMapModelObject(heatRejectionTarget.get());
120
121 ✗ if (_heatRejectionTarget && _heatRejectionTarget->name()) {
122 ✗ idfObject.setString(Coil_WaterHeating_DesuperheaterFields::TankObjectType, _heatRejectionTarget->iddObject().name());
123 ✗ idfObject.setString(Coil_WaterHeating_DesuperheaterFields::TankName, _heatRejectionTarget->name().get());
124 }
125 11 }
126
127 // HeatingSourceObjectType
128 // HeatingSourceName
129
2/3
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
22 if (boost::optional<ModelObject> heatingSource = modelObject.heatingSource()) {
130
131
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 boost::optional<IdfObject> _heatingSource = translateAndMapModelObject(*heatingSource);
132
133
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (_heatingSource) {
134
135 // Note JM 2019-03-14:
136 // If the coil in question is a DX coil (CoilCoolingDXSingleSpeed, CoilCoolingDXTwoSpeed, CoilCoolingDXTwoStageWithHumidityControlMode,
137 // CoilCoolingDXVariableSpeed, CoilCoolingDXMultiSpeed, CoilCoolingDX)
138 // and this DX coil isn't already wrapped in a Unitary, then the FT will wrap it into a CoilSystem:Cooling:DX object and return that, but we
139 // need the DX coil here and not the wrapper.
140 //
141 // Note: Other accepted types are objects and don't suffer the same problem
142 // (Refrigeration:Condenser:AirCooled, Refrigeration:Condenser:EvaporativeCooled, Refrigeration:Condenser:WaterCooled,
143 // Coil:Cooling:WaterToAirHeatPump:EquationFit, Refrigeration:CompressorRack)
144
145 11 std::string objectType;
146 11 std::string objectName;
147
148
6/6
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 14 taken 5 times.
✓ Branch 15 taken 6 times.
11 if (_heatingSource->iddObject().type() == IddObjectType::CoilSystem_Cooling_DX) {
149 // We must retrieve the coil itself, not the wrapper
150
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
5 objectType = _heatingSource->getString(CoilSystem_Cooling_DXFields::CoolingCoilObjectType).get();
151
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
5 objectName = _heatingSource->getString(CoilSystem_Cooling_DXFields::CoolingCoilName).get();
152 } else {
153
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 objectType = _heatingSource->iddObject().name();
154
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
6 objectName = _heatingSource->name().get();
155 }
156
157
3/6
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
11 if (objectType.empty() || objectName.empty()) {
158 // We log an error but let E+ fail eventually
159 ✗ LOG(Error, "Something went wrong in the translation of " << modelObject.briefDescription() << ", couldn't retrieve the coil");
160 // OS_ASSERT(false);
161 } else {
162
1/1
✓ Branch 1 taken 11 times.
11 idfObject.setString(Coil_WaterHeating_DesuperheaterFields::HeatingSourceObjectType, objectType);
163
1/1
✓ Branch 1 taken 11 times.
11 idfObject.setString(Coil_WaterHeating_DesuperheaterFields::HeatingSourceName, objectName);
164 }
165 11 }
166 22 }
167
168 // WaterFlowRate
169
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.waterFlowRate();
170
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
171
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::WaterFlowRate, d.get());
172 }
173
174 // WaterPumpPower
175
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.waterPumpPower();
176
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
177
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::WaterPumpPower, d.get());
178 }
179
180 // FractionofPumpHeattoWater
181
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.fractionofPumpHeattoWater();
182
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
183
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::FractionofPumpHeattoWater, d.get());
184 }
185
186 // OnCycleParasiticElectricLoad
187
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.onCycleParasiticElectricLoad();
188
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
189
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::OnCycleParasiticElectricLoad, d.get());
190 }
191
192 // OffCycleParasiticElectricLoad
193
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 d = modelObject.offCycleParasiticElectricLoad();
194
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (d) {
195
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 idfObject.setDouble(Coil_WaterHeating_DesuperheaterFields::OffCycleParasiticElectricLoad, d.get());
196 }
197
198
1/1
✓ Branch 1 taken 11 times.
22 return idfObject;
199 11 }
200
201 } // namespace energyplus
202
203 } // namespace openstudio
204