From b30c7c3cb04f72d9a2adde63b425f6ffe14a043a Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 24 Oct 2024 08:54:35 -0700 Subject: [PATCH 01/11] Add ft test file for UnitarySystemPerformanceMultispeed. --- src/energyplus/CMakeLists.txt | 1 + ...itarySystemPerformanceMultispeed_GTest.cpp | 135 ++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index 819c24b557..48aa9f11c1 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -829,6 +829,7 @@ set(${target_name}_test_src Test/ThermalStorageChilledWaterStratified_GTest.cpp Test/ThermalZone_GTest.cpp Test/ThermostatSetpointDualSetpoint_GTest.cpp + Test/UnitarySystemPerformanceMultispeed_GTest.cpp Test/WindowPropertyFrameAndDivider_GTest.cpp Test/WaterHeaterMixed_GTest.cpp Test/WaterHeaterSizing_GTest.cpp diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp new file mode 100644 index 0000000000..b25efdbfbc --- /dev/null +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -0,0 +1,135 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/ThermalZone.hpp" +#include "../../model/Space.hpp" +#include "../../model/AirLoopHVAC.hpp" +#include "../../model/AirLoopHVACUnitarySystem.hpp" +#include "../../model/ZoneHVACWaterToAirHeatPump.hpp" +#include "../../model/ZoneHVACTerminalUnitVariableRefrigerantFlow.hpp" +#include "../../model/CoilCoolingDXVariableSpeed.hpp" +#include "../../model/CoilCoolingDXVariableSpeedSpeedData.hpp" +#include "../../model/CoilHeatingDXMultiSpeed.hpp" +#include "../../model/CoilHeatingDXMultiSpeedStageData.hpp" +#include "../../model/CoilCoolingDXMultiSpeed.hpp" +#include "../../model/CoilCoolingDXMultiSpeedStageData.hpp" +#include "../../model/FanOnOff.hpp" +#include "../../model/CoilHeatingElectric.hpp" +#include "../../model/ScheduleConstant.hpp" +#include "../../model/Node.hpp" +#include "../../model/UnitarySystemPerformanceMultispeed.hpp" + +#include +#include +#include +#include + +#include +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/IdfObject_Impl.hpp" + +#include "../../utilities/idf/WorkspaceObject.hpp" +#include "../../utilities/idf/WorkspaceObject_Impl.hpp" + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_AirLoopHVACUnitarySystem) { + Model m; + + CoilCoolingDXVariableSpeed coil(m); + CoilCoolingDXVariableSpeedSpeedData speed1(m); + EXPECT_TRUE(coil.addSpeed(speed1)); + CoilCoolingDXVariableSpeedSpeedData speed2(m); + EXPECT_TRUE(coil.addSpeed(speed2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setCoolingCoil(coil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); + + UnitarySystemPerformanceMultispeed perf(m); + perf.setName("US Perf Multispeed"); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(0, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); +} + +TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_Speeds) { + // #5277: Forward Translator Issues for UnitarySystemPerformance:Multispeed + Model m; + + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addSpeed(htgstage1)); + CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgcoil.addSpeed(htgstage2)); + CoilHeatingDXMultiSpeedStageData htgstage3(m); + EXPECT_TRUE(htgcoil.addSpeed(htgstage3)); + CoilHeatingDXMultiSpeedStageData htgstage4(m); + EXPECT_TRUE(htgcoil.addSpeed(htgstage4)); + + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXVariableSpeedSpeedData clgstage1(m); + EXPECT_TRUE(clgcoil.addSpeed(clgstage1)); + CoilCoolingDXVariableSpeedSpeedData clgstage2(m); + EXPECT_TRUE(clgcoil.addSpeed(clgstage2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ(unitary.nameString() + " Unitary System Performance", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(4, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(4u, idf_perf.numExtensibleGroups()); +} From 132f0ecefc55ad7a27fd585be30fcd255f8239e4 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 24 Oct 2024 08:54:56 -0700 Subject: [PATCH 02/11] Formatting. --- .../Test/UnitarySystemPerformanceMultispeed_GTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index b25efdbfbc..8d0d7df04c 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -120,7 +120,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_S EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); - EXPECT_EQ(unitary.nameString() + " Unitary System Performance", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + EXPECT_EQ(unitary.nameString() + " Unitary System Performance", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); EXPECT_EQ(1, idf_perfs.size()); From 9c6c1e9cde02c663024fb31671b38d75f669cce6 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 24 Oct 2024 11:05:49 -0700 Subject: [PATCH 03/11] Clean up new test file. --- .../UnitarySystemPerformanceMultispeed_GTest.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index 8d0d7df04c..b81ed18289 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -93,19 +93,19 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_S CoilHeatingDXMultiSpeed htgcoil(m); CoilHeatingDXMultiSpeedStageData htgstage1(m); - EXPECT_TRUE(htgcoil.addSpeed(htgstage1)); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilHeatingDXMultiSpeedStageData htgstage2(m); - EXPECT_TRUE(htgcoil.addSpeed(htgstage2)); + EXPECT_TRUE(htgcoil.addStage(htgstage2)); CoilHeatingDXMultiSpeedStageData htgstage3(m); - EXPECT_TRUE(htgcoil.addSpeed(htgstage3)); + EXPECT_TRUE(htgcoil.addStage(htgstage3)); CoilHeatingDXMultiSpeedStageData htgstage4(m); - EXPECT_TRUE(htgcoil.addSpeed(htgstage4)); + EXPECT_TRUE(htgcoil.addStage(htgstage4)); CoilCoolingDXMultiSpeed clgcoil(m); - CoilCoolingDXVariableSpeedSpeedData clgstage1(m); - EXPECT_TRUE(clgcoil.addSpeed(clgstage1)); - CoilCoolingDXVariableSpeedSpeedData clgstage2(m); - EXPECT_TRUE(clgcoil.addSpeed(clgstage2)); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); From 40e8dd9881152de48d8eb9ba81ebd48b8474c1e9 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Thu, 24 Oct 2024 13:16:47 -0700 Subject: [PATCH 04/11] Missed ft in the new test. --- .../Test/UnitarySystemPerformanceMultispeed_GTest.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index b81ed18289..1ce16f8783 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -114,6 +114,9 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_S AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); EXPECT_EQ(1, idf_unitarys.size()); WorkspaceObject& idf_unitary = idf_unitarys.front(); From d2ffafc0ee77f2017d1193da6ada55db28685100 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 11:12:03 -0700 Subject: [PATCH 05/11] Create more test scenarios in new ft test file. --- ...itarySystemPerformanceMultispeed_GTest.cpp | 362 ++++++++++++++---- 1 file changed, 281 insertions(+), 81 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index 1ce16f8783..5894831620 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -15,6 +15,8 @@ #include "../../model/AirLoopHVACUnitarySystem.hpp" #include "../../model/ZoneHVACWaterToAirHeatPump.hpp" #include "../../model/ZoneHVACTerminalUnitVariableRefrigerantFlow.hpp" +#include "../../model/CoilHeatingDXVariableSpeed.hpp" +#include "../../model/CoilHeatingDXVariableSpeedSpeedData.hpp" #include "../../model/CoilCoolingDXVariableSpeed.hpp" #include "../../model/CoilCoolingDXVariableSpeedSpeedData.hpp" #include "../../model/CoilHeatingDXMultiSpeed.hpp" @@ -43,97 +45,295 @@ using namespace openstudio::energyplus; using namespace openstudio::model; using namespace openstudio; -TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_AirLoopHVACUnitarySystem) { - Model m; +TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_Ctor) { + { // h == c + Model m; + + CoilHeatingDXVariableSpeed htgcoil(m); + CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); + EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); + CoilHeatingDXVariableSpeedSpeedData htgspeed2(m); + EXPECT_TRUE(htgcoil.addSpeed(htgspeed2)); + + CoilCoolingDXVariableSpeed clgcoil(m); + CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); + EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); + CoilCoolingDXVariableSpeedSpeedData clgspeed2(m); + EXPECT_TRUE(clgcoil.addSpeed(clgspeed2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); + + UnitarySystemPerformanceMultispeed perf(m); + perf.setName("US Perf Multispeed"); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + } + + { // h > c + Model m; + + CoilHeatingDXVariableSpeed htgcoil(m); + CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); + EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); + CoilHeatingDXVariableSpeedSpeedData htgspeed2(m); + EXPECT_TRUE(htgcoil.addSpeed(htgspeed2)); + + CoilCoolingDXVariableSpeed clgcoil(m); + CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); + EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); - CoilCoolingDXVariableSpeed coil(m); - CoilCoolingDXVariableSpeedSpeedData speed1(m); - EXPECT_TRUE(coil.addSpeed(speed1)); - CoilCoolingDXVariableSpeedSpeedData speed2(m); - EXPECT_TRUE(coil.addSpeed(speed2)); + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); - AirLoopHVACUnitarySystem unitary(m); - unitary.setCoolingCoil(coil); + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); - AirLoopHVAC airLoop(m); - Node supplyOutletNode = airLoop.supplyOutletNode(); - unitary.addToNode(supplyOutletNode); + UnitarySystemPerformanceMultispeed perf(m); + perf.setName("US Perf Multispeed"); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); - UnitarySystemPerformanceMultispeed perf(m); - perf.setName("US Perf Multispeed"); - EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); - EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); + ForwardTranslator ft; + Workspace w = ft.translateModel(m); - ForwardTranslator ft; - Workspace w = ft.translateModel(m); + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); - EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - EXPECT_EQ("UnitarySystemPerformance:Multispeed", - idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); - EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); - EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); - EXPECT_EQ(0, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); - EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); - EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); - EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + } - ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + { // h < c + Model m; + + CoilHeatingDXVariableSpeed htgcoil(m); + CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); + EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); + + CoilCoolingDXVariableSpeed clgcoil(m); + CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); + EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); + CoilCoolingDXVariableSpeedSpeedData clgspeed2(m); + EXPECT_TRUE(clgcoil.addSpeed(clgspeed2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); + + UnitarySystemPerformanceMultispeed perf(m); + perf.setName("US Perf Multispeed"); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + } } -TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_Speeds) { - // #5277: Forward Translator Issues for UnitarySystemPerformance:Multispeed - Model m; - - CoilHeatingDXMultiSpeed htgcoil(m); - CoilHeatingDXMultiSpeedStageData htgstage1(m); - EXPECT_TRUE(htgcoil.addStage(htgstage1)); - CoilHeatingDXMultiSpeedStageData htgstage2(m); - EXPECT_TRUE(htgcoil.addStage(htgstage2)); - CoilHeatingDXMultiSpeedStageData htgstage3(m); - EXPECT_TRUE(htgcoil.addStage(htgstage3)); - CoilHeatingDXMultiSpeedStageData htgstage4(m); - EXPECT_TRUE(htgcoil.addStage(htgstage4)); - - CoilCoolingDXMultiSpeed clgcoil(m); - CoilCoolingDXMultiSpeedStageData clgstage1(m); - EXPECT_TRUE(clgcoil.addStage(clgstage1)); - CoilCoolingDXMultiSpeedStageData clgstage2(m); - EXPECT_TRUE(clgcoil.addStage(clgstage2)); - - AirLoopHVACUnitarySystem unitary(m); - unitary.setHeatingCoil(htgcoil); - unitary.setCoolingCoil(clgcoil); - - AirLoopHVAC airLoop(m); - Node supplyOutletNode = airLoop.supplyOutletNode(); - - ForwardTranslator ft; - Workspace w = ft.translateModel(m); - - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); - EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); - - EXPECT_EQ("UnitarySystemPerformance:Multispeed", - idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); - EXPECT_EQ(unitary.nameString() + " Unitary System Performance", - idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); - EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); - - EXPECT_EQ(4, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); - EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); - EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); - EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); - - ASSERT_EQ(4u, idf_perf.numExtensibleGroups()); +TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_AirLoopHVACUnitarySystem) { + { // h == c + Model m; + + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); + CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgcoil.addStage(htgstage2)); + + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ(unitary.nameString() + " Unitary System Performance", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + } + + { // #5277: Forward Translator Issues for UnitarySystemPerformance:Multispeed + Model m; + + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); + CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgcoil.addStage(htgstage2)); + CoilHeatingDXMultiSpeedStageData htgstage3(m); + EXPECT_TRUE(htgcoil.addStage(htgstage3)); + CoilHeatingDXMultiSpeedStageData htgstage4(m); + EXPECT_TRUE(htgcoil.addStage(htgstage4)); + + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ(unitary.nameString() + " Unitary System Performance", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(4, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(4u, idf_perf.numExtensibleGroups()); + } + + { // h < c + Model m; + + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); + + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); + + AirLoopHVACUnitarySystem unitary(m); + unitary.setHeatingCoil(htgcoil); + unitary.setCoolingCoil(clgcoil); + + AirLoopHVAC airLoop(m); + Node supplyOutletNode = airLoop.supplyOutletNode(); + + ForwardTranslator ft; + Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + EXPECT_EQ(1, idf_unitarys.size()); + WorkspaceObject& idf_unitary = idf_unitarys.front(); + + EXPECT_EQ("UnitarySystemPerformance:Multispeed", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); + EXPECT_EQ(unitary.nameString() + " Unitary System Performance", + idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); + + WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + EXPECT_EQ(1, idf_perfs.size()); + WorkspaceObject& idf_perf = idf_perfs.front(); + + EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); + EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + } } From 1a12ffdad396eda06a373492119ad367d9023f29 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 15:06:47 -0700 Subject: [PATCH 06/11] Use only multispeed objects. --- ...itarySystemPerformanceMultispeed_GTest.cpp | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index 5894831620..ef3a467d7b 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -15,10 +15,6 @@ #include "../../model/AirLoopHVACUnitarySystem.hpp" #include "../../model/ZoneHVACWaterToAirHeatPump.hpp" #include "../../model/ZoneHVACTerminalUnitVariableRefrigerantFlow.hpp" -#include "../../model/CoilHeatingDXVariableSpeed.hpp" -#include "../../model/CoilHeatingDXVariableSpeedSpeedData.hpp" -#include "../../model/CoilCoolingDXVariableSpeed.hpp" -#include "../../model/CoilCoolingDXVariableSpeedSpeedData.hpp" #include "../../model/CoilHeatingDXMultiSpeed.hpp" #include "../../model/CoilHeatingDXMultiSpeedStageData.hpp" #include "../../model/CoilCoolingDXMultiSpeed.hpp" @@ -49,17 +45,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C { // h == c Model m; - CoilHeatingDXVariableSpeed htgcoil(m); - CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); - EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); - CoilHeatingDXVariableSpeedSpeedData htgspeed2(m); - EXPECT_TRUE(htgcoil.addSpeed(htgspeed2)); + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); + CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgcoil.addStage(htgstage2)); - CoilCoolingDXVariableSpeed clgcoil(m); - CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); - EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); - CoilCoolingDXVariableSpeedSpeedData clgspeed2(m); - EXPECT_TRUE(clgcoil.addSpeed(clgspeed2)); + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); @@ -71,7 +67,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C UnitarySystemPerformanceMultispeed perf(m); perf.setName("US Perf Multispeed"); - EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(0.1, 0.2)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(0.3, 0.4)); EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); ForwardTranslator ft; @@ -100,15 +97,15 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C { // h > c Model m; - CoilHeatingDXVariableSpeed htgcoil(m); - CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); - EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); - CoilHeatingDXVariableSpeedSpeedData htgspeed2(m); - EXPECT_TRUE(htgcoil.addSpeed(htgspeed2)); + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); + CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgcoil.addStage(htgstage2)); - CoilCoolingDXVariableSpeed clgcoil(m); - CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); - EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); @@ -120,7 +117,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C UnitarySystemPerformanceMultispeed perf(m); perf.setName("US Perf Multispeed"); - EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(0.1, 0.2)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(SupplyAirflowRatioField::fromHeatingRatio(0.3))); EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); ForwardTranslator ft; @@ -149,15 +147,15 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C { // h < c Model m; - CoilHeatingDXVariableSpeed htgcoil(m); - CoilHeatingDXVariableSpeedSpeedData htgspeed1(m); - EXPECT_TRUE(htgcoil.addSpeed(htgspeed1)); + CoilHeatingDXMultiSpeed htgcoil(m); + CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgcoil.addStage(htgstage1)); - CoilCoolingDXVariableSpeed clgcoil(m); - CoilCoolingDXVariableSpeedSpeedData clgspeed1(m); - EXPECT_TRUE(clgcoil.addSpeed(clgspeed1)); - CoilCoolingDXVariableSpeedSpeedData clgspeed2(m); - EXPECT_TRUE(clgcoil.addSpeed(clgspeed2)); + CoilCoolingDXMultiSpeed clgcoil(m); + CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgcoil.addStage(clgstage1)); + CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); @@ -169,7 +167,8 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C UnitarySystemPerformanceMultispeed perf(m); perf.setName("US Perf Multispeed"); - EXPECT_TRUE(perf.addSupplyAirflowRatioField(1.0, 2.0)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(0.1, 0.2)); + EXPECT_TRUE(perf.addSupplyAirflowRatioField(SupplyAirflowRatioField::fromCoolingRatio(0.3))); EXPECT_TRUE(unitary.setDesignSpecificationMultispeedObject(perf)); ForwardTranslator ft; @@ -218,6 +217,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); ForwardTranslator ft; Workspace w = ft.translateModel(m); @@ -268,6 +268,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); ForwardTranslator ft; Workspace w = ft.translateModel(m); @@ -312,6 +313,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); + unitary.addToNode(supplyOutletNode); ForwardTranslator ft; Workspace w = ft.translateModel(m); From a1607fbbb60858119f845d66c7feaab19ea4b7b4 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 15:55:53 -0700 Subject: [PATCH 07/11] Check speed supply air flow ratio fields. --- ...itarySystemPerformanceMultispeed_GTest.cpp | 108 +++++++++++++++--- 1 file changed, 93 insertions(+), 15 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index ef3a467d7b..dfb912ab58 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -26,13 +26,12 @@ #include "../../model/UnitarySystemPerformanceMultispeed.hpp" #include -#include -#include #include #include #include "../../utilities/idf/IdfObject.hpp" #include "../../utilities/idf/IdfObject_Impl.hpp" +#include "../../utilities/idf/IdfExtensibleGroup.hpp" #include "../../utilities/idf/WorkspaceObject.hpp" #include "../../utilities/idf/WorkspaceObject_Impl.hpp" @@ -92,6 +91,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); + + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.4, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } { // h > c @@ -142,6 +155,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); + + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ("Autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } { // h < c @@ -192,6 +219,20 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); + + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ("Autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } } @@ -238,12 +279,27 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); - EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + EXPECT_TRUE(idf_perf.isEmpty(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio)); ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); + + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.4, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } - { // #5277: Forward Translator Issues for UnitarySystemPerformance:Multispeed + { // h > c + // #5277: Forward Translator Issues for UnitarySystemPerformance:Multispeed Model m; CoilHeatingDXMultiSpeed htgcoil(m); @@ -251,16 +307,10 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilHeatingDXMultiSpeedStageData htgstage2(m); EXPECT_TRUE(htgcoil.addStage(htgstage2)); - CoilHeatingDXMultiSpeedStageData htgstage3(m); - EXPECT_TRUE(htgcoil.addStage(htgstage3)); - CoilHeatingDXMultiSpeedStageData htgstage4(m); - EXPECT_TRUE(htgcoil.addStage(htgstage4)); CoilCoolingDXMultiSpeed clgcoil(m); CoilCoolingDXMultiSpeedStageData clgstage1(m); EXPECT_TRUE(clgcoil.addStage(clgstage1)); - CoilCoolingDXMultiSpeedStageData clgstage2(m); - EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); @@ -286,12 +336,26 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A EXPECT_EQ(1, idf_perfs.size()); WorkspaceObject& idf_perf = idf_perfs.front(); - EXPECT_EQ(4, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); - EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); - EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + EXPECT_TRUE(idf_perf.isEmpty(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio)); + + ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); - ASSERT_EQ(4u, idf_perf.numExtensibleGroups()); + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } { // h < c @@ -334,8 +398,22 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); - EXPECT_EQ(1.0, idf_perf.getDouble(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio).get()); + EXPECT_TRUE(idf_perf.isEmpty(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio)); ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); + + auto egs = idf_perf.extensibleGroups(); + + IdfExtensibleGroup eg1 = egs[0]; + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + + IdfExtensibleGroup eg2 = egs[1]; + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } } From e96e2013dbe3adc9ae833310bff1d1cb771ad191 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 19:37:42 -0700 Subject: [PATCH 08/11] Set values for stage and unitary flow. --- ...itarySystemPerformanceMultispeed_GTest.cpp | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index dfb912ab58..5505be21c4 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -168,7 +168,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ("Autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ("autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } { // h < c @@ -230,7 +230,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C IdfExtensibleGroup eg2 = egs[1]; ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ("Autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ("autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } @@ -242,19 +242,25 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A CoilHeatingDXMultiSpeed htgcoil(m); CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgstage1.setRatedAirFlowRate(1)); EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgstage1.setRatedAirFlowRate(2)); EXPECT_TRUE(htgcoil.addStage(htgstage2)); CoilCoolingDXMultiSpeed clgcoil(m); CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgstage1.setRatedAirFlowRate(3)); EXPECT_TRUE(clgcoil.addStage(clgstage1)); CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgstage2.setRatedAirFlowRate(4)); EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); unitary.setCoolingCoil(clgcoil); + unitary.setSupplyAirFlowRateDuringCoolingOperation(10); + unitary.setSupplyAirFlowRateDuringHeatingOperation(10); AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); @@ -289,11 +295,11 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.3, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); IdfExtensibleGroup eg2 = egs[1]; ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.2, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); EXPECT_EQ(0.4, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } @@ -304,17 +310,22 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A CoilHeatingDXMultiSpeed htgcoil(m); CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgstage1.setRatedAirFlowRate(1)); EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilHeatingDXMultiSpeedStageData htgstage2(m); + EXPECT_TRUE(htgstage2.setRatedAirFlowRate(2)); EXPECT_TRUE(htgcoil.addStage(htgstage2)); CoilCoolingDXMultiSpeed clgcoil(m); CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgstage1.setRatedAirFlowRate(3)); EXPECT_TRUE(clgcoil.addStage(clgstage1)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); unitary.setCoolingCoil(clgcoil); + unitary.setSupplyAirFlowRateDuringCoolingOperation(10); + unitary.setSupplyAirFlowRateDuringHeatingOperation(10); AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); @@ -347,13 +358,13 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A IdfExtensibleGroup eg1 = egs[0]; ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.3, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); IdfExtensibleGroup eg2 = egs[1]; ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.2, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } @@ -363,17 +374,22 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A CoilHeatingDXMultiSpeed htgcoil(m); CoilHeatingDXMultiSpeedStageData htgstage1(m); + EXPECT_TRUE(htgstage1.setRatedAirFlowRate(1)); EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilCoolingDXMultiSpeed clgcoil(m); CoilCoolingDXMultiSpeedStageData clgstage1(m); + EXPECT_TRUE(clgstage1.setRatedAirFlowRate(2)); EXPECT_TRUE(clgcoil.addStage(clgstage1)); CoilCoolingDXMultiSpeedStageData clgstage2(m); + EXPECT_TRUE(clgstage2.setRatedAirFlowRate(3)); EXPECT_TRUE(clgcoil.addStage(clgstage2)); AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); unitary.setCoolingCoil(clgcoil); + unitary.setSupplyAirFlowRateDuringCoolingOperation(10); + unitary.setSupplyAirFlowRateDuringHeatingOperation(10); AirLoopHVAC airLoop(m); Node supplyOutletNode = airLoop.supplyOutletNode(); @@ -406,14 +422,14 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A IdfExtensibleGroup eg1 = egs[0]; ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); IdfExtensibleGroup eg2 = egs[1]; ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); } } From 918b025461cac1a83ed3a4751752e616b9fd4b2c Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 19:54:41 -0700 Subject: [PATCH 09/11] Typo. --- .../Test/UnitarySystemPerformanceMultispeed_GTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index 5505be21c4..117e0617bb 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -245,7 +245,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A EXPECT_TRUE(htgstage1.setRatedAirFlowRate(1)); EXPECT_TRUE(htgcoil.addStage(htgstage1)); CoilHeatingDXMultiSpeedStageData htgstage2(m); - EXPECT_TRUE(htgstage1.setRatedAirFlowRate(2)); + EXPECT_TRUE(htgstage2.setRatedAirFlowRate(2)); EXPECT_TRUE(htgcoil.addStage(htgstage2)); CoilCoolingDXMultiSpeed clgcoil(m); From c4acaab2e953a59d98c2b675cb94f630b9912065 Mon Sep 17 00:00:00 2001 From: Joe Robertson Date: Mon, 28 Oct 2024 21:49:51 -0700 Subject: [PATCH 10/11] Try a fix. --- ...rwardTranslateAirLoopHVACUnitarySystem.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp index 52e61b813c..538292847c 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp @@ -456,7 +456,8 @@ namespace energyplus { boost::optional varSpeedDXCooling; boost::optional varSpeedWaterToAirCooling; - int maxStages = 0; + int maxHeatingStages = 0; + int maxCoolingStages = 0; if (heatingCoil) { multispeedDXHeating = heatingCoil->optionalCast(); @@ -482,36 +483,36 @@ namespace energyplus { if (multispeedDXHeating) { heatingStages = multispeedDXHeating->stages(); - maxStages = heatingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxStages); + maxHeatingStages = heatingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxHeatingStages); } else if (varSpeedDXHeating) { varHeatingStages = varSpeedDXHeating->speeds(); - maxStages = varHeatingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxStages); + maxHeatingStages = varHeatingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxHeatingStages); } else if (multistageGasHeating) { gasHeatingStages = multistageGasHeating->stages(); - maxStages = gasHeatingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxStages); + maxHeatingStages = gasHeatingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxHeatingStages); } else if (varSpeedWaterToAirHeating) { waterToAirHeatingStages = varSpeedWaterToAirHeating->speeds(); - maxStages = waterToAirHeatingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxStages); + maxHeatingStages = waterToAirHeatingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, maxHeatingStages); } else { _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating, 1); } if (multispeedDXCooling) { coolingStages = multispeedDXCooling->stages(); - maxStages = coolingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxStages); + maxCoolingStages = coolingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxCoolingStages); } else if (varSpeedDXCooling) { varCoolingStages = varSpeedDXCooling->speeds(); - maxStages = varCoolingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxStages); + maxCoolingStages = varCoolingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxCoolingStages); } else if (varSpeedWaterToAirCooling) { waterToAirCoolingStages = varSpeedWaterToAirCooling->speeds(); - maxStages = waterToAirCoolingStages.size(); - _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxStages); + maxCoolingStages = waterToAirCoolingStages.size(); + _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, maxCoolingStages); } else { _unitarySystemPerformance.setInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling, 1); } @@ -529,7 +530,7 @@ namespace energyplus { } }; - for (int i = 0; i < maxStages; ++i) { + for (int i = 0; i < std::max(maxHeatingStages, maxCoolingStages); ++i) { auto extensible = _unitarySystemPerformance.pushExtensibleGroup(); if (static_cast(i) < heatingStages.size()) { @@ -566,7 +567,7 @@ namespace energyplus { } else { extensible.setString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio, "Autosize"); } - } else if (i < 2) { + } else { extensible.setDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio, 1.0); } @@ -595,7 +596,7 @@ namespace energyplus { } else { extensible.setString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio, "Autosize"); } - } else if (i < 2) { + } else { extensible.setDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio, 1.0); } } From 4a3deb36fa8128ae38892861121488233432eefb Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 29 Oct 2024 22:23:11 +0100 Subject: [PATCH 11/11] Test with 2 heating stages and 4 cooling stages + Scope test variables, take refs --- ...itarySystemPerformanceMultispeed_GTest.cpp | 242 ++++++++++-------- 1 file changed, 139 insertions(+), 103 deletions(-) diff --git a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp index 117e0617bb..5b0a709a98 100644 --- a/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp +++ b/src/energyplus/Test/UnitarySystemPerformanceMultispeed_GTest.cpp @@ -73,17 +73,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const WorkspaceObject& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const WorkspaceObject& idf_perf = idf_perfs.front(); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); @@ -137,17 +137,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const WorkspaceObject& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const WorkspaceObject& idf_perf = idf_perfs.front(); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); @@ -156,19 +156,22 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); - auto egs = idf_perf.extensibleGroups(); - - IdfExtensibleGroup eg1 = egs[0]; - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); - - IdfExtensibleGroup eg2 = egs[1]; - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ("autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + const auto egs = idf_perf.extensibleGroups(); + + { + const IdfExtensibleGroup& eg = egs[0]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + { + const IdfExtensibleGroup& eg = egs[1]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_FALSE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ("autosize", eg.getString(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } } { // h < c @@ -201,17 +204,17 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const WorkspaceObject& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ("US Perf Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const WorkspaceObject& idf_perf = idf_perfs.front(); EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); @@ -220,23 +223,27 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_C ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); - auto egs = idf_perf.extensibleGroups(); - - IdfExtensibleGroup eg1 = egs[0]; - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); - - IdfExtensibleGroup eg2 = egs[1]; - ASSERT_FALSE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ("autosize", eg2.getString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + const auto egs = idf_perf.extensibleGroups(); + { + const IdfExtensibleGroup& eg = egs[0]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + { + const IdfExtensibleGroup& eg = egs[1]; + ASSERT_FALSE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ("autosize", eg.getString(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } } } -TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_AirLoopHVACUnitarySystem) { +TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_AirLoopHVACUnitarySystem_Defaulted) { + // When the user didn't specifically instantiate and assign a UnitarySystemPerformanceMultispeed object, the FT creates one + { // h == c Model m; @@ -269,18 +276,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const auto& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ(unitary.nameString() + " Unitary System Performance", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const auto& idf_perf = idf_perfs.front(); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); @@ -289,19 +296,23 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); - auto egs = idf_perf.extensibleGroups(); - - IdfExtensibleGroup eg1 = egs[0]; - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); - - IdfExtensibleGroup eg2 = egs[1]; - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.4, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + const auto egs = idf_perf.extensibleGroups(); + + { + const IdfExtensibleGroup& eg = egs[0]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + + { + const IdfExtensibleGroup& eg = egs[1]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.4, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } } { // h > c @@ -334,18 +345,18 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto& idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const WorkspaceObject& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ(unitary.nameString() + " Unitary System Performance", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const WorkspaceObject& idf_perf = idf_perfs.front(); EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); @@ -354,36 +365,43 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); - auto egs = idf_perf.extensibleGroups(); - - IdfExtensibleGroup eg1 = egs[0]; - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); - - IdfExtensibleGroup eg2 = egs[1]; - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + const auto egs = idf_perf.extensibleGroups(); + { + const IdfExtensibleGroup& eg = egs[0]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + { + const IdfExtensibleGroup& eg = egs[1]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } } { // h < c Model m; + const int maxHeatingStages = 2; + const int maxCoolingStages = 4; + const int maxStages = std::max(maxHeatingStages, maxCoolingStages); + CoilHeatingDXMultiSpeed htgcoil(m); - CoilHeatingDXMultiSpeedStageData htgstage1(m); - EXPECT_TRUE(htgstage1.setRatedAirFlowRate(1)); - EXPECT_TRUE(htgcoil.addStage(htgstage1)); + for (int i = 1; i <= maxHeatingStages; ++i) { + CoilHeatingDXMultiSpeedStageData htgstage(m); + EXPECT_TRUE(htgstage.setRatedAirFlowRate(i)); + EXPECT_TRUE(htgcoil.addStage(htgstage)); + } CoilCoolingDXMultiSpeed clgcoil(m); - CoilCoolingDXMultiSpeedStageData clgstage1(m); - EXPECT_TRUE(clgstage1.setRatedAirFlowRate(2)); - EXPECT_TRUE(clgcoil.addStage(clgstage1)); - CoilCoolingDXMultiSpeedStageData clgstage2(m); - EXPECT_TRUE(clgstage2.setRatedAirFlowRate(3)); - EXPECT_TRUE(clgcoil.addStage(clgstage2)); + for (int i = 1; i <= maxCoolingStages; ++i) { + CoilCoolingDXMultiSpeedStageData clgstage(m); + EXPECT_TRUE(clgstage.setRatedAirFlowRate(i + maxHeatingStages)); + EXPECT_TRUE(clgcoil.addStage(clgstage)); + } AirLoopHVACUnitarySystem unitary(m); unitary.setHeatingCoil(htgcoil); @@ -398,38 +416,56 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_UnitarySystemPerformanceMultispeed_A ForwardTranslator ft; Workspace w = ft.translateModel(m); - WorkspaceObjectVector idf_unitarys(w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem)); + const auto idf_unitarys = w.getObjectsByType(IddObjectType::AirLoopHVAC_UnitarySystem); EXPECT_EQ(1, idf_unitarys.size()); - WorkspaceObject& idf_unitary = idf_unitarys.front(); + const auto& idf_unitary = idf_unitarys.front(); EXPECT_EQ("UnitarySystemPerformance:Multispeed", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectType).get()); EXPECT_EQ(unitary.nameString() + " Unitary System Performance", idf_unitary.getString(AirLoopHVAC_UnitarySystemFields::DesignSpecificationMultispeedObjectName).get()); - WorkspaceObjectVector idf_perfs(w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed)); + const auto idf_perfs = w.getObjectsByType(IddObjectType::UnitarySystemPerformance_Multispeed); EXPECT_EQ(1, idf_perfs.size()); - WorkspaceObject& idf_perf = idf_perfs.front(); + const WorkspaceObject& idf_perf = idf_perfs.front(); - EXPECT_EQ(1, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); - EXPECT_EQ(2, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); + EXPECT_EQ(maxHeatingStages, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforHeating).get()); + EXPECT_EQ(maxCoolingStages, idf_perf.getInt(UnitarySystemPerformance_MultispeedFields::NumberofSpeedsforCooling).get()); EXPECT_EQ("No", idf_perf.getString(UnitarySystemPerformance_MultispeedFields::SingleModeOperation).get()); EXPECT_TRUE(idf_perf.isEmpty(UnitarySystemPerformance_MultispeedFields::NoLoadSupplyAirFlowRateRatio)); - ASSERT_EQ(2u, idf_perf.numExtensibleGroups()); - - auto egs = idf_perf.extensibleGroups(); - - IdfExtensibleGroup eg1 = egs[0]; - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.1, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.2, eg1.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); - - IdfExtensibleGroup eg2 = egs[1]; - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(1, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); - ASSERT_TRUE(eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); - EXPECT_EQ(0.3, eg2.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + ASSERT_EQ(maxStages, idf_perf.numExtensibleGroups()); + + const auto egs = idf_perf.extensibleGroups(); + + { + const IdfExtensibleGroup& eg = egs[0]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.1, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.3, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + + { + const IdfExtensibleGroup& eg = egs[1]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.2, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.4, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + { + const IdfExtensibleGroup& eg = egs[2]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1.0, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.5, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } + { + const IdfExtensibleGroup& eg = egs[3]; + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(1.0, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::HeatingSpeedSupplyAirFlowRatio).get()); + ASSERT_TRUE(eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio)); + EXPECT_EQ(0.6, eg.getDouble(UnitarySystemPerformance_MultispeedExtensibleFields::CoolingSpeedSupplyAirFlowRatio).get()); + } } }