GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 76.9% 30 / 0 / 39
Functions: 100.0% 1 / 0 / 1
Branches: 68.4% 52 / 0 / 76

src/energyplus/ForwardTranslator/ForwardTranslateUnitarySystemPerformanceMultispeed.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/UnitarySystemPerformanceMultispeed.hpp"
9 #include "../../model/UnitarySystemPerformanceMultispeed_Impl.hpp"
10 #include "../../model/AirLoopHVACUnitarySystem.hpp"
11 #include "../../model/AirLoopHVACUnitarySystem_Impl.hpp"
12 #include "../../model/CoilHeatingDXMultiSpeed.hpp"
13 #include "../../model/CoilHeatingDXMultiSpeed_Impl.hpp"
14 #include "../../model/CoilHeatingDXMultiSpeedStageData.hpp"
15 #include "../../model/CoilHeatingDXMultiSpeedStageData_Impl.hpp"
16 #include "../../model/CoilHeatingGas.hpp"
17 #include "../../model/CoilHeatingGas_Impl.hpp"
18 #include "../../model/CoilHeatingGasMultiStage.hpp"
19 #include "../../model/CoilHeatingGasMultiStage_Impl.hpp"
20 #include "../../model/CoilHeatingGasMultiStageStageData.hpp"
21 #include "../../model/CoilHeatingGasMultiStageStageData_Impl.hpp"
22 #include "../../model/CoilCoolingDX.hpp"
23 #include "../../model/CoilCoolingDX_Impl.hpp"
24 #include "../../model/CoilCoolingDXCurveFitPerformance.hpp"
25 #include "../../model/CoilCoolingDXCurveFitPerformance_Impl.hpp"
26 #include "../../model/CoilCoolingDXCurveFitOperatingMode.hpp"
27 #include "../../model/CoilCoolingDXCurveFitOperatingMode_Impl.hpp"
28 #include "../../model/CoilCoolingDXCurveFitSpeed.hpp"
29 #include "../../model/CoilCoolingDXCurveFitSpeed_Impl.hpp"
30 #include "../../model/CoilCoolingDXMultiSpeed.hpp"
31 #include "../../model/CoilCoolingDXMultiSpeed_Impl.hpp"
32 #include "../../model/CoilCoolingDXMultiSpeedStageData.hpp"
33 #include "../../model/CoilCoolingDXMultiSpeedStageData_Impl.hpp"
34 #include <utilities/idd/UnitarySystemPerformance_Multispeed_FieldEnums.hxx>
35 #include "../../utilities/idd/IddEnums.hpp"
36 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
37 #include <utilities/idd/IddFactory.hxx>
38
39 using namespace openstudio::model;
40
41 namespace openstudio {
42 namespace energyplus {
43
44 11 boost::optional<IdfObject> ForwardTranslator::translateUnitarySystemPerformanceMultispeed(UnitarySystemPerformanceMultispeed& modelObject) {
45 11 boost::optional<std::string> s;
46 11 boost::optional<double> d;
47
48 // Name
49
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 IdfObject sysPerf = createRegisterAndNameIdfObject(openstudio::IddObjectType::UnitarySystemPerformance_Multispeed, modelObject);
50
51 // Find the associated AirLoopHVACUnitarySystem
52
1/1
✓ Branch 1 taken 11 times.
11 std::vector<AirLoopHVACUnitarySystem> unitarySystems = modelObject.getModelObjectSources<AirLoopHVACUnitarySystem>();
53
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if (unitarySystems.size() != 1) {
54 ✗ LOG(Error, "OS:UnitarySystemPerformance:Multispeed should be referenced by one and only one OS:AirLoopHVAC:UnitarySystem, "
55 << modelObject.nameString() << " is referenced by " << unitarySystems.size() << ".")
56 ✗ return boost::none;
57 }
58 11 AirLoopHVACUnitarySystem& unitarySystem = unitarySystems[0];
59
60 // Number of speeds for heating
61
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<HVACComponent> heatingCoil = unitarySystem.heatingCoil();
62
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
11 if (heatingCoil) {
63
5/5
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 1 time.
7 if (heatingCoil->iddObjectType() == openstudio::IddObjectType::OS_Coil_Heating_DX_MultiSpeed) {
64
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 auto heatingCoilDXMultispeed = heatingCoil->cast<CoilHeatingDXMultiSpeed>();
65
2/2
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
6 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, heatingCoilDXMultispeed.stages().size());
66
4/5
✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
7 } else if (heatingCoil->iddObjectType() == openstudio::IddObjectType::OS_Coil_Heating_Gas_MultiStage) {
67 ✗ auto heatingCoilGasMultiStage = heatingCoil->cast<CoilHeatingGasMultiStage>();
68 ✗ sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, heatingCoilGasMultiStage.stages().size());
69 ✗ } else {
70
1/1
✓ Branch 1 taken 1 time.
1 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, 1);
71 }
72 } else {
73
1/1
✓ Branch 1 taken 4 times.
4 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, 0);
74 }
75
76 // Number of speeds for cooling
77
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<HVACComponent> coolingCoil = unitarySystem.coolingCoil();
78
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4 times.
11 if (coolingCoil) {
79
5/5
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 1 time.
7 if (coolingCoil->iddObjectType() == openstudio::IddObjectType::OS_Coil_Cooling_DX_MultiSpeed) {
80
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 auto coolingCoilDXMultispeed = coolingCoil->cast<CoilCoolingDXMultiSpeed>();
81
2/2
✓ Branch 1 taken 6 times.
✓ Branch 5 taken 6 times.
6 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, coolingCoilDXMultispeed.stages().size());
82
4/5
✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
7 } else if (coolingCoil->iddObjectType() == openstudio::IddObjectType::OS_Coil_Cooling_DX) {
83 ✗ auto coolingCoilDX = coolingCoil->cast<CoilCoolingDX>();
84 ✗ sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling,
85 ✗ coolingCoilDX.performanceObject().baseOperatingMode().speeds().size());
86 ✗ } else {
87
1/1
✓ Branch 1 taken 1 time.
1 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, 1);
88 }
89 } else {
90
1/1
✓ Branch 1 taken 4 times.
4 sysPerf.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, 0);
91 }
92
93 // Single mode operation
94
4/5
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 6 taken 11 times.
✓ Branch 9 taken 11 times.
11 sysPerf.setString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation, modelObject.singleModeOperation() ? "Yes" : "No");
95
96 // No Load Supply Air Flow Rate Ratio
97
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 sysPerf.setDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio, modelObject.noLoadSupplyAirflowRateRatio());
98
99
3/3
✓ Branch 1 taken 11 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 11 times.
17 for (const auto& airflowRatioField : modelObject.supplyAirflowRatioFields()) {
100
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 sysPerf.pushExtensibleGroup(airflowRatioField.getHeatingCoolingRatiosAsStrings());
101 11 }
102
103
1/1
✓ Branch 1 taken 11 times.
11 return sysPerf;
104 11 }
105
106 } // namespace energyplus
107 } // namespace openstudio
108