GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 96.6% 257 / 0 / 266
Functions: 100.0% 5 / 0 / 5
Branches: 82.7% 326 / 0 / 394

src/energyplus/ForwardTranslator/ForwardTranslateHeatPumpAirToWater.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
9 #include "../../model/HeatPumpAirToWater.hpp"
10 #include "../../model/HeatPumpAirToWaterCooling.hpp"
11 #include "../../model/HeatPumpAirToWaterCoolingSpeedData.hpp"
12 #include "../../model/HeatPumpAirToWaterHeating.hpp"
13 #include "../../model/HeatPumpAirToWaterHeatingSpeedData.hpp"
14
15 #include "../../model/Schedule.hpp"
16 #include "../../model/Curve.hpp"
17 #include "../../model/Node.hpp"
18 #include "../../model/Node_Impl.hpp"
19
20 #include <utilities/idd/HeatPump_AirToWater_FieldEnums.hxx>
21 #include <utilities/idd/IddEnums.hxx>
22
23 using namespace openstudio::model;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 3 void ForwardTranslator::translateHeatPumpAirToWaterCooling(model::HeatPumpAirToWaterCooling& modelObject, IdfObject& idfObject) {
30 // Number of Speeds for Cooling: Optional Integer
31
4/4
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 2 times.
6 const int numberofSpeedsforCooling = modelObject.plantLoop() ? modelObject.numberOfSpeeds() : 0;
32
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setInt(HeatPump_AirToWaterFields::NumberofSpeedsforCooling, numberofSpeedsforCooling);
33
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (numberofSpeedsforCooling == 0) {
34 1 return;
35 }
36
37 // Availability Schedule Name Cooling: Optional Object
38 {
39
1/1
✓ Branch 1 taken 2 times.
2 auto sch = modelObject.availabilitySchedule();
40
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(sch)) {
41
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::AvailabilityScheduleNameCooling, wo_->nameString());
42 2 }
43 2 }
44
45 // Rated Inlet Air Temperature in Cooling Mode: Optional Double
46
1/1
✓ Branch 1 taken 2 times.
2 const double ratedInletAirTemperature = modelObject.ratedInletAirTemperature();
47
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedInletAirTemperatureinCoolingMode, ratedInletAirTemperature);
48
49 // Rated Air Flow Rate
50
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (modelObject.isRatedAirFlowRateAutosized()) {
51 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedAirFlowRateinCoolingMode, "Autosize");
52 } else {
53 // Rated Air Flow Rate in Cooling Mode: boost::optional<double>
54
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<double> ratedAirFlowRate_ = modelObject.ratedAirFlowRate()) {
55
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedAirFlowRateinCoolingMode, ratedAirFlowRate_.get());
56 }
57 }
58
59 // Rated Leaving Water Temperature in Cooling Mode: Optional Double
60
1/1
✓ Branch 1 taken 2 times.
2 const double ratedLeavingWaterTemperature = modelObject.ratedLeavingWaterTemperature();
61
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedLeavingWaterTemperatureinCoolingMode, ratedLeavingWaterTemperature);
62
63
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (modelObject.isRatedWaterFlowRateAutosized()) {
64 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedWaterFlowRateinCoolingMode, "Autosize");
65 } else {
66 // Rated Water Flow Rate in Cooling Mode: boost::optional<double>
67
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<double> ratedWaterFlowRate_ = modelObject.ratedWaterFlowRate()) {
68
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedWaterFlowRateinCoolingMode, ratedWaterFlowRate_.get());
69 }
70 }
71
72 // Minimum Outdoor Air Temperature in Cooling Mode: Optional Double
73
1/1
✓ Branch 1 taken 2 times.
2 const double minimumOutdoorAirTemperature = modelObject.minimumOutdoorAirTemperature();
74
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::MinimumOutdoorAirTemperatureinCoolingMode, minimumOutdoorAirTemperature);
75
76 // Maximum Outdoor Air Temperature in Cooling Mode: Optional Double
77
1/1
✓ Branch 1 taken 2 times.
2 const double maximumOutdoorAirTemperature = modelObject.maximumOutdoorAirTemperature();
78
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::MaximumOutdoorAirTemperatureinCoolingMode, maximumOutdoorAirTemperature);
79
80 // Minimum Leaving Water Temperature Curve Name in Cooling Mode: Optional Object
81
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<Curve> minimumLeavingWaterTemperatureCurve_ = modelObject.minimumLeavingWaterTemperatureCurve()) {
82
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(minimumLeavingWaterTemperatureCurve_.get())) {
83
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::MinimumLeavingWaterTemperatureCurveNameinCoolingMode, wo_->nameString());
84 2 }
85 2 }
86
87 // Maximum Leaving Water Temperature Curve Name in Cooling Mode: Optional Object
88
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<Curve> maximumLeavingWaterTemperatureCurve_ = modelObject.maximumLeavingWaterTemperatureCurve()) {
89
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(maximumLeavingWaterTemperatureCurve_.get())) {
90
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::MaximumLeavingWaterTemperatureCurveNameinCoolingMode, wo_->nameString());
91 2 }
92 2 }
93
94 // Sizing Factor for Cooling: Optional Double
95
1/1
✓ Branch 1 taken 2 times.
2 const double sizingFactor = modelObject.sizingFactor();
96
1/1
✓ Branch 1 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::SizingFactorforCooling, sizingFactor);
97
98 // Chilled Water Inlet Node Name: Optional Node
99
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<ModelObject> mo_ = modelObject.inletModelObject()) {
100
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<Node> node_ = mo_->optionalCast<Node>()) {
101
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::ChilledWaterInletNodeName, node_->nameString());
102 2 }
103 2 }
104
105 // Chilled Water Outlet Node Name: Optional Node
106
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<ModelObject> mo_ = modelObject.outletModelObject()) {
107
3/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
4 if (boost::optional<Node> node_ = mo_->optionalCast<Node>()) {
108
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::ChilledWaterOutletNodeName, node_->nameString());
109 2 }
110 2 }
111
112
1/1
✓ Branch 1 taken 2 times.
2 auto speeds = modelObject.speeds();
113 2 unsigned startIndex = HeatPump_AirToWaterFields::RatedCoolingCapacityatSpeed1;
114 2 const unsigned number_fields =
115 2 static_cast<unsigned>(HeatPump_AirToWaterFields::CoolingEnergyInputRatioFunctionofPLRCurveNameatSpeed1) - startIndex + 1;
116
117 50 auto getFieldIndex = [&startIndex](HeatPump_AirToWaterFields::domain field) -> unsigned {
118 50 return startIndex + (static_cast<unsigned>(field) - static_cast<unsigned>(HeatPump_AirToWaterFields::RatedCoolingCapacityatSpeed1));
119 2 };
120
121
2/2
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 2 times.
12 for (const auto& speed : speeds) {
122
123 // Rated Cooling Capacity at Speed
124
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
10 if (speed.isRatedCoolingCapacityAutosized()) {
125
2/2
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
4 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::RatedCoolingCapacityatSpeed1), "Autosize");
126 } else {
127
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 8 taken 8 times.
8 idfObject.setDouble(getFieldIndex(HeatPump_AirToWaterFields::RatedCoolingCapacityatSpeed1), speed.ratedCoolingCapacity().get());
128 }
129
130 // Rated COP for Cooling at Speed
131
2/2
✓ Branch 1 taken 10 times.
✓ Branch 5 taken 10 times.
10 idfObject.setDouble(getFieldIndex(HeatPump_AirToWaterFields::RatedCOPforCoolingatSpeed1), speed.ratedCOPforCooling());
132
133 // Normalized Cooling Capacity Function of Temperature Curve Name at Speed
134 {
135
1/1
✓ Branch 1 taken 10 times.
10 auto curve = speed.normalizedCoolingCapacityFunctionofTemperatureCurve();
136
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
20 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
137
1/1
✓ Branch 2 taken 10 times.
10 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::NormalizedCoolingCapacityFunctionofTemperatureCurveNameatSpeed1),
138
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 wo_->nameString());
139 10 }
140 10 }
141
142 // Cooling Energy Input Ratio Function of Temperature Curve Name at Speed
143 {
144
1/1
✓ Branch 1 taken 10 times.
10 auto curve = speed.coolingEnergyInputRatioFunctionofTemperatureCurve();
145
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
20 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
146
1/1
✓ Branch 2 taken 10 times.
10 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::CoolingEnergyInputRatioFunctionofTemperatureCurveNameatSpeed1),
147
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 wo_->nameString());
148 10 }
149 10 }
150
151 // Cooling Energy Input Ratio Function of PLR Curve Name at Speed
152 {
153
1/1
✓ Branch 1 taken 10 times.
10 auto curve = speed.coolingEnergyInputRatioFunctionofPLRCurve();
154
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
20 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
155
3/3
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 8 taken 10 times.
10 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::CoolingEnergyInputRatioFunctionofPLRCurveNameatSpeed1), wo_->nameString());
156 10 }
157 10 }
158
159 10 startIndex += number_fields;
160 }
161
162 // Booster Mode On Speed: Optional HeatPump:AirToWater:CoolingSpeedData
163
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (auto boosterModeOnSpeed_ = modelObject.boosterModeOnSpeed()) {
164
165
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::BoosterModeOnCooling, "Yes");
166
167
1/1
✓ Branch 1 taken 2 times.
2 auto speed = std::move(*boosterModeOnSpeed_);
168
169 // Rated Cooling Capacity at Speed
170
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (speed.isRatedCoolingCapacityAutosized()) {
171 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedCoolingCapacityinBoosterMode, "Autosize");
172 } else {
173
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedCoolingCapacityinBoosterMode, speed.ratedCoolingCapacity().get());
174 }
175
176 // Rated COP for Cooling at Speed
177
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 idfObject.setDouble(HeatPump_AirToWaterFields::RatedCoolingCOPinBoosterMode, speed.ratedCOPforCooling());
178
179 // Normalized Cooling Capacity Function of Temperature Curve Name at Speed
180 {
181
1/1
✓ Branch 1 taken 2 times.
2 auto curve = speed.normalizedCoolingCapacityFunctionofTemperatureCurve();
182
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
183
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::NormalizedCoolingCapacityFunctionofTemperatureCurveNameinBoosterMode, wo_->nameString());
184 2 }
185 2 }
186
187 // Cooling Energy Input Ratio Function of Temperature Curve Name at Speed
188 {
189
1/1
✓ Branch 1 taken 2 times.
2 auto curve = speed.coolingEnergyInputRatioFunctionofTemperatureCurve();
190
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
191
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::CoolingEnergyInputRatioFunctionofTemperatureCurveNameinBoosterMode, wo_->nameString());
192 2 }
193 2 }
194
195 // Cooling Energy Input Ratio Function of PLR Curve Name at Speed
196 {
197
1/1
✓ Branch 1 taken 2 times.
2 auto curve = speed.coolingEnergyInputRatioFunctionofPLRCurve();
198
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
4 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
199
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 idfObject.setString(HeatPump_AirToWaterFields::CoolingEnergyInputRatioFunctionofPLRCurveNameinBoosterMode, wo_->nameString());
200 2 }
201 2 }
202
203 2 } else {
204 // Reset the field to blank if no booster mode
205 ✗ idfObject.setString(HeatPump_AirToWaterFields::BoosterModeOnCooling, "No");
206 2 }
207 2 }
208
209 3 void ForwardTranslator::translateHeatPumpAirToWaterHeating(model::HeatPumpAirToWaterHeating& modelObject, IdfObject& idfObject) {
210
211
3/4
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 3 times.
6 const int numberofSpeedsforHeating = modelObject.plantLoop() ? modelObject.numberOfSpeeds() : 0;
212
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setInt(HeatPump_AirToWaterFields::NumberofSpeedsforHeating, numberofSpeedsforHeating);
213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (numberofSpeedsforHeating == 0) {
214 ✗ return;
215 }
216
217 // Availability Schedule Name Heating: Optional Object
218 {
219
1/1
✓ Branch 1 taken 3 times.
3 auto sch = modelObject.availabilitySchedule();
220
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(sch)) {
221
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::AvailabilityScheduleNameHeating, wo_->nameString());
222 3 }
223 3 }
224
225 // Rated Inlet Air Temperature in Heating Mode: Optional Double
226
1/1
✓ Branch 1 taken 3 times.
3 const double ratedInletAirTemperature = modelObject.ratedInletAirTemperature();
227
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedInletAirTemperatureinHeatingMode, ratedInletAirTemperature);
228
229 // Rated Air Flow Rate
230
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (modelObject.isRatedAirFlowRateAutosized()) {
231 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedAirFlowRateinHeatingMode, "Autosize");
232 } else {
233 // Rated Air Flow Rate in Heating Mode: boost::optional<double>
234
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<double> ratedAirFlowRate_ = modelObject.ratedAirFlowRate()) {
235
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedAirFlowRateinHeatingMode, ratedAirFlowRate_.get());
236 }
237 }
238
239 // Rated Leaving Water Temperature in Heating Mode: Optional Double
240
1/1
✓ Branch 1 taken 3 times.
3 const double ratedLeavingWaterTemperature = modelObject.ratedLeavingWaterTemperature();
241
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedLeavingWaterTemperatureinHeatingMode, ratedLeavingWaterTemperature);
242
243
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (modelObject.isRatedWaterFlowRateAutosized()) {
244 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedWaterFlowRateinHeatingMode, "Autosize");
245 } else {
246 // Rated Water Flow Rate in Heating Mode: boost::optional<double>
247
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<double> ratedWaterFlowRate_ = modelObject.ratedWaterFlowRate()) {
248
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedWaterFlowRateinHeatingMode, ratedWaterFlowRate_.get());
249 }
250 }
251
252 // Minimum Outdoor Air Temperature in Heating Mode: Optional Double
253
1/1
✓ Branch 1 taken 3 times.
3 const double minimumOutdoorAirTemperature = modelObject.minimumOutdoorAirTemperature();
254
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::MinimumOutdoorAirTemperatureinHeatingMode, minimumOutdoorAirTemperature);
255
256 // Maximum Outdoor Air Temperature in Heating Mode: Optional Double
257
1/1
✓ Branch 1 taken 3 times.
3 const double maximumOutdoorAirTemperature = modelObject.maximumOutdoorAirTemperature();
258
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::MaximumOutdoorAirTemperatureinHeatingMode, maximumOutdoorAirTemperature);
259
260 // Minimum Leaving Water Temperature Curve Name in Heating Mode: Optional Object
261
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<Curve> minimumLeavingWaterTemperatureCurve_ = modelObject.minimumLeavingWaterTemperatureCurve()) {
262
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(minimumLeavingWaterTemperatureCurve_.get())) {
263
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::MinimumLeavingWaterTemperatureCurveNameinHeatingMode, wo_->nameString());
264 3 }
265 3 }
266
267 // Maximum Leaving Water Temperature Curve Name in Heating Mode: Optional Object
268
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<Curve> maximumLeavingWaterTemperatureCurve_ = modelObject.maximumLeavingWaterTemperatureCurve()) {
269
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(maximumLeavingWaterTemperatureCurve_.get())) {
270
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::MaximumLeavingWaterTemperatureCurveNameinHeatingMode, wo_->nameString());
271 3 }
272 3 }
273
274 // Sizing Factor for Heating: Optional Double
275
1/1
✓ Branch 1 taken 3 times.
3 const double sizingFactor = modelObject.sizingFactor();
276
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::SizingFactorforHeating, sizingFactor);
277
278 // Hot Water Inlet Node Name: Optional Node
279
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<ModelObject> mo_ = modelObject.inletModelObject()) {
280
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<Node> node_ = mo_->optionalCast<Node>()) {
281
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::HotWaterInletNodeName, node_->nameString());
282 3 }
283 3 }
284
285 // Hot Water Outlet Node Name: Optional Node
286
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<ModelObject> mo_ = modelObject.outletModelObject()) {
287
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<Node> node_ = mo_->optionalCast<Node>()) {
288
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::HotWaterOutletNodeName, node_->nameString());
289 3 }
290 3 }
291
292
1/1
✓ Branch 1 taken 3 times.
3 auto speeds = modelObject.speeds();
293 3 unsigned startIndex = HeatPump_AirToWaterFields::RatedHeatingCapacityatSpeed1;
294 3 const unsigned number_fields =
295 3 static_cast<unsigned>(HeatPump_AirToWaterFields::HeatingEnergyInputRatioFunctionofPLRCurveNameatSpeed1) - startIndex + 1;
296
297 75 auto getFieldIndex = [&startIndex](HeatPump_AirToWaterFields::domain field) -> unsigned {
298 75 return startIndex + (static_cast<unsigned>(field) - static_cast<unsigned>(HeatPump_AirToWaterFields::RatedHeatingCapacityatSpeed1));
299 3 };
300
301
2/2
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 3 times.
18 for (const auto& speed : speeds) {
302
303 // Rated Heating Capacity at Speed
304
3/3
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 12 times.
15 if (speed.isRatedHeatingCapacityAutosized()) {
305
2/2
✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
6 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::RatedHeatingCapacityatSpeed1), "Autosize");
306 } else {
307
3/3
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 8 taken 12 times.
12 idfObject.setDouble(getFieldIndex(HeatPump_AirToWaterFields::RatedHeatingCapacityatSpeed1), speed.ratedHeatingCapacity().get());
308 }
309
310 // Rated COP for Heating at Speed
311
2/2
✓ Branch 1 taken 15 times.
✓ Branch 5 taken 15 times.
15 idfObject.setDouble(getFieldIndex(HeatPump_AirToWaterFields::RatedCOPforHeatingatSpeed1), speed.ratedCOPforHeating());
312
313 // Normalized Heating Capacity Function of Temperature Curve Name at Speed
314 {
315
1/1
✓ Branch 1 taken 15 times.
15 auto curve = speed.normalizedHeatingCapacityFunctionofTemperatureCurve();
316
2/3
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
30 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
317
1/1
✓ Branch 2 taken 15 times.
15 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::NormalizedHeatingCapacityFunctionofTemperatureCurveNameatSpeed1),
318
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
30 wo_->nameString());
319 15 }
320 15 }
321
322 // Heating Energy Input Ratio Function of Temperature Curve Name at Speed
323 {
324
1/1
✓ Branch 1 taken 15 times.
15 auto curve = speed.heatingEnergyInputRatioFunctionofTemperatureCurve();
325
2/3
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
30 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
326
1/1
✓ Branch 2 taken 15 times.
15 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::HeatingEnergyInputRatioFunctionofTemperatureCurveNameatSpeed1),
327
2/2
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
30 wo_->nameString());
328 15 }
329 15 }
330
331 // Heating Energy Input Ratio Function of PLR Curve Name at Speed
332 {
333
1/1
✓ Branch 1 taken 15 times.
15 auto curve = speed.heatingEnergyInputRatioFunctionofPLRCurve();
334
2/3
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
30 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
335
3/3
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 8 taken 15 times.
15 idfObject.setString(getFieldIndex(HeatPump_AirToWaterFields::HeatingEnergyInputRatioFunctionofPLRCurveNameatSpeed1), wo_->nameString());
336 15 }
337 15 }
338
339 15 startIndex += number_fields;
340 }
341
342 // Booster Mode On Speed: Optional HeatPump:AirToWater:HeatingSpeedData
343
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (auto boosterModeOnSpeed_ = modelObject.boosterModeOnSpeed()) {
344
345
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::BoosterModeOnHeating, "Yes");
346
347
1/1
✓ Branch 1 taken 3 times.
3 auto speed = std::move(*boosterModeOnSpeed_);
348
349 // Rated Heating Capacity at Speed
350
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (speed.isRatedHeatingCapacityAutosized()) {
351 ✗ idfObject.setString(HeatPump_AirToWaterFields::RatedHeatingCapacityinBoosterMode, "Autosize");
352 } else {
353
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedHeatingCapacityinBoosterMode, speed.ratedHeatingCapacity().get());
354 }
355
356 // Rated COP for Heating at Speed
357
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::RatedHeatingCOPinBoosterMode, speed.ratedCOPforHeating());
358
359 // Normalized Heating Capacity Function of Temperature Curve Name at Speed
360 {
361
1/1
✓ Branch 1 taken 3 times.
3 auto curve = speed.normalizedHeatingCapacityFunctionofTemperatureCurve();
362
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
363
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::NormalizedHeatingCapacityFunctionofTemperatureCurveNameinBoosterMode, wo_->nameString());
364 3 }
365 3 }
366
367 // Heating Energy Input Ratio Function of Temperature Curve Name at Speed
368 {
369
1/1
✓ Branch 1 taken 3 times.
3 auto curve = speed.heatingEnergyInputRatioFunctionofTemperatureCurve();
370
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
371
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::HeatingEnergyInputRatioFunctionofTemperatureCurveNameinBoosterMode, wo_->nameString());
372 3 }
373 3 }
374
375 // Heating Energy Input Ratio Function of PLR Curve Name at Speed
376 {
377
1/1
✓ Branch 1 taken 3 times.
3 auto curve = speed.heatingEnergyInputRatioFunctionofPLRCurve();
378
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(curve)) {
379
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::HeatingEnergyInputRatioFunctionofPLRCurveNameinBoosterMode, wo_->nameString());
380 3 }
381 3 }
382
383 3 } else {
384 // Reset the field to blank if no booster mode
385 ✗ idfObject.setString(HeatPump_AirToWaterFields::BoosterModeOnHeating, "No");
386 3 }
387 3 }
388
389 3 boost::optional<IdfObject> ForwardTranslator::translateHeatPumpAirToWater(model::HeatPumpAirToWater& modelObject) {
390
391 // Instantiate an IdfObject of the class to store the values
392
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::HeatPump_AirToWater, modelObject);
393
394 // Operating Mode Control Method: Optional String
395
1/1
✓ Branch 1 taken 3 times.
3 const std::string operatingModeControlMethod = modelObject.operatingModeControlMethod();
396
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::OperatingModeControlMethod, operatingModeControlMethod);
397
398 // Operating Mode Control Option for Multiple Unit: Optional String
399
1/1
✓ Branch 1 taken 3 times.
3 const std::string operatingModeControlOptionforMultipleUnit = modelObject.operatingModeControlOptionforMultipleUnit();
400
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::OperatingModeControlOptionforMultipleUnit, operatingModeControlOptionforMultipleUnit);
401
402 // Operating Mode Control Schedule Name: Optional Object
403
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<Schedule> operatingModeControlSchedule_ = modelObject.operatingModeControlSchedule()) {
404
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(operatingModeControlSchedule_.get())) {
405
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::OperatingModeControlScheduleName, wo_->nameString());
406 3 }
407 3 }
408
409 // Minimum Part Load Ratio: Optional Double
410
1/1
✓ Branch 1 taken 3 times.
3 const double minimumPartLoadRatio = modelObject.minimumPartLoadRatio();
411
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::MinimumPartLoadRatio, minimumPartLoadRatio);
412
413 // Air Inlet Node Name: Required Node
414 {
415
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
416 {
417
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 const std::string airInletNodeName = modelObject.airInletNodeName().value_or(modelObject.nameString() + " Air Inlet Node");
418
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::AirInletNodeName, airInletNodeName);
419
1/1
✓ Branch 1 taken 3 times.
3 oaNodeListIdf.setString(0, airInletNodeName);
420 3 }
421
422 // Air Outlet Node Name: Required Node
423 {
424
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 const std::string airOutletNodeName = modelObject.airOutletNodeName().value_or(modelObject.nameString() + " Air Outlet Node");
425
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::AirOutletNodeName, airOutletNodeName);
426
1/1
✓ Branch 1 taken 3 times.
3 oaNodeListIdf.setString(1, airOutletNodeName);
427 3 }
428
1/1
✓ Branch 2 taken 3 times.
3 m_idfObjects.emplace_back(std::move(oaNodeListIdf));
429 3 }
430
431 // Maximum Outdoor Dry Bulb Temperature For Defrost Operation: Optional Double
432
1/1
✓ Branch 1 taken 3 times.
3 const double maximumOutdoorDryBulbTemperatureForDefrostOperation = modelObject.maximumOutdoorDryBulbTemperatureForDefrostOperation();
433
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::MaximumOutdoorDryBulbTemperatureForDefrostOperation,
434 maximumOutdoorDryBulbTemperatureForDefrostOperation);
435
436 // Heat Pump Defrost Control: Optional String
437
1/1
✓ Branch 1 taken 3 times.
3 const std::string heatPumpDefrostControl = modelObject.heatPumpDefrostControl();
438
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::HeatPumpDefrostControl, heatPumpDefrostControl);
439
440 // Heat Pump Defrost Time Period Fraction: Optional Double
441
1/1
✓ Branch 1 taken 3 times.
3 const double heatPumpDefrostTimePeriodFraction = modelObject.heatPumpDefrostTimePeriodFraction();
442
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::HeatPumpDefrostTimePeriodFraction, heatPumpDefrostTimePeriodFraction);
443
444
1/1
✓ Branch 1 taken 3 times.
3 const double resistiveDefrostHeaterCapacity = modelObject.resistiveDefrostHeaterCapacity();
445
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::ResistiveDefrostHeaterCapacity, resistiveDefrostHeaterCapacity);
446
447 // Defrost Energy Input Ratio Function of Temperature Curve Name: Optional Object
448
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<Curve> defrostEnergyInputRatioFunctionofTemperatureCurve_ = modelObject.defrostEnergyInputRatioFunctionofTemperatureCurve()) {
449
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(defrostEnergyInputRatioFunctionofTemperatureCurve_.get())) {
450
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::DefrostEnergyInputRatioFunctionofTemperatureCurveName, wo_->nameString());
451 3 }
452 3 }
453
454 // Heat Pump Multiplier: Optional Integer
455
1/1
✓ Branch 1 taken 3 times.
3 const int heatPumpMultiplier = modelObject.heatPumpMultiplier();
456
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setInt(HeatPump_AirToWaterFields::HeatPumpMultiplier, heatPumpMultiplier);
457
458 // Control Type: Optional String
459
1/1
✓ Branch 1 taken 3 times.
3 const std::string controlType = modelObject.controlType();
460
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::ControlType, controlType);
461
462 // Crankcase Heater Capacity: Optional Double
463
1/1
✓ Branch 1 taken 3 times.
3 const double crankcaseHeaterCapacity = modelObject.crankcaseHeaterCapacity();
464
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::CrankcaseHeaterCapacity, crankcaseHeaterCapacity);
465
466 // Crankcase Heater Capacity Function of Temperature Curve Name: Optional Object
467
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<Curve> crankcaseHeaterCapacityFunctionofTemperatureCurve_ = modelObject.crankcaseHeaterCapacityFunctionofTemperatureCurve()) {
468
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(crankcaseHeaterCapacityFunctionofTemperatureCurve_.get())) {
469
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatPump_AirToWaterFields::CrankcaseHeaterCapacityFunctionofTemperatureCurveName, wo_->nameString());
470 3 }
471 3 }
472
473 // Maximum Ambient Temperature for Crankcase Heater Operation: Optional Double
474
1/1
✓ Branch 1 taken 3 times.
3 const double maximumAmbientTemperatureforCrankcaseHeaterOperation = modelObject.maximumAmbientTemperatureforCrankcaseHeaterOperation();
475
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setDouble(HeatPump_AirToWaterFields::MaximumAmbientTemperatureforCrankcaseHeaterOperation,
476 maximumAmbientTemperatureforCrankcaseHeaterOperation);
477
478
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (auto awhp_cc_ = modelObject.coolingOperationMode()) {
479
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 translateHeatPumpAirToWaterCooling(*awhp_cc_, idfObject);
480 3 }
481
482
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (auto awhp_cc_ = modelObject.heatingOperationMode()) {
483
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 translateHeatPumpAirToWaterHeating(*awhp_cc_, idfObject);
484 3 }
485
486
1/1
✓ Branch 1 taken 3 times.
6 return idfObject;
487 3 } // End of translate function
488
489 } // end namespace energyplus
490 } // end namespace openstudio
491