GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.9% 45 / 0 / 53
Functions: 100.0% 1 / 0 / 1
Branches: 67.3% 76 / 0 / 113

src/energyplus/ForwardTranslator/ForwardTranslatePumpConstantSpeed.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/PumpConstantSpeed.hpp"
8 #include "../../model/PumpConstantSpeed_Impl.hpp"
9 #include "../../model/Model.hpp"
10 #include "../../model/Schedule.hpp"
11 #include "../../model/Schedule_Impl.hpp"
12 #include "../../model/Node.hpp"
13 #include "../../model/Node_Impl.hpp"
14 #include "../../model/Curve.hpp"
15 #include "../../model/Curve_Impl.hpp"
16 #include "../../utilities/core/Assert.hpp"
17 #include <utilities/idd/Pump_ConstantSpeed_FieldEnums.hxx>
18 #include <utilities/idd/IddEnums.hxx>
19
20 using namespace openstudio::model;
21 using namespace std;
22
23 namespace openstudio {
24
25 namespace energyplus {
26
27 10 boost::optional<IdfObject> ForwardTranslator::translatePumpConstantSpeed(PumpConstantSpeed& modelObject) {
28 10 boost::optional<std::string> s;
29 10 boost::optional<double> value;
30 10 OptionalSchedule schedule;
31
32
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 IdfObject idfObject(IddObjectType::Pump_ConstantSpeed);
33
34
1/1
✓ Branch 1 taken 10 times.
10 m_idfObjects.push_back(idfObject);
35
36 // Name
37
38
1/1
✓ Branch 1 taken 10 times.
10 s = modelObject.name();
39
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (s) {
40
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setName(*s);
41 }
42
43 // InletNodeName
44
45
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
20 if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) {
46
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
20 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
47
4/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
10 idfObject.setString(Pump_ConstantSpeedFields::InletNodeName, node->name().get());
48 10 }
49 10 }
50
51 // OutletNodeName
52
53
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
20 if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) {
54
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
20 if (boost::optional<Node> node = mo->optionalCast<Node>()) {
55
4/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 10 times.
10 idfObject.setString(Pump_ConstantSpeedFields::OutletNodeName, node->name().get());
56 10 }
57 10 }
58
59 // RatedFlowRate
60
61
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
10 if (modelObject.isRatedFlowRateAutosized()) {
62
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 idfObject.setString(Pump_ConstantSpeedFields::DesignFlowRate, "Autosize");
63 ✗ } else if ((value = modelObject.ratedFlowRate())) {
64 ✗ idfObject.setDouble(Pump_ConstantSpeedFields::DesignFlowRate, value.get());
65 }
66
67 // RatedPumpHead
68
69
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 if ((value = modelObject.ratedPumpHead())) {
70
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setDouble(Pump_ConstantSpeedFields::DesignPumpHead, value.get());
71 }
72
73 // RatedPowerConsumption
74
75
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
10 if (modelObject.isRatedPowerConsumptionAutosized()) {
76
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 idfObject.setString(Pump_ConstantSpeedFields::DesignPowerConsumption, "Autosize");
77 ✗ } else if ((value = modelObject.ratedPowerConsumption())) {
78 ✗ idfObject.setDouble(Pump_ConstantSpeedFields::DesignPowerConsumption, value.get());
79 }
80
81 // MotorEfficiency
82
83
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 if ((value = modelObject.motorEfficiency())) {
84
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setDouble(Pump_ConstantSpeedFields::MotorEfficiency, value.get());
85 }
86
87 // FractionofMotorInefficienciestoFluidStream
88
89
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
20 if ((value = modelObject.fractionofMotorInefficienciestoFluidStream())) {
90
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setDouble(Pump_ConstantSpeedFields::FractionofMotorInefficienciestoFluidStream, value.get());
91 }
92
93 // PumpControlType
94
95
3/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
20 if ((s = modelObject.pumpControlType())) {
96
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setString(Pump_ConstantSpeedFields::PumpControlType, s.get());
97 }
98
99 // PumpFlowRateSchedule
100
101
2/3
✓ Branch 1 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
20 if ((schedule = modelObject.pumpFlowRateSchedule())) {
102 ✗ idfObject.setString(Pump_ConstantSpeedFields::PumpFlowRateScheduleName, schedule->name().get());
103 }
104
105 // PumpCurve
106
107
2/3
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
20 if (OptionalCurve curve = modelObject.pumpCurve()) {
108 ✗ idfObject.setString(Pump_ConstantSpeedFields::PumpCurveName, curve->name().get());
109 10 }
110
111 // ImpellerDiameter
112
113
2/3
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
20 if ((value = modelObject.impellerDiameter())) {
114 ✗ idfObject.setDouble(Pump_ConstantSpeedFields::ImpellerDiameter, value.get());
115 }
116
117 // SkinLossRadiativeFraction
118
119
2/3
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
20 if ((value = modelObject.skinLossRadiativeFraction())) {
120 ✗ idfObject.setDouble(Pump_ConstantSpeedFields::SkinLossRadiativeFraction, value.get());
121 }
122
123 {
124
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 s = modelObject.designPowerSizingMethod();
125
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setString(Pump_ConstantSpeedFields::DesignPowerSizingMethod, s.get());
126 }
127
128 {
129
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 value = modelObject.designElectricPowerPerUnitFlowRate();
130
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setDouble(Pump_ConstantSpeedFields::DesignElectricPowerperUnitFlowRate, value.get());
131 }
132
133 {
134
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 value = modelObject.designShaftPowerPerUnitFlowRatePerUnitHead();
135
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setDouble(Pump_ConstantSpeedFields::DesignShaftPowerperUnitFlowRateperUnitHead, value.get());
136 }
137
138 // End Use Subcategory
139
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 idfObject.setString(Pump_ConstantSpeedFields::EndUseSubcategory, modelObject.endUseSubcategory());
140
141
1/1
✓ Branch 1 taken 10 times.
20 return idfObject;
142 10 }
143
144 } // namespace energyplus
145 } // namespace openstudio
146