From 67f7d2365a6993e3dac691382cb1bec4428122c0 Mon Sep 17 00:00:00 2001 From: Jermy Thomas Date: Mon, 12 Oct 2020 10:09:54 -0600 Subject: [PATCH 1/2] Changing static variables to namesake variables Partial fix to #7729 --- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 2ee60052143..90b6fd66dc7 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -221,6 +221,9 @@ namespace HVACVariableRefrigerantFlow { Array1D MinDeltaT; // minimum zone temperature difference from setpoint Array1D SumCoolingLoads; // sum of cooling loads Array1D SumHeatingLoads; // sum of heating loads + Real64 CurrentEndTime; // end time of current time step + Real64 CurrentEndTimeLast; // end time of last time step + Real64 TimeStepSysLast; // system time step on last time step // Object Data Array1D VRF; // AirConditioner:VariableRefrigerantFlow object @@ -516,9 +519,6 @@ namespace HVACVariableRefrigerantFlow { Real64 HREIRFTConst; // stead-state EIR fraction Real64 HRInitialEIRFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode Real64 HREIRTC; // Time constant used to recover from initial degradation in cooling heat recovery - static Real64 CurrentEndTime; // end time of current time step - static Real64 CurrentEndTimeLast; // end time of last time step - static Real64 TimeStepSysLast; // system time step on last time step Real64 SUMultiplier; // multiplier for simulating mode changes Real64 CondPower; // condenser power [W] Real64 CondCapacity; // condenser heat rejection [W] @@ -5106,9 +5106,6 @@ namespace HVACVariableRefrigerantFlow { int TUListIndex; // pointer to TU list for this VRF system int IndexToTUInTUList; // index to TU in TerminalUnilList Real64 RhoAir; // air density at InNode - static Real64 CurrentEndTime; // end time of current time step - static Real64 CurrentEndTimeLast; // end time of last time step - static Real64 TimeStepSysLast; // system time step on last time step Real64 TempOutput; // Sensible output of TU Real64 LoadToCoolingSP; // thermostat load to cooling setpoint (W) Real64 LoadToHeatingSP; // thermostat load to heating setpoint (W) @@ -10210,9 +10207,6 @@ namespace HVACVariableRefrigerantFlow { Real64 HRCapTC; // Time constant used to recover from initial degradation in cooling heat recovery Real64 HRInitialEIRFrac; // Fractional cooling degradation at the start of heat recovery from cooling mode Real64 HREIRTC; // Time constant used to recover from initial degradation in cooling heat recovery - static Real64 CurrentEndTime; // end time of current time step - static Real64 CurrentEndTimeLast; // end time of last time step - static Real64 TimeStepSysLast; // system time step on last time step Real64 SUMultiplier; // multiplier for simulating mode changes Real64 CondPower; // condenser power [W] Real64 CondCapacity; // condenser heat rejection [W] From 469d49d31ff7d819eb6eea50f4ac8004bcc2be86 Mon Sep 17 00:00:00 2001 From: Jermy Thomas Date: Wed, 14 Oct 2020 13:36:56 -0600 Subject: [PATCH 2/2] Hotfix #7723 revert + Add flag to reset CurrentEndTimeLast when InitVRF is not called The unit test will work without Hotfix #7723. Not sure if multiple condensors will work. The HRTime, HRTimer variables still exist. --- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 13 +++++++++++++ .../unit/HVACVariableRefrigerantFlow.unit.cc | 14 +++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 6eca20489a5..e93f11a5ec0 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -223,6 +223,7 @@ namespace HVACVariableRefrigerantFlow { Real64 CurrentEndTime; // end time of current time step Real64 CurrentEndTimeLast; // end time of last time step Real64 TimeStepSysLast; // system time step on last time step + bool HasInitVRFbeenCalledFlag(false); // To find if CurrentEndTimeLast was initialized, checks if InitVRF function has been called // Object Data Array1D VRF; // AirConditioner:VariableRefrigerantFlow object @@ -346,6 +347,7 @@ namespace HVACVariableRefrigerantFlow { // Initialize terminal unit InitVRF(state, VRFTUNum, ZoneNum, FirstHVACIteration, OnOffAirFlowRatio, QZnReq); // Initialize all VRFTU related parameters + HasInitVRFbeenCalledFlag = true; // Flag for InitVRF // Simulate terminal unit SimVRF(state, VRFTUNum, FirstHVACIteration, OnOffAirFlowRatio, SysOutputProvided, LatOutputProvided, QZnReq); @@ -388,6 +390,7 @@ namespace HVACVariableRefrigerantFlow { if (VRF(VRFCondenser).CondenserType == DataHVACGlobals::WaterCooled) UpdateVRFCondenser(VRFCondenser); } + HasInitVRFbeenCalledFlag = false; // Resetting this flag to false, for unit tests to reset CurrentEndTimeLast to 0.0 } PlantComponent *VRFCondenserEquipment::factory(EnergyPlusData &state, std::string const &objectName) @@ -1001,6 +1004,11 @@ namespace HVACVariableRefrigerantFlow { Real64 HREIRAdjustment = 1.0; if (!DoingSizing && !WarmupFlag) { + + if (!HasInitVRFbeenCalledFlag) { // If the CurrentEndTimeLast has not been set yet: + CurrentEndTimeLast = 0.0; + } + if (HRHeatRequestFlag && HRCoolRequestFlag) { // determine operating mode change if (!VRF(VRFCond).HRCoolingActive && !VRF(VRFCond).HRHeatingActive) { @@ -11220,6 +11228,11 @@ namespace HVACVariableRefrigerantFlow { HRCapTC = 0.0; HREIRTC = 0.0; if (!DoingSizing && !WarmupFlag) { + + if (!HasInitVRFbeenCalledFlag) { // If the CurrentEndTimeLast has not been set yet: + CurrentEndTimeLast = 0.0; + } + if (HRHeatRequestFlag && HRCoolRequestFlag) { // Simultaneous Heating and Cooling operations for HR system // determine operating mode change: (1) ModeChange (2) HRCoolingActive (3) HRHeatingActive if (!this->HRCoolingActive && !this->HRHeatingActive) { diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index 11d233dad37..9867abaad82 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -13109,7 +13109,7 @@ TEST_F(EnergyPlusFixture, VRFTest_CondenserCalcTest_HREIRFTHeat) } // set up environment - DataGlobals::DayOfSim = 2; // user a higher day than previous unit test to get around static timer variables problem + DataGlobals::DayOfSim = 1; // revert hotfix 7723 // user a higher day than previous unit test to get around static timer variables problem DataGlobals::CurrentTime = 0.25; DataGlobals::TimeStepZone = 0.25; DataHVACGlobals::TimeStepSys = 0.25; @@ -13119,12 +13119,12 @@ TEST_F(EnergyPlusFixture, VRFTest_CondenserCalcTest_HREIRFTHeat) DataEnvironment::OutBaroPress = 101325.0; DataEnvironment::OutWetBulbTemp = 21.1340575; - // call with zero loads to reset CurrentEndTimeLast until that's resolved - TerminalUnitList(1).TotalCoolLoad = 0.0; - TerminalUnitList(1).HRCoolRequest = false; - TerminalUnitList(1).TotalHeatLoad = 0.0; - TerminalUnitList(1).HRHeatRequest = false; - CalcVRFCondenser(state, VRFCond); + // revert hotfix 7723 // call with zero loads to reset CurrentEndTimeLast until that's resolved + //TerminalUnitList(1).TotalCoolLoad = 0.0; + //TerminalUnitList(1).HRCoolRequest = false; + //TerminalUnitList(1).TotalHeatLoad = 0.0; + //TerminalUnitList(1).HRHeatRequest = false; + //CalcVRFCondenser(state, VRFCond); // increment time step DataGlobals::CurrentTime += DataGlobals::TimeStepZone; // 0.5