From c0f690a17ec0168ff526db9bbd4dd62615aff7d9 Mon Sep 17 00:00:00 2001 From: Matt Larson <> Date: Fri, 11 Dec 2020 13:21:04 -0700 Subject: [PATCH 1/2] Move operating settings initialization to before determining if in standby mode or not. --- src/EnergyPlus/HybridEvapCoolingModel.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/HybridEvapCoolingModel.cc b/src/EnergyPlus/HybridEvapCoolingModel.cc index 58b6aeeee89..318ee217195 100644 --- a/src/EnergyPlus/HybridEvapCoolingModel.cc +++ b/src/EnergyPlus/HybridEvapCoolingModel.cc @@ -1271,11 +1271,6 @@ namespace HybridEvapCoolingModel { Real64 PreviousMaxiumConditioningOutput = 0; Real64 PreviousMaxiumHumidOrDehumidOutput = 0; std::string ObjectID = Name.c_str(); - int size = CurrentOperatingSettings.size(); - CSetting empty_setting; - for (int i = 0; i < size; i++) { - CurrentOperatingSettings[i] = empty_setting; - } if (StepIns.RHosa > 1) { ShowSevereError(state, "Unitary hybrid system error, required relative humidity value 0-1, called in object" + ObjectID + ".Check inputs"); assert(true); @@ -1854,6 +1849,14 @@ namespace HybridEvapCoolingModel { UnitOn = 0; ForceOff = true; } + + // Initialize all settings for all operating modes + int size = CurrentOperatingSettings.size(); + CSetting empty_setting; + for (int i = 1; i < size; i++) { + CurrentOperatingSettings[i] = empty_setting; + } + // Go into standby if unit is off or not needed if ((!CoolingRequested && !HeatingRequested && !VentilationRequested && !HumidificationRequested && !DehumidificationRequested) || ForceOff) From 8ddf9910a771a2c8d344dbaaa4ebf09c3293191a Mon Sep 17 00:00:00 2001 From: Matt Larson <> Date: Mon, 14 Dec 2020 09:54:11 -0700 Subject: [PATCH 2/2] add unit test for rtf initialization check. --- .../unit/UnitaryHybridAirConditioner.unit.cc | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc b/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc index 0227e28c8da..94d2ae5da8d 100644 --- a/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc +++ b/tst/EnergyPlus/unit/UnitaryHybridAirConditioner.unit.cc @@ -1391,4 +1391,123 @@ TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_ValidateOptionalError } +TEST_F(EnergyPlusFixture, Test_UnitaryHybridAirConditioner_RuntimeFraction_Initialization) +{ + std::vector snippet = getAllLinesInFile2(configured_source_directory() + "/tst/EnergyPlus/unit/Resources/UnitaryHybridUnitTest_DOSA.idf"); + std::string string = delimited_string(snippet); + ASSERT_TRUE(process_idf(string)); + // setup environment + bool ErrorsFound(false); + GetZoneData(*state, ErrorsFound); + EXPECT_FALSE(ErrorsFound); + // Initialize schedule values + state->dataGlobal->TimeStep = 1; + DataHVACGlobals::TimeStepSys = 1; + state->dataGlobal->NumOfTimeStepInHour = 1; + state->dataGlobal->MinutesPerTimeStep = 60; + state->dataEnvrn->Month = 1; + state->dataEnvrn->DayOfMonth = 21; + state->dataGlobal->HourOfDay = 1; + state->dataEnvrn->DSTIndicator = 0; + state->dataEnvrn->DayOfWeek = 2; + state->dataEnvrn->HolidayIndex = 0; + state->dataGlobal->WarmupFlag = false; + state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); + ScheduleManager::UpdateScheduleValues(*state); + // Initialize zone areas and volumes - too many other things need to be set up to do these in the normal routines + DataHeatBalance::Zone(1).FloorArea = 232.26; + state->dataEnvrn->StdRhoAir = 1.225; + state->dataEnvrn->OutBaroPress = 101325; + DataHeatBalance::ZoneIntGain.allocate(1); + + SizingManager::GetOARequirements(*state); + GetOAControllerInputs(*state); + using DataZoneEquipment::CalcDesignSpecificationOutdoorAir; + + // Setup performance tables + using namespace EnergyPlus::DataEnvironment; + // process schedules + ProcessScheduleInput(*state); // read schedules + UpdateScheduleValues(*state); + // Get Unitary system + GetInputZoneHybridUnitaryAirConditioners(*state, ErrorsFound); + // All to get OA requirements + GetOARequirements(*state); + + EXPECT_FALSE(ErrorsFound); + // Initialize unit + InitZoneHybridUnitaryAirConditioners(*state, 1, 1); + Model *pZoneHybridUnitaryAirConditioner = &HybridUnitaryAirConditioners::ZoneHybridUnitaryAirConditioner(1); + // setup local variables for model inputs + Real64 Tosa, Tra, Wra, Wosa, RHosa, RHra, DesignMinVR, Requestedheating, RequestedCooling, Requested_Humidification, Requested_Dehumidification; + RHosa = 0; + std::string TimeDate; + Real64 MsaRatio, OSAF; + MsaRatio = OSAF = 1; + + Requestedheating = RequestedCooling = Requested_Humidification = Requested_Dehumidification = 0; + + DesignMinVR = 1.622720855; // Zone Hybrid Unitary HVAC Requested Outdoor Air Ventilation Mass Flow Rate + Tra = 22.93929413; // Zone Hybrid Unitary HVAC Return Air Temperature + Tosa = 26.67733333; // Zone Hybrid Unitary HVAC Outside Air Temperature + RHra = 17.3042157; // Zone Hybrid Unitary HVAC Return Air Relative Humidity + RHosa = 13.1602401; // Zone Hybrid Unitary HVAC Outside Air Relative Humidity + Wra = PsyWFnTdbRhPb(*state, Tra, RHra / 100, 101325); + Wosa = PsyWFnTdbRhPb(*state, Tosa, RHosa / 100, 101325); + pZoneHybridUnitaryAirConditioner->InletTemp = Tra; + pZoneHybridUnitaryAirConditioner->InletHumRat = Wra; + pZoneHybridUnitaryAirConditioner->InletEnthalpy = PsyHFnTdbRhPb(*state, Tra, RHra / 100, 101325, "test"); + pZoneHybridUnitaryAirConditioner->InletPressure = 101325; + pZoneHybridUnitaryAirConditioner->InletRH = RHra / 100; + pZoneHybridUnitaryAirConditioner->SecInletTemp = Tosa; + pZoneHybridUnitaryAirConditioner->SecInletHumRat = Wosa; + pZoneHybridUnitaryAirConditioner->SecInletEnthalpy = PsyHFnTdbRhPb(*state, Tosa, RHosa / 100, 101325, "test"); + pZoneHybridUnitaryAirConditioner->SecInletPressure = 101325; + pZoneHybridUnitaryAirConditioner->SecInletRH = RHosa / 100; + + // Scenario 1: Low Cooling + + Requestedheating = -64358.68966; //- + RequestedCooling = -633.6613591; // W + pZoneHybridUnitaryAirConditioner->Initialize(1); + pZoneHybridUnitaryAirConditioner->InitializeModelParams(); + pZoneHybridUnitaryAirConditioner->doStep( + *state, RequestedCooling, Requestedheating, Requested_Humidification, Requested_Dehumidification, DesignMinVR); + + // output results + Real64 Setting0Mode = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[0].Mode; + Real64 Setting0RuntimeFraction = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[0].Runtime_Fraction; + Real64 Setting1Mode = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[1].Mode; + Real64 Setting1RuntimeFraction = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[1].Runtime_Fraction; + + // checks + EXPECT_EQ(Setting0Mode, 1); // IEC Mode + EXPECT_NEAR(Setting0RuntimeFraction, 0.547, 0.001); // IEC RTF + EXPECT_EQ(Setting1Mode, 0); // Standby Mode + EXPECT_NEAR(Setting1RuntimeFraction, 0.453, 0.001); // Standby Mode + + // Scenario 2: Outside of env conditions. should go to standby and have standby energy + Requestedheating = -55795.8058; + RequestedCooling = 8171.47128; + pZoneHybridUnitaryAirConditioner->Initialize(1); + pZoneHybridUnitaryAirConditioner->InitializeModelParams(); + pZoneHybridUnitaryAirConditioner->SecInletTemp = 150; + pZoneHybridUnitaryAirConditioner->SecInletHumRat = 0; + pZoneHybridUnitaryAirConditioner->doStep( + *state, RequestedCooling, Requestedheating, Requested_Humidification, Requested_Dehumidification, 0); + + // output results + Setting0Mode = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[0].Mode; + Setting0RuntimeFraction = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[0].Runtime_Fraction; + Setting1Mode = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[1].Mode; + Setting1RuntimeFraction = pZoneHybridUnitaryAirConditioner->CurrentOperatingSettings[1].Runtime_Fraction; + + // checks + EXPECT_EQ(Setting0Mode, 0); // Standby Mode + EXPECT_EQ(Setting0RuntimeFraction, 1); // Standby RTF + EXPECT_EQ(Setting1Mode, 0); // Standby Mode + EXPECT_EQ(Setting1RuntimeFraction, 0); // Standby RTF + +} + } // namespace EnergyPlus