Skip to content

Commit

Permalink
Hotfix #7723 revert + Add flag to reset CurrentEndTimeLast when InitV…
Browse files Browse the repository at this point in the history
…RF is not called

The unit test will work without Hotfix #7723.

Not sure if multiple condensors will work.
The HRTime, HRTimer variables still exist.
  • Loading branch information
jmythms committed Oct 14, 2020
1 parent 83db52b commit 469d49d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/EnergyPlus/HVACVariableRefrigerantFlow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<VRFCondenserEquipment> VRF; // AirConditioner:VariableRefrigerantFlow object
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 469d49d

Please sign in to comment.