Skip to content

Commit

Permalink
Move static VRF variables to namespace (#8345)
Browse files Browse the repository at this point in the history
* 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 469d49d.

* Revert "Changing static variables to namesake variables"

This reverts commit 67f7d23.

* 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.
  • Loading branch information
jmythms authored Nov 4, 2020
1 parent fb8d228 commit cfdf320
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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) {
Expand All @@ -1146,7 +1145,6 @@ namespace HVACVariableRefrigerantFlow {
}
VRF(VRFCond).SUMultiplier = SUMultiplier;

TimeStepSysLast = DataHVACGlobals::TimeStepSys;
CurrentEndTimeLast = CurrentEndTime;

if (VRF(VRFCond).HeatRecoveryUsed && VRF(VRFCond).HRCoolingActive) {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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) {
Expand All @@ -11304,7 +11297,6 @@ namespace HVACVariableRefrigerantFlow {
}
this->SUMultiplier = SUMultiplier;

TimeStepSysLast = DataHVACGlobals::TimeStepSys;
CurrentEndTimeLast = CurrentEndTime;
}

Expand Down Expand Up @@ -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();
Expand Down

5 comments on commit cfdf320

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jmythms) - x86_64-MacOS-10.15-clang-11.0.0: OK (2272 of 2272 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (2292 of 2292 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1553 of 1553 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jmythms) - Win64-Windows-10-VisualStudio-16: OK (2245 of 2245 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (jmythms) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (722 of 722 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.