GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 148
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 358

src/energyplus/ReverseTranslator/ReverseTranslateCoilCoolingDXSingleSpeed.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 "../ReverseTranslator.hpp"
7
8 #include "../../model/CoilCoolingDXSingleSpeed.hpp"
9 #include "../../model/CoilCoolingDXSingleSpeed_Impl.hpp"
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12 #include "../../model/Curve.hpp"
13 #include "../../model/Curve_Impl.hpp"
14
15 #include <utilities/idd/Coil_Cooling_DX_SingleSpeed_FieldEnums.hxx>
16
17 using namespace openstudio::model;
18
19 namespace openstudio {
20
21 namespace energyplus {
22
23 ✗ OptionalModelObject ReverseTranslator::translateCoilCoolingDXSingleSpeed(const WorkspaceObject& workspaceObject) {
24 ✗ OptionalModelObject result;
25 ✗ OptionalModelObject temp;
26 ✗ OptionalSchedule schedule;
27
28 //get the Schedule
29 ✗ OptionalWorkspaceObject owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::AvailabilityScheduleName);
30 ✗ if (!owo) {
31 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find Schedule.");
32 ✗ return result;
33 }
34 ✗ temp = translateAndMapWorkspaceObject(*owo);
35 ✗ if (temp) {
36 ✗ schedule = temp->optionalCast<Schedule>();
37 }
38
39 ✗ if (!schedule) {
40 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription()
41 << "Failed to convert iddObject (schedule) into ModelObject. Maybe it does not exist in model yet");
42 ✗ return result;
43 }
44
45 //collect the curves
46 ✗ owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofTemperatureCurveName);
47 ✗ if (!owo) {
48 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find TotalCoolingCapacityFunctionOfTemperatureCurve.");
49 ✗ return result;
50 }
51 ✗ if (owo->numSources() > 1) {
52 ✗ owo = owo->workspace().addObject(owo.get());
53 }
54
55 ✗ temp = translateAndMapWorkspaceObject(*owo);
56
57 ✗ if (!temp) {
58 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't convert workspace curve into a model curve. ");
59 ✗ return result;
60 }
61 ✗ boost::optional<Curve> tccfot = temp->optionalCast<Curve>();
62 ✗ if (!tccfot) {
63 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " curve is wrong type. ");
64 ✗ return result;
65 }
66
67 ✗ owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofTemperatureCurveName);
68 ✗ if (!owo) {
69 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find EnergyInputRatioFunctionofTemperatureCurveName.");
70 ✗ return result;
71 }
72 ✗ if (owo->numSources() > 1) {
73 ✗ owo = owo->workspace().addObject(owo.get());
74 }
75 ✗ temp = translateAndMapWorkspaceObject(*owo);
76 ✗ if (!temp) {
77 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't convert workspace curve into a model curve. ");
78 ✗ return result;
79 }
80 ✗ boost::optional<Curve> eirfot = temp->optionalCast<Curve>();
81 ✗ if (!eirfot) {
82 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " curve is wrong type. ");
83 ✗ return result;
84 }
85
86 ✗ owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::TotalCoolingCapacityFunctionofFlowFractionCurveName);
87 ✗ if (!owo) {
88 ✗ LOG(Error,
89 "Error importing object: " << workspaceObject.briefDescription() << " Can't find TotalCoolingCapacityFunctionofFlowFractionCurveName.");
90 ✗ return result;
91 }
92 ✗ if (owo->numSources() > 1) {
93 ✗ owo = owo->workspace().addObject(owo.get());
94 }
95 ✗ temp = translateAndMapWorkspaceObject(*owo);
96 ✗ if (!temp) {
97 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't convert workspace curve into a model curve. ");
98 ✗ return result;
99 }
100 ✗ boost::optional<Curve> tccfoff = temp->optionalCast<Curve>();
101 ✗ if (!tccfoff) {
102 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " curve is wrong type. ");
103 ✗ return result;
104 }
105
106 ✗ owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::EnergyInputRatioFunctionofFlowFractionCurveName);
107 ✗ if (!owo) {
108 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find EnergyInputRatioFunctionofFlowFractionCurveName.");
109 ✗ return result;
110 }
111 ✗ if (owo->numSources() > 1) {
112 ✗ owo = owo->workspace().addObject(owo.get());
113 }
114 ✗ temp = translateAndMapWorkspaceObject(*owo);
115 ✗ if (!temp) {
116 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't convert workspace curve into a model curve. ");
117 ✗ return result;
118 }
119 ✗ boost::optional<Curve> eirfoff = temp->optionalCast<Curve>();
120 ✗ if (!eirfoff) {
121 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " curve is wrong type. ");
122 ✗ return result;
123 }
124
125 ✗ owo = workspaceObject.getTarget(Coil_Cooling_DX_SingleSpeedFields::PartLoadFractionCorrelationCurveName);
126 ✗ if (!owo) {
127 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't find PartLoadFractionCorrelationCurveName.");
128 ✗ return result;
129 }
130 ✗ if (owo->numSources() > 1) {
131 ✗ owo = owo->workspace().addObject(owo.get());
132 }
133 ✗ temp = translateAndMapWorkspaceObject(*owo);
134 ✗ if (!temp) {
135 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " Can't convert workspace curve into a model curve. ");
136 ✗ return result;
137 }
138 ✗ boost::optional<Curve> plfcc = temp->optionalCast<Curve>();
139 ✗ if (!plfcc) {
140 ✗ LOG(Error, "Error importing object: " << workspaceObject.briefDescription() << " curve is wrong type. ");
141 ✗ return result;
142 }
143
144 try {
145 ✗ CoilCoolingDXSingleSpeed coil(m_model, *schedule, *tccfot, *tccfoff, *eirfot, *eirfoff, *plfcc);
146
147 ✗ OptionalString optS = workspaceObject.name();
148 ✗ if (optS) {
149 ✗ coil.setName(*optS);
150 }
151
152 ✗ OptionalDouble d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedTotalCoolingCapacity);
153 ✗ if (d) {
154 ✗ coil.setRatedTotalCoolingCapacity(*d);
155 }
156
157 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedSensibleHeatRatio);
158 ✗ if (d) {
159 ✗ coil.setRatedSensibleHeatRatio(*d);
160 }
161
162 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::GrossRatedCoolingCOP);
163 ✗ if (d) {
164 ✗ coil.setRatedCOP(*d);
165 }
166
167 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::RatedAirFlowRate);
168 ✗ if (d) {
169 ✗ coil.setRatedAirFlowRate(*d);
170 }
171
172 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::RatedEvaporatorFanPowerPerVolumeFlowRate2017);
173 ✗ if (d) {
174 ✗ coil.setRatedEvaporatorFanPowerPerVolumeFlowRate2017(*d);
175 }
176
177 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::RatedEvaporatorFanPowerPerVolumeFlowRate2023);
178 ✗ if (d) {
179 ✗ coil.setRatedEvaporatorFanPowerPerVolumeFlowRate2023(*d);
180 }
181
182 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::NominalTimeforCondensateRemovaltoBegin);
183 ✗ if (d) {
184 ✗ coil.setNominalTimeForCondensateRemovalToBegin(*d);
185 }
186
187 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::MinimumOutdoorDryBulbTemperatureforCompressorOperation);
188 ✗ if (d) {
189 ✗ coil.setMinimumOutdoorDryBulbTemperatureforCompressorOperation(*d);
190 }
191
192 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::RatioofInitialMoistureEvaporationRateandSteadyStateLatentCapacity);
193 ✗ if (d) {
194 ✗ coil.setRatioOfInitialMoistureEvaporationRateAndSteadyStateLatentCapacity(*d);
195 }
196
197 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumCyclingRate);
198 ✗ if (d) {
199 ✗ coil.setMaximumCyclingRate(*d);
200 }
201
202 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::LatentCapacityTimeConstant);
203 ✗ if (d) {
204 ✗ coil.setLatentCapacityTimeConstant(*d);
205 }
206
207 ✗ optS = workspaceObject.getString(Coil_Cooling_DX_SingleSpeedFields::CondenserAirInletNodeName);
208 ✗ if (optS) {
209 ✗ coil.setCondenserAirInletNodeName(*optS);
210 }
211
212 ✗ optS = workspaceObject.getString(Coil_Cooling_DX_SingleSpeedFields::CondenserType);
213 ✗ if (optS) {
214 ✗ coil.setCondenserType(*optS);
215 }
216
217 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserEffectiveness);
218 ✗ if (d) {
219 ✗ coil.setEvaporativeCondenserEffectiveness(*d);
220 }
221
222 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserAirFlowRate);
223 ✗ if (d) {
224 ✗ coil.setEvaporativeCondenserAirFlowRate(*d);
225 }
226
227 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::EvaporativeCondenserPumpRatedPowerConsumption);
228 ✗ if (d) {
229 ✗ coil.setEvaporativeCondenserPumpRatedPowerConsumption(*d);
230 }
231
232 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::CrankcaseHeaterCapacity);
233 ✗ if (d) {
234 ✗ coil.setCrankcaseHeaterCapacity(*d);
235 }
236
237 ✗ d = workspaceObject.getDouble(Coil_Cooling_DX_SingleSpeedFields::MaximumOutdoorDryBulbTemperatureforCrankcaseHeaterOperation);
238 ✗ if (d) {
239 ✗ coil.setMaximumOutdoorDryBulbTemperatureForCrankcaseHeaterOperation(*d);
240 }
241
242 ✗ result = coil;
243
244 ✗ } catch (std::exception& e) {
245 ✗ LOG(Error, "Could not reverse translate " << workspaceObject.briefDescription() << ", because " << e.what() << ".");
246 ✗ }
247 ✗ return result;
248 ✗ }
249
250 } // namespace energyplus
251
252 } // namespace openstudio
253