From b7b900ecde5abcfdaa232726a85f5b2dd12590f0 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Fri, 12 Mar 2021 08:51:18 -0700 Subject: [PATCH] move HVACControllers to state --- src/EnergyPlus/FaultsManager.cc | 12 +- src/EnergyPlus/HVACControllers.cc | 184 ++++++++++-------- src/EnergyPlus/HVACControllers.hh | 53 ++--- src/EnergyPlus/MixedAir.cc | 9 +- src/EnergyPlus/SimAirServingZones.cc | 8 +- src/EnergyPlus/StateManagement.cc | 2 - tst/EnergyPlus/unit/FaultsManager.unit.cc | 4 +- tst/EnergyPlus/unit/HVACControllers.unit.cc | 56 +++--- .../unit/OASystemHWPreheatCoil.unit.cc | 4 +- 9 files changed, 177 insertions(+), 155 deletions(-) diff --git a/src/EnergyPlus/FaultsManager.cc b/src/EnergyPlus/FaultsManager.cc index 6605108fecb..966219c5ce9 100644 --- a/src/EnergyPlus/FaultsManager.cc +++ b/src/EnergyPlus/FaultsManager.cc @@ -873,13 +873,13 @@ namespace FaultsManager { ErrorsFound = true; } // Read in controller input if not done yet - if (HVACControllers::GetControllerInputFlag) { + if (state.dataHVACControllers->GetControllerInputFlag) { HVACControllers::GetControllerInput(state); - HVACControllers::GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } // Check the controller name int ControlNum = UtilityRoutines::FindItemInList(state.dataFaultsMgr->FaultsCoilSATSensor(jFault_CoilSAT).WaterCoilControllerName, - HVACControllers::ControllerProps, + state.dataHVACControllers->ControllerProps, &HVACControllers::ControllerPropsType::ControllerName); if (ControlNum <= 0) { ShowSevereError(state, cFaultCurrentObject + " = \"" + cAlphaArgs(1) + "\" invalid " + cAlphaFieldNames(6) + " = \"" + @@ -887,11 +887,11 @@ namespace FaultsManager { ErrorsFound = true; } else { // Link the controller with the fault model - HVACControllers::ControllerProps(ControlNum).FaultyCoilSATFlag = true; - HVACControllers::ControllerProps(ControlNum).FaultyCoilSATIndex = jFault_CoilSAT; + state.dataHVACControllers->ControllerProps(ControlNum).FaultyCoilSATFlag = true; + state.dataHVACControllers->ControllerProps(ControlNum).FaultyCoilSATIndex = jFault_CoilSAT; // Check whether the controller match the coil - if (HVACControllers::ControllerProps(ControlNum).SensedNode != state.dataWaterCoils->WaterCoil(CoilNum).AirOutletNodeNum) { + if (state.dataHVACControllers->ControllerProps(ControlNum).SensedNode != state.dataWaterCoils->WaterCoil(CoilNum).AirOutletNodeNum) { ShowSevereError(state, cFaultCurrentObject + " = \"" + cAlphaArgs(1) + "\" invalid " + cAlphaFieldNames(6) + " = \"" + cAlphaArgs(6) + "\" does not match " + cAlphaFieldNames(5) + " = \"" + cAlphaArgs(5)); ErrorsFound = true; diff --git a/src/EnergyPlus/HVACControllers.cc b/src/EnergyPlus/HVACControllers.cc index 09d3db17a82..df3a0adc3ad 100644 --- a/src/EnergyPlus/HVACControllers.cc +++ b/src/EnergyPlus/HVACControllers.cc @@ -182,26 +182,6 @@ namespace EnergyPlus::HVACControllers { constexpr Real64 SomeFloatingPoint(1.0); int const NumSigDigits(PRECISION(SomeFloatingPoint)); - // MODULE VARIABLE DECLARATIONS: - int NumControllers(0); // The number of controllers found in the Input - int NumAirLoopStats(0); // Same size as NumPrimaryAirSys if controllers - // are defined, 0 otherwise. - // all controllers per air loop - Array1D_bool CheckEquipName; - - // Flag set to make sure you get input once - bool GetControllerInputFlag(true); - - // Object Data - Array1D ControllerProps; - Array1D RootFinders; - Array1D AirLoopStats; // Statistics array to analyze computational profile for - - namespace { - bool InitControllerOneTimeFlag(true); - bool InitControllerSetPointCheckFlag(true); - } // namespace - std::string ControlVariableTypes(iCtrl const &c) { switch (c) { @@ -219,21 +199,6 @@ namespace EnergyPlus::HVACControllers { return "no controller type found"; } - // Needed for unit tests, should not be normally called. - void clear_state() - { - NumControllers = 0; - NumAirLoopStats = 0; - GetControllerInputFlag = true; - InitControllerOneTimeFlag = true; - InitControllerSetPointCheckFlag = true; - - ControllerProps.deallocate(); - RootFinders.deallocate(); - AirLoopStats.deallocate(); - CheckEquipName.deallocate(); - } - void ManageControllers(EnergyPlusData &state, std::string const &ControllerName, int &ControllerIndex, @@ -278,10 +243,15 @@ namespace EnergyPlus::HVACControllers { int ControlNum; int ControllerType; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & NumControllers(state.dataHVACControllers->NumControllers); + auto & CheckEquipName(state.dataHVACControllers->CheckEquipName); + auto & RootFinders(state.dataHVACControllers->RootFinders); + // Obtains and Allocates Controller related parameters from input file - if (GetControllerInputFlag) { // First time subroutine has been entered + if (state.dataHVACControllers->GetControllerInputFlag) { // First time subroutine has been entered GetControllerInput(state); - GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } if (ControllerIndex == 0) { @@ -366,8 +336,8 @@ namespace EnergyPlus::HVACControllers { auto const SELECT_CASE_var(Operation); if (SELECT_CASE_var == iControllerOpColdStart) { // For temperature and humidity control reset humidity control override if it was set - if (HVACControllers::ControllerProps(ControlNum).HumRatCtrlOverride) { - HVACControllers::ControllerProps(ControlNum).HumRatCtrlOverride = false; + if (ControllerProps(ControlNum).HumRatCtrlOverride) { + ControllerProps(ControlNum).HumRatCtrlOverride = false; // Put the controller tolerance (offset) back to it's original value RootFinder::SetupRootFinder(state, RootFinders(ControlNum), @@ -423,7 +393,7 @@ namespace EnergyPlus::HVACControllers { auto const SELECT_CASE_var1(ControllerType); if (SELECT_CASE_var1 == ControllerSimple_Type) { // 'Controller:WaterCoil' CheckSimpleController(state, ControlNum, IsConvergedFlag); - SaveSimpleController(ControlNum, FirstHVACIteration, IsConvergedFlag); + SaveSimpleController(state, ControlNum, FirstHVACIteration, IsConvergedFlag); } else { ShowFatalError(state, "Invalid controller type in ManageControllers=" + ControllerProps(ControlNum).ControllerType); } @@ -535,6 +505,13 @@ namespace EnergyPlus::HVACControllers { bool NodeNotFound; // flag true if the sensor node is on the coil air outlet node bool EMSSetPointErrorFlag; // flag true is EMS is used to set node setpoints + auto & NumControllers(state.dataHVACControllers->NumControllers); + auto & NumAirLoopStats(state.dataHVACControllers->NumAirLoopStats); + auto & AirLoopStats(state.dataHVACControllers->AirLoopStats); + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + auto & CheckEquipName(state.dataHVACControllers->CheckEquipName); + // All the controllers are loaded into the same derived type, both the PI and Limit // These controllers are separate objects and loaded sequentially, but will // be retrieved by name as they are needed. @@ -788,6 +765,9 @@ namespace EnergyPlus::HVACControllers { int SensedNode; Real64 NoFlowResetValue; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + ActuatedNode = ControllerProps(ControlNum).ActuatedNode; SensedNode = ControllerProps(ControlNum).SensedNode; @@ -884,11 +864,17 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; int SensedNode; int ControllerIndex; - static Array1D_bool MyEnvrnFlag; - static Array1D_bool MySizeFlag; - static Array1D_bool MyPlantIndexsFlag; Real64 rho; // local fluid density + auto & NumControllers(state.dataHVACControllers->NumControllers); + auto & InitControllerOneTimeFlag(state.dataHVACControllers->InitControllerOneTimeFlag); + auto & InitControllerSetPointCheckFlag(state.dataHVACControllers->InitControllerSetPointCheckFlag); + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + auto & MyEnvrnFlag(state.dataHVACControllers->MyEnvrnFlag); + auto & MySizeFlag(state.dataHVACControllers->MySizeFlag); + auto & MyPlantIndexsFlag(state.dataHVACControllers->MyPlantIndexsFlag); + if (InitControllerOneTimeFlag) { MyEnvrnFlag.allocate(NumControllers); @@ -1104,7 +1090,7 @@ namespace EnergyPlus::HVACControllers { // ATolX: absolute tolerance for X variables | ATolY: absolute tolerance for // Y variables } else { - ShowFatalError(state, "InitController: Invalid controller action. Valid choices are \"Normal\" or \"Reverse\""); + ShowFatalError(state, R"(InitController: Invalid controller action. Valid choices are "Normal" or "Reverse")"); } } @@ -1281,6 +1267,8 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; // node number of actuated node int WaterCompNum; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + ActuatedNode = ControllerProps(ControlNum).ActuatedNode; if (ControllerProps(ControlNum).MaxVolFlowActuated == AutoSize) { @@ -1369,6 +1357,9 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; int SensedNode; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + // Increment counter ++ControllerProps(ControlNum).NumCalcCalls; @@ -1379,7 +1370,7 @@ namespace EnergyPlus::HVACControllers { // Check to see if the component is running; if not converged and return. This check will be done // by looking at the component mass flow rate at the sensed node. if (Node(SensedNode).MassFlowRate == 0.0) { - ExitCalcController(ControlNum, DataPrecisionGlobals::constant_zero, iModeOff, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, DataPrecisionGlobals::constant_zero, iModeOff, IsConvergedFlag, IsUpToDateFlag); return; } @@ -1485,6 +1476,9 @@ namespace EnergyPlus::HVACControllers { int PreviousSolutionMode; Real64 PreviousSolutionValue; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + // Obtain actuated and sensed nodes ActuatedNode = ControllerProps(ControlNum).ActuatedNode; SensedNode = ControllerProps(ControlNum).SensedNode; @@ -1542,17 +1536,17 @@ namespace EnergyPlus::HVACControllers { } else if ((SELECT_CASE_var == iStatus::OK) || (SELECT_CASE_var == iStatus::OKRoundOff)) { // Indicate convergence with base value (used to obtain DeltaSensed!) - ExitCalcController(ControlNum, RootFinders(ControlNum).XCandidate, iModeActive, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, RootFinders(ControlNum).XCandidate, iModeActive, IsConvergedFlag, IsUpToDateFlag); } else if (SELECT_CASE_var == iStatus::OKMin) { // Indicate convergence with min value // Should be the same as ControllerProps(ControlNum)%MinAvailActuated - ExitCalcController(ControlNum, RootFinders(ControlNum).MinPoint.X, iModeMinActive, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, RootFinders(ControlNum).MinPoint.X, iModeMinActive, IsConvergedFlag, IsUpToDateFlag); } else if (SELECT_CASE_var == iStatus::OKMax) { // Indicate convergence with max value // Should be the same as ControllerProps(ControlNum)%MaxAvailActuated - ExitCalcController(ControlNum, RootFinders(ControlNum).MaxPoint.X, iModeMaxActive, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, RootFinders(ControlNum).MaxPoint.X, iModeMaxActive, IsConvergedFlag, IsUpToDateFlag); } else if (SELECT_CASE_var == iStatus::ErrorSingular) { // Indicate inactive mode with min actuated value @@ -1562,7 +1556,7 @@ namespace EnergyPlus::HVACControllers { // with RootFinders(ControlNum)%MinPoint%X // which is the same as (see SUBROUTINE InitController) // ControllerProps(ControlNum)%MinAvailActuated - ExitCalcController(ControlNum, RootFinders(ControlNum).MinPoint.X, iModeInactive, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, RootFinders(ControlNum).MinPoint.X, iModeInactive, IsConvergedFlag, IsUpToDateFlag); // Abnormal case: should never happen } else if (SELECT_CASE_var == iStatus::ErrorRange) { @@ -1662,7 +1656,7 @@ namespace EnergyPlus::HVACControllers { } // Indicate convergence with min value // Should be the same as ControllerProps(ControlNum)%MaxAvailActuated - ExitCalcController(ControlNum, RootFinders(ControlNum).MaxPoint.X, iModeMaxActive, IsConvergedFlag, IsUpToDateFlag); + ExitCalcController(state, ControlNum, RootFinders(ControlNum).MaxPoint.X, iModeMaxActive, IsConvergedFlag, IsUpToDateFlag); } else { // Should never happen @@ -1698,6 +1692,9 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; int SensedNode; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + auto & RootFinders(state.dataHVACControllers->RootFinders); + // Obtain actuated and sensed nodes ActuatedNode = ControllerProps(ControlNum).ActuatedNode; SensedNode = ControllerProps(ControlNum).SensedNode; @@ -1709,7 +1706,7 @@ namespace EnergyPlus::HVACControllers { auto const SELECT_CASE_var(ControllerProps(ControlNum).Mode); if (SELECT_CASE_var == iModeOff) { // Check whether the component is running - // This check is perfomed by looking at the component mass flow rate at the sensed node. + // This check is performed by looking at the component mass flow rate at the sensed node. // Since the components have been simulated before getting here, if they are zero they should be OFF. if (Node(SensedNode).MassFlowRate == 0.0) { if (ControllerProps(ControlNum).ActuatedValue == 0.0) { @@ -1814,6 +1811,8 @@ namespace EnergyPlus::HVACControllers { CheckMinActiveController = false; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Check that actuated value is the min avail actuated value if (ControllerProps(ControlNum).ActuatedValue != ControllerProps(ControlNum).MinAvailActuated) { CheckMinActiveController = false; @@ -1864,6 +1863,8 @@ namespace EnergyPlus::HVACControllers { CheckMaxActiveController = false; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Check that actuated value is the max avail actuated value if (ControllerProps(ControlNum).ActuatedValue != ControllerProps(ControlNum).MaxAvailActuated) { CheckMaxActiveController = false; @@ -1898,7 +1899,7 @@ namespace EnergyPlus::HVACControllers { return CheckMaxActiveController; } - void SaveSimpleController(int const ControlNum, bool const FirstHVACIteration, bool const IsConvergedFlag) + void SaveSimpleController(EnergyPlusData &state, int const ControlNum, bool const FirstHVACIteration, bool const IsConvergedFlag) { // SUBROUTINE INFORMATION: @@ -1913,6 +1914,8 @@ namespace EnergyPlus::HVACControllers { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int PreviousSolutionIndex; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Save solution and mode for next call only if converged if (IsConvergedFlag) { if (FirstHVACIteration) { @@ -1952,6 +1955,8 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; int SensedNode; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Set the sensed and actuated node numbers ActuatedNode = ControllerProps(ControlNum).ActuatedNode; SensedNode = ControllerProps(ControlNum).SensedNode; @@ -1978,7 +1983,7 @@ namespace EnergyPlus::HVACControllers { { { - auto &thisController(ControllerProps(ControlNum)); + auto &thisController(state.dataHVACControllers->ControllerProps(ControlNum)); if (IsConvergedFlag) { if (thisController.ControlVar == iCtrl::TemperatureAndHumidityRatio) { // For temperature and humidity control, after temperature control is converged, check if humidity setpoint is met @@ -1991,7 +1996,7 @@ namespace EnergyPlus::HVACControllers { if (thisController.Action == iReverseAction) { // Cooling coil controller should always be ReverseAction, but skip this if not RootFinder::SetupRootFinder(state, - RootFinders(ControlNum), + state.dataHVACControllers->RootFinders(ControlNum), iSlopeDecreasing, DataRootFinder::iMethod::FalsePosition, DataPrecisionGlobals::constant_zero, @@ -2007,7 +2012,7 @@ namespace EnergyPlus::HVACControllers { } } - void ExitCalcController(int const ControlNum, Real64 const NextActuatedValue, int const Mode, bool &IsConvergedFlag, bool &IsUpToDateFlag) + void ExitCalcController(EnergyPlusData &state, int const ControlNum, Real64 const NextActuatedValue, int const Mode, bool &IsConvergedFlag, bool &IsUpToDateFlag) { // SUBROUTINE INFORMATION: @@ -2027,6 +2032,8 @@ namespace EnergyPlus::HVACControllers { // - IsConvergedFlag // - IsUpToDateFlag + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + ControllerProps(ControlNum).NextActuatedValue = NextActuatedValue; ControllerProps(ControlNum).Mode = Mode; IsConvergedFlag = true; @@ -2070,10 +2077,12 @@ namespace EnergyPlus::HVACControllers { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ControllerNum; - // If no controllers on this air loop then we have nothig to do + auto & AirLoopStats(state.dataHVACControllers->AirLoopStats); + + // If no controllers on this air loop then we have nothing to do if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumControllers == 0) return; // To avoid tracking statistics in case of no air loop or no HVAC controllers are defined - if (NumAirLoopStats == 0) return; + if (state.dataHVACControllers->NumAirLoopStats == 0) return; // Update performance statistics for air loop ++AirLoopStats(AirLoopNum).NumCalls; @@ -2129,6 +2138,9 @@ namespace EnergyPlus::HVACControllers { // Current operating mode int Mode; + auto & AirLoopStats(state.dataHVACControllers->AirLoopStats); + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + ControlIndex = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).ControllerIndex(AirLoopControlNum); // We use NumCalcCalls instead of the iteration counter used in SolveAirLoopControllers() @@ -2175,7 +2187,7 @@ namespace EnergyPlus::HVACControllers { // note that the AirLoopStats object does not seem to be initialized when this code // is executed and it causes a crash here for (int AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { - WriteAirLoopStatistics(statisticsFile, state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum), AirLoopStats(AirLoopNum)); + WriteAirLoopStatistics(statisticsFile, state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum), state.dataHVACControllers->AirLoopStats(AirLoopNum)); } } @@ -2322,6 +2334,8 @@ namespace EnergyPlus::HVACControllers { // Open main controller trace file for each air loop const auto TraceFileName = "controller." + state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Name + ".csv"; + auto & AirLoopStats(state.dataHVACControllers->AirLoopStats); + // Store file unit in air loop stats AirLoopStats(AirLoopNum).TraceFile->fileName = TraceFileName; AirLoopStats(AirLoopNum).TraceFile->open(); @@ -2387,10 +2401,12 @@ namespace EnergyPlus::HVACControllers { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ControllerNum; + auto & AirLoopStats(state.dataHVACControllers->AirLoopStats); + // IF no controllers on this air loop then we have nothing to do if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumControllers == 0) return; // To avoid tracking statistics in case of no air loop or no HVAC controllers are defined - if (NumAirLoopStats == 0) return; + if (state.dataHVACControllers->NumAirLoopStats == 0) return; // Setup trace file on first call only if (AirLoopStats(AirLoopNum).FirstTraceFlag) { @@ -2408,7 +2424,7 @@ namespace EnergyPlus::HVACControllers { // Loop over the air sys controllers and write diagnostic to trace file for (ControllerNum = 1; ControllerNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumControllers; ++ControllerNum) { - TraceAirLoopController(TraceFile, state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).ControllerIndex(ControllerNum)); + TraceAirLoopController(state, TraceFile, state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).ControllerIndex(ControllerNum)); } // Go to next line @@ -2458,7 +2474,7 @@ namespace EnergyPlus::HVACControllers { LogicalToInteger(AirLoopConverged)); } - void TraceAirLoopController(InputOutputFile &TraceFile, int const ControlNum) + void TraceAirLoopController(EnergyPlusData &state, InputOutputFile &TraceFile, int const ControlNum) { // SUBROUTINE INFORMATION: @@ -2475,6 +2491,8 @@ namespace EnergyPlus::HVACControllers { int ActuatedNode; int SensedNode; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Set the sensed and actuated node numbers ActuatedNode = ControllerProps(ControlNum).ActuatedNode; SensedNode = ControllerProps(ControlNum).SensedNode; @@ -2503,6 +2521,8 @@ namespace EnergyPlus::HVACControllers { using RootFinder::WriteRootFinderTraceHeader; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + const auto TraceFileName = "controller." + ControllerProps(ControlNum).ControllerName + ".csv"; auto &TraceFile = *ControllerProps(ControlNum).TraceFile; TraceFile.fileName = TraceFileName; @@ -2553,6 +2573,8 @@ namespace EnergyPlus::HVACControllers { int SensedNode; bool SkipLineFlag; + auto & ControllerProps(state.dataHVACControllers->ControllerProps); + // Setup individual trace file on first trace only if (ControllerProps(ControlNum).FirstTraceFlag) { SetupIndividualControllerTracer(state, ControlNum); @@ -2635,7 +2657,7 @@ namespace EnergyPlus::HVACControllers { // X | Y | setpoint | DeltaSensed = Y - YRoot | Offset | Mode | IsConvergedFlag // Append trace for root finder - WriteRootFinderTrace(TraceFile, RootFinders(ControlNum)); + WriteRootFinderTrace(TraceFile, state.dataHVACControllers->RootFinders(ControlNum)); // Finally skip line print(TraceFile, "\n"); @@ -2803,9 +2825,9 @@ namespace EnergyPlus::HVACControllers { if (UtilityRoutines::SameString(state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).ControllerType(ContrlNum), "CONTROLLER:WATERCOIL")) { ++SensedNodeIndex; foundControl = UtilityRoutines::FindItemInList( - state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).ControllerName(ContrlNum), ControllerProps, &ControllerPropsType::ControllerName); + state.dataAirSystemsData->PrimaryAirSystems(AirSysNum).ControllerName(ContrlNum), state.dataHVACControllers->ControllerProps, &ControllerPropsType::ControllerName); if (foundControl > 0) { - ContrlSensedNodeNums(1, SensedNodeIndex) = ControllerProps(foundControl).SensedNode; + ContrlSensedNodeNums(1, SensedNodeIndex) = state.dataHVACControllers->ControllerProps(foundControl).SensedNode; } } } @@ -2872,14 +2894,14 @@ namespace EnergyPlus::HVACControllers { // FUNCTION LOCAL VARIABLE DECLARATIONS: int ControlNum; - if (GetControllerInputFlag) { + if (state.dataHVACControllers->GetControllerInputFlag) { GetControllerInput(state); - GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } NodeNotFound = true; - for (ControlNum = 1; ControlNum <= NumControllers; ++ControlNum) { - if (ControllerProps(ControlNum).ActuatedNode == WaterInletNodeNum) { + for (ControlNum = 1; ControlNum <= state.dataHVACControllers->NumControllers; ++ControlNum) { + if (state.dataHVACControllers->ControllerProps(ControlNum).ActuatedNode == WaterInletNodeNum) { NodeNotFound = false; } } @@ -2904,17 +2926,17 @@ namespace EnergyPlus::HVACControllers { // FUNCTION LOCAL VARIABLE DECLARATIONS: int ControlNum; - if (GetControllerInputFlag) { + if (state.dataHVACControllers->GetControllerInputFlag) { GetControllerInput(state); - GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } ControllerName = " "; ControllerIndex = 0; - for (ControlNum = 1; ControlNum <= NumControllers; ++ControlNum) { - if (ControllerProps(ControlNum).ActuatedNode == WaterInletNodeNum) { + for (ControlNum = 1; ControlNum <= state.dataHVACControllers->NumControllers; ++ControlNum) { + if (state.dataHVACControllers->ControllerProps(ControlNum).ActuatedNode == WaterInletNodeNum) { ControllerIndex = ControlNum; - ControllerName = ControllerProps(ControlNum).ControllerName; + ControllerName = state.dataHVACControllers->ControllerProps(ControlNum).ControllerName; break; } } @@ -2943,15 +2965,15 @@ namespace EnergyPlus::HVACControllers { // FUNCTION LOCAL VARIABLE DECLARATIONS: int ControlNum; - if (GetControllerInputFlag) { + if (state.dataHVACControllers->GetControllerInputFlag) { GetControllerInput(state); - GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } NodeNotFound = true; - ControlNum = UtilityRoutines::FindItemInList(ControllerName, ControllerProps, &ControllerPropsType::ControllerName); - if (ControlNum > 0 && ControlNum <= NumControllers) { - WaterInletNodeNum = ControllerProps(ControlNum).ActuatedNode; + ControlNum = UtilityRoutines::FindItemInList(ControllerName, state.dataHVACControllers->ControllerProps, &ControllerPropsType::ControllerName); + if (ControlNum > 0 && ControlNum <= state.dataHVACControllers->NumControllers) { + WaterInletNodeNum = state.dataHVACControllers->ControllerProps(ControlNum).ActuatedNode; NodeNotFound = false; } } @@ -2966,12 +2988,12 @@ namespace EnergyPlus::HVACControllers { // This subroutine finds the controllers actuator node number - if (GetControllerInputFlag) { + if (state.dataHVACControllers->GetControllerInputFlag) { GetControllerInput(state); - GetControllerInputFlag = false; + state.dataHVACControllers->GetControllerInputFlag = false; } - int ControllerIndex = UtilityRoutines::FindItemInList(ControllerName, ControllerProps, &ControllerPropsType::ControllerName); + int ControllerIndex = UtilityRoutines::FindItemInList(ControllerName, state.dataHVACControllers->ControllerProps, &ControllerPropsType::ControllerName); if (ControllerIndex == 0) { ShowFatalError(state, "ManageControllers: Invalid controller=" + ControllerName + ". The only valid controller type for an AirLoopHVAC is Controller:WaterCoil."); diff --git a/src/EnergyPlus/HVACControllers.hh b/src/EnergyPlus/HVACControllers.hh index d354ea5930e..11a7050726a 100644 --- a/src/EnergyPlus/HVACControllers.hh +++ b/src/EnergyPlus/HVACControllers.hh @@ -94,18 +94,6 @@ namespace HVACControllers { Heating, }; - // MODULE VARIABLE DECLARATIONS: - extern int NumControllers; // The number of controllers found in the Input - extern int NumAirLoopStats; // Same size as NumPrimaryAirSys if controllers - // are defined, 0 otherwise. - // all controllers per air loop - extern Array1D_bool CheckEquipName; - - // Flag set to make sure you get input once - extern bool GetControllerInputFlag; - - // Types - struct SolutionTrackerType { // Members @@ -264,16 +252,6 @@ namespace HVACControllers { } }; - // Object Data - extern Array1D ControllerProps; - extern Array1D RootFinders; - extern Array1D AirLoopStats; // Statistics array to analyze computational profile for - - // Functions - - // Needed for unit tests, should not be normally called. - void clear_state(); - void ManageControllers(EnergyPlusData &state, std::string const &ControllerName, int &ControllerIndex, @@ -317,11 +295,11 @@ namespace HVACControllers { void CheckTempAndHumRatCtrl(EnergyPlusData &state, int ControlNum, bool &IsConvergedFlag); - void SaveSimpleController(int ControlNum, bool FirstHVACIteration, bool IsConvergedFlag); + void SaveSimpleController(EnergyPlusData &state, int ControlNum, bool FirstHVACIteration, bool IsConvergedFlag); void UpdateController(EnergyPlusData &state, int ControlNum); - void ExitCalcController(int ControlNum, Real64 NextActuatedValue, int Mode, bool &IsConvergedFlag, bool &IsUpToDateFlag); + void ExitCalcController(EnergyPlusData &state, int ControlNum, Real64 NextActuatedValue, int Mode, bool &IsConvergedFlag, bool &IsUpToDateFlag); void TrackAirLoopControllers( EnergyPlusData &state, int AirLoopNum, int WarmRestartStatus, int AirLoopIterMax, int AirLoopIterTot, int AirLoopNumCalls); @@ -345,7 +323,7 @@ namespace HVACControllers { void TraceIterationStamp( EnergyPlusData &state, InputOutputFile &TraceFile, bool FirstHVACIteration, int AirLoopPass, bool AirLoopConverged, int AirLoopNumCalls); - void TraceAirLoopController(InputOutputFile &TraceFile, int ControlNum); + void TraceAirLoopController(EnergyPlusData &state, InputOutputFile &TraceFile, int ControlNum); void SetupIndividualControllerTracer(EnergyPlusData &state, int ControlNum); @@ -390,9 +368,34 @@ namespace HVACControllers { struct HVACControllersData : BaseGlobalStruct { + int NumControllers = 0; // The number of controllers found in the Input + int NumAirLoopStats = 0; // Same size as NumPrimaryAirSys if controllers + Array1D_bool CheckEquipName; + bool GetControllerInputFlag = true; + bool InitControllerOneTimeFlag = true; + bool InitControllerSetPointCheckFlag = true; + Array1D ControllerProps; + Array1D RootFinders; + Array1D AirLoopStats; // Statistics array to analyze computational profile for + Array1D_bool MyEnvrnFlag; + Array1D_bool MySizeFlag; + Array1D_bool MyPlantIndexsFlag; + void clear_state() override { + this->NumControllers = 0; + this->NumAirLoopStats = 0; + this->CheckEquipName.deallocate(); + this->GetControllerInputFlag = true; + this->InitControllerOneTimeFlag = true; + this->InitControllerSetPointCheckFlag = true; + this->ControllerProps.deallocate(); + this->RootFinders.deallocate(); + this->AirLoopStats.deallocate(); + this->MyEnvrnFlag.deallocate(); + this->MySizeFlag.deallocate(); + this->MyPlantIndexsFlag.deallocate(); } }; diff --git a/src/EnergyPlus/MixedAir.cc b/src/EnergyPlus/MixedAir.cc index 8b66fa6118b..b71f632242f 100644 --- a/src/EnergyPlus/MixedAir.cc +++ b/src/EnergyPlus/MixedAir.cc @@ -407,7 +407,6 @@ namespace EnergyPlus::MixedAir { using HeatingCoils::SimulateHeatingCoilComponents; using HeatRecovery::SimHeatRecovery; using Humidifiers::SimHumidifier; - using HVACControllers::ControllerProps; using HVACDXHeatPumpSystem::SimDXHeatPumpSystem; using HVACDXSystem::SimDXCoolingSystem; using HVACHXAssistedCoolingCoil::HXAssistedCoil; @@ -478,7 +477,7 @@ namespace EnergyPlus::MixedAir { state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex, false); // set flag to tell HVAC controller it will be simulated only in SolveWaterCoilController() - ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; + state.dataHVACControllers->ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; } OACoolingCoil = true; } else if (SELECT_CASE_var == WaterCoil_SimpleHeat) { // 'Coil:Heating:Water') @@ -495,7 +494,7 @@ namespace EnergyPlus::MixedAir { state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex, false); // set flag to tell HVAC controller it will be simulated only in SolveWaterCoilController() - ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; + state.dataHVACControllers->ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; } OAHeatingCoil = true; } else if (SELECT_CASE_var == SteamCoil_AirHeat) { // 'Coil:Heating:Steam' @@ -517,7 +516,7 @@ namespace EnergyPlus::MixedAir { state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex, false); // set flag to tell HVAC controller it will be simulated only in SolveWaterCoilController() - ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; + state.dataHVACControllers->ControllerProps(state.dataWaterCoils->WaterCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; } OACoolingCoil = true; } else if (SELECT_CASE_var == Coil_ElectricHeat) { // 'Coil:Heating:Electric' @@ -546,7 +545,7 @@ namespace EnergyPlus::MixedAir { HXAssistedCoil(CompIndex).ControllerIndex, true); // set flag to tell HVAC controller it will be simulated only in SolveWaterCoilController() - ControllerProps(HXAssistedCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; + state.dataHVACControllers->ControllerProps(HXAssistedCoil(CompIndex).ControllerIndex).BypassControllerCalc = true; } OACoolingCoil = true; } else if (SELECT_CASE_var == DXSystem) { // CoilSystem:Cooling:DX old 'AirLoopHVAC:UnitaryCoolOnly' diff --git a/src/EnergyPlus/SimAirServingZones.cc b/src/EnergyPlus/SimAirServingZones.cc index 7c001bea995..d909a849653 100644 --- a/src/EnergyPlus/SimAirServingZones.cc +++ b/src/EnergyPlus/SimAirServingZones.cc @@ -2840,7 +2840,7 @@ namespace EnergyPlus::SimAirServingZones { for (int AirLoopControlNum = 1; AirLoopControlNum <= PrimaryAirSystems(AirLoopNum).NumControllers; ++AirLoopControlNum) { PrimaryAirSystems(AirLoopNum).ControllerIndex(AirLoopControlNum) = HVACControllers::GetControllerIndex(state, PrimaryAirSystems(AirLoopNum).ControllerName(AirLoopControlNum)); - HVACControllers::ControllerProps(PrimaryAirSystems(AirLoopNum).ControllerIndex(AirLoopControlNum)).AirLoopControllerIndex = + state.dataHVACControllers->ControllerProps(PrimaryAirSystems(AirLoopNum).ControllerIndex(AirLoopControlNum)).AirLoopControllerIndex = AirLoopControlNum; } // When using controllers, size air loop coils so ControllerProps (e.g., Min/Max Actuated) can be set @@ -3111,7 +3111,7 @@ namespace EnergyPlus::SimAirServingZones { // if the controller can be locked out by the economizer operation and the economizer is active, leave the controller inactive if (AirLoopCheck) { if (AirLoopControlInfo(AirLoopNum).EconoActive) { - if (PrimaryAirSystems(AirLoopNum).CanBeLockedOutByEcono(HVACControllers::ControllerProps(ControllerIndex).AirLoopControllerIndex)) { + if (PrimaryAirSystems(AirLoopNum).CanBeLockedOutByEcono(state.dataHVACControllers->ControllerProps(ControllerIndex).AirLoopControllerIndex)) { ControllerConvergedFlag = true; } } @@ -3133,7 +3133,7 @@ namespace EnergyPlus::SimAirServingZones { BypassOAController); if (AirLoopCheck) { - PrimaryAirSystems(AirLoopNum).ControlConverged(HVACControllers::ControllerProps(ControllerIndex).AirLoopControllerIndex) = + PrimaryAirSystems(AirLoopNum).ControlConverged(state.dataHVACControllers->ControllerProps(ControllerIndex).AirLoopControllerIndex) = ControllerConvergedFlag; } @@ -3196,7 +3196,7 @@ namespace EnergyPlus::SimAirServingZones { // pass convergence of OA system water coils back to SolveAirLoopControllers via PrimaryAirSystem().ControlConverged flag if (AirLoopCheck) { - PrimaryAirSystems(AirLoopNum).ControlConverged(HVACControllers::ControllerProps(ControllerIndex).AirLoopControllerIndex) = + PrimaryAirSystems(AirLoopNum).ControlConverged(state.dataHVACControllers->ControllerProps(ControllerIndex).AirLoopControllerIndex) = ControllerConvergedFlag; AirLoopControlInfo(AirLoopNum).ConvergedFlag = AirLoopControlInfo(AirLoopNum).ConvergedFlag && ControllerConvergedFlag; } diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 64793510914..74909dc57d9 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -80,7 +80,6 @@ #include #include #include -#include #include #include #include @@ -159,7 +158,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) HeatingCoils::clear_state(); HighTempRadiantSystem::clear_state(); Humidifiers::clear_state(); - HVACControllers::clear_state(); HVACCooledBeam::clear_state(); HVACDuct::clear_state(); HVACDXSystem::clear_state(); diff --git a/tst/EnergyPlus/unit/FaultsManager.unit.cc b/tst/EnergyPlus/unit/FaultsManager.unit.cc index 06838da7afe..876024d61ed 100644 --- a/tst/EnergyPlus/unit/FaultsManager.unit.cc +++ b/tst/EnergyPlus/unit/FaultsManager.unit.cc @@ -467,8 +467,8 @@ TEST_F(EnergyPlusFixture, FaultsManager_TemperatureSensorOffset_CoilSAT) // Check EXPECT_EQ(2.0, state->dataFaultsMgr->FaultsCoilSATSensor(1).Offset); EXPECT_EQ("COIL:COOLING:WATER", state->dataFaultsMgr->FaultsCoilSATSensor(1).CoilType); - EXPECT_TRUE(HVACControllers::ControllerProps(1).FaultyCoilSATFlag); - EXPECT_EQ(1, HVACControllers::ControllerProps(1).FaultyCoilSATIndex); + EXPECT_TRUE(state->dataHVACControllers->ControllerProps(1).FaultyCoilSATFlag); + EXPECT_EQ(1, state->dataHVACControllers->ControllerProps(1).FaultyCoilSATIndex); } TEST_F(EnergyPlusFixture, FaultsManager_FaultChillerSWTSensor_CalFaultChillerSWT) diff --git a/tst/EnergyPlus/unit/HVACControllers.unit.cc b/tst/EnergyPlus/unit/HVACControllers.unit.cc index 527f4d23e46..ddfae3c1bcd 100644 --- a/tst/EnergyPlus/unit/HVACControllers.unit.cc +++ b/tst/EnergyPlus/unit/HVACControllers.unit.cc @@ -139,13 +139,13 @@ TEST_F(EnergyPlusFixture, HVACControllers_ResetHumidityRatioCtrlVarType) // check control variable type in AllSetPtMgr is reset to "MaximumHumidityRatio" ASSERT_EQ(iCtrlVarType::MaxHumRat, state->dataSetPointManager->AllSetPtMgr(1).CtrlTypeMode); - // ControllerProps always expects the control variable type to be "HumididtyRatio" - ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, ControllerProps(1).SensedNode); - ASSERT_EQ(iCtrlVarType::HumRat, ControllerProps(1).HumRatCntrlType); + // ControllerProps always expects the control variable type to be "HumidityRatio" + state->dataHVACControllers->ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, state->dataHVACControllers->ControllerProps(1).SensedNode); + ASSERT_EQ(iCtrlVarType::HumRat, state->dataHVACControllers->ControllerProps(1).HumRatCntrlType); - ASSERT_EQ(ControllerProps.size(), 1u); - EXPECT_EQ(ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); - EXPECT_EQ(ControllerProps(1).Offset, DataSizing::AutoSize); + ASSERT_EQ(state->dataHVACControllers->ControllerProps.size(), 1u); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).Offset, DataSizing::AutoSize); } TEST_F(EnergyPlusFixture, HVACControllers_TestTempAndHumidityRatioCtrlVarType) @@ -212,12 +212,12 @@ TEST_F(EnergyPlusFixture, HVACControllers_TestTempAndHumidityRatioCtrlVarType) ASSERT_EQ(iCtrlVarType::MaxHumRat, state->dataSetPointManager->AllSetPtMgr(1).CtrlTypeMode); // ControllerProps expects the control variable type to be "MaximumHumididtyRatio" - ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, ControllerProps(1).SensedNode); - ASSERT_EQ(iCtrlVarType::MaxHumRat, ControllerProps(1).HumRatCntrlType); + state->dataHVACControllers->ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, state->dataHVACControllers->ControllerProps(1).SensedNode); + ASSERT_EQ(iCtrlVarType::MaxHumRat, state->dataHVACControllers->ControllerProps(1).HumRatCntrlType); // test index for air loop controllers // before controllers are simulated, AirLoopControllerIndex = 0 - ASSERT_EQ(0, ControllerProps(1).AirLoopControllerIndex); + ASSERT_EQ(0, state->dataHVACControllers->ControllerProps(1).AirLoopControllerIndex); OutputReportPredefined::SetPredefinedTables(*state); state->dataSimAirServingZones->GetAirLoopInputFlag = false; @@ -272,7 +272,7 @@ TEST_F(EnergyPlusFixture, HVACControllers_TestTempAndHumidityRatioCtrlVarType) // after controllers are simulated, AirLoopControllerIndex = index to this controller on this air loop (e.g., n of num contollers on air loop) ASSERT_EQ(1, state->dataAirSystemsData->PrimaryAirSystems(1).NumControllers); ASSERT_EQ(1, state->dataAirSystemsData->PrimaryAirSystems(1).ControllerIndex(1)); - ASSERT_EQ(1, ControllerProps(1).AirLoopControllerIndex); + ASSERT_EQ(1, state->dataHVACControllers->ControllerProps(1).AirLoopControllerIndex); } TEST_F(EnergyPlusFixture, HVACControllers_SchSetPointMgrsOrderTest) @@ -360,8 +360,8 @@ TEST_F(EnergyPlusFixture, HVACControllers_SchSetPointMgrsOrderTest) GetControllerInput(*state); // check ControllerProps control variable is set to "MaximumHumidityRatio" - ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, ControllerProps(1).SensedNode); - ASSERT_EQ(iCtrlVarType::MaxHumRat, ControllerProps(1).HumRatCntrlType); // MaximumHumidityRatio + state->dataHVACControllers->ControllerProps(1).HumRatCntrlType = GetHumidityRatioVariableType(*state, state->dataHVACControllers->ControllerProps(1).SensedNode); + ASSERT_EQ(iCtrlVarType::MaxHumRat, state->dataHVACControllers->ControllerProps(1).HumRatCntrlType); // MaximumHumidityRatio } TEST_F(EnergyPlusFixture, HVACControllers_WaterCoilOnPrimaryLoopCheckTest) @@ -691,11 +691,11 @@ TEST_F(EnergyPlusFixture, HVACControllers_CoilSystemCoolingWaterOnOutsideAirSyst } TEST_F(EnergyPlusFixture, HVACControllers_CheckTempAndHumRatCtrl) { - HVACControllers::ControllerProps.allocate(1); - HVACControllers::RootFinders.allocate(1); + state->dataHVACControllers->ControllerProps.allocate(1); + state->dataHVACControllers->RootFinders.allocate(1); bool isConverged = true; int const controlNum = 1; - auto &thisController(ControllerProps(1)); + auto &thisController(state->dataHVACControllers->ControllerProps(1)); thisController.ControlVar = HVACControllers::iCtrl::TemperatureAndHumidityRatio; thisController.Offset = 0.0001; int sensedNode = 1; @@ -843,10 +843,10 @@ TEST_F(EnergyPlusFixture, HVACControllers_BlankAutosized) GetControllerInput(*state); - ASSERT_EQ(ControllerProps.size(), 1u); - EXPECT_EQ(ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); - EXPECT_EQ(ControllerProps(1).Offset, DataSizing::AutoSize); - EXPECT_EQ(ControllerProps(1).MinVolFlowActuated, 0.0); + ASSERT_EQ(state->dataHVACControllers->ControllerProps.size(), 1u); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).Offset, DataSizing::AutoSize); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MinVolFlowActuated, 0.0); } TEST_F(EnergyPlusFixture, HVACControllers_MaxFlowZero) @@ -918,14 +918,14 @@ TEST_F(EnergyPlusFixture, HVACControllers_MaxFlowZero) GetControllerInput(*state); - ASSERT_EQ(ControllerProps.size(), 1u); - EXPECT_EQ(ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); - EXPECT_EQ(ControllerProps(1).Offset, DataSizing::AutoSize); - EXPECT_EQ(ControllerProps(1).MinVolFlowActuated, 0.0); + ASSERT_EQ(state->dataHVACControllers->ControllerProps.size(), 1u); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MaxVolFlowActuated, DataSizing::AutoSize); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).Offset, DataSizing::AutoSize); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MinVolFlowActuated, 0.0); // test index for air loop controllers // before controllers are simulated, AirLoopControllerIndex = 0 - ASSERT_EQ(0, ControllerProps(1).AirLoopControllerIndex); + ASSERT_EQ(0, state->dataHVACControllers->ControllerProps(1).AirLoopControllerIndex); OutputReportPredefined::SetPredefinedTables(*state); state->dataSimAirServingZones->GetAirLoopInputFlag = false; @@ -1006,18 +1006,18 @@ TEST_F(EnergyPlusFixture, HVACControllers_MaxFlowZero) // after controllers are simulated, AirLoopControllerIndex = index to this controller on this air loop (e.g., n of num contollers on air loop) ASSERT_EQ(1, state->dataAirSystemsData->PrimaryAirSystems(1).NumControllers); ASSERT_EQ(1, state->dataAirSystemsData->PrimaryAirSystems(1).ControllerIndex(1)); - ASSERT_EQ(1, ControllerProps(1).AirLoopControllerIndex); + ASSERT_EQ(1, state->dataHVACControllers->ControllerProps(1).AirLoopControllerIndex); // This should have been autosized to zero - EXPECT_EQ(ControllerProps(1).MaxVolFlowActuated, 0.0); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MaxVolFlowActuated, 0.0); // This should have been reset to zero - EXPECT_EQ(ControllerProps(1).MinVolFlowActuated, 0.0); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).MinVolFlowActuated, 0.0); Real64 expectedOffset = (0.001 / (2100.0 * DataHVACGlobals::SmallWaterVolFlow)) * (DataConvergParams::HVACEnergyToler / 10.0); // do not let the controller tolerance exceed 1/10 of the loop temperature tolerance. expectedOffset = min(0.1 * DataConvergParams::HVACTemperatureToler, expectedOffset); EXPECT_EQ(expectedOffset, 0.1 * DataConvergParams::HVACTemperatureToler); - EXPECT_EQ(ControllerProps(1).Offset, expectedOffset); + EXPECT_EQ(state->dataHVACControllers->ControllerProps(1).Offset, expectedOffset); std::string const error_string = delimited_string({ " ** Warning ** InitController: Controller:WaterCoil=\"CW COIL CONTROLLER\", Maximum Actuated Flow is zero.", diff --git a/tst/EnergyPlus/unit/OASystemHWPreheatCoil.unit.cc b/tst/EnergyPlus/unit/OASystemHWPreheatCoil.unit.cc index 830039f4f84..c6f8edce601 100644 --- a/tst/EnergyPlus/unit/OASystemHWPreheatCoil.unit.cc +++ b/tst/EnergyPlus/unit/OASystemHWPreheatCoil.unit.cc @@ -2043,8 +2043,8 @@ TEST_F(EnergyPlusFixture, OASystem_HotWaterPreheatCoilScheduledOnSim) 1.0); // test that OA sys water coil bypasses normal controller calls before air loop simulation - EXPECT_EQ("PREHEAT COIL CONTROLLER", HVACControllers::ControllerProps(1).ControllerName); - EXPECT_TRUE(HVACControllers::ControllerProps(1).BypassControllerCalc); + EXPECT_EQ("PREHEAT COIL CONTROLLER", state->dataHVACControllers->ControllerProps(1).ControllerName); + EXPECT_TRUE(state->dataHVACControllers->ControllerProps(1).BypassControllerCalc); // test that water coil knows which controller controls the HW coil EXPECT_EQ(state->dataWaterCoils->WaterCoil(1).ControllerIndex, 1); }