GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 91.8% 67 / 0 / 73
Functions: 100.0% 2 / 0 / 2
Branches: 78.0% 96 / 0 / 123

src/energyplus/ForwardTranslator/ForwardTranslateCoilCoolingDX.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/CoilCoolingDX.hpp"
10
11 #include "../../model/Node.hpp"
12 #include "../../model/Node_Impl.hpp"
13 #include "../../model/Schedule.hpp"
14 #include "../../model/Schedule_Impl.hpp"
15 #include "../../model/ThermalZone.hpp"
16 #include "../../model/ThermalZone_Impl.hpp"
17 #include "../../model/CoilCoolingDXCurveFitPerformance.hpp"
18 #include "../../model/CoilCoolingDXCurveFitPerformance_Impl.hpp"
19 #include <utilities/idd/CoilSystem_Cooling_DX_FieldEnums.hxx>
20 #include <utilities/idd/Coil_Cooling_DX_FieldEnums.hxx>
21 // #include "../../utilities/idd/IddEnums.hpp"
22 #include <utilities/idd/IddEnums.hxx>
23
24 using namespace openstudio::model;
25
26 namespace openstudio {
27
28 namespace energyplus {
29
30 16 boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXWithoutUnitary(model::CoilCoolingDX& modelObject) {
31 16 boost::optional<std::string> s;
32 16 boost::optional<double> value;
33
34 // PerformanceObjectName, is required, so start by that
35
1/1
✓ Branch 1 taken 16 times.
16 CoilCoolingDXCurveFitPerformance performance = modelObject.performanceObject();
36
2/3
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
32 if (boost::optional<IdfObject> _performance = translateAndMapModelObject(performance)) {
37
4/4
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
16 s = _performance->name().get();
38 } else {
39 ✗ LOG(Warn, modelObject.briefDescription() << " cannot be translated as its performance object cannot be translated: "
40 << performance.briefDescription() << ".");
41 ✗ return boost::none;
42 16 }
43
44
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Coil_Cooling_DX, modelObject);
45
46 // PerformanceObjectName
47
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 idfObject.setString(Coil_Cooling_DXFields::PerformanceObjectName, s.get());
48
49 // Evaporator Nodes are handled in the FT for AirLoopHVACUnitarySystem when inside a Unitary, but we set them here in case it's NOT inside a
50 // unitary (yet, we'll put it on a CoilSystem:Cooling:DX)
51 // EvaporatorInletNodeName
52 // EvaporatorOutletNodeName
53
1/1
✓ Branch 1 taken 16 times.
16 OptionalModelObject omo = modelObject.inletModelObject();
54
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 15 times.
16 if (omo) {
55
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(*omo);
56
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 s = omo->name();
57
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
58
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setString(Coil_Cooling_DXFields::EvaporatorInletNodeName, *s);
59 }
60 }
61
62
1/1
✓ Branch 1 taken 16 times.
16 omo = modelObject.outletModelObject();
63
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 15 times.
16 if (omo) {
64
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(*omo);
65
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 s = omo->name();
66
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
67
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 idfObject.setString(Coil_Cooling_DXFields::EvaporatorOutletNodeName, *s);
68 }
69 }
70
71 // AvailabilityScheduleName
72 {
73
1/1
✓ Branch 1 taken 16 times.
16 auto schedule = modelObject.availabilitySchedule();
74
2/3
✓ Branch 1 taken 16 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
32 if (boost::optional<IdfObject> _schedule = translateAndMapModelObject(schedule)) {
75
4/4
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
16 idfObject.setString(Coil_Cooling_DXFields::AvailabilityScheduleName, _schedule->name().get());
76 16 }
77 16 }
78
79 // CondenserZoneName: as of E+ 9.3.0, this appears unused.
80 // TODO: eventually handle the condenser inlet/outlet node connections if the Condenser Zone is used?
81
2/3
✓ Branch 1 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
32 if (boost::optional<ThermalZone> thermalZone = modelObject.condenserZone()) {
82 ✗ if (boost::optional<IdfObject> _thermalZone = translateAndMapModelObject(thermalZone.get())) {
83 ✗ idfObject.setString(Coil_Cooling_DXFields::CondenserZoneName, _thermalZone->name().get());
84 ✗ }
85 16 }
86
87 // CondenserInletNodeName
88
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 std::string condenserInletNodeName(modelObject.nameString() + " Condenser Inlet Node");
89 // if (auto _s = modelObject.condenserInletNodeName()) {
90 // condenserInletNodeName = _s.get();
91 // } else {
92 // Create an OutdoorAir:NodeList for the condenser inlet conditions to be set directly from weather file
93
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
94
1/1
✓ Branch 1 taken 16 times.
16 oaNodeListIdf.setString(0, condenserInletNodeName);
95
1/1
✓ Branch 1 taken 16 times.
16 m_idfObjects.push_back(oaNodeListIdf);
96 // }
97
1/1
✓ Branch 1 taken 16 times.
16 idfObject.setString(Coil_Cooling_DXFields::CondenserInletNodeName, condenserInletNodeName);
98
99 // CondenserOutletNodeName
100
2/2
✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
16 std::string condenserOutletNodeName(modelObject.nameString() + " Condenser Outlet Node");
101 //if (auto _s = modelObject.condenserOutletNodeName()) {
102 //condenserOutletNodeName = _s.get();
103 //}
104
1/1
✓ Branch 1 taken 16 times.
16 idfObject.setString(Coil_Cooling_DXFields::CondenserOutletNodeName, condenserOutletNodeName);
105
106 // CondensateCollectionWaterStorageTankName
107
108 // EvaporativeCondenserSupplyWaterStorageTankName
109
110
1/1
✓ Branch 1 taken 16 times.
16 return boost::optional<IdfObject>(idfObject);
111 16 } // End of translate function
112
113 2 boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDX(CoilCoolingDX& modelObject) {
114
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject coilSystemCoolingDXIdf(IddObjectType::CoilSystem_Cooling_DX);
115
116
1/1
✓ Branch 1 taken 2 times.
2 m_idfObjects.push_back(coilSystemCoolingDXIdf);
117
118
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<IdfObject> oIdfObject = translateCoilCoolingDXWithoutUnitary(modelObject);
119
120
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (!oIdfObject) {
121 ✗ return boost::none;
122 }
123
124
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 IdfObject idfObject = oIdfObject.get();
125
126 2 OptionalString s;
127
128
1/1
✓ Branch 1 taken 2 times.
2 s = modelObject.name();
129
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
130
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilObjectType, idfObject.iddObject().name());
131
132
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilName, *s);
133
134
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 coilSystemCoolingDXIdf.setName(*s + " CoilSystem");
135 }
136
137
1/1
✓ Branch 1 taken 2 times.
2 Schedule sched = modelObject.availabilitySchedule();
138
1/1
✓ Branch 1 taken 2 times.
2 translateAndMapModelObject(sched);
139
140
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::AvailabilityScheduleName, sched.name().get());
141
142
1/1
✓ Branch 1 taken 2 times.
2 OptionalModelObject omo = modelObject.inletModelObject();
143
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (omo) {
144
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(*omo);
145
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 s = omo->name();
146
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
147
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemInletNodeName, *s);
148 }
149 }
150
151
1/1
✓ Branch 1 taken 2 times.
2 omo = modelObject.outletModelObject();
152
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (omo) {
153
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(*omo);
154
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 s = omo->name();
155
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (s) {
156
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemOutletNodeName, *s);
157
158
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemSensorNodeName, *s);
159 }
160 }
161
162
1/1
✓ Branch 1 taken 2 times.
2 return coilSystemCoolingDXIdf;
163 2 }
164
165 } // end namespace energyplus
166 } // end namespace openstudio
167