GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 92.2% 107 / 0 / 116
Functions: 100.0% 1 / 0 / 1
Branches: 76.2% 202 / 0 / 265

src/energyplus/ForwardTranslator/ForwardTranslateAirTerminalSingleDuctVAVReheat.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/AirTerminalSingleDuctVAVReheat.hpp"
9 #include "../../model/AirTerminalSingleDuctVAVReheat_Impl.hpp"
10 #include "../../model/HVACComponent.hpp"
11 #include "../../model/Schedule.hpp"
12 #include "../../model/Schedule_Impl.hpp"
13 #include "../../model/Node.hpp"
14 #include "../../model/Node_Impl.hpp"
15 #include "../../model/ThermalZone.hpp"
16 #include "../../model/ThermalZone_Impl.hpp"
17 #include "../../model/Space.hpp"
18 #include "../../model/Space_Impl.hpp"
19 #include "../../model/DesignSpecificationOutdoorAir.hpp"
20 #include "../../model/DesignSpecificationOutdoorAir_Impl.hpp"
21 #include <utilities/idd/AirTerminal_SingleDuct_VAV_Reheat_FieldEnums.hxx>
22 #include <utilities/idd/ZoneHVAC_AirDistributionUnit_FieldEnums.hxx>
23 #include <utilities/idd/Coil_Heating_Fuel_FieldEnums.hxx>
24 #include <utilities/idd/Coil_Heating_Electric_FieldEnums.hxx>
25 #include <utilities/idd/Coil_Heating_Water_FieldEnums.hxx>
26 #include "../../utilities/idd/IddEnums.hpp"
27 #include <utilities/idd/IddEnums.hxx>
28 #include <utilities/idd/IddFactory.hxx>
29
30 using namespace openstudio::model;
31
32 namespace openstudio {
33
34 namespace energyplus {
35
36 3 boost::optional<IdfObject> ForwardTranslator::translateAirTerminalSingleDuctVAVReheat(AirTerminalSingleDuctVAVReheat& modelObject) {
37 3 OptionalModelObject temp;
38 3 OptionalString optS;
39 3 boost::optional<std::string> s;
40
41
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string baseName = modelObject.name().get();
42
43
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject _airDistributionUnit(openstudio::IddObjectType::ZoneHVAC_AirDistributionUnit);
44
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 _airDistributionUnit.setName("ADU " + baseName); //ADU: Air Distribution Unit
45
46
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject idfObject(openstudio::IddObjectType::AirTerminal_SingleDuct_VAV_Reheat);
47
48
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setName(baseName);
49
50
1/1
✓ Branch 1 taken 3 times.
3 HVACComponent coil = modelObject.reheatCoil();
51
52
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(_airDistributionUnit);
53
54
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(idfObject);
55
56
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<IdfObject> _reheatCoil = translateAndMapModelObject(coil);
57
58
6/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
9 if (_reheatCoil && _reheatCoil->name()) {
59
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::string damperOutletNodeName = modelObject.name().get() + " Damper Outlet";
60
61 3 boost::optional<std::string> inletNodeName;
62 3 boost::optional<std::string> outletNodeName;
63
64
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject()) {
65
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> inletNode = inletModelObject->optionalCast<Node>()) {
66
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 inletNodeName = inletNode->name().get();
67 3 }
68 3 }
69
70
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<ModelObject> outletModelObject = modelObject.outletModelObject()) {
71
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> outletNode = outletModelObject->optionalCast<Node>()) {
72
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 outletNodeName = outletNode->name().get();
73 3 }
74 3 }
75
76 // Reheat Coil Name
77
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::ReheatCoilName, _reheatCoil->name().get());
78
79 // Reheat Coil Type
80
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::ReheatCoilObjectType, _reheatCoil->iddObject().name());
81
82
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::DamperAirOutletNodeName, damperOutletNodeName);
83
84
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
6 if (outletNodeName && inletNodeName) {
85
5/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 3 times.
3 if (_reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Fuel) {
86 ✗ _reheatCoil->setString(Coil_Heating_FuelFields::AirInletNodeName, damperOutletNodeName);
87 ✗ _reheatCoil->setString(Coil_Heating_FuelFields::AirOutletNodeName, outletNodeName.get());
88
5/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
3 } else if (_reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Electric) {
89
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 _reheatCoil->setString(Coil_Heating_ElectricFields::AirInletNodeName, damperOutletNodeName);
90
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 _reheatCoil->setString(Coil_Heating_ElectricFields::AirOutletNodeName, outletNodeName.get());
91 ✗ } else if (_reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Water) {
92 ✗ _reheatCoil->setString(Coil_Heating_WaterFields::AirInletNodeName, damperOutletNodeName);
93 ✗ _reheatCoil->setString(Coil_Heating_WaterFields::AirOutletNodeName, outletNodeName.get());
94 }
95
96
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::AirOutletNodeName, outletNodeName.get());
97
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::AirInletNodeName, inletNodeName.get());
98 }
99 3 } else {
100 ✗ LOG(Error, modelObject.briefDescription() << ": Could not translate heating coil");
101
102 ✗ return boost::none;
103 }
104
105 // AvailabilityScheduleName
106
1/1
✓ Branch 1 taken 3 times.
3 Schedule availabilitySchedule = modelObject.availabilitySchedule();
107
108
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule);
109
110
6/12
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 3 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
9 if (_availabilitySchedule && _availabilitySchedule->name()) {
111
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::AvailabilityScheduleName, _availabilitySchedule->name().get());
112 }
113
114 // MaximumAirFlowRate
115
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<double> value = modelObject.maximumAirFlowRate();
116
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (value) {
117
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumAirFlowRate, value.get());
118
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (modelObject.isMaximumAirFlowRateAutosized()) {
119
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumAirFlowRate, "Autosize");
120 }
121
122 // ZoneMinimumAirFlowInputMethod
123
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.zoneMinimumAirFlowInputMethod();
124
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
125
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::ZoneMinimumAirFlowInputMethod, s.get());
126 }
127
128 // ConstantMinimumAirFlowFraction: autosizable
129
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (modelObject.isConstantMinimumAirFlowFractionAutosized()) {
130 ✗ idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::ConstantMinimumAirFlowFraction, "Autosize");
131
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 } else if ((value = modelObject.constantMinimumAirFlowFraction())) {
132
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::ConstantMinimumAirFlowFraction, value.get());
133 }
134
135 // FixedMinimumAirFlowRate: autosizable
136
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
3 if (modelObject.isFixedMinimumAirFlowRateAutosized()) {
137 ✗ idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::FixedMinimumAirFlowRate, "Autosize");
138
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 } else if ((value = modelObject.fixedMinimumAirFlowRate())) {
139
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::FixedMinimumAirFlowRate, value.get());
140 }
141
142 // MinimumAirFlowFractionScheduleName
143
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<Schedule> minAirFlowFractionSchedule = modelObject.minimumAirFlowFractionSchedule();
144
145
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (minAirFlowFractionSchedule) {
146
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 boost::optional<IdfObject> _minAirFlowFractionSchedule = translateAndMapModelObject(minAirFlowFractionSchedule.get());
147
148
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (_minAirFlowFractionSchedule) {
149
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MinimumAirFlowFractionScheduleName, _minAirFlowFractionSchedule->nameString());
150 }
151 1 }
152
153 // MaximumHotWaterOrSteamFlowRate
154
1/1
✓ Branch 1 taken 3 times.
3 value = modelObject.maximumHotWaterOrSteamFlowRate();
155
156
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (value) {
157
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumHotWaterorSteamFlowRate, value.get());
158
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (modelObject.isMaximumHotWaterOrSteamFlowRateAutosized()) {
159
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumHotWaterorSteamFlowRate, "Autosize");
160 }
161
162 // MinimumHotWaterOrSteamFlowRate
163
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 value = modelObject.minimumHotWaterOrSteamFlowRate();
164
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MinimumHotWaterorSteamFlowRate, value.get());
165
166 // ConvergenceTolerance
167
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 value = modelObject.convergenceTolerance();
168
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::ConvergenceTolerance, value.get());
169
170 // DamperHeatingAction
171
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 s = modelObject.damperHeatingAction();
172
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::DamperHeatingAction, s.get());
173
174 // MaximumFlowPerZoneFloorAreaDuringReheat
175
1/1
✓ Branch 1 taken 3 times.
3 value = modelObject.maximumFlowPerZoneFloorAreaDuringReheat();
176
177
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (value) {
178
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumFlowperZoneFloorAreaDuringReheat, value.get());
179
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (modelObject.isMaximumFlowPerZoneFloorAreaDuringReheatAutosized()) {
180
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumFlowperZoneFloorAreaDuringReheat, "Autocalculate");
181 }
182
183 // MaximumFlowFractionDuringReheat
184
1/1
✓ Branch 1 taken 3 times.
3 value = modelObject.maximumFlowFractionDuringReheat();
185
186
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (value) {
187
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumFlowFractionDuringReheat, value.get());
188
2/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 } else if (modelObject.isMaximumFlowFractionDuringReheatAutosized()) {
189
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumFlowFractionDuringReheat, "Autocalculate");
190 }
191
192 // MaximumReheatAirTemperature
193
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 value = modelObject.maximumReheatAirTemperature();
194
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(AirTerminal_SingleDuct_VAV_ReheatFields::MaximumReheatAirTemperature, value.get());
195
196 // Populate fields for AirDistributionUnit
197
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<ModelObject> outletNode = modelObject.outletModelObject()) {
198
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirDistributionUnitOutletNodeName, outletNode->name().get());
199 3 }
200
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalObjectType, idfObject.iddObject().name());
201
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalName, idfObject.name().get());
202
203 // ControlForOutdoorAir
204 {
205
3/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
3 if (modelObject.controlForOutdoorAir()) {
206
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (auto airLoopHVAC = modelObject.airLoopHVAC()) {
207
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 auto zones = airLoopHVAC->demandComponents(modelObject, airLoopHVAC->demandOutletNode(), model::ThermalZone::iddObjectType());
208
1/2
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
1 if (!zones.empty()) {
209
1/1
✓ Branch 2 taken 1 time.
1 auto zone = zones.front();
210
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (auto dsoaOrList_ = getOrCreateThermalZoneDSOA(zone.cast<ThermalZone>())) {
211
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::DesignSpecificationOutdoorAirObjectName, dsoaOrList_->nameString());
212 1 }
213 1 }
214 2 }
215 }
216 }
217
218 // MinimumAirFlowTurndownScheduleName
219
3/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
6 if (boost::optional<Schedule> minAirFlowTurndownSchedule = modelObject.minimumAirFlowTurndownSchedule()) {
220
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<IdfObject> _minAirFlowTurndownSchedule = translateAndMapModelObject(minAirFlowTurndownSchedule.get())) {
221
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 idfObject.setString(AirTerminal_SingleDuct_VAV_ReheatFields::MinimumAirFlowTurndownScheduleName, _minAirFlowTurndownSchedule->nameString());
222 1 }
223 3 }
224
225
1/1
✓ Branch 1 taken 3 times.
3 return _airDistributionUnit;
226 3 }
227
228 } // namespace energyplus
229
230 } // namespace openstudio
231