From cfdf3205193a7b4a95d8cee78c3fdc40df313ee4 Mon Sep 17 00:00:00 2001 From: Jermy Thomas <45446967+jmythms@users.noreply.github.com> Date: Wed, 4 Nov 2020 11:23:26 -0700 Subject: [PATCH] Move static VRF variables to namespace (#8345) * Changing static variables to namesake variables Partial fix to #7729 * 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. * Revert "Hotfix #7723 revert + Add flag to reset CurrentEndTimeLast when InitVRF is not called" This reverts commit 469d49d31ff7d819eb6eea50f4ac8004bcc2be86. * Revert "Changing static variables to namesake variables" This reverts commit 67f7d2365a6993e3dac691382cb1bec4428122c0. * Removed static for CurrentEndTime + Removed TimeStepSysLast * Changed TimeStepSysLast to non-static * moved Real64 TimeStepSysLast; to namespace To try to get rid of build errors * Changed two of the CurrentEndTimeLast to non-static * trying to fix the condensor function * Change Final static variable to namespace Fingers crossed * Moving namespace variables to module level * Initialized variables Got build errors from uninitialized variables. Static variables are automatically zero initialized. Why were there no errors when they were in the namespace? * Removed and combine the three CurrentEndTimeLast Test if everything else working. * Resolve Conflict * Fixed license... * Split the InitVRF and CalcVRFCond CurrentEndTimeLast variables + code cleanup * Missed this variable rename. * Update clear_state() * Temp check * Code cleanup removed helper variables... * Comment + whitespace. --- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 3c7f82a9d0b..3fae24bf058 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -199,6 +199,7 @@ namespace HVACVariableRefrigerantFlow { Real64 LoopDXCoolCoilRTF(0.0); // holds value of DX cooling coil RTF Real64 LoopDXHeatCoilRTF(0.0); // holds value of DX heating coil RTF Real64 CondenserWaterMassFlowRate(0.0); // VRF water-cooled condenser mass flow rate (kg/s) + Real64 CurrentEndTimeLast; // end time of last time step Array1D_bool HeatingLoad; // defines a heating load on VRFTerminalUnits Array1D_bool CoolingLoad; // defines a cooling load on VRFTerminalUnits Array1D_bool LastModeHeating; // defines last mode was heating mode @@ -515,9 +516,7 @@ 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 CurrentEndTime; // end time of current time step Real64 SUMultiplier; // multiplier for simulating mode changes Real64 CondPower; // condenser power [W] Real64 CondCapacity; // condenser heat rejection [W] @@ -1119,7 +1118,7 @@ namespace HVACVariableRefrigerantFlow { VRF(VRFCond).HRTimer = 0.0; } - // calculate end time of current time step to determine if max capacity reset is required + // Calculate the capacity modification factor (SUMultiplier) for the HR mode transition period CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + CurrentTime - TimeStepZone + DataHVACGlobals::SysTimeElapsed; if (VRF(VRFCond).ModeChange || VRF(VRFCond).HRModeChange) { @@ -1146,7 +1145,6 @@ namespace HVACVariableRefrigerantFlow { } VRF(VRFCond).SUMultiplier = SUMultiplier; - TimeStepSysLast = DataHVACGlobals::TimeStepSys; CurrentEndTimeLast = CurrentEndTime; if (VRF(VRFCond).HeatRecoveryUsed && VRF(VRFCond).HRCoolingActive) { @@ -5062,8 +5060,7 @@ namespace HVACVariableRefrigerantFlow { } } - void - InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool const FirstHVACIteration, Real64 &OnOffAirFlowRatio, Real64 &QZnReq) + void InitVRF(EnergyPlusData &state, int const VRFTUNum, int const ZoneNum, bool const FirstHVACIteration, Real64 &OnOffAirFlowRatio, Real64 &QZnReq) { // SUBROUTINE INFORMATION: @@ -5111,9 +5108,8 @@ 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 CurrentEndTime; // end time of current time step + Real64 TimeStepSysLast(0.0); // 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) @@ -6236,7 +6232,7 @@ namespace HVACVariableRefrigerantFlow { } // IF(MyVRFFlag(VRFTUNum))THEN // calculate end time of current time step to determine if max capacity reset is required - CurrentEndTime = CurrentTime + DataHVACGlobals::SysTimeElapsed; + CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + CurrentTime - TimeStepZone + DataHVACGlobals::SysTimeElapsed; // Initialize the maximum allowed terminal unit capacity. Total terminal unit capacity must not // exceed the available condenser capacity. This variable is used to limit the terminal units @@ -10212,9 +10208,7 @@ 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 CurrentEndTime; // end time of current time step Real64 SUMultiplier; // multiplier for simulating mode changes Real64 CondPower; // condenser power [W] Real64 CondCapacity; // condenser heat rejection [W] @@ -11277,7 +11271,6 @@ namespace HVACVariableRefrigerantFlow { // Calculate the capacity modification factor (SUMultiplier) for the HR mode transition period { - // calculate end time of current time step to determine if max capacity reset is required CurrentEndTime = double((state.dataGlobal->DayOfSim - 1) * 24) + CurrentTime - TimeStepZone + DataHVACGlobals::SysTimeElapsed; if (this->ModeChange || this->HRModeChange) { @@ -11304,7 +11297,6 @@ namespace HVACVariableRefrigerantFlow { } this->SUMultiplier = SUMultiplier; - TimeStepSysLast = DataHVACGlobals::TimeStepSys; CurrentEndTimeLast = CurrentEndTime; } @@ -14550,12 +14542,11 @@ namespace HVACVariableRefrigerantFlow { LoopDXCoolCoilRTF = 0.0; LoopDXHeatCoilRTF = 0.0; CondenserWaterMassFlowRate = 0.0; - + CurrentEndTimeLast = 0.0; GetVRFInputFlag = true; MyOneTimeFlag = true; MyOneTimeSizeFlag = true; ZoneEquipmentListNotChecked = true; - VRF.deallocate(); VrfUniqueNames.clear(); VRFTU.deallocate();