GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 96.7% 116 / 0 / 120
Functions: 100.0% 2 / 0 / 2
Branches: 90.0% 188 / 0 / 209

src/energyplus/ForwardTranslator/ForwardTranslateCoilCoolingDXSingleSpeed.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/Schedule.hpp"
9 #include "../../model/Schedule_Impl.hpp"
10 #include "../../model/CoilCoolingDXSingleSpeed.hpp"
11 #include "../../model/CoilCoolingDXSingleSpeed_Impl.hpp"
12 #include "../../model/Curve.hpp"
13 #include "../../model/Curve_Impl.hpp"
14 #include "../../utilities/core/Logger.hpp"
15 #include "../../utilities/core/Assert.hpp"
16 #include <utilities/idd/CoilSystem_Cooling_DX_FieldEnums.hxx>
17 #include <utilities/idd/Coil_Cooling_DX_SingleSpeed_FieldEnums.hxx>
18 #include "../../utilities/idd/IddEnums.hpp"
19 #include <utilities/idd/IddFactory.hxx>
20
21 using namespace openstudio::model;
22
23 using namespace std;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 87 boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXSingleSpeedWithoutUnitary(model::CoilCoolingDXSingleSpeed& modelObject) {
30 87 OptionalString s;
31
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 IdfObject idfObject(IddObjectType::Coil_Cooling_DX_SingleSpeed);
32
33
1/1
✓ Branch 1 taken 87 times.
87 s = modelObject.name();
34
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if (s) {
35
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setName(*s);
36 }
37
38 // hook up required objects
39 try {
40
1/1
✓ Branch 1 taken 87 times.
87 Schedule sched = modelObject.availabilitySchedule();
41
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(sched);
42
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AvailabilityScheduleName, sched.name().get());
43
44
1/1
✓ Branch 1 taken 87 times.
87 Curve cb = modelObject.totalCoolingCapacityFunctionOfTemperatureCurve();
45
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(cb);
46
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofTemperatureCurveName, cb.name().get());
47
48
1/1
✓ Branch 1 taken 87 times.
87 Curve cq = modelObject.totalCoolingCapacityFunctionOfFlowFractionCurve();
49
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(cq);
50
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofFlowFractionCurveName, cq.name().get());
51
52
1/1
✓ Branch 1 taken 87 times.
87 cb = modelObject.energyInputRatioFunctionOfTemperatureCurve();
53
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(cb);
54
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofTemperatureCurveName, cb.name().get());
55
56
1/1
✓ Branch 1 taken 87 times.
87 cq = modelObject.energyInputRatioFunctionOfFlowFractionCurve();
57
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(cq);
58
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofFlowFractionCurveName, cq.name().get());
59
60
1/1
✓ Branch 1 taken 87 times.
87 cq = modelObject.partLoadFractionCorrelationCurve();
61
1/1
✓ Branch 1 taken 87 times.
87 translateAndMapModelObject(cq);
62
3/3
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
✓ Branch 7 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::PartLoadFractionCorrelationCurveName, cq.name().get());
63
0/2
✗ Branch 6 not taken.
✗ Branch 7 not taken.
87 } catch (std::exception& e) {
64 ✗ LOG(Error, "Could not translate " << modelObject.briefDescription() << ", because " << e.what() << ".");
65 ✗ return boost::none;
66 ✗ }
67
68
1/1
✓ Branch 1 taken 87 times.
87 OptionalDouble d = modelObject.ratedTotalCoolingCapacity();
69
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (d) {
70
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedTotalCoolingCapacity, *d);
71 } else {
72
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
172 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::GrossRatedTotalCoolingCapacity, "Autosize");
73 }
74
75
1/1
✓ Branch 1 taken 87 times.
87 d = modelObject.ratedSensibleHeatRatio();
76
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (d) {
77
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedSensibleHeatRatio, *d);
78 } else {
79
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
172 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::GrossRatedSensibleHeatRatio, "Autosize");
80 }
81
82
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedCoolingCOP, modelObject.ratedCOP());
83
84
1/1
✓ Branch 1 taken 87 times.
87 d = modelObject.ratedAirFlowRate();
85
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (d) {
86
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatedAirFlowRate, *d);
87 } else {
88
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
172 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::RatedAirFlowRate, "Autosize");
89 }
90
91
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatedEvaporatorFanPowerPerVolumeFlowRate2017,
92 modelObject.ratedEvaporatorFanPowerPerVolumeFlowRate2017());
93
94
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatedEvaporatorFanPowerPerVolumeFlowRate2023,
95 modelObject.ratedEvaporatorFanPowerPerVolumeFlowRate2023());
96
97
1/1
✓ Branch 1 taken 87 times.
87 OptionalModelObject omo = modelObject.inletModelObject();
98
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 49 times.
87 if (omo) {
99
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 translateAndMapModelObject(*omo);
100
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 s = omo->name();
101
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (s) {
102
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AirInletNodeName, *s);
103 }
104 }
105
106
1/1
✓ Branch 1 taken 87 times.
87 omo = modelObject.outletModelObject();
107
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 49 times.
87 if (omo) {
108
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 translateAndMapModelObject(*omo);
109
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 s = omo->name();
110
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (s) {
111
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::AirOutletNodeName, *s);
112 }
113 }
114
115
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::NominalTimeforCondensateRemovaltoBegin,
116 modelObject.nominalTimeForCondensateRemovalToBegin());
117
118
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation,
119 modelObject.minimumOutdoorDryBulbTemperatureforCompressorOperation());
120
121
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::RatioofInitialMoistureEvaporationRateandSteadyStateLatentCapacity,
122 modelObject.ratioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity());
123
124
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumCyclingRate, modelObject.maximumCyclingRate());
125
126
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::LatentCapacityTimeConstant, modelObject.latentCapacityTimeConstant());
127
128
1/1
✓ Branch 1 taken 87 times.
87 s = modelObject.condenserAirInletNodeName();
129
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 if (s) {
130
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::CondenserAirInletNodeName, *s);
131 }
132
133
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::CondenserType, modelObject.condenserType());
134
135
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserEffectiveness, modelObject.evaporativeCondenserEffectiveness());
136
137
1/1
✓ Branch 1 taken 87 times.
87 d = modelObject.evaporativeCondenserAirFlowRate();
138
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (d) {
139
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserAirFlowRate, *d);
140 } else {
141
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
172 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserAirFlowRate, "Autosize");
142 }
143
144
1/1
✓ Branch 1 taken 87 times.
87 d = modelObject.evaporativeCondenserPumpRatedPowerConsumption();
145
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (d) {
146
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserPumpRatedPowerConsumption, *d);
147 } else {
148
2/2
✓ Branch 1 taken 86 times.
✓ Branch 4 taken 86 times.
172 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserPumpRatedPowerConsumption, "Autosize");
149 }
150
151
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::CrankcaseHeaterCapacity, modelObject.crankcaseHeaterCapacity());
152
153
3/3
✓ Branch 1 taken 87 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 86 times.
174 if (auto crankCurve_ = modelObject.crankcaseHeaterCapacityFunctionofTemperatureCurve()) {
154
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (auto curve_ = translateAndMapModelObject(*crankCurve_)) {
155
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::CrankcaseHeaterCapacityFunctionofTemperatureCurveName, curve_->nameString());
156 1 }
157 87 }
158
159
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation,
160 modelObject.maximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation());
161
162 //TODO
163 //getSupplyWaterStorageTankName
164 //getCondensateCollectionWaterStorageTankName
165
166
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterCapacity, modelObject.basinHeaterCapacity());
167
168
2/2
✓ Branch 1 taken 87 times.
✓ Branch 4 taken 87 times.
87 idfObject.setDouble(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterSetpointTemperature, modelObject.basinHeaterSetpointTemperature());
169
170
1/1
✓ Branch 1 taken 87 times.
87 OptionalSchedule os = modelObject.basinHeaterOperatingSchedule();
171
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 86 times.
87 if (os) {
172
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(*os);
173
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 idfObject.setString(Coil_Cooling_DX_SingleSpeedFields::BasinHeaterOperatingScheduleName, os->name().get());
174 }
175
176
1/1
✓ Branch 1 taken 87 times.
87 m_idfObjects.push_back(idfObject);
177
1/1
✓ Branch 1 taken 87 times.
87 return idfObject;
178 87 }
179
180 47 boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXSingleSpeed(CoilCoolingDXSingleSpeed& modelObject) {
181
2/2
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
47 IdfObject coilSystemCoolingDXIdf(IddObjectType::CoilSystem_Cooling_DX);
182
183
1/1
✓ Branch 1 taken 47 times.
47 m_idfObjects.push_back(coilSystemCoolingDXIdf);
184
185
1/1
✓ Branch 1 taken 47 times.
47 boost::optional<IdfObject> oIdfObject = translateCoilCoolingDXSingleSpeedWithoutUnitary(modelObject);
186
187
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
47 if (!oIdfObject) {
188 ✗ return boost::none;
189 }
190
191
2/2
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
47 IdfObject idfObject = oIdfObject.get();
192
193 47 OptionalString s;
194
195
1/1
✓ Branch 1 taken 47 times.
47 s = modelObject.name();
196
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if (s) {
197
3/3
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
47 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilObjectType, idfObject.iddObject().name());
198
199
2/2
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
47 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilName, *s);
200
201
3/3
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
47 coilSystemCoolingDXIdf.setName(*s + " CoilSystem");
202 }
203
204
1/1
✓ Branch 1 taken 47 times.
47 Schedule sched = modelObject.availabilitySchedule();
205
1/1
✓ Branch 1 taken 47 times.
47 translateAndMapModelObject(sched);
206
207
3/3
✓ Branch 1 taken 47 times.
✓ Branch 4 taken 47 times.
✓ Branch 7 taken 47 times.
47 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::AvailabilityScheduleName, sched.name().get());
208
209
1/1
✓ Branch 1 taken 47 times.
47 OptionalModelObject omo = modelObject.inletModelObject();
210
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9 times.
47 if (omo) {
211
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 translateAndMapModelObject(*omo);
212
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 s = omo->name();
213
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (s) {
214
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemInletNodeName, *s);
215 }
216 }
217
218
1/1
✓ Branch 1 taken 47 times.
47 omo = modelObject.outletModelObject();
219
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9 times.
47 if (omo) {
220
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 translateAndMapModelObject(*omo);
221
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 s = omo->name();
222
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (s) {
223
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemOutletNodeName, *s);
224
225
2/2
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 38 times.
38 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemSensorNodeName, *s);
226 }
227 }
228
229
1/1
✓ Branch 1 taken 47 times.
47 return coilSystemCoolingDXIdf;
230 47 }
231
232 } // namespace energyplus
233
234 } // namespace openstudio
235