GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 82.9% 63 / 0 / 76
Functions: 100.0% 1 / 0 / 1
Branches: 62.1% 110 / 0 / 177

src/energyplus/ForwardTranslator/ForwardTranslateHeatExchangerFluidToFluid.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/HeatExchangerFluidToFluid.hpp"
9 #include "../../model/HeatExchangerFluidToFluid_Impl.hpp"
10 #include "../../model/Node.hpp"
11 #include "../../model/Node_Impl.hpp"
12 #include "../../model/SetpointManager.hpp"
13 #include "../../model/SetpointManager_Impl.hpp"
14 #include "../../model/Schedule.hpp"
15 #include "../../utilities/idf/Workspace.hpp"
16 #include "../../utilities/core/Compare.hpp"
17 #include "../../utilities/core/Logger.hpp"
18 #include <utilities/idd/HeatExchanger_FluidToFluid_FieldEnums.hxx>
19 #include <utilities/idd/IddEnums.hxx>
20
21 using namespace openstudio::model;
22
23 namespace openstudio {
24
25 namespace energyplus {
26
27 3 boost::optional<IdfObject> ForwardTranslator::translateHeatExchangerFluidToFluid(HeatExchangerFluidToFluid& modelObject) {
28 3 OptionalString s;
29 3 OptionalDouble d;
30 3 OptionalModelObject mo;
31 3 boost::optional<IdfObject> idfo;
32
33
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 IdfObject idfObject(IddObjectType::HeatExchanger_FluidToFluid);
34
35
1/1
✓ Branch 1 taken 3 times.
3 m_idfObjects.push_back(idfObject);
36
37 // Name
38
1/1
✓ Branch 1 taken 3 times.
3 s = modelObject.name();
39
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (s) {
40
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setName(*s);
41 }
42
43 // AvailabilityScheduleName
44
2/3
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
6 if (boost::optional<Schedule> sched = modelObject.availabilitySchedule()) {
45 ✗ if ((idfo = translateAndMapModelObject(sched.get()))) {
46 ✗ idfObject.setString(HeatExchanger_FluidToFluidFields::AvailabilityScheduleName, idfo->name().get());
47 }
48 3 }
49
50 // LoopDemandSideInletNode
51
1/1
✓ Branch 1 taken 3 times.
3 mo = modelObject.demandInletModelObject();
52
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (mo) {
53
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(HeatExchanger_FluidToFluidFields::LoopDemandSideInletNodeName, mo->name().get());
54 }
55
56 // LoopDemandSideOutletNode
57
1/1
✓ Branch 1 taken 3 times.
3 mo = modelObject.demandOutletModelObject();
58
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (mo) {
59
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(HeatExchanger_FluidToFluidFields::LoopDemandSideOutletNodeName, mo->name().get());
60 }
61
62 // LoopDemandSideDesignFlowRate
63
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (modelObject.isLoopDemandSideDesignFlowRateAutosized()) {
64
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 idfObject.setString(HeatExchanger_FluidToFluidFields::LoopDemandSideDesignFlowRate, "Autosize");
65 } else {
66 ✗ if ((d = modelObject.loopDemandSideDesignFlowRate())) {
67 ✗ idfObject.setDouble(HeatExchanger_FluidToFluidFields::LoopDemandSideDesignFlowRate, d.get());
68 }
69 }
70
71 // LoopSupplySideInletNode
72
1/1
✓ Branch 1 taken 3 times.
3 mo = modelObject.supplyInletModelObject();
73
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (mo) {
74
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(HeatExchanger_FluidToFluidFields::LoopSupplySideInletNodeName, mo->name().get());
75 }
76
77 // LoopSupplySideOutletNode
78
1/1
✓ Branch 1 taken 3 times.
3 mo = modelObject.supplyOutletModelObject();
79
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (mo) {
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(HeatExchanger_FluidToFluidFields::LoopSupplySideOutletNodeName, mo->name().get());
81 }
82
83 // LoopSupplySideDesignFlowRate
84
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (modelObject.isLoopSupplySideDesignFlowRateAutosized()) {
85
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 idfObject.setString(HeatExchanger_FluidToFluidFields::LoopSupplySideDesignFlowRate, "Autosize");
86 } else {
87 ✗ if ((d = modelObject.loopSupplySideDesignFlowRate())) {
88 ✗ idfObject.setDouble(HeatExchanger_FluidToFluidFields::LoopSupplySideDesignFlowRate, d.get());
89 }
90 }
91
92 // HeatExchangeModelType
93
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
6 if ((s = modelObject.heatExchangeModelType())) {
94
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(HeatExchanger_FluidToFluidFields::HeatExchangeModelType, s.get());
95 }
96
97 // HeatExchangerUFactorTimesAreaValue
98
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
3 if (modelObject.isHeatExchangerUFactorTimesAreaValueAutosized()) {
99
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 idfObject.setString(HeatExchanger_FluidToFluidFields::HeatExchangerUFactorTimesAreaValue, "Autosize");
100 } else {
101 ✗ if ((d = modelObject.heatExchangerUFactorTimesAreaValue())) {
102 ✗ idfObject.setDouble(HeatExchanger_FluidToFluidFields::HeatExchangerUFactorTimesAreaValue, d.get());
103 }
104 }
105
106 // ControlType
107
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
6 if ((s = modelObject.controlType())) {
108
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(HeatExchanger_FluidToFluidFields::ControlType, s.get());
109 }
110
111 // HeatExchangerSetpointNodeName
112
2/3
✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
6 if ((mo = modelObject.supplyOutletModelObject())) {
113
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 auto node = mo->optionalCast<Node>();
114
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(node);
115
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
3 if (!node->setpointManagers().empty()) {
116 ✗ idfObject.setString(HeatExchanger_FluidToFluidFields::HeatExchangerSetpointNodeName, mo->name().get());
117 } else {
118
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 auto plant = node->plantLoop();
119
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 4 not taken.
3 OS_ASSERT(plant);
120
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 auto supplyOutletModelObject = plant->supplyOutletNode();
121
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 idfObject.setString(HeatExchanger_FluidToFluidFields::HeatExchangerSetpointNodeName, supplyOutletModelObject.name().get());
122 3 }
123 3 }
124
125 // MinimumTemperatureDifferencetoActivateHeatExchanger
126
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
6 if ((d = modelObject.minimumTemperatureDifferencetoActivateHeatExchanger())) {
127
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatExchanger_FluidToFluidFields::MinimumTemperatureDifferencetoActivateHeatExchanger, d.get());
128 }
129
130 // HeatTransferMeteringEndUseType
131
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
6 if ((s = modelObject.heatTransferMeteringEndUseType())) {
132 // TODO: deal with the removed "HeatRecovery" option. I don't think it should have been removed at all
133 // https://github.com/NatLabRockies/EnergyPlus/pull/11344#issuecomment-4863193836
134
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 std::string heatTransferMeteringEndUseType = s.get();
135
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
6 if (openstudio::istringEqual("HeatRecovery", heatTransferMeteringEndUseType)) {
136 ✗ LOG(Warn, "HeatExchanger_FluidToFluid: HeatTransferMeteringEndUseType 'HeatRecovery' is no longer supported. Using 'LoopToLoop' instead.");
137 ✗ heatTransferMeteringEndUseType = "LoopToLoop";
138 }
139
1/1
✓ Branch 1 taken 3 times.
3 idfObject.setString(HeatExchanger_FluidToFluidFields::HeatTransferMeteringEndUseType, heatTransferMeteringEndUseType);
140 3 }
141
142 // ComponentOverrideLoopSupplySideInletNode
143
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
6 if ((mo = modelObject.componentOverrideLoopSupplySideInletNode())) {
144 ✗ idfObject.setString(HeatExchanger_FluidToFluidFields::ComponentOverrideLoopSupplySideInletNodeName, mo->name().get());
145 }
146
147 // ComponentOverrideLoopDemandSideInletNode
148
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
6 if ((mo = modelObject.componentOverrideLoopDemandSideInletNode())) {
149 ✗ idfObject.setString(HeatExchanger_FluidToFluidFields::ComponentOverrideLoopDemandSideInletNodeName, mo->name().get());
150 }
151
152 // ComponentOverrideCoolingControlTemperatureMode
153
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
6 if ((s = modelObject.componentOverrideCoolingControlTemperatureMode())) {
154
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setString(HeatExchanger_FluidToFluidFields::ComponentOverrideCoolingControlTemperatureMode, s.get());
155 }
156
157 // SizingFactor
158
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
6 if ((d = modelObject.sizingFactor())) {
159
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatExchanger_FluidToFluidFields::SizingFactor, d.get());
160 }
161
162 // OperationMinimumTemperatureLimit
163
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if ((d = modelObject.operationMinimumTemperatureLimit())) {
164
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatExchanger_FluidToFluidFields::OperationMinimumTemperatureLimit, d.get());
165 }
166
167 // OperationMaximumTemperatureLimit
168
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if ((d = modelObject.operationMaximumTemperatureLimit())) {
169
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 idfObject.setDouble(HeatExchanger_FluidToFluidFields::OperationMaximumTemperatureLimit, d.get());
170 }
171
172
1/1
✓ Branch 1 taken 3 times.
6 return idfObject;
173 3 }
174
175 } // namespace energyplus
176
177 } // namespace openstudio
178