From 733f969ffd0ea22df8b5d2be325b162e3f520c91 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 10:45:00 -0600 Subject: [PATCH 01/10] Global HVACManager --- src/EnergyPlus/HVACManager.cc | 4930 +++++++++++++++-------------- src/EnergyPlus/HVACManager.hh | 45 +- src/EnergyPlus/StateManagement.cc | 2 - 3 files changed, 2595 insertions(+), 2382 deletions(-) diff --git a/src/EnergyPlus/HVACManager.cc b/src/EnergyPlus/HVACManager.cc index 256e50573fc..8d2d2580b46 100644 --- a/src/EnergyPlus/HVACManager.cc +++ b/src/EnergyPlus/HVACManager.cc @@ -105,672 +105,690 @@ namespace EnergyPlus::HVACManager { - // PURPOSE OF THIS MODULE: - // This module contains the high level HVAC control - // subroutines. Subroutine ManageHVAC, which is called from the heat balance, - // calls the HVAC simulation and is the most probable insertion point for - // connections to other HVAC engines. ManageHVAC also controls the system - // timestep, automatically shortening the timestep to meet convergence criteria. +// PURPOSE OF THIS MODULE: +// This module contains the high level HVAC control +// subroutines. Subroutine ManageHVAC, which is called from the heat balance, +// calls the HVAC simulation and is the most probable insertion point for +// connections to other HVAC engines. ManageHVAC also controls the system +// timestep, automatically shortening the timestep to meet convergence criteria. + +// METHODOLOGY EMPLOYED: +// The basic solution technique is iteration with lagging. +// The timestep is shortened using a bisection method. + +using namespace DataEnvironment; + +using DataHeatBalFanSys::iCorrectStep; +using DataHeatBalFanSys::iGetZoneSetPoints; +using DataHeatBalFanSys::iPredictStep; +using DataHeatBalFanSys::iPushSystemTimestepHistories; +using DataHeatBalFanSys::iPushZoneTimestepHistories; +using DataHeatBalFanSys::iRevertZoneTimestepHistories; +using namespace DataHVACGlobals; +using namespace DataLoopNode; +using namespace DataAirLoop; + +void ManageHVAC(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHORS: Russ Taylor, Dan Fisher + // DATE WRITTEN: Jan. 1998 + // MODIFIED Jul 2003 (CC) added a subroutine call for air models + // RE-ENGINEERED May 2008, Brent Griffith, revised variable time step method and zone conditions history + + // PURPOSE OF THIS SUBROUTINE: + // This routine effectively replaces the IBLAST + // "SystemDriver" routine. The main function of the routine + // is to set the system timestep, "TimeStepSys", call the models related to zone + // air temperatures, and . // METHODOLOGY EMPLOYED: - // The basic solution technique is iteration with lagging. - // The timestep is shortened using a bisection method. - - using namespace DataEnvironment; - - using DataHeatBalFanSys::iCorrectStep; - using DataHeatBalFanSys::iGetZoneSetPoints; - using DataHeatBalFanSys::iPredictStep; - using DataHeatBalFanSys::iPushSystemTimestepHistories; - using DataHeatBalFanSys::iPushZoneTimestepHistories; - using DataHeatBalFanSys::iRevertZoneTimestepHistories; - using namespace DataHVACGlobals; - using namespace DataLoopNode; - using namespace DataAirLoop; - - int HVACManageIteration(0); // counts iterations to enforce maximum iteration limit - int RepIterAir(0); - - namespace { - // These were static variables within different functions. They were pulled out into the namespace - // to facilitate easier unit testing of those functions. - // These are purposefully not in the header file as an extern variable. No one outside of this should - // use these. They are cleared by clear_state() for use by unit tests, but normal simulations should be unaffected. - // This is purposefully in an anonymous namespace so nothing outside this implementation file can use it. - bool SimHVACIterSetup(false); - bool TriggerGetAFN(true); - bool ReportAirHeatBalanceFirstTimeFlag(true); - bool MyOneTimeFlag(true); - bool PrintedWarmup(false); - bool MyEnvrnFlag(true); - bool DebugNamesReported(false); - bool MySetPointInit(true); - bool MyEnvrnFlag2(true); - bool FlowMaxAvailAlreadyReset(false); - bool FlowResolutionNeeded(false); - } // namespace - - // Functions - void clear_state() - { - HVACManageIteration = 0; - RepIterAir = 0; - SimHVACIterSetup = false; - TriggerGetAFN = true; - ReportAirHeatBalanceFirstTimeFlag = true; - MyOneTimeFlag = true; - PrintedWarmup = false; - MyEnvrnFlag = true; - DebugNamesReported = false; - MySetPointInit = true; - MyEnvrnFlag2 = true; - FlowMaxAvailAlreadyReset = false; - FlowResolutionNeeded = false; + // manage calls to Predictor and Corrector and other updates in ZoneTempPredictorCorrector + // manage variable time step and when zone air histories are updated. + + // Using/Aliasing + using AirflowNetworkBalanceManager::ManageAirflowNetworkBalance; + using DemandManager::ManageDemand; + using DemandManager::UpdateDemandManagers; + using EMSManager::ManageEMS; + using InternalHeatGains::UpdateInternalGainValues; + using NodeInputManager::CalcMoreNodeInfo; + using OutAirNodeManager::SetOutAirNodes; + using OutputReportTabular::GatherComponentLoadsHVAC; + using OutputReportTabular::UpdateTabularReports; // added for writing tabular output reports + using PollutionModule::CalculatePollution; + using RefrigeratedCase::ManageRefrigeratedCaseRacks; + using ScheduleManager::GetCurrentScheduleValue; + using SizingManager::UpdateFacilitySizing; + using SystemAvailabilityManager::ManageHybridVentilation; + using SystemReports::InitEnergyReports; + using SystemReports::ReportMaxVentilationLoads; + using SystemReports::ReportSystemEnergyUse; + using WaterManager::ManageWater; + using WaterManager::ManageWaterInits; + using ZoneContaminantPredictorCorrector::ManageZoneContaminanUpdates; + using ZoneEquipmentManager::CalcAirFlowSimple; + using ZoneEquipmentManager::UpdateZoneSizing; + using ZoneTempPredictorCorrector::DetectOscillatingZoneTemp; + using ZoneTempPredictorCorrector::ManageZoneAirUpdates; + + // SUBROUTINE PARAMETER DEFINITIONS: + static constexpr auto EndOfHeaderString("End of Data Dictionary"); // End of data dictionary marker + static constexpr auto EnvironmentStampFormatStr("{},{},{:7.2F},{:7.2F},{:7.2F},{:7.2F}\n"); // Format descriptor for environ stamp + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + Real64 PriorTimeStep; // magnitude of time step for previous history terms + Real64 ZoneTempChange(0.0); // change in zone air temperature from timestep t-1 to t + int NodeNum; + bool ReportDebug; + int ZoneNum; + + static int ZTempTrendsNumSysSteps(0); + static int SysTimestepLoop(0); + bool DummyLogical; + + // Formats + + // SYSTEM INITIALIZATION + if (state.dataHVACMgr->TriggerGetAFN) { + state.dataHVACMgr->TriggerGetAFN = false; + DisplayString(state, "Initializing HVAC"); + ManageAirflowNetworkBalance(state); // first call only gets input and returns. } - void ManageHVAC(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHORS: Russ Taylor, Dan Fisher - // DATE WRITTEN: Jan. 1998 - // MODIFIED Jul 2003 (CC) added a subroutine call for air models - // RE-ENGINEERED May 2008, Brent Griffith, revised variable time step method and zone conditions history - - // PURPOSE OF THIS SUBROUTINE: - // This routine effectively replaces the IBLAST - // "SystemDriver" routine. The main function of the routine - // is to set the system timestep, "TimeStepSys", call the models related to zone - // air temperatures, and . - - // METHODOLOGY EMPLOYED: - // manage calls to Predictor and Corrector and other updates in ZoneTempPredictorCorrector - // manage variable time step and when zone air histories are updated. - - // Using/Aliasing - using ZoneTempPredictorCorrector::DetectOscillatingZoneTemp; - using ZoneTempPredictorCorrector::ManageZoneAirUpdates; - using AirflowNetworkBalanceManager::ManageAirflowNetworkBalance; - using DemandManager::ManageDemand; - using DemandManager::UpdateDemandManagers; - using EMSManager::ManageEMS; - using InternalHeatGains::UpdateInternalGainValues; - using NodeInputManager::CalcMoreNodeInfo; - using OutAirNodeManager::SetOutAirNodes; - using OutputReportTabular::GatherComponentLoadsHVAC; - using OutputReportTabular::UpdateTabularReports; // added for writing tabular output reports - using PollutionModule::CalculatePollution; - using RefrigeratedCase::ManageRefrigeratedCaseRacks; - using ScheduleManager::GetCurrentScheduleValue; - using SizingManager::UpdateFacilitySizing; - using SystemAvailabilityManager::ManageHybridVentilation; - using SystemReports::InitEnergyReports; - using SystemReports::ReportMaxVentilationLoads; - using SystemReports::ReportSystemEnergyUse; - using WaterManager::ManageWater; - using WaterManager::ManageWaterInits; - using ZoneContaminantPredictorCorrector::ManageZoneContaminanUpdates; - using ZoneEquipmentManager::CalcAirFlowSimple; - using ZoneEquipmentManager::UpdateZoneSizing; - - // SUBROUTINE PARAMETER DEFINITIONS: - static constexpr auto EndOfHeaderString("End of Data Dictionary"); // End of data dictionary marker - static constexpr auto EnvironmentStampFormatStr("{},{},{:7.2F},{:7.2F},{:7.2F},{:7.2F}\n"); // Format descriptor for environ stamp - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 PriorTimeStep; // magnitude of time step for previous history terms - Real64 ZoneTempChange(0.0); // change in zone air temperature from timestep t-1 to t - int NodeNum; - bool ReportDebug; - int ZoneNum; - - static int ZTempTrendsNumSysSteps(0); - static int SysTimestepLoop(0); - bool DummyLogical; - - // Formats - - // SYSTEM INITIALIZATION - if (TriggerGetAFN) { - TriggerGetAFN = false; - DisplayString(state, "Initializing HVAC"); - ManageAirflowNetworkBalance(state); // first call only gets input and returns. - } - - state.dataHeatBalFanSys->ZT = state.dataHeatBalFanSys->MAT; - // save for use with thermal comfort control models (Fang, Pierce, and KSU) - state.dataHeatBalFanSys->ZTAVComf = state.dataHeatBalFanSys->ZTAV; - state.dataHeatBalFanSys->ZoneAirHumRatAvgComf = state.dataHeatBalFanSys->ZoneAirHumRatAvg; - state.dataHeatBalFanSys->ZTAV = 0.0; - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver = 0.0; - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver = 0.0; - state.dataHeatBalFanSys->ZoneAirHumRatAvg = 0.0; - PrintedWarmup = false; - if (state.dataContaminantBalance->Contaminant.CO2Simulation) { - state.dataContaminantBalance->OutdoorCO2 = GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr); - state.dataContaminantBalance->ZoneAirCO2Avg = 0.0; - } - if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { - state.dataContaminantBalance->OutdoorGC = GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr); - if (allocated(state.dataContaminantBalance->ZoneAirGCAvg)) state.dataContaminantBalance->ZoneAirGCAvg = 0.0; - } + state.dataHeatBalFanSys->ZT = state.dataHeatBalFanSys->MAT; + // save for use with thermal comfort control models (Fang, Pierce, and KSU) + state.dataHeatBalFanSys->ZTAVComf = state.dataHeatBalFanSys->ZTAV; + state.dataHeatBalFanSys->ZoneAirHumRatAvgComf = state.dataHeatBalFanSys->ZoneAirHumRatAvg; + state.dataHeatBalFanSys->ZTAV = 0.0; + state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver = 0.0; + state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver = 0.0; + state.dataHeatBalFanSys->ZoneAirHumRatAvg = 0.0; + state.dataHVACMgr->PrintedWarmup = false; + if (state.dataContaminantBalance->Contaminant.CO2Simulation) { + state.dataContaminantBalance->OutdoorCO2 = GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.CO2OutdoorSchedPtr); + state.dataContaminantBalance->ZoneAirCO2Avg = 0.0; + } + if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { + state.dataContaminantBalance->OutdoorGC = + GetCurrentScheduleValue(state, state.dataContaminantBalance->Contaminant.GenericContamOutdoorSchedPtr); + if (allocated(state.dataContaminantBalance->ZoneAirGCAvg)) state.dataContaminantBalance->ZoneAirGCAvg = 0.0; + } - if (state.dataGlobal->BeginEnvrnFlag && MyEnvrnFlag) { - AirLoopsSimOnce = false; - MyEnvrnFlag = false; - NumOfSysTimeStepsLastZoneTimeStep = 1; - PreviousTimeStep = state.dataGlobal->TimeStepZone; - } - if (!state.dataGlobal->BeginEnvrnFlag) { - MyEnvrnFlag = true; - } + if (state.dataGlobal->BeginEnvrnFlag && state.dataHVACMgr->MyEnvrnFlag) { + AirLoopsSimOnce = false; + state.dataHVACMgr->MyEnvrnFlag = false; + NumOfSysTimeStepsLastZoneTimeStep = 1; + PreviousTimeStep = state.dataGlobal->TimeStepZone; + } + if (!state.dataGlobal->BeginEnvrnFlag) { + state.dataHVACMgr->MyEnvrnFlag = true; + } - state.dataHeatBalFanSys->QRadSurfAFNDuct = 0.0; - SysTimeElapsed = 0.0; - TimeStepSys = state.dataGlobal->TimeStepZone; - FirstTimeStepSysFlag = true; - ShortenTimeStepSys = false; - UseZoneTimeStepHistory = true; - PriorTimeStep = state.dataGlobal->TimeStepZone; - NumOfSysTimeSteps = 1; - FracTimeStepZone = TimeStepSys / state.dataGlobal->TimeStepZone; + state.dataHeatBalFanSys->QRadSurfAFNDuct = 0.0; + SysTimeElapsed = 0.0; + TimeStepSys = state.dataGlobal->TimeStepZone; + FirstTimeStepSysFlag = true; + ShortenTimeStepSys = false; + UseZoneTimeStepHistory = true; + PriorTimeStep = state.dataGlobal->TimeStepZone; + NumOfSysTimeSteps = 1; + FracTimeStepZone = TimeStepSys / state.dataGlobal->TimeStepZone; - bool anyEMSRan; - ManageEMS(state, EMSManager::EMSCallFrom::BeginTimestepBeforePredictor, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point + bool anyEMSRan; + ManageEMS(state, EMSManager::EMSCallFrom::BeginTimestepBeforePredictor, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point - SetOutAirNodes(state); + SetOutAirNodes(state); - ManageRefrigeratedCaseRacks(state); + ManageRefrigeratedCaseRacks(state); - // ZONE INITIALIZATION 'Get Zone Setpoints' - ManageZoneAirUpdates(state, iGetZoneSetPoints, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) - ManageZoneContaminanUpdates(state, iGetZoneSetPoints, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + // ZONE INITIALIZATION 'Get Zone Setpoints' + ManageZoneAirUpdates(state, iGetZoneSetPoints, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iGetZoneSetPoints, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - ManageHybridVentilation(state); + ManageHybridVentilation(state); - CalcAirFlowSimple(state); - if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { - AirflowNetwork::RollBackFlag = false; - ManageAirflowNetworkBalance(state, false); - } + CalcAirFlowSimple(state); + if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { + AirflowNetwork::RollBackFlag = false; + ManageAirflowNetworkBalance(state, false); + } - SetHeatToReturnAirFlag(state); + SetHeatToReturnAirFlag(state); - state.dataHeatBalFanSys->SysDepZoneLoadsLagged = state.dataHeatBalFanSys->SysDepZoneLoads; + state.dataHeatBalFanSys->SysDepZoneLoadsLagged = state.dataHeatBalFanSys->SysDepZoneLoads; - UpdateInternalGainValues(state, true, true); + UpdateInternalGainValues(state, true, true); - ManageZoneAirUpdates(state, iPredictStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + ManageZoneAirUpdates(state, iPredictStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) ManageZoneContaminanUpdates(state, iPredictStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iPredictStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - SimHVAC(state); + SimHVAC(state); - if (state.dataGlobal->AnyIdealCondEntSetPointInModel && state.dataGlobal->MetersHaveBeenInitialized && !state.dataGlobal->WarmupFlag) { - state.dataGlobal->RunOptCondEntTemp = true; - while (state.dataGlobal->RunOptCondEntTemp) { - SimHVAC(state); - } + if (state.dataGlobal->AnyIdealCondEntSetPointInModel && state.dataGlobal->MetersHaveBeenInitialized && !state.dataGlobal->WarmupFlag) { + state.dataGlobal->RunOptCondEntTemp = true; + while (state.dataGlobal->RunOptCondEntTemp) { + SimHVAC(state); } + } - ManageWaterInits(state); + ManageWaterInits(state); - // Only simulate once per zone timestep; must be after SimHVAC - if (FirstTimeStepSysFlag && state.dataGlobal->MetersHaveBeenInitialized) { - ManageDemand(state); - } + // Only simulate once per zone timestep; must be after SimHVAC + if (FirstTimeStepSysFlag && state.dataGlobal->MetersHaveBeenInitialized) { + ManageDemand(state); + } - state.dataGlobal->BeginTimeStepFlag = false; // At this point, we have been through the first pass through SimHVAC so this needs to be set - - ManageZoneAirUpdates(state, iCorrectStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) ManageZoneContaminanUpdates(state, iCorrectStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - - if (ZoneTempChange > state.dataConvergeParams->MaxZoneTempDiff && !state.dataGlobal->KickOffSimulation) { - // determine value of adaptive system time step - // model how many system timesteps we want in zone timestep - ZTempTrendsNumSysSteps = int(ZoneTempChange / state.dataConvergeParams->MaxZoneTempDiff + 1.0); // add 1 for truncation - NumOfSysTimeSteps = min(ZTempTrendsNumSysSteps, LimitNumSysSteps); - // then determine timestep length for even distribution, protect div by zero - if (NumOfSysTimeSteps > 0) TimeStepSys = state.dataGlobal->TimeStepZone / NumOfSysTimeSteps; - TimeStepSys = max(TimeStepSys, state.dataConvergeParams->MinTimeStepSys); - UseZoneTimeStepHistory = false; - ShortenTimeStepSys = true; - } else { - NumOfSysTimeSteps = 1; - UseZoneTimeStepHistory = true; - } + state.dataGlobal->BeginTimeStepFlag = false; // At this point, we have been through the first pass through SimHVAC so this needs to be set + + ManageZoneAirUpdates(state, iCorrectStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iCorrectStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + + if (ZoneTempChange > state.dataConvergeParams->MaxZoneTempDiff && !state.dataGlobal->KickOffSimulation) { + // determine value of adaptive system time step + // model how many system timesteps we want in zone timestep + ZTempTrendsNumSysSteps = int(ZoneTempChange / state.dataConvergeParams->MaxZoneTempDiff + 1.0); // add 1 for truncation + NumOfSysTimeSteps = min(ZTempTrendsNumSysSteps, LimitNumSysSteps); + // then determine timestep length for even distribution, protect div by zero + if (NumOfSysTimeSteps > 0) TimeStepSys = state.dataGlobal->TimeStepZone / NumOfSysTimeSteps; + TimeStepSys = max(TimeStepSys, state.dataConvergeParams->MinTimeStepSys); + UseZoneTimeStepHistory = false; + ShortenTimeStepSys = true; + } else { + NumOfSysTimeSteps = 1; + UseZoneTimeStepHistory = true; + } - if (UseZoneTimeStepHistory) PreviousTimeStep = state.dataGlobal->TimeStepZone; - for (SysTimestepLoop = 1; SysTimestepLoop <= NumOfSysTimeSteps; ++SysTimestepLoop) { - if (state.dataGlobal->stopSimulation) break; + if (UseZoneTimeStepHistory) PreviousTimeStep = state.dataGlobal->TimeStepZone; + for (SysTimestepLoop = 1; SysTimestepLoop <= NumOfSysTimeSteps; ++SysTimestepLoop) { + if (state.dataGlobal->stopSimulation) break; - if (TimeStepSys < state.dataGlobal->TimeStepZone) { + if (TimeStepSys < state.dataGlobal->TimeStepZone) { - ManageHybridVentilation(state); - CalcAirFlowSimple(state, SysTimestepLoop); - if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { - AirflowNetwork::RollBackFlag = false; - ManageAirflowNetworkBalance(state, false); - } + ManageHybridVentilation(state); + CalcAirFlowSimple(state, SysTimestepLoop); + if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { + AirflowNetwork::RollBackFlag = false; + ManageAirflowNetworkBalance(state, false); + } - UpdateInternalGainValues(state, true, true); + UpdateInternalGainValues(state, true, true); - ManageZoneAirUpdates(state, iPredictStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, - PriorTimeStep); + ManageZoneAirUpdates(state, iPredictStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) - ManageZoneContaminanUpdates(state, iPredictStep, ShortenTimeStepSys, UseZoneTimeStepHistory, - PriorTimeStep); - SimHVAC(state); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iPredictStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + SimHVAC(state); - if (state.dataGlobal->AnyIdealCondEntSetPointInModel && state.dataGlobal->MetersHaveBeenInitialized && !state.dataGlobal->WarmupFlag) { - state.dataGlobal->RunOptCondEntTemp = true; - while (state.dataGlobal->RunOptCondEntTemp) { - SimHVAC(state); - } + if (state.dataGlobal->AnyIdealCondEntSetPointInModel && state.dataGlobal->MetersHaveBeenInitialized && !state.dataGlobal->WarmupFlag) { + state.dataGlobal->RunOptCondEntTemp = true; + while (state.dataGlobal->RunOptCondEntTemp) { + SimHVAC(state); } + } - ManageWaterInits(state); + ManageWaterInits(state); - // Need to set the flag back since we do not need to shift the temps back again in the correct step. - ShortenTimeStepSys = false; + // Need to set the flag back since we do not need to shift the temps back again in the correct step. + ShortenTimeStepSys = false; - ManageZoneAirUpdates(state, iCorrectStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, - PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) - ManageZoneContaminanUpdates(state, iCorrectStep, ShortenTimeStepSys, UseZoneTimeStepHistory, - PriorTimeStep); + ManageZoneAirUpdates(state, iCorrectStep, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iCorrectStep, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - ManageZoneAirUpdates(state, iPushSystemTimestepHistories, ZoneTempChange, ShortenTimeStepSys, - UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) - ManageZoneContaminanUpdates(state, iPushSystemTimestepHistories, ShortenTimeStepSys, - UseZoneTimeStepHistory, PriorTimeStep); - PreviousTimeStep = TimeStepSys; - } + ManageZoneAirUpdates(state, iPushSystemTimestepHistories, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iPushSystemTimestepHistories, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + PreviousTimeStep = TimeStepSys; + } - FracTimeStepZone = TimeStepSys / state.dataGlobal->TimeStepZone; + FracTimeStepZone = TimeStepSys / state.dataGlobal->TimeStepZone; - for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - state.dataHeatBalFanSys->ZTAV(ZoneNum) += state.dataHeatBalFanSys->ZT(ZoneNum) * FracTimeStepZone; - state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneNum) += state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNum) * FracTimeStepZone; - if (state.dataContaminantBalance->Contaminant.CO2Simulation) state.dataContaminantBalance->ZoneAirCO2Avg(ZoneNum) += state.dataContaminantBalance->ZoneAirCO2(ZoneNum) * FracTimeStepZone; - if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) state.dataContaminantBalance->ZoneAirGCAvg(ZoneNum) += state.dataContaminantBalance->ZoneAirGC(ZoneNum) * FracTimeStepZone; - if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { - state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver(ZoneNum) += state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) * FracTimeStepZone; - state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver(ZoneNum) += state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) * FracTimeStepZone; - } + for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { + state.dataHeatBalFanSys->ZTAV(ZoneNum) += state.dataHeatBalFanSys->ZT(ZoneNum) * FracTimeStepZone; + state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneNum) += state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNum) * FracTimeStepZone; + if (state.dataContaminantBalance->Contaminant.CO2Simulation) + state.dataContaminantBalance->ZoneAirCO2Avg(ZoneNum) += state.dataContaminantBalance->ZoneAirCO2(ZoneNum) * FracTimeStepZone; + if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) + state.dataContaminantBalance->ZoneAirGCAvg(ZoneNum) += state.dataContaminantBalance->ZoneAirGC(ZoneNum) * FracTimeStepZone; + if (state.dataZoneTempPredictorCorrector->NumOnOffCtrZone > 0) { + state.dataHeatBalFanSys->ZoneThermostatSetPointHiAver(ZoneNum) += + state.dataHeatBalFanSys->ZoneThermostatSetPointHi(ZoneNum) * FracTimeStepZone; + state.dataHeatBalFanSys->ZoneThermostatSetPointLoAver(ZoneNum) += + state.dataHeatBalFanSys->ZoneThermostatSetPointLo(ZoneNum) * FracTimeStepZone; } + } - DetectOscillatingZoneTemp(state); - UpdateZoneListAndGroupLoads(state); // Must be called before UpdateDataandReport(OutputProcessor::TimeStepType::TimeStepSystem) - IceThermalStorage::UpdateIceFractions(state); // Update fraction of ice stored in TES - ManageWater(state); - // update electricity data for net, purchased, sold etc. - DummyLogical = false; - facilityElectricServiceObj->manageElectricPowerService(state, false, DummyLogical, true); + DetectOscillatingZoneTemp(state); + UpdateZoneListAndGroupLoads(state); // Must be called before UpdateDataandReport(OutputProcessor::TimeStepType::TimeStepSystem) + IceThermalStorage::UpdateIceFractions(state); // Update fraction of ice stored in TES + ManageWater(state); + // update electricity data for net, purchased, sold etc. + DummyLogical = false; + facilityElectricServiceObj->manageElectricPowerService(state, false, DummyLogical, true); - // Update the plant and condenser loop capacitance model temperature history. - PlantManager::UpdateNodeThermalHistory(state); + // Update the plant and condenser loop capacitance model temperature history. + PlantManager::UpdateNodeThermalHistory(state); - if (state.dataOutRptTab->displayHeatEmissionsSummary) { - OutputReportTabular::CalcHeatEmissionReport(state); - } + if (state.dataOutRptTab->displayHeatEmissionsSummary) { + OutputReportTabular::CalcHeatEmissionReport(state); + } - ManageEMS(state, EMSManager::EMSCallFrom::EndSystemTimestepBeforeHVACReporting, anyEMSRan, ObjexxFCL::Optional_int_const()); // EMS calling point + ManageEMS( + state, EMSManager::EMSCallFrom::EndSystemTimestepBeforeHVACReporting, anyEMSRan, ObjexxFCL::Optional_int_const()); // EMS calling point - // This is where output processor data is updated for System Timestep reporting - if (!state.dataGlobal->WarmupFlag) { - if (state.dataGlobal->DoOutputReporting) { - CalcMoreNodeInfo(state); - CalculatePollution(state); - InitEnergyReports(state); - ReportSystemEnergyUse(state); - } - if (state.dataGlobal->DoOutputReporting || (state.dataGlobal->ZoneSizingCalc && state.dataGlobal->CompLoadReportIsReq)) { - ReportAirHeatBalance(state); - if (state.dataGlobal->ZoneSizingCalc) GatherComponentLoadsHVAC(state); - } - if (state.dataGlobal->DoOutputReporting) { - ReportMaxVentilationLoads(state); - UpdateDataandReport(state, OutputProcessor::TimeStepType::TimeStepSystem); - if (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeDesignDay || state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeRunPeriodDesign) { - if (hvacSizingSimulationManager) hvacSizingSimulationManager->UpdateSizingLogsSystemStep(state); - } - UpdateTabularReports(state, OutputProcessor::TimeStepType::TimeStepSystem); - } - if (state.dataGlobal->ZoneSizingCalc) { - UpdateZoneSizing(state, DataGlobalConstants::CallIndicator::DuringDay); - UpdateFacilitySizing(state, DataGlobalConstants::CallIndicator::DuringDay); - } - EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::checkConcurrentOperation(state); - } else if (!state.dataGlobal->KickOffSimulation && state.dataGlobal->DoOutputReporting && state.dataSysVars->ReportDuringWarmup) { - if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) { - state.dataEnvrn->PrintEnvrnStampWarmup = true; - state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true; - } - if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false; - if (state.dataEnvrn->PrintEnvrnStampWarmup) { - if (state.dataReportFlag->PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !PrintedWarmup) { - print(state.files.eso, "{}\n", EndOfHeaderString); - print(state.files.mtr, "{}\n", EndOfHeaderString); - state.dataReportFlag->PrintEndDataDictionary = false; - } - if (state.dataGlobal->DoOutputReporting && !PrintedWarmup) { - - print(state.files.eso, - EnvironmentStampFormatStr, - "1", - "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, - state.dataEnvrn->Latitude, - state.dataEnvrn->Longitude, - state.dataEnvrn->TimeZoneNumber, - state.dataEnvrn->Elevation); - print(state.files.mtr, - EnvironmentStampFormatStr, - "1", - "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, - state.dataEnvrn->Latitude, - state.dataEnvrn->Longitude, - state.dataEnvrn->TimeZoneNumber, - state.dataEnvrn->Elevation); - state.dataEnvrn->PrintEnvrnStampWarmup = false; - } - PrintedWarmup = true; - } + // This is where output processor data is updated for System Timestep reporting + if (!state.dataGlobal->WarmupFlag) { + if (state.dataGlobal->DoOutputReporting) { CalcMoreNodeInfo(state); + CalculatePollution(state); + InitEnergyReports(state); + ReportSystemEnergyUse(state); + } + if (state.dataGlobal->DoOutputReporting || (state.dataGlobal->ZoneSizingCalc && state.dataGlobal->CompLoadReportIsReq)) { + ReportAirHeatBalance(state); + if (state.dataGlobal->ZoneSizingCalc) GatherComponentLoadsHVAC(state); + } + if (state.dataGlobal->DoOutputReporting) { + ReportMaxVentilationLoads(state); UpdateDataandReport(state, OutputProcessor::TimeStepType::TimeStepSystem); - if (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeDesignDay || state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeRunPeriodDesign) { + if (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeDesignDay || + state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeRunPeriodDesign) { if (hvacSizingSimulationManager) hvacSizingSimulationManager->UpdateSizingLogsSystemStep(state); } - } else if (state.dataSysVars->UpdateDataDuringWarmupExternalInterface) { // added for FMI - if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) { - state.dataEnvrn->PrintEnvrnStampWarmup = true; - state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true; + UpdateTabularReports(state, OutputProcessor::TimeStepType::TimeStepSystem); + } + if (state.dataGlobal->ZoneSizingCalc) { + UpdateZoneSizing(state, DataGlobalConstants::CallIndicator::DuringDay); + UpdateFacilitySizing(state, DataGlobalConstants::CallIndicator::DuringDay); + } + EIRPlantLoopHeatPumps::EIRPlantLoopHeatPump::checkConcurrentOperation(state); + } else if (!state.dataGlobal->KickOffSimulation && state.dataGlobal->DoOutputReporting && state.dataSysVars->ReportDuringWarmup) { + if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) { + state.dataEnvrn->PrintEnvrnStampWarmup = true; + state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true; + } + if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false; + if (state.dataEnvrn->PrintEnvrnStampWarmup) { + if (state.dataReportFlag->PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !state.dataHVACMgr->PrintedWarmup) { + print(state.files.eso, "{}\n", EndOfHeaderString); + print(state.files.mtr, "{}\n", EndOfHeaderString); + state.dataReportFlag->PrintEndDataDictionary = false; } - if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false; - if (state.dataEnvrn->PrintEnvrnStampWarmup) { - if (state.dataReportFlag->PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !PrintedWarmup) { - print(state.files.eso, "{}\n", EndOfHeaderString); - print(state.files.mtr, "{}\n", EndOfHeaderString); - state.dataReportFlag->PrintEndDataDictionary = false; - } - if (state.dataGlobal->DoOutputReporting && !PrintedWarmup) { - print(state.files.eso, - EnvironmentStampFormatStr, - "1", - "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, - state.dataEnvrn->Latitude, - state.dataEnvrn->Longitude, - state.dataEnvrn->TimeZoneNumber, - state.dataEnvrn->Elevation); - print(state.files.mtr, - EnvironmentStampFormatStr, - "1", - "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, - state.dataEnvrn->Latitude, - state.dataEnvrn->Longitude, - state.dataEnvrn->TimeZoneNumber, - state.dataEnvrn->Elevation); - state.dataEnvrn->PrintEnvrnStampWarmup = false; - } - PrintedWarmup = true; + if (state.dataGlobal->DoOutputReporting && !state.dataHVACMgr->PrintedWarmup) { + + print(state.files.eso, + EnvironmentStampFormatStr, + "1", + "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, + state.dataEnvrn->Latitude, + state.dataEnvrn->Longitude, + state.dataEnvrn->TimeZoneNumber, + state.dataEnvrn->Elevation); + print(state.files.mtr, + EnvironmentStampFormatStr, + "1", + "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, + state.dataEnvrn->Latitude, + state.dataEnvrn->Longitude, + state.dataEnvrn->TimeZoneNumber, + state.dataEnvrn->Elevation); + state.dataEnvrn->PrintEnvrnStampWarmup = false; } - UpdateDataandReport(state, OutputProcessor::TimeStepType::TimeStepSystem); + state.dataHVACMgr->PrintedWarmup = true; + } + CalcMoreNodeInfo(state); + UpdateDataandReport(state, OutputProcessor::TimeStepType::TimeStepSystem); + if (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeDesignDay || + state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::HVACSizeRunPeriodDesign) { + if (hvacSizingSimulationManager) hvacSizingSimulationManager->UpdateSizingLogsSystemStep(state); } - ManageEMS(state, EMSManager::EMSCallFrom::EndSystemTimestepAfterHVACReporting, anyEMSRan, ObjexxFCL::Optional_int_const()); // EMS calling point - // UPDATE SYSTEM CLOCKS - SysTimeElapsed += TimeStepSys; + } else if (state.dataSysVars->UpdateDataDuringWarmupExternalInterface) { // added for FMI + if (state.dataGlobal->BeginDayFlag && !state.dataEnvrn->PrintEnvrnStampWarmupPrinted) { + state.dataEnvrn->PrintEnvrnStampWarmup = true; + state.dataEnvrn->PrintEnvrnStampWarmupPrinted = true; + } + if (!state.dataGlobal->BeginDayFlag) state.dataEnvrn->PrintEnvrnStampWarmupPrinted = false; + if (state.dataEnvrn->PrintEnvrnStampWarmup) { + if (state.dataReportFlag->PrintEndDataDictionary && state.dataGlobal->DoOutputReporting && !state.dataHVACMgr->PrintedWarmup) { + print(state.files.eso, "{}\n", EndOfHeaderString); + print(state.files.mtr, "{}\n", EndOfHeaderString); + state.dataReportFlag->PrintEndDataDictionary = false; + } + if (state.dataGlobal->DoOutputReporting && !state.dataHVACMgr->PrintedWarmup) { + print(state.files.eso, + EnvironmentStampFormatStr, + "1", + "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, + state.dataEnvrn->Latitude, + state.dataEnvrn->Longitude, + state.dataEnvrn->TimeZoneNumber, + state.dataEnvrn->Elevation); + print(state.files.mtr, + EnvironmentStampFormatStr, + "1", + "Warmup {" + state.dataReportFlag->cWarmupDay + "} " + state.dataEnvrn->EnvironmentName, + state.dataEnvrn->Latitude, + state.dataEnvrn->Longitude, + state.dataEnvrn->TimeZoneNumber, + state.dataEnvrn->Elevation); + state.dataEnvrn->PrintEnvrnStampWarmup = false; + } + state.dataHVACMgr->PrintedWarmup = true; + } + UpdateDataandReport(state, OutputProcessor::TimeStepType::TimeStepSystem); + } + ManageEMS( + state, EMSManager::EMSCallFrom::EndSystemTimestepAfterHVACReporting, anyEMSRan, ObjexxFCL::Optional_int_const()); // EMS calling point + // UPDATE SYSTEM CLOCKS + SysTimeElapsed += TimeStepSys; - FirstTimeStepSysFlag = false; - } // system time step loop (loops once if no downstepping) + FirstTimeStepSysFlag = false; + } // system time step loop (loops once if no downstepping) - ManageZoneAirUpdates(state, iPushZoneTimestepHistories, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - if (state.dataContaminantBalance->Contaminant.SimulateContaminants) - ManageZoneContaminanUpdates(state, iPushZoneTimestepHistories, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + ManageZoneAirUpdates(state, iPushZoneTimestepHistories, ZoneTempChange, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); + if (state.dataContaminantBalance->Contaminant.SimulateContaminants) + ManageZoneContaminanUpdates(state, iPushZoneTimestepHistories, ShortenTimeStepSys, UseZoneTimeStepHistory, PriorTimeStep); - NumOfSysTimeStepsLastZoneTimeStep = NumOfSysTimeSteps; + NumOfSysTimeStepsLastZoneTimeStep = NumOfSysTimeSteps; - UpdateDemandManagers(state); + UpdateDemandManagers(state); - // DO FINAL UPDATE OF RECORD KEEPING VARIABLES - // Report the Node Data to Aid in Debugging - if (state.dataReportFlag->DebugOutput) { - if (state.dataReportFlag->EvenDuringWarmup) { - ReportDebug = true; - } else { - ReportDebug = !state.dataGlobal->WarmupFlag; - } - if ((ReportDebug) && (state.dataGlobal->DayOfSim > 0)) { // Report the node data - if (size(state.dataLoopNodes->Node) > 0 && !DebugNamesReported) { - print(state.files.debug, "{}\n", "node # Name"); - for (NodeNum = 1; NodeNum <= isize(state.dataLoopNodes->Node); ++NodeNum) { - print(state.files.debug, " {:3} {}\n", NodeNum, state.dataLoopNodes->NodeID(NodeNum)); - } - DebugNamesReported = true; - } - if (size(state.dataLoopNodes->Node) > 0) { - print(state.files.debug, "\n\n Day of Sim Hour of Day Time\n"); - print(state.files.debug, "{:12}{:12} {:22.15N} \n", state.dataGlobal->DayOfSim, state.dataGlobal->HourOfDay, state.dataGlobal->TimeStep * state.dataGlobal->TimeStepZone); - print(state.files.debug, - "{}\n", - "node # Temp MassMinAv MassMaxAv TempSP MassFlow MassMin MassMax MassSP Press " - "Enthal HumRat Fluid Type"); - } + // DO FINAL UPDATE OF RECORD KEEPING VARIABLES + // Report the Node Data to Aid in Debugging + if (state.dataReportFlag->DebugOutput) { + if (state.dataReportFlag->EvenDuringWarmup) { + ReportDebug = true; + } else { + ReportDebug = !state.dataGlobal->WarmupFlag; + } + if ((ReportDebug) && (state.dataGlobal->DayOfSim > 0)) { // Report the node data + if (size(state.dataLoopNodes->Node) > 0 && !state.dataHVACMgr->DebugNamesReported) { + print(state.files.debug, "{}\n", "node # Name"); for (NodeNum = 1; NodeNum <= isize(state.dataLoopNodes->Node); ++NodeNum) { - static constexpr auto Format_20{ - " {:3} {:8.2F} {:8.3F} {:8.3F} {:8.2F} {:13.2F} {:13.2F} {:13.2F} {:13.2F} {:#8.0F} {:11.2F} {:9.5F} {}\n"}; - - print(state.files.debug, - Format_20, - NodeNum, - state.dataLoopNodes->Node(NodeNum).Temp, - state.dataLoopNodes->Node(NodeNum).MassFlowRateMinAvail, - state.dataLoopNodes->Node(NodeNum).MassFlowRateMaxAvail, - state.dataLoopNodes->Node(NodeNum).TempSetPoint, - state.dataLoopNodes->Node(NodeNum).MassFlowRate, - state.dataLoopNodes->Node(NodeNum).MassFlowRateMin, - state.dataLoopNodes->Node(NodeNum).MassFlowRateMax, - state.dataLoopNodes->Node(NodeNum).MassFlowRateSetPoint, - state.dataLoopNodes->Node(NodeNum).Press, - state.dataLoopNodes->Node(NodeNum).Enthalpy, - state.dataLoopNodes->Node(NodeNum).HumRat, - DataLoopNode::ValidNodeFluidTypes(state.dataLoopNodes->Node(NodeNum).FluidType)); + print(state.files.debug, " {:3} {}\n", NodeNum, state.dataLoopNodes->NodeID(NodeNum)); } + state.dataHVACMgr->DebugNamesReported = true; } + if (size(state.dataLoopNodes->Node) > 0) { + print(state.files.debug, "\n\n Day of Sim Hour of Day Time\n"); + print(state.files.debug, + "{:12}{:12} {:22.15N} \n", + state.dataGlobal->DayOfSim, + state.dataGlobal->HourOfDay, + state.dataGlobal->TimeStep * state.dataGlobal->TimeStepZone); + print(state.files.debug, + "{}\n", + "node # Temp MassMinAv MassMaxAv TempSP MassFlow MassMin MassMax MassSP Press " + "Enthal HumRat Fluid Type"); + } + for (NodeNum = 1; NodeNum <= isize(state.dataLoopNodes->Node); ++NodeNum) { + static constexpr auto Format_20{ + " {:3} {:8.2F} {:8.3F} {:8.3F} {:8.2F} {:13.2F} {:13.2F} {:13.2F} {:13.2F} {:#8.0F} {:11.2F} {:9.5F} {}\n"}; + + print(state.files.debug, + Format_20, + NodeNum, + state.dataLoopNodes->Node(NodeNum).Temp, + state.dataLoopNodes->Node(NodeNum).MassFlowRateMinAvail, + state.dataLoopNodes->Node(NodeNum).MassFlowRateMaxAvail, + state.dataLoopNodes->Node(NodeNum).TempSetPoint, + state.dataLoopNodes->Node(NodeNum).MassFlowRate, + state.dataLoopNodes->Node(NodeNum).MassFlowRateMin, + state.dataLoopNodes->Node(NodeNum).MassFlowRateMax, + state.dataLoopNodes->Node(NodeNum).MassFlowRateSetPoint, + state.dataLoopNodes->Node(NodeNum).Press, + state.dataLoopNodes->Node(NodeNum).Enthalpy, + state.dataLoopNodes->Node(NodeNum).HumRat, + DataLoopNode::ValidNodeFluidTypes(state.dataLoopNodes->Node(NodeNum).FluidType)); + } + } + } +} + +void SimHVAC(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR: Dan Fisher + // DATE WRITTEN: April 1997 + // DATE MODIFIED: May 1998 (RKS,RDT) + + // PURPOSE OF THIS SUBROUTINE: Selects and calls the HVAC loop managers + + // METHODOLOGY EMPLOYED: Each loop manager is called or passed over + // in succession based on the logical flags associated with the manager. + // The logical flags are set in the manager routines and passed + // as parameters to this routine. Each loop manager potentially + // affects a different set of other loop managers. + + // Future development could involve specifying any number of user + // selectable control schemes based on the logical flags used in + // this default control algorithm. + + // Using/Aliasing + using DataPlant::ConvergenceHistoryARR; + using DataPlant::DemandSide; + using DataPlant::NumConvergenceHistoryTerms; + using DataPlant::square_sum_ConvergenceHistoryARR; + using DataPlant::sum_ConvergenceHistoryARR; + using DataPlant::sum_square_ConvergenceHistoryARR; + using DataPlant::SupplySide; + using EMSManager::ManageEMS; + using General::CreateSysTimeIntervalString; + using NonZoneEquipmentManager::ManageNonZoneEquipment; + using PlantCondLoopOperation::SetupPlantEMSActuators; + using PlantManager::GetPlantInput; + using PlantManager::GetPlantLoopData; + using PlantManager::InitOneTimePlantSizingInfo; + using PlantManager::ReInitPlantLoopsAtFirstHVACIteration; + using PlantManager::SetupBranchControlTypes; + using PlantManager::SetupInitialPlantCallingOrder; + using PlantManager::SetupReports; + using PlantUtilities::AnyPlantSplitterMixerLacksContinuity; + using PlantUtilities::CheckForRunawayPlantTemps; + using PlantUtilities::CheckPlantMixerSplitterConsistency; + using PlantUtilities::SetAllPlantSimFlagsToValue; + using SetPointManager::ManageSetPoints; + using SystemAvailabilityManager::ManageSystemAvailability; + using ZoneEquipmentManager::ManageZoneEquipment; + + // SUBROUTINE PARAMETER DEFINITIONS: + bool const SimWithPlantFlowUnlocked(false); + bool const SimWithPlantFlowLocked(true); + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + bool FirstHVACIteration; // True when solution technique on first iteration + static int ErrCount(0); // Number of times that the maximum iterations was exceeded + static int MaxErrCount(0); + static std::string ErrEnvironmentName; + int LoopNum; + int LoopSide; + int ThisLoopSide; + + int AirSysNum; + int StackDepth; + std::string HistoryTrace; + Real64 SlopeHumRat; + Real64 SlopeMdot; + Real64 SlopeTemps; + Real64 AvgValue; + bool FoundOscillationByDuplicate; + int ZoneNum; + int NodeIndex; + bool MonotonicIncreaseFound; + bool MonotonicDecreaseFound; + + Array1D const ConvergLogStackARR(DataConvergParams::ConvergLogStackDepth, {0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0}); + Real64 const sum_ConvergLogStackARR(sum(ConvergLogStackARR)); + Real64 const square_sum_ConvergLogStackARR(pow_2(sum_ConvergLogStackARR)); + Real64 const sum_square_ConvergLogStackARR(sum(pow(ConvergLogStackARR, 2))); + + // Initialize all of the simulation flags to true for the first iteration + SimZoneEquipmentFlag = true; + SimNonZoneEquipmentFlag = true; + SimAirLoopsFlag = true; + SimPlantLoopsFlag = true; + SimElecCircuitsFlag = true; + FirstHVACIteration = true; + + if (state.dataAirLoop->AirLoopInputsFilled) { + for (auto &e : state.dataAirLoop->AirLoopControlInfo) { + // Reset air loop control info for cooling coil active flag (used in TU's for reheat air flow control) + e.CoolingActiveFlag = false; + // Reset air loop control info for heating coil active flag (used in OA controller for HX control) + e.HeatingActiveFlag = false; + // reset outside air system HX to off first time through + e.HeatRecoveryBypass = true; + // set HX check status flag to check for custom control in MixedAir.cc + e.CheckHeatRecoveryBypassStatus = true; + // set OA comp simulated flag to false + e.OASysComponentsSimulated = false; + // set economizer flow locked flag to false, will reset if custom HX control is used + e.EconomizerFlowLocked = false; + // set air loop resim flags for when heat recovery is used and air loop needs another iteration + e.HeatRecoveryResimFlag = true; + e.HeatRecoveryResimFlag2 = false; + e.ResimAirLoopFlag = false; } } - void SimHVAC(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR: Dan Fisher - // DATE WRITTEN: April 1997 - // DATE MODIFIED: May 1998 (RKS,RDT) - - // PURPOSE OF THIS SUBROUTINE: Selects and calls the HVAC loop managers - - // METHODOLOGY EMPLOYED: Each loop manager is called or passed over - // in succession based on the logical flags associated with the manager. - // The logical flags are set in the manager routines and passed - // as parameters to this routine. Each loop manager potentially - // affects a different set of other loop managers. - - // Future development could involve specifying any number of user - // selectable control schemes based on the logical flags used in - // this default control algorithm. - - // Using/Aliasing - using DataPlant::ConvergenceHistoryARR; - using DataPlant::DemandSide; - using DataPlant::NumConvergenceHistoryTerms; - using DataPlant::square_sum_ConvergenceHistoryARR; - using DataPlant::sum_ConvergenceHistoryARR; - using DataPlant::sum_square_ConvergenceHistoryARR; - using DataPlant::SupplySide; - using EMSManager::ManageEMS; - using General::CreateSysTimeIntervalString; - using NonZoneEquipmentManager::ManageNonZoneEquipment; - using PlantCondLoopOperation::SetupPlantEMSActuators; - using PlantManager::GetPlantInput; - using PlantManager::GetPlantLoopData; - using PlantManager::InitOneTimePlantSizingInfo; - using PlantManager::ReInitPlantLoopsAtFirstHVACIteration; - using PlantManager::SetupBranchControlTypes; - using PlantManager::SetupInitialPlantCallingOrder; - using PlantManager::SetupReports; - using PlantUtilities::AnyPlantSplitterMixerLacksContinuity; - using PlantUtilities::CheckForRunawayPlantTemps; - using PlantUtilities::CheckPlantMixerSplitterConsistency; - using PlantUtilities::SetAllPlantSimFlagsToValue; - using SetPointManager::ManageSetPoints; - using SystemAvailabilityManager::ManageSystemAvailability; - using ZoneEquipmentManager::ManageZoneEquipment; - - // SUBROUTINE PARAMETER DEFINITIONS: - bool const SimWithPlantFlowUnlocked(false); - bool const SimWithPlantFlowLocked(true); - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - bool FirstHVACIteration; // True when solution technique on first iteration - static int ErrCount(0); // Number of times that the maximum iterations was exceeded - static int MaxErrCount(0); - static std::string ErrEnvironmentName; - int LoopNum; - int LoopSide; - int ThisLoopSide; - - int AirSysNum; - int StackDepth; - std::string HistoryTrace; - Real64 SlopeHumRat; - Real64 SlopeMdot; - Real64 SlopeTemps; - Real64 AvgValue; - bool FoundOscillationByDuplicate; - int ZoneNum; - int NodeIndex; - bool MonotonicIncreaseFound; - bool MonotonicDecreaseFound; - - Array1D const ConvergLogStackARR(DataConvergParams::ConvergLogStackDepth, {0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0, -9.0}); - Real64 const sum_ConvergLogStackARR(sum(ConvergLogStackARR)); - Real64 const square_sum_ConvergLogStackARR(pow_2(sum_ConvergLogStackARR)); - Real64 const sum_square_ConvergLogStackARR(sum(pow(ConvergLogStackARR, 2))); - - // Initialize all of the simulation flags to true for the first iteration - SimZoneEquipmentFlag = true; - SimNonZoneEquipmentFlag = true; - SimAirLoopsFlag = true; - SimPlantLoopsFlag = true; - SimElecCircuitsFlag = true; - FirstHVACIteration = true; - - if (state.dataAirLoop->AirLoopInputsFilled) { - for (auto &e : state.dataAirLoop->AirLoopControlInfo) { - // Reset air loop control info for cooling coil active flag (used in TU's for reheat air flow control) - e.CoolingActiveFlag = false; - // Reset air loop control info for heating coil active flag (used in OA controller for HX control) - e.HeatingActiveFlag = false; - // reset outside air system HX to off first time through - e.HeatRecoveryBypass = true; - // set HX check status flag to check for custom control in MixedAir.cc - e.CheckHeatRecoveryBypassStatus = true; - // set OA comp simulated flag to false - e.OASysComponentsSimulated = false; - // set economizer flow locked flag to false, will reset if custom HX control is used - e.EconomizerFlowLocked = false; - // set air loop resim flags for when heat recovery is used and air loop needs another iteration - e.HeatRecoveryResimFlag = true; - e.HeatRecoveryResimFlag2 = false; - e.ResimAirLoopFlag = false; - } + // This setups the reports for the Iteration variable that limits how many times + // it goes through all of the HVAC managers before moving on. + // The plant loop 'get inputs' and initialization are also done here in order to allow plant loop connected components + // simulated by managers other than the plant manager to run correctly. + state.dataHVACMgr->HVACManageIteration = 0; + state.dataPlnt->PlantManageSubIterations = 0; + state.dataPlnt->PlantManageHalfLoopCalls = 0; + SetAllPlantSimFlagsToValue(state, true); + if (!state.dataHVACMgr->SimHVACIterSetup) { + SetupOutputVariable(state, + "HVAC System Solver Iteration Count", + OutputProcessor::Unit::None, + state.dataHVACMgr->HVACManageIteration, + "HVAC", + "Sum", + "SimHVAC"); + SetupOutputVariable( + state, "Air System Solver Iteration Count", OutputProcessor::Unit::None, state.dataHVACMgr->RepIterAir, "HVAC", "Sum", "SimHVAC"); + SetupOutputVariable(state, + "Air System Relief Air Total Heat Loss Energy", + OutputProcessor::Unit::J, + state.dataHeatBal->SysTotalHVACReliefHeatLoss, + "HVAC", + "Sum", + "SimHVAC"); + SetupOutputVariable(state, + "HVAC System Total Heat Rejection Energy", + OutputProcessor::Unit::J, + state.dataHeatBal->SysTotalHVACRejectHeatLoss, + "HVAC", + "Sum", + "SimHVAC"); + ManageSetPoints(state); // need to call this before getting plant loop data so setpoint checks can complete okay + GetPlantLoopData(state); + GetPlantInput(state); + SetupInitialPlantCallingOrder(state); + SetupBranchControlTypes(state); // new routine to do away with input for branch control type + // CALL CheckPlantLoopData + SetupReports(state); + if (state.dataGlobal->AnyEnergyManagementSystemInModel) { + SetupPlantEMSActuators(state); } - // This setups the reports for the Iteration variable that limits how many times - // it goes through all of the HVAC managers before moving on. - // The plant loop 'get inputs' and initialization are also done here in order to allow plant loop connected components - // simulated by managers other than the plant manager to run correctly. - HVACManageIteration = 0; - state.dataPlnt->PlantManageSubIterations = 0; - state.dataPlnt->PlantManageHalfLoopCalls = 0; - SetAllPlantSimFlagsToValue(state, true); - if (!SimHVACIterSetup) { - SetupOutputVariable(state, "HVAC System Solver Iteration Count", OutputProcessor::Unit::None, HVACManageIteration, "HVAC", "Sum", "SimHVAC"); - SetupOutputVariable(state, "Air System Solver Iteration Count", OutputProcessor::Unit::None, RepIterAir, "HVAC", "Sum", "SimHVAC"); - SetupOutputVariable(state, "Air System Relief Air Total Heat Loss Energy", - OutputProcessor::Unit::J, - state.dataHeatBal->SysTotalHVACReliefHeatLoss, + if (state.dataPlnt->TotNumLoops > 0) { + SetupOutputVariable(state, + "Plant Solver Sub Iteration Count", + OutputProcessor::Unit::None, + state.dataPlnt->PlantManageSubIterations, "HVAC", "Sum", "SimHVAC"); - SetupOutputVariable(state, "HVAC System Total Heat Rejection Energy", - OutputProcessor::Unit::J, - state.dataHeatBal->SysTotalHVACRejectHeatLoss, + SetupOutputVariable(state, + "Plant Solver Half Loop Calls Count", + OutputProcessor::Unit::None, + state.dataPlnt->PlantManageHalfLoopCalls, "HVAC", "Sum", "SimHVAC"); - ManageSetPoints(state); // need to call this before getting plant loop data so setpoint checks can complete okay - GetPlantLoopData(state); - GetPlantInput(state); - SetupInitialPlantCallingOrder(state); - SetupBranchControlTypes(state); // new routine to do away with input for branch control type - // CALL CheckPlantLoopData - SetupReports(state); - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { - SetupPlantEMSActuators(state); - } - - if (state.dataPlnt->TotNumLoops > 0) { - SetupOutputVariable(state, - "Plant Solver Sub Iteration Count", OutputProcessor::Unit::None, state.dataPlnt->PlantManageSubIterations, "HVAC", "Sum", "SimHVAC"); - SetupOutputVariable(state, - "Plant Solver Half Loop Calls Count", OutputProcessor::Unit::None, state.dataPlnt->PlantManageHalfLoopCalls, "HVAC", "Sum", "SimHVAC"); - for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { - // init plant sizing numbers in main plant data structure - InitOneTimePlantSizingInfo(state, LoopNum); - } + for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { + // init plant sizing numbers in main plant data structure + InitOneTimePlantSizingInfo(state, LoopNum); } - SimHVACIterSetup = true; } + state.dataHVACMgr->SimHVACIterSetup = true; + } - if (state.dataGlobal->ZoneSizingCalc) { - ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipmentFlag, SimAirLoopsFlag); - // need to call non zone equipment so water use zone gains can be included in sizing calcs - ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipmentFlag); - facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); - return; - } + if (state.dataGlobal->ZoneSizingCalc) { + ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipmentFlag, SimAirLoopsFlag); + // need to call non zone equipment so water use zone gains can be included in sizing calcs + ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipmentFlag); + facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); + return; + } - // Before the HVAC simulation, reset control flags and specified flow - // rates that might have been set by the set point and availability - // managers. + // Before the HVAC simulation, reset control flags and specified flow + // rates that might have been set by the set point and availability + // managers. - ResetHVACControl(state); + ResetHVACControl(state); - // Before the HVAC simulation, call ManageSetPoints to set all the HVAC - // node setpoints - bool anyEMSRan = false; - ManageEMS(state, EMSManager::EMSCallFrom::BeforeHVACManagers, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point + // Before the HVAC simulation, call ManageSetPoints to set all the HVAC + // node setpoints + bool anyEMSRan = false; + ManageEMS(state, EMSManager::EMSCallFrom::BeforeHVACManagers, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point - ManageSetPoints(state); + ManageSetPoints(state); - // re-initialize plant loop and nodes. - ReInitPlantLoopsAtFirstHVACIteration(state); + // re-initialize plant loop and nodes. + ReInitPlantLoopsAtFirstHVACIteration(state); - // Before the HVAC simulation, call ManageSystemAvailability to set - // the system on/off flags - ManageSystemAvailability(state); + // Before the HVAC simulation, call ManageSystemAvailability to set + // the system on/off flags + ManageSystemAvailability(state); - ManageEMS(state, EMSManager::EMSCallFrom::AfterHVACManagers, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point - ManageEMS(state, EMSManager::EMSCallFrom::HVACIterationLoop, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point id + ManageEMS(state, EMSManager::EMSCallFrom::AfterHVACManagers, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point + ManageEMS(state, EMSManager::EMSCallFrom::HVACIterationLoop, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point id + + // first explicitly call each system type with FirstHVACIteration, + + // Manages the various component simulations + SimSelectedEquipment(state, + SimAirLoopsFlag, + SimZoneEquipmentFlag, + SimNonZoneEquipmentFlag, + SimPlantLoopsFlag, + SimElecCircuitsFlag, + FirstHVACIteration, + SimWithPlantFlowUnlocked); + + // Eventually, when all of the flags are set to false, the + // simulation has converged for this system time step. + + SimPlantLoopsFlag = true; + SetAllPlantSimFlagsToValue(state, true); // set so loop to simulate at least once on non-first hvac + + FirstHVACIteration = false; - // first explicitly call each system type with FirstHVACIteration, + // then iterate among all systems after first HVAC iteration is over + + // Main iteration loop for HVAC. If any of the simulation flags are + // true, then specific components must be resimulated. + while ((SimAirLoopsFlag || SimZoneEquipmentFlag || SimNonZoneEquipmentFlag || SimPlantLoopsFlag || SimElecCircuitsFlag) && + (state.dataHVACMgr->HVACManageIteration <= state.dataConvergeParams->MaxIter)) { + + if (state.dataGlobal->stopSimulation) break; + + ManageEMS(state, EMSManager::EMSCallFrom::HVACIterationLoop, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point id // Manages the various component simulations - SimSelectedEquipment(state, SimAirLoopsFlag, + SimSelectedEquipment(state, + SimAirLoopsFlag, SimZoneEquipmentFlag, SimNonZoneEquipmentFlag, SimPlantLoopsFlag, @@ -781,1200 +799,1307 @@ namespace EnergyPlus::HVACManager { // Eventually, when all of the flags are set to false, the // simulation has converged for this system time step. - SimPlantLoopsFlag = true; - SetAllPlantSimFlagsToValue(state, true); // set so loop to simulate at least once on non-first hvac - - FirstHVACIteration = false; - - // then iterate among all systems after first HVAC iteration is over - - // Main iteration loop for HVAC. If any of the simulation flags are - // true, then specific components must be resimulated. - while ((SimAirLoopsFlag || SimZoneEquipmentFlag || SimNonZoneEquipmentFlag || SimPlantLoopsFlag || SimElecCircuitsFlag) && - (HVACManageIteration <= state.dataConvergeParams->MaxIter)) { - - if (state.dataGlobal->stopSimulation) break; + UpdateZoneInletConvergenceLog(state); - ManageEMS(state, EMSManager::EMSCallFrom::HVACIterationLoop, anyEMSRan, ObjexxFCL::Optional_int_const()); // calling point id + ++state.dataHVACMgr->HVACManageIteration; // Increment the iteration counter - // Manages the various component simulations - SimSelectedEquipment(state, SimAirLoopsFlag, + if (anyEMSRan && state.dataHVACMgr->HVACManageIteration <= 2) { + // the calling point emsCallFromHVACIterationLoop is only effective for air loops if this while loop runs at least twice + SimAirLoopsFlag = true; + } + if (state.dataHVACMgr->HVACManageIteration < MinAirLoopIterationsAfterFirst) { + // sequenced zone loads for airloops may require extra iterations depending upon zone equipment order and load distribution type + SimAirLoopsFlag = true; + SimZoneEquipmentFlag = true; + } + } + if (state.dataGlobal->AnyPlantInModel) { + if (AnyPlantSplitterMixerLacksContinuity(state)) { + // rerun systems in a "Final flow lock/last iteration" mode + // now call for one second to last plant simulation + SimAirLoopsFlag = false; + SimZoneEquipmentFlag = false; + SimNonZoneEquipmentFlag = false; + SimPlantLoopsFlag = true; + SimElecCircuitsFlag = false; + SimSelectedEquipment(state, + SimAirLoopsFlag, SimZoneEquipmentFlag, SimNonZoneEquipmentFlag, SimPlantLoopsFlag, SimElecCircuitsFlag, FirstHVACIteration, SimWithPlantFlowUnlocked); - - // Eventually, when all of the flags are set to false, the - // simulation has converged for this system time step. - + // now call for all non-plant simulation, but with plant flow lock on + SimAirLoopsFlag = true; + SimZoneEquipmentFlag = true; + SimNonZoneEquipmentFlag = true; + SimPlantLoopsFlag = false; + SimElecCircuitsFlag = true; + SimSelectedEquipment(state, + SimAirLoopsFlag, + SimZoneEquipmentFlag, + SimNonZoneEquipmentFlag, + SimPlantLoopsFlag, + SimElecCircuitsFlag, + FirstHVACIteration, + SimWithPlantFlowLocked); + UpdateZoneInletConvergenceLog(state); + // now call for a last plant simulation + SimAirLoopsFlag = false; + SimZoneEquipmentFlag = false; + SimNonZoneEquipmentFlag = false; + SimPlantLoopsFlag = true; + SimElecCircuitsFlag = false; + SimSelectedEquipment(state, + SimAirLoopsFlag, + SimZoneEquipmentFlag, + SimNonZoneEquipmentFlag, + SimPlantLoopsFlag, + SimElecCircuitsFlag, + FirstHVACIteration, + SimWithPlantFlowUnlocked); + // now call for a last all non-plant simulation, but with plant flow lock on + SimAirLoopsFlag = true; + SimZoneEquipmentFlag = true; + SimNonZoneEquipmentFlag = true; + SimPlantLoopsFlag = false; + SimElecCircuitsFlag = true; + SimSelectedEquipment(state, + SimAirLoopsFlag, + SimZoneEquipmentFlag, + SimNonZoneEquipmentFlag, + SimPlantLoopsFlag, + SimElecCircuitsFlag, + FirstHVACIteration, + SimWithPlantFlowLocked); UpdateZoneInletConvergenceLog(state); + } + } - ++HVACManageIteration; // Increment the iteration counter + // Test plant loop for errors + for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { + for (LoopSide = DemandSide; LoopSide <= SupplySide; ++LoopSide) { + CheckPlantMixerSplitterConsistency(state, LoopNum, LoopSide, FirstHVACIteration); + CheckForRunawayPlantTemps(state, LoopNum, LoopSide); + } + } - if (anyEMSRan && HVACManageIteration <= 2) { - // the calling point emsCallFromHVACIterationLoop is only effective for air loops if this while loop runs at least twice - SimAirLoopsFlag = true; + if ((state.dataHVACMgr->HVACManageIteration > state.dataConvergeParams->MaxIter) && (!state.dataGlobal->WarmupFlag)) { + ++ErrCount; + if (ErrCount < 15) { + ErrEnvironmentName = state.dataEnvrn->EnvironmentName; + ShowWarningError(state, + format("SimHVAC: Maximum iterations ({}) exceeded for all HVAC loops, at {}, {} {}", + state.dataConvergeParams->MaxIter, + state.dataEnvrn->EnvironmentName, + state.dataEnvrn->CurMnDy, + CreateSysTimeIntervalString(state))); + if (SimAirLoopsFlag) { + ShowContinueError(state, "The solution for one or more of the Air Loop HVAC systems did not appear to converge"); } - if (HVACManageIteration < MinAirLoopIterationsAfterFirst) { - // sequenced zone loads for airloops may require extra iterations depending upon zone equipment order and load distribution type - SimAirLoopsFlag = true; - SimZoneEquipmentFlag = true; + if (SimZoneEquipmentFlag) { + ShowContinueError(state, "The solution for zone HVAC equipment did not appear to converge"); } - } - if (state.dataGlobal->AnyPlantInModel) { - if (AnyPlantSplitterMixerLacksContinuity(state)) { - // rerun systems in a "Final flow lock/last iteration" mode - // now call for one second to last plant simulation - SimAirLoopsFlag = false; - SimZoneEquipmentFlag = false; - SimNonZoneEquipmentFlag = false; - SimPlantLoopsFlag = true; - SimElecCircuitsFlag = false; - SimSelectedEquipment(state, SimAirLoopsFlag, - SimZoneEquipmentFlag, - SimNonZoneEquipmentFlag, - SimPlantLoopsFlag, - SimElecCircuitsFlag, - FirstHVACIteration, - SimWithPlantFlowUnlocked); - // now call for all non-plant simulation, but with plant flow lock on - SimAirLoopsFlag = true; - SimZoneEquipmentFlag = true; - SimNonZoneEquipmentFlag = true; - SimPlantLoopsFlag = false; - SimElecCircuitsFlag = true; - SimSelectedEquipment(state, SimAirLoopsFlag, - SimZoneEquipmentFlag, - SimNonZoneEquipmentFlag, - SimPlantLoopsFlag, - SimElecCircuitsFlag, - FirstHVACIteration, - SimWithPlantFlowLocked); - UpdateZoneInletConvergenceLog(state); - // now call for a last plant simulation - SimAirLoopsFlag = false; - SimZoneEquipmentFlag = false; - SimNonZoneEquipmentFlag = false; - SimPlantLoopsFlag = true; - SimElecCircuitsFlag = false; - SimSelectedEquipment(state, SimAirLoopsFlag, - SimZoneEquipmentFlag, - SimNonZoneEquipmentFlag, - SimPlantLoopsFlag, - SimElecCircuitsFlag, - FirstHVACIteration, - SimWithPlantFlowUnlocked); - // now call for a last all non-plant simulation, but with plant flow lock on - SimAirLoopsFlag = true; - SimZoneEquipmentFlag = true; - SimNonZoneEquipmentFlag = true; - SimPlantLoopsFlag = false; - SimElecCircuitsFlag = true; - SimSelectedEquipment(state, SimAirLoopsFlag, - SimZoneEquipmentFlag, - SimNonZoneEquipmentFlag, - SimPlantLoopsFlag, - SimElecCircuitsFlag, - FirstHVACIteration, - SimWithPlantFlowLocked); - UpdateZoneInletConvergenceLog(state); + if (SimNonZoneEquipmentFlag) { + ShowContinueError(state, "The solution for non-zone equipment did not appear to converge"); } - } - - // Test plant loop for errors - for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { - for (LoopSide = DemandSide; LoopSide <= SupplySide; ++LoopSide) { - CheckPlantMixerSplitterConsistency(state, LoopNum, LoopSide, FirstHVACIteration); - CheckForRunawayPlantTemps(state, LoopNum, LoopSide); + if (SimPlantLoopsFlag) { + ShowContinueError(state, "The solution for one or more plant systems did not appear to converge"); } - } - - if ((HVACManageIteration > state.dataConvergeParams->MaxIter) && (!state.dataGlobal->WarmupFlag)) { - ++ErrCount; - if (ErrCount < 15) { - ErrEnvironmentName = state.dataEnvrn->EnvironmentName; - ShowWarningError(state, - format("SimHVAC: Maximum iterations ({}) exceeded for all HVAC loops, at {}, {} {}", - state.dataConvergeParams->MaxIter, - state.dataEnvrn->EnvironmentName, - state.dataEnvrn->CurMnDy, - CreateSysTimeIntervalString(state))); - if (SimAirLoopsFlag) { - ShowContinueError(state, "The solution for one or more of the Air Loop HVAC systems did not appear to converge"); - } - if (SimZoneEquipmentFlag) { - ShowContinueError(state, "The solution for zone HVAC equipment did not appear to converge"); - } - if (SimNonZoneEquipmentFlag) { - ShowContinueError(state, "The solution for non-zone equipment did not appear to converge"); - } - if (SimPlantLoopsFlag) { - ShowContinueError(state, "The solution for one or more plant systems did not appear to converge"); - } - if (SimElecCircuitsFlag) { - ShowContinueError(state, "The solution for on-site electric generators did not appear to converge"); - } - if (ErrCount == 1 && !state.dataGlobal->DisplayExtraWarnings) { - ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on each max iteration exceeded."); - } - if (state.dataGlobal->DisplayExtraWarnings) { + if (SimElecCircuitsFlag) { + ShowContinueError(state, "The solution for on-site electric generators did not appear to converge"); + } + if (ErrCount == 1 && !state.dataGlobal->DisplayExtraWarnings) { + ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on each max iteration exceeded."); + } + if (state.dataGlobal->DisplayExtraWarnings) { - for (AirSysNum = 1; AirSysNum <= NumPrimaryAirSys; ++AirSysNum) { + for (AirSysNum = 1; AirSysNum <= NumPrimaryAirSys; ++AirSysNum) { - if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACMassFlowNotConverged)) { + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACMassFlowNotConverged)) { - ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + + ShowContinueError(state, + "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for mass flow rate"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowDemandToSupplyTolValue(StackDepth)); + } + + ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck1ToDemandTolValue(StackDepth)); + } + ShowContinueError(state, + "Supply-to-demand interface deck 1 mass flow rate check value iteration history trace: " + HistoryTrace); + + if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowDemandToSupplyTolValue(StackDepth)); + HistoryTrace += + format("{:.6R},", + state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck2ToDemandTolValue(StackDepth)); } + ShowContinueError( + state, "Supply-to-demand interface deck 2 mass flow rate check value iteration history trace: " + HistoryTrace); + } + } // mass flow rate not converged + + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumRatNotConverged)) { - ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); + ShowContinueError(state, + "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + + " did not converge for humidity ratio"); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumDemandToSupplyTolValue(StackDepth)); + } + ShowContinueError(state, "Demand-to-Supply interface humidity ratio check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck1ToDemandTolValue(StackDepth)); + } + ShowContinueError(state, + "Supply-to-demand interface deck 1 humidity ratio check value iteration history trace: " + HistoryTrace); + + if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck1ToDemandTolValue(StackDepth)); + HistoryTrace += + format("{:.6R},", + state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck2ToDemandTolValue(StackDepth)); } - ShowContinueError(state, "Supply-to-demand interface deck 1 mass flow rate check value iteration history trace: " + - HistoryTrace); + ShowContinueError( + state, "Supply-to-demand interface deck 2 humidity ratio check value iteration history trace: " + HistoryTrace); + } + } // humidity ratio not converged - if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACFlowSupplyDeck2ToDemandTolValue(StackDepth)); - } - ShowContinueError(state, "Supply-to-demand interface deck 2 mass flow rate check value iteration history trace: " + - HistoryTrace); - } - } // mass flow rate not converged + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempNotConverged)) { - if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumRatNotConverged)) { + ShowContinueError(state, + "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + + " did not converge for temperature"); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempDemandToSupplyTolValue(StackDepth)); + } + ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); + } + ShowContinueError(state, + "Supply-to-demand interface deck 1 temperature check value iteration history trace: " + HistoryTrace); - ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + - " did not converge for humidity ratio"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumDemandToSupplyTolValue(StackDepth)); + HistoryTrace += + format("{:.6R},", + state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); } - ShowContinueError(state, "Demand-to-Supply interface humidity ratio check value iteration history trace: " + HistoryTrace); + ShowContinueError(state, + "Supply-to-demand interface deck 2 temperature check value iteration history trace: " + HistoryTrace); + } + } // Temps not converged + if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyNotConverged)) { + + ShowContinueError(state, + "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + + " did not converge for energy"); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyDemandToSupplyTolValue(StackDepth)); + } + ShowContinueError(state, "Demand-to-Supply interface energy check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck1ToDemandTolValue(StackDepth)); + } + ShowContinueError(state, "Supply-to-demand interface deck 1 energy check value iteration history trace: " + HistoryTrace); + + if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck1ToDemandTolValue(StackDepth)); + HistoryTrace += + format("{:.6R},", + state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck2ToDemandTolValue(StackDepth)); } - ShowContinueError(state, "Supply-to-demand interface deck 1 humidity ratio check value iteration history trace: " + - HistoryTrace); + ShowContinueError(state, "Supply-to-demand interface deck 2 energy check value iteration history trace: " + HistoryTrace); + } + } // energy not converged - if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACHumSupplyDeck2ToDemandTolValue(StackDepth)); - } - ShowContinueError(state, "Supply-to-demand interface deck 2 humidity ratio check value iteration history trace: " + - HistoryTrace); - } - } // humidity ratio not converged + } // loop over air loop systems - if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempNotConverged)) { + // loop over zones and check for issues with zone inlet nodes + for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for temperature"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempDemandToSupplyTolValue(StackDepth)); + for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { + + // Check humidity ratio + FoundOscillationByDuplicate = false; + MonotonicDecreaseFound = false; + MonotonicIncreaseFound = false; + // check for evidence of oscillation by identifying duplicates when latest value not equal to average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) / + double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - AvgValue) > + DataConvergParams::HVACHumRatOscillationToler) { // last iterate differs from average + FoundOscillationByDuplicate = false; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) < + DataConvergParams::HVACHumRatOscillationToler) { + FoundOscillationByDuplicate = true; + ShowContinueError( + state, + format("Node named {} shows oscillating humidity ratio across iterations with a repeated value of {:.6R}", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1))); + break; + } } - ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); + if (!FoundOscillationByDuplicate) { + SlopeHumRat = + (sum_ConvergLogStackARR * + sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeHumRat) > DataConvergParams::HVACHumRatSlopeToler) { + + if (SlopeHumRat < 0.0) { // check for monotic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio( + StackDepth - 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio( + StackDepth)) { + MonotonicDecreaseFound = false; + break; + } + } + if (MonotonicDecreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically decreasing humidity ratio with a trend " + "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeHumRat)); + } + } else { // check for monotic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio( + StackDepth - 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio( + StackDepth)) { + MonotonicIncreaseFound = false; + break; + } + } + if (MonotonicIncreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically increasing humidity ratio with a trend " + "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeHumRat)); + } + } + } // significant slope in iterates + } // no osciallation + } // last value does not equal average of stack. + + if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); + HistoryTrace += + format("{:.6R},", + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)); } - ShowContinueError(state, "Supply-to-demand interface deck 1 temperature check value iteration history trace: " + HistoryTrace); - - if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACTempSupplyDeck1ToDemandTolValue(StackDepth)); + ShowContinueError( + state, + "Node named " + + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + " humidity ratio [kg-water/kg-dryair] iteration history trace (most recent first): " + HistoryTrace); + } // need to report trace + // end humidity ratio + + // Check Mass flow rate + FoundOscillationByDuplicate = false; + MonotonicDecreaseFound = false; + MonotonicIncreaseFound = false; + // check for evidence of oscillation by indentify duplicates when latest value not equal to average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) / + double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - AvgValue) > + DataConvergParams::HVACFlowRateOscillationToler) { // last iterate differs from average + FoundOscillationByDuplicate = false; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) < + DataConvergParams::HVACFlowRateOscillationToler) { + FoundOscillationByDuplicate = true; + ShowContinueError( + state, + format("Node named {} shows oscillating mass flow rate across iterations with a repeated value of {:.6R}", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1))); + break; } - ShowContinueError(state, "Supply-to-demand interface deck 2 temperature check value iteration history trace: " + - HistoryTrace); } - } // Temps not converged - if (any(state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyNotConverged)) { + if (!FoundOscillationByDuplicate) { + SlopeMdot = + (sum_ConvergLogStackARR * + sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeMdot) > DataConvergParams::HVACFlowRateSlopeToler) { + if (SlopeMdot < 0.0) { // check for monotic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - + 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate( + StackDepth)) { + MonotonicDecreaseFound = false; + break; + } + } + if (MonotonicDecreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically decreasing mass flow rate with a trend " + "rate across iterations of {:.6R} [kg/s/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeMdot)); + } + } else { // check for monotic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - + 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate( + StackDepth)) { + MonotonicIncreaseFound = false; + break; + } + } + if (MonotonicIncreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically increasing mass flow rate with a trend " + "rate across iterations of {:.6R} [kg/s/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeMdot)); + } + } + } // significant slope in iterates + } // no osciallation + } // last value does not equal average of stack. - ShowContinueError(state, "Air System Named = " + state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).AirLoopName + " did not converge for energy"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergyDemandToSupplyTolValue(StackDepth)); + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)); } - ShowContinueError(state, "Demand-to-Supply interface energy check value iteration history trace: " + HistoryTrace); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck1ToDemandTolValue(StackDepth)); + ShowContinueError(state, + "Node named " + + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); + } // need to report trace + // end mass flow rate + + // Check Temperatures + FoundOscillationByDuplicate = false; + MonotonicDecreaseFound = false; + MonotonicIncreaseFound = false; + // check for evidence of oscillation by indentify duplicates when latest value not equal to average + AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) / + double(DataConvergParams::ConvergLogStackDepth); + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - AvgValue) > + DataConvergParams::HVACTemperatureOscillationToler) { // last iterate differs from average + FoundOscillationByDuplicate = false; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) < + DataConvergParams::HVACTemperatureOscillationToler) { + FoundOscillationByDuplicate = true; + ShowContinueError( + state, + format("Node named {} shows oscillating temperatures across iterations with a repeated value of {:.6R}", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1))); + break; + } } - ShowContinueError(state, "Supply-to-demand interface deck 1 energy check value iteration history trace: " + HistoryTrace); + if (!FoundOscillationByDuplicate) { + SlopeTemps = + (sum_ConvergLogStackARR * + sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) - + double(DataConvergParams::ConvergLogStackDepth) * + sum((ConvergLogStackARR * + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature))) / + (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); + if (std::abs(SlopeTemps) > DataConvergParams::HVACTemperatureSlopeToler) { + if (SlopeTemps < 0.0) { // check for monotonic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - + 1) > + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature( + StackDepth)) { + MonotonicDecreaseFound = false; + break; + } + } + if (MonotonicDecreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically decreasing temperature with a trend rate " + "across iterations of {:.4R} [C/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeTemps)); + } + } else { // check for monotic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - + 1) < + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature( + StackDepth)) { + MonotonicIncreaseFound = false; + break; + } + } + if (MonotonicIncreaseFound) { + ShowContinueError( + state, + format("Node named {} shows monotonically increasing temperatures with a trend " + "rate across iterations of {:.4R} [C/iteration]", + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), + SlopeTemps)); + } + } + } // significant slope in iterates + } // no osciallation + } // last value does not equal average of stack. - if (state.dataAirLoop->AirToZoneNodeInfo(AirSysNum).NumSupplyNodes >= 2) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += - format("{:.6R},", state.dataConvergeParams->AirLoopConvergence(AirSysNum).HVACEnergySupplyDeck2ToDemandTolValue(StackDepth)); - } - ShowContinueError(state, "Supply-to-demand interface deck 2 energy check value iteration history trace: " + HistoryTrace); + if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += format( + "{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)); } - } // energy not converged + ShowContinueError(state, + "Node named " + + state.dataLoopNodes->NodeID( + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + + " temperature [C] iteration history trace (most recent first): " + HistoryTrace); + } // need to report trace + // end Temperature checks - } // loop over air loop systems + } // loop over zone inlet nodes + } // loop over zones - // loop over zones and check for issues with zone inlet nodes - for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { + for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { - for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { + if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantMassFlowNotConverged) { + ShowContinueError(state, + "Plant System Named = " + state.dataPlnt->PlantLoop(LoopNum).Name + " did not converge for mass flow rate"); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowDemandToSupplyTolValue(StackDepth)); + } + ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowSupplyToDemandTolValue(StackDepth)); + } + ShowContinueError(state, "Supply-to-Demand interface mass flow rate check value iteration history trace: " + HistoryTrace); - // Check humidity ratio + // now work with history logs for mass flow to detect issues + for (ThisLoopSide = 1; ThisLoopSide <= isize(state.dataPlnt->PlantLoop(LoopNum).LoopSide); ++ThisLoopSide) { + // loop side inlet node FoundOscillationByDuplicate = false; MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; - // check for evidence of oscillation by identifying duplicates when latest value not equal to average - AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) / double(DataConvergParams::ConvergLogStackDepth); - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - AvgValue) > - DataConvergParams::HVACHumRatOscillationToler) { // last iterate differs from average + AvgValue = sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory) / + double(NumConvergenceHistoryTerms); + if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - AvgValue) > + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) - - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) < - DataConvergParams::HVACHumRatOscillationToler) { + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (std::abs( + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) < + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, - format("Node named {} shows oscillating humidity ratio across iterations with a repeated value of {:.6R}", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1))); + format("Node named {} shows oscillating flow rates across iterations with a repeated value of {:.7R}", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1))); break; } } - if (!FoundOscillationByDuplicate) { - SlopeHumRat = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio) - - double(DataConvergParams::ConvergLogStackDepth) * - sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio))) / - (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeHumRat) > DataConvergParams::HVACHumRatSlopeToler) { - - if (SlopeHumRat < 0.0) { // check for monotic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) > - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing humidity ratio with a trend " - "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeHumRat)); - } - } else { // check for monotic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth - 1) < - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } + } + if (!FoundOscillationByDuplicate) { + SlopeMdot = + (sum_ConvergenceHistoryARR * + sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory) - + double(NumConvergenceHistoryTerms) * + sum((ConvergenceHistoryARR * + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory))) / + (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); + if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { + if (SlopeMdot < 0.0) { // check for monotonic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .InletNode.MassFlowRateHistory(StackDepth - 1) > + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) { + MonotonicDecreaseFound = false; + break; } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing humidity ratio with a trend " - "rate across iterations of {:.6R} [ kg-water/kg-dryair/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeHumRat)); + } + if (MonotonicDecreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically decreasing mass flow rate with a trend " + "rate across iterations of {:.7R} [kg/s/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + SlopeMdot)); + } + } else { // check for monotonic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .InletNode.MassFlowRateHistory(StackDepth - 1) < + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) { + MonotonicIncreaseFound = false; + break; } } - } // significant slope in iterates - } // no osciallation - } // last value does not equal average of stack. + if (MonotonicIncreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically increasing mass flow rate with a trend " + "rate across iterations of {:.7R} [kg/s/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + SlopeMdot)); + } + } + } // significant slope found + } // no oscillation found if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(StackDepth)); + for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + HistoryTrace += + format("{:.7R},", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)); } ShowContinueError(state, - "Node named " + state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + - " humidity ratio [kg-water/kg-dryair] iteration history trace (most recent first): " + HistoryTrace); + "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn + + " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace - // end humidity ratio + // end of inlet node - // Check Mass flow rate + // loop side outlet node FoundOscillationByDuplicate = false; MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; - // check for evidence of oscillation by indentify duplicates when latest value not equal to average - AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) / double(DataConvergParams::ConvergLogStackDepth); - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - AvgValue) > - DataConvergParams::HVACFlowRateOscillationToler) { // last iterate differs from average + AvgValue = sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory) / + double(NumConvergenceHistoryTerms); + if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - AvgValue) > + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) - - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) < - DataConvergParams::HVACFlowRateOscillationToler) { + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (std::abs( + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)) < + DataConvergParams::PlantFlowRateOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, - format("Node named {} shows oscillating mass flow rate across iterations with a repeated value of {:.6R}", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1))); + format("Node named {} shows oscillating flow rates across iterations with a repeated value of {:.7R}", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1))); break; } } - if (!FoundOscillationByDuplicate) { - SlopeMdot = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate) - - double(DataConvergParams::ConvergLogStackDepth) * - sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate))) / - (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeMdot) > DataConvergParams::HVACFlowRateSlopeToler) { - if (SlopeMdot < 0.0) { // check for monotic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) > - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing mass flow rate with a trend " - "rate across iterations of {:.6R} [kg/s/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeMdot)); - } - } else { // check for monotic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth - 1) < - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } + } + if (!FoundOscillationByDuplicate) { + SlopeMdot = + (sum_ConvergenceHistoryARR * + sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory) - + double(NumConvergenceHistoryTerms) * + sum((ConvergenceHistoryARR * + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory))) / + (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); + if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { + if (SlopeMdot < 0.0) { // check for monotonic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.MassFlowRateHistory(StackDepth - 1) > + state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.MassFlowRateHistory(StackDepth)) { + MonotonicDecreaseFound = false; + break; } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing mass flow rate with a trend " - "rate across iterations of {:.6R} [kg/s/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeMdot)); + } + if (MonotonicDecreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically decreasing mass flow rate with a trend " + "rate across iterations of {:.7R} [kg/s/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + SlopeMdot)); + } + } else { // check for monotonic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.MassFlowRateHistory(StackDepth - 1) < + state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.MassFlowRateHistory(StackDepth)) { + MonotonicIncreaseFound = false; + break; } } - } // significant slope in iterates - } // no osciallation - } // last value does not equal average of stack. + if (MonotonicIncreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically increasing mass flow rate with a trend " + "rate across iterations of {:.7R} [kg/s/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + SlopeMdot)); + } + } + } // significant slope found + } // no oscillation found if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(StackDepth)); + for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + HistoryTrace += + format("{:.7R},", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)); } - ShowContinueError(state, "Node named " + state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + - " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); + ShowContinueError(state, + "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut + + " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace - // end mass flow rate + // end of Outlet node - // Check Temperatures + } // plant loop sides + + } // mass flow not converged + + if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempNotConverged) { + ShowContinueError(state, + "Plant System Named = " + state.dataPlnt->PlantLoop(LoopNum).Name + " did not converge for temperature"); + ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempDemandToSupplyTolValue(StackDepth)); + } + ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { + HistoryTrace += + format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempSupplyToDemandTolValue(StackDepth)); + } + ShowContinueError(state, "Supply-to-Demand interface temperature check value iteration history trace: " + HistoryTrace); + + // now work with history logs for mass flow to detect issues + for (ThisLoopSide = 1; ThisLoopSide <= isize(state.dataPlnt->PlantLoop(LoopNum).LoopSide); ++ThisLoopSide) { + // loop side inlet node FoundOscillationByDuplicate = false; MonotonicDecreaseFound = false; MonotonicIncreaseFound = false; - // check for evidence of oscillation by indentify duplicates when latest value not equal to average - AvgValue = sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) / double(DataConvergParams::ConvergLogStackDepth); - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - AvgValue) > - DataConvergParams::HVACTemperatureOscillationToler) { // last iterate differs from average + AvgValue = sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory) / + double(NumConvergenceHistoryTerms); + if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - AvgValue) > + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (std::abs(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) - - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) < - DataConvergParams::HVACTemperatureOscillationToler) { + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) < + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = true; ShowContinueError( state, - format("Node named {} shows oscillating temperatures across iterations with a repeated value of {:.6R}", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1))); + format("Node named {} shows oscillating temperatures across iterations with a repeated value of {:.5R}", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1))); break; } } - if (!FoundOscillationByDuplicate) { - SlopeTemps = (sum_ConvergLogStackARR * sum(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature) - - double(DataConvergParams::ConvergLogStackDepth) * - sum((ConvergLogStackARR * state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature))) / - (square_sum_ConvergLogStackARR - double(DataConvergParams::ConvergLogStackDepth) * sum_square_ConvergLogStackARR); - if (std::abs(SlopeTemps) > DataConvergParams::HVACTemperatureSlopeToler) { - if (SlopeTemps < 0.0) { // check for monotonic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) > - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing temperature with a trend rate " - "across iterations of {:.4R} [C/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeTemps)); + } + if (!FoundOscillationByDuplicate) { + SlopeTemps = + (sum_ConvergenceHistoryARR * + sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory) - + double(NumConvergenceHistoryTerms) * + sum((ConvergenceHistoryARR * + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory))) / + (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); + if (std::abs(SlopeTemps) > DataConvergParams::PlantTemperatureSlopeToler) { + if (SlopeTemps < 0.0) { // check for monotic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .InletNode.TemperatureHistory(StackDepth - 1) > + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) { + MonotonicDecreaseFound = false; + break; } - } else { // check for monotic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - if (state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth - 1) < - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } - } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing temperatures with a trend " - "rate across iterations of {:.4R} [C/iteration]", - state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum), - SlopeTemps)); + } + if (MonotonicDecreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically decreasing temperatures with a trend " + "rate across iterations of {:.5R} [C/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + SlopeTemps)); + } + } else { // check for monotic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .InletNode.TemperatureHistory(StackDepth - 1) < + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) { + MonotonicIncreaseFound = false; + break; } } - } // significant slope in iterates - } // no osciallation - } // last value does not equal average of stack. + if (MonotonicIncreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically increasing temperatures with a trend " + "rate across iterations of {:.5R} [C/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, + SlopeTemps)); + } + } + } // significant slope found + } // no oscillation found if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(StackDepth)); + for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + HistoryTrace += + format("{:.5R},", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)); } - ShowContinueError(state, "Node named " + state.dataLoopNodes->NodeID(state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum) + - " temperature [C] iteration history trace (most recent first): " + HistoryTrace); + ShowContinueError(state, + "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn + + " temperature [C] iteration history trace (most recent first): " + HistoryTrace); } // need to report trace - // end Temperature checks - - } // loop over zone inlet nodes - } // loop over zones + // end of inlet node - for (LoopNum = 1; LoopNum <= state.dataPlnt->TotNumLoops; ++LoopNum) { - - if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantMassFlowNotConverged) { - ShowContinueError(state, "Plant System Named = " + state.dataPlnt->PlantLoop(LoopNum).Name + " did not converge for mass flow rate"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowDemandToSupplyTolValue(StackDepth)); - } - ShowContinueError(state, "Demand-to-Supply interface mass flow rate check value iteration history trace: " + HistoryTrace); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantFlowSupplyToDemandTolValue(StackDepth)); - } - ShowContinueError(state, "Supply-to-Demand interface mass flow rate check value iteration history trace: " + HistoryTrace); - - // now work with history logs for mass flow to detect issues - for (ThisLoopSide = 1; ThisLoopSide <= isize(state.dataPlnt->PlantLoop(LoopNum).LoopSide); ++ThisLoopSide) { - // loop side inlet node + // loop side outlet node + FoundOscillationByDuplicate = false; + MonotonicDecreaseFound = false; + MonotonicIncreaseFound = false; + AvgValue = sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory) / + double(NumConvergenceHistoryTerms); + if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - AvgValue) > + DataConvergParams::PlantTemperatureOscillationToler) { FoundOscillationByDuplicate = false; - MonotonicDecreaseFound = false; - MonotonicIncreaseFound = false; - AvgValue = - sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory) / double(NumConvergenceHistoryTerms); - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - AvgValue) > - DataConvergParams::PlantFlowRateOscillationToler) { - FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1) - - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) < - DataConvergParams::PlantFlowRateOscillationToler) { - FoundOscillationByDuplicate = true; - ShowContinueError( - state, - format("Node named {} shows oscillating flow rates across iterations with a repeated value of {:.7R}", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(1))); - break; - } + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (std::abs( + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) < + DataConvergParams::PlantTemperatureOscillationToler) { + FoundOscillationByDuplicate = true; + ShowContinueError( + state, + format("Node named {} shows oscillating temperatures across iterations with a repeated value of {:.5R}", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1))); + break; } } - if (!FoundOscillationByDuplicate) { - SlopeMdot = - (sum_ConvergenceHistoryARR * sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory) - - double(NumConvergenceHistoryTerms) * - sum((ConvergenceHistoryARR * state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory))) / - (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { - if (SlopeMdot < 0.0) { // check for monotonic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth - 1) > - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing mass flow rate with a trend " - "rate across iterations of {:.7R} [kg/s/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - SlopeMdot)); - } - } else { // check for monotonic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth - 1) < - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } - } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing mass flow rate with a trend " - "rate across iterations of {:.7R} [kg/s/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - SlopeMdot)); + } + if (!FoundOscillationByDuplicate) { + SlopeTemps = + (sum_ConvergenceHistoryARR * + sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory) - + double(NumConvergenceHistoryTerms) * + sum((ConvergenceHistoryARR * + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory))) / + (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); + if (std::abs(SlopeTemps) > DataConvergParams::PlantFlowRateSlopeToler) { + if (SlopeTemps < 0.0) { // check for monotic decrease + MonotonicDecreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.TemperatureHistory(StackDepth - 1) > + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) { + MonotonicDecreaseFound = false; + break; } } - } // significant slope found - } // no oscillation found - - if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - HistoryTrace += - format("{:.7R},", state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.MassFlowRateHistory(StackDepth)); - } - ShowContinueError(state, "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn + - " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); - } // need to report trace - // end of inlet node - - // loop side outlet node - FoundOscillationByDuplicate = false; - MonotonicDecreaseFound = false; - MonotonicIncreaseFound = false; - AvgValue = sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory) / - double(NumConvergenceHistoryTerms); - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - AvgValue) > - DataConvergParams::PlantFlowRateOscillationToler) { - FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1) - - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)) < - DataConvergParams::PlantFlowRateOscillationToler) { - FoundOscillationByDuplicate = true; - ShowContinueError( - state, - format("Node named {} shows oscillating flow rates across iterations with a repeated value of {:.7R}", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(1))); - break; + if (MonotonicDecreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically decreasing temperatures with a trend " + "rate across iterations of {:.5R} [C/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + SlopeTemps)); } - } - } - if (!FoundOscillationByDuplicate) { - SlopeMdot = - (sum_ConvergenceHistoryARR * sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory) - - double(NumConvergenceHistoryTerms) * - sum((ConvergenceHistoryARR * - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory))) / - (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeMdot) > DataConvergParams::PlantFlowRateSlopeToler) { - if (SlopeMdot < 0.0) { // check for monotonic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth - 1) > - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing mass flow rate with a trend " - "rate across iterations of {:.7R} [kg/s/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - SlopeMdot)); - } - } else { // check for monotonic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth - 1) < - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } + } else { // check for monotic incrase + MonotonicIncreaseFound = true; + for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + if (state.dataPlnt->PlantLoop(LoopNum) + .LoopSide(ThisLoopSide) + .OutletNode.TemperatureHistory(StackDepth - 1) < + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) { + MonotonicIncreaseFound = false; + break; } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing mass flow rate with a trend " - "rate across iterations of {:.7R} [kg/s/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - SlopeMdot)); - } - } - } // significant slope found - } // no oscillation found - - if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - HistoryTrace += - format("{:.7R},", state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.MassFlowRateHistory(StackDepth)); - } - ShowContinueError(state, "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut + - " mass flow rate [kg/s] iteration history trace (most recent first): " + HistoryTrace); - } // need to report trace - // end of Outlet node - - } // plant loop sides - - } // mass flow not converged - - if (state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempNotConverged) { - ShowContinueError(state, "Plant System Named = " + state.dataPlnt->PlantLoop(LoopNum).Name + " did not converge for temperature"); - ShowContinueError(state, "Check values should be zero. Most Recent values listed first."); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempDemandToSupplyTolValue(StackDepth)); - } - ShowContinueError(state, "Demand-to-Supply interface temperature check value iteration history trace: " + HistoryTrace); - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= DataConvergParams::ConvergLogStackDepth; ++StackDepth) { - HistoryTrace += format("{:.6R},", state.dataConvergeParams->PlantConvergence(LoopNum).PlantTempSupplyToDemandTolValue(StackDepth)); - } - ShowContinueError(state, "Supply-to-Demand interface temperature check value iteration history trace: " + HistoryTrace); - - // now work with history logs for mass flow to detect issues - for (ThisLoopSide = 1; ThisLoopSide <= isize(state.dataPlnt->PlantLoop(LoopNum).LoopSide); ++ThisLoopSide) { - // loop side inlet node - FoundOscillationByDuplicate = false; - MonotonicDecreaseFound = false; - MonotonicIncreaseFound = false; - AvgValue = - sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory) / double(NumConvergenceHistoryTerms); - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - AvgValue) > - DataConvergParams::PlantTemperatureOscillationToler) { - FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1) - - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) < - DataConvergParams::PlantTemperatureOscillationToler) { - FoundOscillationByDuplicate = true; - ShowContinueError( - state, - format( - "Node named {} shows oscillating temperatures across iterations with a repeated value of {:.5R}", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(1))); - break; } - } - } - if (!FoundOscillationByDuplicate) { - SlopeTemps = - (sum_ConvergenceHistoryARR * sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory) - - double(NumConvergenceHistoryTerms) * - sum((ConvergenceHistoryARR * state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory))) / - (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeTemps) > DataConvergParams::PlantTemperatureSlopeToler) { - if (SlopeTemps < 0.0) { // check for monotic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth - 1) > - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing temperatures with a trend " - "rate across iterations of {:.5R} [C/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - SlopeTemps)); - } - } else { // check for monotic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth - 1) < - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } - } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing temperatures with a trend " - "rate across iterations of {:.5R} [C/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn, - SlopeTemps)); - } + if (MonotonicIncreaseFound) { + ShowContinueError(state, + format("Node named {} shows monotonically increasing temperatures with a trend " + "rate across iterations of {:.5R} [C/iteration]", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, + SlopeTemps)); } - } // significant slope found - } // no oscillation found - - if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - HistoryTrace += - format("{:.5R},", state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).InletNode.TemperatureHistory(StackDepth)); } - ShowContinueError(state, "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameIn + - " temperature [C] iteration history trace (most recent first): " + HistoryTrace); - } // need to report trace - // end of inlet node + } // significant slope found + } // no oscillation found - // loop side outlet node - FoundOscillationByDuplicate = false; - MonotonicDecreaseFound = false; - MonotonicIncreaseFound = false; - AvgValue = - sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory) / double(NumConvergenceHistoryTerms); - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - AvgValue) > - DataConvergParams::PlantTemperatureOscillationToler) { - FoundOscillationByDuplicate = false; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (std::abs(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1) - - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) < - DataConvergParams::PlantTemperatureOscillationToler) { - FoundOscillationByDuplicate = true; - ShowContinueError( - state, - format( - "Node named {} shows oscillating temperatures across iterations with a repeated value of {:.5R}", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(1))); - break; - } - } + if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { + HistoryTrace = ""; + for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { + HistoryTrace += + format("{:.5R},", + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)); } - if (!FoundOscillationByDuplicate) { - SlopeTemps = - (sum_ConvergenceHistoryARR * sum(state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory) - - double(NumConvergenceHistoryTerms) * - sum((ConvergenceHistoryARR * state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory))) / - (square_sum_ConvergenceHistoryARR - double(NumConvergenceHistoryTerms) * sum_square_ConvergenceHistoryARR); - if (std::abs(SlopeTemps) > DataConvergParams::PlantFlowRateSlopeToler) { - if (SlopeTemps < 0.0) { // check for monotic decrease - MonotonicDecreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth - 1) > - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) { - MonotonicDecreaseFound = false; - break; - } - } - if (MonotonicDecreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically decreasing temperatures with a trend " - "rate across iterations of {:.5R} [C/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - SlopeTemps)); - } - } else { // check for monotic incrase - MonotonicIncreaseFound = true; - for (StackDepth = 2; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - if (state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth - 1) < - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)) { - MonotonicIncreaseFound = false; - break; - } - } - if (MonotonicIncreaseFound) { - ShowContinueError(state, - format("Node named {} shows monotonically increasing temperatures with a trend " - "rate across iterations of {:.5R} [C/iteration]", - state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut, - SlopeTemps)); - } - } - } // significant slope found - } // no oscillation found - - if (MonotonicDecreaseFound || MonotonicIncreaseFound || FoundOscillationByDuplicate) { - HistoryTrace = ""; - for (StackDepth = 1; StackDepth <= NumConvergenceHistoryTerms; ++StackDepth) { - HistoryTrace += - format("{:.5R},", state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).OutletNode.TemperatureHistory(StackDepth)); - } - ShowContinueError(state, "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut + + ShowContinueError(state, + "Node named " + state.dataPlnt->PlantLoop(LoopNum).LoopSide(ThisLoopSide).NodeNameOut + " temperature [C] iteration history trace (most recent first): " + HistoryTrace); - } // need to report trace - // end of Outlet node + } // need to report trace + // end of Outlet node - } // plant loop sides + } // plant loop sides - } // temperature not converged - } // loop over plant loop systems - } + } // temperature not converged + } // loop over plant loop systems + } + } else { + if (state.dataEnvrn->EnvironmentName == ErrEnvironmentName) { + ShowRecurringWarningErrorAtEnd(state, + "SimHVAC: Exceeding Maximum iterations for all HVAC loops, during " + + state.dataEnvrn->EnvironmentName + " continues", + MaxErrCount); } else { - if (state.dataEnvrn->EnvironmentName == ErrEnvironmentName) { - ShowRecurringWarningErrorAtEnd(state, - "SimHVAC: Exceeding Maximum iterations for all HVAC loops, during " + state.dataEnvrn->EnvironmentName + " continues", MaxErrCount); - } else { - MaxErrCount = 0; - ErrEnvironmentName = state.dataEnvrn->EnvironmentName; - ShowRecurringWarningErrorAtEnd(state, - "SimHVAC: Exceeding Maximum iterations for all HVAC loops, during " + state.dataEnvrn->EnvironmentName + " continues", MaxErrCount); - } + MaxErrCount = 0; + ErrEnvironmentName = state.dataEnvrn->EnvironmentName; + ShowRecurringWarningErrorAtEnd(state, + "SimHVAC: Exceeding Maximum iterations for all HVAC loops, during " + + state.dataEnvrn->EnvironmentName + " continues", + MaxErrCount); } } + } - CheckAirLoopFlowBalance(state); - - // Set node setpoints to a flag value so that controllers can check whether their sensed nodes - // have a setpoint - if (!state.dataGlobal->ZoneSizingCalc && !state.dataGlobal->SysSizingCalc) { - if (MySetPointInit) { - if (state.dataLoopNodes->NumOfNodes > 0) { - for (auto &e : state.dataLoopNodes->Node) { - e.TempSetPoint = SensedNodeFlagValue; - e.HumRatSetPoint = SensedNodeFlagValue; - e.HumRatMin = SensedNodeFlagValue; - e.HumRatMax = SensedNodeFlagValue; - e.MassFlowRateSetPoint = SensedNodeFlagValue; // BG 5-26-2009 (being checked in HVACControllers.cc) - } - state.dataLoopNodes->DefaultNodeValues.TempSetPoint = SensedNodeFlagValue; - state.dataLoopNodes->DefaultNodeValues.HumRatSetPoint = SensedNodeFlagValue; - state.dataLoopNodes->DefaultNodeValues.HumRatMin = SensedNodeFlagValue; - state.dataLoopNodes->DefaultNodeValues.HumRatMax = SensedNodeFlagValue; - state.dataLoopNodes->DefaultNodeValues.MassFlowRateSetPoint = SensedNodeFlagValue; // BG 5-26-2009 (being checked in HVACControllers.cc) + CheckAirLoopFlowBalance(state); + + // Set node setpoints to a flag value so that controllers can check whether their sensed nodes + // have a setpoint + if (!state.dataGlobal->ZoneSizingCalc && !state.dataGlobal->SysSizingCalc) { + if (state.dataHVACMgr->MySetPointInit) { + if (state.dataLoopNodes->NumOfNodes > 0) { + for (auto &e : state.dataLoopNodes->Node) { + e.TempSetPoint = SensedNodeFlagValue; + e.HumRatSetPoint = SensedNodeFlagValue; + e.HumRatMin = SensedNodeFlagValue; + e.HumRatMax = SensedNodeFlagValue; + e.MassFlowRateSetPoint = SensedNodeFlagValue; // BG 5-26-2009 (being checked in HVACControllers.cc) } - MySetPointInit = false; - DoSetPointTest = true; - } else { - DoSetPointTest = false; + state.dataLoopNodes->DefaultNodeValues.TempSetPoint = SensedNodeFlagValue; + state.dataLoopNodes->DefaultNodeValues.HumRatSetPoint = SensedNodeFlagValue; + state.dataLoopNodes->DefaultNodeValues.HumRatMin = SensedNodeFlagValue; + state.dataLoopNodes->DefaultNodeValues.HumRatMax = SensedNodeFlagValue; + state.dataLoopNodes->DefaultNodeValues.MassFlowRateSetPoint = + SensedNodeFlagValue; // BG 5-26-2009 (being checked in HVACControllers.cc) } + state.dataHVACMgr->MySetPointInit = false; + DoSetPointTest = true; + } else { + DoSetPointTest = false; } - if (SetPointErrorFlag) { - ShowFatalError(state, "Previous severe set point errors cause program termination"); - } } + if (SetPointErrorFlag) { + ShowFatalError(state, "Previous severe set point errors cause program termination"); + } +} + +void SimSelectedEquipment(EnergyPlusData &state, + bool &SimAirLoops, // True when the air loops need to be (re)simulated + bool &SimZoneEquipment, // True when zone equipment components need to be (re)simulated + bool &SimNonZoneEquipment, // True when non-zone equipment components need to be (re)simulated + bool &SimPlantLoops, // True when the main plant loops need to be (re)simulated + bool &SimElecCircuits, // True when electric circuits need to be (re)simulated + bool &FirstHVACIteration, // True when solution technique on first iteration + bool const LockPlantFlows) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Russ Taylor, Rick Strand + // DATE WRITTEN May 1998 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This subroutine receives the flags from SimHVAC which determines + // which middle-level managers must be called. - void SimSelectedEquipment(EnergyPlusData &state, bool &SimAirLoops, // True when the air loops need to be (re)simulated - bool &SimZoneEquipment, // True when zone equipment components need to be (re)simulated - bool &SimNonZoneEquipment, // True when non-zone equipment components need to be (re)simulated - bool &SimPlantLoops, // True when the main plant loops need to be (re)simulated - bool &SimElecCircuits, // True when electric circuits need to be (re)simulated - bool &FirstHVACIteration, // True when solution technique on first iteration - bool const LockPlantFlows) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Russ Taylor, Rick Strand - // DATE WRITTEN May 1998 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine receives the flags from SimHVAC which determines - // which middle-level managers must be called. - - // METHODOLOGY EMPLOYED: - // Each flag is checked and the appropriate manager is then called. - - // Using/Aliasing - using AirflowNetworkBalanceManager::ManageAirflowNetworkBalance; - using NonZoneEquipmentManager::ManageNonZoneEquipment; - using PlantManager::ManagePlantLoops; - using PlantUtilities::AnyPlantLoopSidesNeedSim; - using PlantUtilities::ResetAllPlantInterConnectFlags; - using PlantUtilities::SetAllFlowLocks; - using SimAirServingZones::ManageAirLoops; - using ZoneEquipmentManager::ManageZoneEquipment; - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - bool ResimulateAirZone; // True when solution technique on third iteration used in AirflowNetwork - - // SUBROUTINE PARAMETER DEFINITIONS: - int const MaxAir(5); // Iteration Max for Air Simulation Iterations - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int IterAir; // counts iterations to enforce maximum iteration limit - - IterAir = 0; - - // Set all plant flow locks to UNLOCKED to allow air side components to operate properly - // This requires that the plant flow resolver carefully set the min/max avail limits on - // air side components to ensure they request within bounds. - if (LockPlantFlows) { - SetAllFlowLocks(state, DataPlant::iFlowLock::Locked); - } else { - SetAllFlowLocks(state, DataPlant::iFlowLock::Unlocked); - } - ResetAllPlantInterConnectFlags(state); - - if (state.dataGlobal->BeginEnvrnFlag && MyEnvrnFlag2) { - // Following comment is incorrect! (LKL) Even the first time through this does more than read in data. - // Zone equipment data needs to be read in before air loop data to allow the - // determination of which zones are connected to which air loops. - // This call of ManageZoneEquipment does nothing except force the - // zone equipment data to be read in. - ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); - MyEnvrnFlag2 = false; - } - if (!state.dataGlobal->BeginEnvrnFlag) { - MyEnvrnFlag2 = true; - } + // METHODOLOGY EMPLOYED: + // Each flag is checked and the appropriate manager is then called. + + // Using/Aliasing + using AirflowNetworkBalanceManager::ManageAirflowNetworkBalance; + using NonZoneEquipmentManager::ManageNonZoneEquipment; + using PlantManager::ManagePlantLoops; + using PlantUtilities::AnyPlantLoopSidesNeedSim; + using PlantUtilities::ResetAllPlantInterConnectFlags; + using PlantUtilities::SetAllFlowLocks; + using SimAirServingZones::ManageAirLoops; + using ZoneEquipmentManager::ManageZoneEquipment; + + // Locals + // SUBROUTINE ARGUMENT DEFINITIONS: + bool ResimulateAirZone; // True when solution technique on third iteration used in AirflowNetwork + + // SUBROUTINE PARAMETER DEFINITIONS: + int const MaxAir(5); // Iteration Max for Air Simulation Iterations + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int IterAir; // counts iterations to enforce maximum iteration limit + + IterAir = 0; + + // Set all plant flow locks to UNLOCKED to allow air side components to operate properly + // This requires that the plant flow resolver carefully set the min/max avail limits on + // air side components to ensure they request within bounds. + if (LockPlantFlows) { + SetAllFlowLocks(state, DataPlant::iFlowLock::Locked); + } else { + SetAllFlowLocks(state, DataPlant::iFlowLock::Unlocked); + } + ResetAllPlantInterConnectFlags(state); + + if (state.dataGlobal->BeginEnvrnFlag && state.dataHVACMgr->MyEnvrnFlag2) { + // Following comment is incorrect! (LKL) Even the first time through this does more than read in data. + // Zone equipment data needs to be read in before air loop data to allow the + // determination of which zones are connected to which air loops. + // This call of ManageZoneEquipment does nothing except force the + // zone equipment data to be read in. + ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); + state.dataHVACMgr->MyEnvrnFlag2 = false; + } + if (!state.dataGlobal->BeginEnvrnFlag) { + state.dataHVACMgr->MyEnvrnFlag2 = true; + } - if (FirstHVACIteration) { - RepIterAir = 0; + if (FirstHVACIteration) { + state.dataHVACMgr->RepIterAir = 0; + // Call AirflowNetwork simulation to calculate air flows and pressures + if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { + ManageAirflowNetworkBalance(state, FirstHVACIteration); + } + ManageAirLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment); + state.dataAirLoop->AirLoopInputsFilled = true; // all air loop inputs have been read in + SimAirLoops = true; // Need to make sure that SimAirLoop is simulated at min twice to calculate PLR in some air loop equipment + AirLoopsSimOnce = true; // air loops simulated once for this environment + ResetTerminalUnitFlowLimits(state); + state.dataHVACMgr->FlowMaxAvailAlreadyReset = true; + ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); + SimZoneEquipment = true; // needs to be simulated at least twice for flow resolution to propagate to this routine + ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipment); + facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); + + ManagePlantLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment, SimNonZoneEquipment, SimPlantLoops, SimElecCircuits); + + state.dataErrTracking->AskForPlantCheckOnAbort = true; // need to make a first pass through plant calcs before this check make sense + facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); + } else { + state.dataHVACMgr->FlowResolutionNeeded = false; + while ((SimAirLoops || SimZoneEquipment) && (IterAir <= MaxAir)) { + ++IterAir; // Increment the iteration counter // Call AirflowNetwork simulation to calculate air flows and pressures + ResimulateAirZone = false; if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { - ManageAirflowNetworkBalance(state, FirstHVACIteration); + ManageAirflowNetworkBalance(state, FirstHVACIteration, IterAir, ResimulateAirZone); + } + if (SimAirLoops) { + ManageAirLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment); + SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated } - ManageAirLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment); - state.dataAirLoop->AirLoopInputsFilled = true; // all air loop inputs have been read in - SimAirLoops = true; // Need to make sure that SimAirLoop is simulated at min twice to calculate PLR in some air loop equipment - AirLoopsSimOnce = true; // air loops simulated once for this environment - ResetTerminalUnitFlowLimits(state); - FlowMaxAvailAlreadyReset = true; - ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); - SimZoneEquipment = true; // needs to be simulated at least twice for flow resolution to propagate to this routine - ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipment); - facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); - - ManagePlantLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment, SimNonZoneEquipment, SimPlantLoops, SimElecCircuits); - state.dataErrTracking->AskForPlantCheckOnAbort = true; // need to make a first pass through plant calcs before this check make sense - facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); - } else { - FlowResolutionNeeded = false; - while ((SimAirLoops || SimZoneEquipment) && (IterAir <= MaxAir)) { - ++IterAir; // Increment the iteration counter - // Call AirflowNetwork simulation to calculate air flows and pressures - ResimulateAirZone = false; - if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { - ManageAirflowNetworkBalance(state, FirstHVACIteration, IterAir, ResimulateAirZone); - } - if (SimAirLoops) { - ManageAirLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment); - SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated + // make sure flow resolution gets done + if (state.dataHVACMgr->FlowResolutionNeeded) { + SimZoneEquipment = true; + } + if (SimZoneEquipment) { + if ((IterAir == 1) && (!state.dataHVACMgr->FlowMaxAvailAlreadyReset)) { // don't do reset if already done in FirstHVACIteration + // ResetTerminalUnitFlowLimits(); // don't do reset at all - interferes with convergence and terminal unit flow controls + state.dataHVACMgr->FlowResolutionNeeded = true; + } else { + ResolveAirLoopFlowLimits(state); + state.dataHVACMgr->FlowResolutionNeeded = false; } + ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); + SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated + } + state.dataHVACMgr->FlowMaxAvailAlreadyReset = false; - // make sure flow resolution gets done - if (FlowResolutionNeeded) { + // IterAir = IterAir + 1 ! Increment the iteration counter + if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { + if (ResimulateAirZone) { // Need to make sure that SimAirLoop and SimZoneEquipment are simulated + SimAirLoops = true; // at min three times using ONOFF fan with the AirflowNetwork model SimZoneEquipment = true; } - if (SimZoneEquipment) { - if ((IterAir == 1) && (!FlowMaxAvailAlreadyReset)) { // don't do reset if already done in FirstHVACIteration - // ResetTerminalUnitFlowLimits(); // don't do reset at all - interferes with convergence and terminal unit flow controls - FlowResolutionNeeded = true; - } else { - ResolveAirLoopFlowLimits(state); - FlowResolutionNeeded = false; - } - ManageZoneEquipment(state, FirstHVACIteration, SimZoneEquipment, SimAirLoops); - SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated - } - FlowMaxAvailAlreadyReset = false; - - // IterAir = IterAir + 1 ! Increment the iteration counter - if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) { - if (ResimulateAirZone) { // Need to make sure that SimAirLoop and SimZoneEquipment are simulated - SimAirLoops = true; // at min three times using ONOFF fan with the AirflowNetwork model - SimZoneEquipment = true; - } - } } + } - RepIterAir += IterAir; - if (IterAir > MaxAir) { - state.dataConvergeParams->AirLoopConvergFail = 1; - } else { - state.dataConvergeParams->AirLoopConvergFail = 0; - } - // Check to see if any components have been locked out. If so, SimAirLoops will be reset to TRUE. - ResolveLockoutFlags(state, SimAirLoops); + state.dataHVACMgr->RepIterAir += IterAir; + if (IterAir > MaxAir) { + state.dataConvergeParams->AirLoopConvergFail = 1; + } else { + state.dataConvergeParams->AirLoopConvergFail = 0; + } + // Check to see if any components have been locked out. If so, SimAirLoops will be reset to TRUE. + ResolveLockoutFlags(state, SimAirLoops); - if (SimNonZoneEquipment) { - ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipment); - SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated - } + if (SimNonZoneEquipment) { + ManageNonZoneEquipment(state, FirstHVACIteration, SimNonZoneEquipment); + SimElecCircuits = true; // If this was simulated there are possible electric changes that need to be simulated + } - if (SimElecCircuits) { - facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); - } + if (SimElecCircuits) { + facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); + } - if (!SimPlantLoops) { - // check to see if any air side component may have requested plant resim - if (AnyPlantLoopSidesNeedSim(state)) { - SimPlantLoops = true; - } + if (!SimPlantLoops) { + // check to see if any air side component may have requested plant resim + if (AnyPlantLoopSidesNeedSim(state)) { + SimPlantLoops = true; } + } - if (SimPlantLoops) { - ManagePlantLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment, SimNonZoneEquipment, SimPlantLoops, SimElecCircuits); - } + if (SimPlantLoops) { + ManagePlantLoops(state, FirstHVACIteration, SimAirLoops, SimZoneEquipment, SimNonZoneEquipment, SimPlantLoops, SimElecCircuits); + } - if (SimElecCircuits) { - facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); - } + if (SimElecCircuits) { + facilityElectricServiceObj->manageElectricPowerService(state, FirstHVACIteration, SimElecCircuitsFlag, false); } } +} - void ResetTerminalUnitFlowLimits(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN Feb 2010 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // Reset the max flow available limits at the inlet nodes of terminal units - - // METHODOLOGY EMPLOYED: - // Loops through all air loops, finds the inlet nodes of the terminal units - // served by each air loop, and resets the node MassFlowRateMaxAvail (and MinAvail) to - // the hard max and mins. - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int AirLoopIndex; - int ZonesCooledIndex; - int ZonesHeatedIndex; - int TermInletNode; - - for (AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops - for (ZonesCooledIndex = 1; ZonesCooledIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; - ++ZonesCooledIndex) { // loop over the zones cooled by this air loop - TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); - // reset the max avail flow rate at the terminal unit cold air inlet to the max - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMin; - } - for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; - ++ZonesHeatedIndex) { // loop over the zones heated by this air loop - TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); - // reset the max avail flow rate at the terminal unit hot air inlet to the max - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMin; - } +void ResetTerminalUnitFlowLimits(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Fred Buhl + // DATE WRITTEN Feb 2010 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // Reset the max flow available limits at the inlet nodes of terminal units + + // METHODOLOGY EMPLOYED: + // Loops through all air loops, finds the inlet nodes of the terminal units + // served by each air loop, and resets the node MassFlowRateMaxAvail (and MinAvail) to + // the hard max and mins. + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int AirLoopIndex; + int ZonesCooledIndex; + int ZonesHeatedIndex; + int TermInletNode; + + for (AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops + for (ZonesCooledIndex = 1; ZonesCooledIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; + ++ZonesCooledIndex) { // loop over the zones cooled by this air loop + TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); + // reset the max avail flow rate at the terminal unit cold air inlet to the max + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMin; + } + for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; + ++ZonesHeatedIndex) { // loop over the zones heated by this air loop + TermInletNode = state.dataAirLoop->AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); + // reset the max avail flow rate at the terminal unit hot air inlet to the max + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMin; } } +} - void ResolveAirLoopFlowLimits(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN August 2003 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine is for resolving hard flow mismatches between zone equipment and - // the primary air loop. Such a mismatch can occur when the air terminal units are - // requesting more air than the central air system can supply. - - // METHODOLOGY EMPLOYED: - // Sets the MassFlowRateMaxAvail on the terminal unit inlet nodes to match the - // maximum available from the primary air loop. - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int AirLoopIndex; - int ZonesCooledIndex; - int ZonesHeatedIndex; - int TermInletNode; - int SupplyIndex; - int SupplyNode; - Real64 FlowRatio; - - auto &AirToZoneNodeInfo(state.dataAirLoop->AirToZoneNodeInfo); - - for (AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops - for (SupplyIndex = 1; SupplyIndex <= AirToZoneNodeInfo(AirLoopIndex).NumSupplyNodes; - ++SupplyIndex) { // loop over the air loop supply outlets - if (AirToZoneNodeInfo(AirLoopIndex).SupplyDuctType(SupplyIndex) == Cooling) { // check for cooling duct - // check if terminal units requesting more air than air loop can supply; if so, set terminal unit inlet - // node mass flow max avail to what air loop can supply - SupplyNode = AirToZoneNodeInfo(AirLoopIndex).AirLoopSupplyNodeNum(SupplyIndex); - if (state.dataLoopNodes->Node(SupplyNode).MassFlowRate > 0.0) { - // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) - if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > - DataConvergParams::HVACFlowRateToler * 0.01) { - FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; +void ResolveAirLoopFlowLimits(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Fred Buhl + // DATE WRITTEN August 2003 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This subroutine is for resolving hard flow mismatches between zone equipment and + // the primary air loop. Such a mismatch can occur when the air terminal units are + // requesting more air than the central air system can supply. + + // METHODOLOGY EMPLOYED: + // Sets the MassFlowRateMaxAvail on the terminal unit inlet nodes to match the + // maximum available from the primary air loop. + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int AirLoopIndex; + int ZonesCooledIndex; + int ZonesHeatedIndex; + int TermInletNode; + int SupplyIndex; + int SupplyNode; + Real64 FlowRatio; + + auto &AirToZoneNodeInfo(state.dataAirLoop->AirToZoneNodeInfo); + + for (AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops + for (SupplyIndex = 1; SupplyIndex <= AirToZoneNodeInfo(AirLoopIndex).NumSupplyNodes; ++SupplyIndex) { // loop over the air loop supply outlets + if (AirToZoneNodeInfo(AirLoopIndex).SupplyDuctType(SupplyIndex) == Cooling) { // check for cooling duct + // check if terminal units requesting more air than air loop can supply; if so, set terminal unit inlet + // node mass flow max avail to what air loop can supply + SupplyNode = AirToZoneNodeInfo(AirLoopIndex).AirLoopSupplyNodeNum(SupplyIndex); + if (state.dataLoopNodes->Node(SupplyNode).MassFlowRate > 0.0) { + // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) + if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - + state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > DataConvergParams::HVACFlowRateToler * 0.01) { + FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; + for (ZonesCooledIndex = 1; ZonesCooledIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { + TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = + min(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); + } + } + if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - + state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < -DataConvergParams::HVACFlowRateToler * 0.01) { + if (state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint == 0.0) { + // CALL ShowFatalError('ResolveAirLoopFlowLimits: Node MassFlowRateSetPoint = 0.0, Node='// & + // TRIM(state.dataLoopNodes->NodeID(SupplyNode))// & + // ', check for Node Connection Errors in the following messages.') for (ZonesCooledIndex = 1; ZonesCooledIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = - min(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); + state.dataLoopNodes->Node(SupplyNode).MassFlowRate / double(AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled); } - } - if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < - -DataConvergParams::HVACFlowRateToler * 0.01) { - if (state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint == 0.0) { - // CALL ShowFatalError('ResolveAirLoopFlowLimits: Node MassFlowRateSetPoint = 0.0, Node='// & - // TRIM(state.dataLoopNodes->NodeID(SupplyNode))// & - // ', check for Node Connection Errors in the following messages.') - for (ZonesCooledIndex = 1; ZonesCooledIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { - TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = - state.dataLoopNodes->Node(SupplyNode).MassFlowRate / double(AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled); - } - } else { - FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; - for (ZonesCooledIndex = 1; ZonesCooledIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { - TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = - max(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); - } + } else { + FlowRatio = + state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; + for (ZonesCooledIndex = 1; ZonesCooledIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled; ++ZonesCooledIndex) { + TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitCoolInletNodes(ZonesCooledIndex); + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + max(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); } } } } } - for (SupplyIndex = 1; SupplyIndex <= AirToZoneNodeInfo(AirLoopIndex).NumSupplyNodes; - ++SupplyIndex) { // loop over the air loop supply outlets - if (AirToZoneNodeInfo(AirLoopIndex).SupplyDuctType(SupplyIndex) == Heating) { // check for heating duct - // check if terminal units requesting more air than air loop can supply; if so, set terminal unit inlet - // node mass flow max avail to what air loop can supply - SupplyNode = AirToZoneNodeInfo(AirLoopIndex).AirLoopSupplyNodeNum(SupplyIndex); - if (state.dataLoopNodes->Node(SupplyNode).MassFlowRate > 0.0) { - // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) - if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > - DataConvergParams::HVACFlowRateToler * 0.01) { - FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; + } + for (SupplyIndex = 1; SupplyIndex <= AirToZoneNodeInfo(AirLoopIndex).NumSupplyNodes; ++SupplyIndex) { // loop over the air loop supply outlets + if (AirToZoneNodeInfo(AirLoopIndex).SupplyDuctType(SupplyIndex) == Heating) { // check for heating duct + // check if terminal units requesting more air than air loop can supply; if so, set terminal unit inlet + // node mass flow max avail to what air loop can supply + SupplyNode = AirToZoneNodeInfo(AirLoopIndex).AirLoopSupplyNodeNum(SupplyIndex); + if (state.dataLoopNodes->Node(SupplyNode).MassFlowRate > 0.0) { + // must include bypass flow for ChangeoverBypass system so that terminal units are not restricted (e.g., MaxAvail is lowered) + if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - + state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) > DataConvergParams::HVACFlowRateToler * 0.01) { + FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; + for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { + TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = + min(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); + } + } + if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - + state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < -DataConvergParams::HVACFlowRateToler * 0.01) { + if (state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint == 0.0) { + // ', check for Node Connection Errors in the following messages.') for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = - min(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); + state.dataLoopNodes->Node(SupplyNode).MassFlowRate / double(AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled); } - } - if ((state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint - state.dataLoopNodes->Node(SupplyNode).MassFlowRate - state.dataAirLoop->AirLoopFlow(AirLoopIndex).BypassMassFlow) < - -DataConvergParams::HVACFlowRateToler * 0.01) { - if (state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint == 0.0) { - // ', check for Node Connection Errors in the following messages.') - for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { - TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRateMax; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = - state.dataLoopNodes->Node(SupplyNode).MassFlowRate / double(AirToZoneNodeInfo(AirLoopIndex).NumZonesCooled); - } - } else { - FlowRatio = state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; - for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { - TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; - state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = - max(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); - } + } else { + FlowRatio = + state.dataLoopNodes->Node(SupplyNode).MassFlowRate / state.dataLoopNodes->Node(SupplyNode).MassFlowRateSetPoint; + for (ZonesHeatedIndex = 1; ZonesHeatedIndex <= AirToZoneNodeInfo(AirLoopIndex).NumZonesHeated; ++ZonesHeatedIndex) { + TermInletNode = AirToZoneNodeInfo(AirLoopIndex).TermUnitHeatInletNodes(ZonesHeatedIndex); + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail = + state.dataLoopNodes->Node(TermInletNode).MassFlowRate * FlowRatio; + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail = + max(state.dataLoopNodes->Node(TermInletNode).MassFlowRateMaxAvail, + state.dataLoopNodes->Node(TermInletNode).MassFlowRateMinAvail); } } } @@ -1982,851 +2107,924 @@ namespace EnergyPlus::HVACManager { } } } +} - void ResolveLockoutFlags(EnergyPlusData &state, bool &SimAir) // TRUE means air loops must be (re)simulated - { +void ResolveLockoutFlags(EnergyPlusData &state, bool &SimAir) // TRUE means air loops must be (re)simulated +{ - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN December 2003 - // MODIFIED na - // RE-ENGINEERED na + // SUBROUTINE INFORMATION: + // AUTHOR Fred Buhl + // DATE WRITTEN December 2003 + // MODIFIED na + // RE-ENGINEERED na - // PURPOSE OF THIS SUBROUTINE: - // This subroutine checks for components lockout flags and asks for air loop resimulation - // if any components have been locked out + // PURPOSE OF THIS SUBROUTINE: + // This subroutine checks for components lockout flags and asks for air loop resimulation + // if any components have been locked out - // METHODOLOGY EMPLOYED: - // Checks if loop lockout flags are .TRUE.; if so, sets SimAirLoops to .TRUE. + // METHODOLOGY EMPLOYED: + // Checks if loop lockout flags are .TRUE.; if so, sets SimAirLoops to .TRUE. - auto &AirLoopControlInfo(state.dataAirLoop->AirLoopControlInfo); + auto &AirLoopControlInfo(state.dataAirLoop->AirLoopControlInfo); - for (int AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops - // check if economizer ia active and if there is a request that it be locked out - if (AirLoopControlInfo(AirLoopIndex).EconoActive && - (AirLoopControlInfo(AirLoopIndex).ReqstEconoLockoutWithCompressor || AirLoopControlInfo(AirLoopIndex).ReqstEconoLockoutWithHeating)) { - AirLoopControlInfo(AirLoopIndex).EconoLockout = true; - SimAir = true; - } + for (int AirLoopIndex = 1; AirLoopIndex <= NumPrimaryAirSys; ++AirLoopIndex) { // loop over the primary air loops + // check if economizer ia active and if there is a request that it be locked out + if (AirLoopControlInfo(AirLoopIndex).EconoActive && + (AirLoopControlInfo(AirLoopIndex).ReqstEconoLockoutWithCompressor || AirLoopControlInfo(AirLoopIndex).ReqstEconoLockoutWithHeating)) { + AirLoopControlInfo(AirLoopIndex).EconoLockout = true; + SimAir = true; } } - - void ResetHVACControl(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN December 2004 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine resets loop control flags and specified flow rates that may - // have been set by the set point and availability managers in the previous - // time step - - if (NumPrimaryAirSys == 0) return; - for (auto &e : state.dataAirLoop->AirLoopControlInfo) { - e.NightVent = false; - e.LoopFlowRateSet = false; - } - for (auto &e : state.dataAirLoop->AirLoopFlow) - e.ReqSupplyFrac = 1.0; +} + +void ResetHVACControl(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Fred Buhl + // DATE WRITTEN December 2004 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This subroutine resets loop control flags and specified flow rates that may + // have been set by the set point and availability managers in the previous + // time step + + if (NumPrimaryAirSys == 0) return; + for (auto &e : state.dataAirLoop->AirLoopControlInfo) { + e.NightVent = false; + e.LoopFlowRateSet = false; } - - void ResetNodeData(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Linda Lawrie - // DATE WRITTEN March 2005 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This routine resets all node data to "initial" conditions. - - if (state.dataLoopNodes->NumOfNodes <= 0) return; - - for (auto &e : state.dataLoopNodes->Node) { - e.Temp = state.dataLoopNodes->DefaultNodeValues.Temp; - e.TempMin = state.dataLoopNodes->DefaultNodeValues.TempMin; - e.TempMax = state.dataLoopNodes->DefaultNodeValues.TempMax; - e.TempSetPoint = state.dataLoopNodes->DefaultNodeValues.TempSetPoint; - e.MassFlowRate = state.dataLoopNodes->DefaultNodeValues.MassFlowRate; - e.MassFlowRateMin = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMin; - e.MassFlowRateMax = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMax; - e.MassFlowRateMinAvail = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMinAvail; - e.MassFlowRateMaxAvail = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMaxAvail; - e.MassFlowRateSetPoint = state.dataLoopNodes->DefaultNodeValues.MassFlowRateSetPoint; - e.Quality = state.dataLoopNodes->DefaultNodeValues.Quality; - e.Press = state.dataLoopNodes->DefaultNodeValues.Press; - e.Enthalpy = state.dataLoopNodes->DefaultNodeValues.Enthalpy; - e.HumRat = state.dataLoopNodes->DefaultNodeValues.HumRat; - e.HumRatMin = state.dataLoopNodes->DefaultNodeValues.HumRatMin; - e.HumRatMax = state.dataLoopNodes->DefaultNodeValues.HumRatMax; - e.HumRatSetPoint = state.dataLoopNodes->DefaultNodeValues.HumRatSetPoint; - e.TempSetPointHi = state.dataLoopNodes->DefaultNodeValues.TempSetPointHi; - e.TempSetPointLo = state.dataLoopNodes->DefaultNodeValues.TempSetPointLo; - } - - if (allocated(state.dataLoopNodes->MoreNodeInfo)) { - for (auto &e : state.dataLoopNodes->MoreNodeInfo) { - e.WetBulbTemp = state.dataLoopNodes->DefaultNodeValues.Temp; - e.RelHumidity = 0.0; - e.ReportEnthalpy = state.dataLoopNodes->DefaultNodeValues.Enthalpy; - e.VolFlowRateStdRho = 0.0; - e.VolFlowRateCrntRho = 0.0; - e.Density = 0.0; - } - } + for (auto &e : state.dataAirLoop->AirLoopFlow) + e.ReqSupplyFrac = 1.0; +} + +void ResetNodeData(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Linda Lawrie + // DATE WRITTEN March 2005 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This routine resets all node data to "initial" conditions. + + if (state.dataLoopNodes->NumOfNodes <= 0) return; + + for (auto &e : state.dataLoopNodes->Node) { + e.Temp = state.dataLoopNodes->DefaultNodeValues.Temp; + e.TempMin = state.dataLoopNodes->DefaultNodeValues.TempMin; + e.TempMax = state.dataLoopNodes->DefaultNodeValues.TempMax; + e.TempSetPoint = state.dataLoopNodes->DefaultNodeValues.TempSetPoint; + e.MassFlowRate = state.dataLoopNodes->DefaultNodeValues.MassFlowRate; + e.MassFlowRateMin = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMin; + e.MassFlowRateMax = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMax; + e.MassFlowRateMinAvail = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMinAvail; + e.MassFlowRateMaxAvail = state.dataLoopNodes->DefaultNodeValues.MassFlowRateMaxAvail; + e.MassFlowRateSetPoint = state.dataLoopNodes->DefaultNodeValues.MassFlowRateSetPoint; + e.Quality = state.dataLoopNodes->DefaultNodeValues.Quality; + e.Press = state.dataLoopNodes->DefaultNodeValues.Press; + e.Enthalpy = state.dataLoopNodes->DefaultNodeValues.Enthalpy; + e.HumRat = state.dataLoopNodes->DefaultNodeValues.HumRat; + e.HumRatMin = state.dataLoopNodes->DefaultNodeValues.HumRatMin; + e.HumRatMax = state.dataLoopNodes->DefaultNodeValues.HumRatMax; + e.HumRatSetPoint = state.dataLoopNodes->DefaultNodeValues.HumRatSetPoint; + e.TempSetPointHi = state.dataLoopNodes->DefaultNodeValues.TempSetPointHi; + e.TempSetPointLo = state.dataLoopNodes->DefaultNodeValues.TempSetPointLo; } - void UpdateZoneListAndGroupLoads(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Apparently someone who doesn't believe in documenting. - // DATE WRITTEN ??? - // MODIFIED na - // RE-ENGINEERED na - - // Using/Aliasing - using namespace DataHeatBalance; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneNum; - int ListNum; - int GroupNum; - int Mult; - - auto &ZoneList(state.dataHeatBal->ZoneList); - auto &ZoneGroup(state.dataHeatBal->ZoneGroup); - auto &ListSNLoadHeatEnergy(state.dataHeatBal->ListSNLoadHeatEnergy); - auto &ListSNLoadCoolEnergy(state.dataHeatBal->ListSNLoadCoolEnergy); - auto &ListSNLoadHeatRate(state.dataHeatBal->ListSNLoadHeatRate); - auto &ListSNLoadCoolRate(state.dataHeatBal->ListSNLoadCoolRate); - - // Sum ZONE LIST and ZONE GROUP report variables - ListSNLoadHeatEnergy = 0.0; - ListSNLoadCoolEnergy = 0.0; - ListSNLoadHeatRate = 0.0; - ListSNLoadCoolRate = 0.0; - - for (ListNum = 1; ListNum <= state.dataHeatBal->NumOfZoneLists; ++ListNum) { - for (ZoneNum = 1; ZoneNum <= ZoneList(ListNum).NumOfZones; ++ZoneNum) { - Mult = state.dataHeatBal->Zone(ZoneNum).Multiplier; - ListSNLoadHeatEnergy(ListNum) += state.dataHeatBal->SNLoadHeatEnergy(ZoneList(ListNum).Zone(ZoneNum)) * Mult; - ListSNLoadCoolEnergy(ListNum) += state.dataHeatBal->SNLoadCoolEnergy(ZoneList(ListNum).Zone(ZoneNum)) * Mult; - ListSNLoadHeatRate(ListNum) += state.dataHeatBal->SNLoadHeatRate(ZoneList(ListNum).Zone(ZoneNum)) * Mult; - ListSNLoadCoolRate(ListNum) += state.dataHeatBal->SNLoadCoolRate(ZoneList(ListNum).Zone(ZoneNum)) * Mult; - } // ZoneNum - } // ListNum - - for (GroupNum = 1; GroupNum <= state.dataHeatBal->NumOfZoneGroups; ++GroupNum) { - Mult = state.dataHeatBal->ZoneGroup(GroupNum).Multiplier; - state.dataHeatBal->GroupSNLoadHeatEnergy(GroupNum) = ListSNLoadHeatEnergy(ZoneGroup(GroupNum).ZoneList) * Mult; - state.dataHeatBal->GroupSNLoadCoolEnergy(GroupNum) = ListSNLoadCoolEnergy(ZoneGroup(GroupNum).ZoneList) * Mult; - state.dataHeatBal->GroupSNLoadHeatRate(GroupNum) = ListSNLoadHeatRate(ZoneGroup(GroupNum).ZoneList) * Mult; - state.dataHeatBal->GroupSNLoadCoolRate(GroupNum) = ListSNLoadCoolRate(ZoneGroup(GroupNum).ZoneList) * Mult; - } // GroupNum + if (allocated(state.dataLoopNodes->MoreNodeInfo)) { + for (auto &e : state.dataLoopNodes->MoreNodeInfo) { + e.WetBulbTemp = state.dataLoopNodes->DefaultNodeValues.Temp; + e.RelHumidity = 0.0; + e.ReportEnthalpy = state.dataLoopNodes->DefaultNodeValues.Enthalpy; + e.VolFlowRateStdRho = 0.0; + e.VolFlowRateCrntRho = 0.0; + e.Density = 0.0; + } } - - void ReportAirHeatBalance(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Linda Lawrie - // DATE WRITTEN July 2000 - // MODIFIED Shirey, Jan 2008 (MIXING/CROSS MIXING outputs) - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This subroutine updates the report variables for the AirHeatBalance. - - // Using/Aliasing - using DataHeatBalance::AirBalanceQuadrature; - using DataHVACGlobals::CycleOn; - using DataHVACGlobals::CycleOnZoneFansOnly; - using Psychrometrics::PsyCpAirFnW; - using Psychrometrics::PsyHgAirFnWTdb; - using Psychrometrics::PsyRhoAirFnPbTdbW; - using AirflowNetworkBalanceManager::ReportAirflowNetwork; - using DataHVACGlobals::FanType_ZoneExhaust; - - // SUBROUTINE PARAMETER DEFINITIONS: - static std::string const RoutineName3("ReportAirHeatBalance:3"); - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneLoop; // Counter for the # of zones (nz) - int ZoneA; // Mated zone number for pair pf zones sharing refrigeration door opening - int ZoneB; // Mated zone number for pair pf zones sharing refrigeration door opening - int VentNum; // Counter for ventilation statements - int FanNum; // Counter for exhaust fans - Real64 AirDensity; // Density of air (kg/m^3) - Real64 CpAir; // Heat capacity of air (J/kg-C) - Real64 ADSCorrectionFactor; // Correction factor of air flow model values when ADS is simulated - Real64 H2OHtOfVap; // Heat of vaporization of air - Real64 TotalLoad; // Total loss or gain - int MixNum; // Counter for MIXING and Cross Mixing statements - static Array1D MixSenLoad; // Mixing sensible loss or gain - static Array1D MixLatLoad; // Mixing latent loss or gain - int j; // Index in a do-loop - int VentZoneNum; // Number of ventilation object per zone - Real64 VentZoneMassflow; // Total mass flow rate per zone - Real64 VentZoneAirTemp; // Average Zone inlet temperature - - state.dataHeatBal->ZoneTotalExfiltrationHeatLoss = 0.0; - state.dataHeatBal->ZoneTotalExhaustHeatLoss = 0.0; - - auto &Zone(state.dataHeatBal->Zone); - auto &ZnAirRpt(state.dataHeatBal->ZnAirRpt); - auto &Ventilation(state.dataHeatBal->Ventilation); - auto &Mixing(state.dataHeatBal->Mixing); - auto &CrossMixing(state.dataHeatBal->CrossMixing); - auto &RefDoorMixing(state.dataHeatBal->RefDoorMixing); - auto &ZoneEquipConfig(state.dataZoneEquip->ZoneEquipConfig); - auto &Fan(state.dataFans->Fan); - - // Ensure no airflownetwork and simple calculations - if (AirflowNetwork::SimulateAirflowNetwork == 0) return; - - if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) ReportAirflowNetwork(state); - - // Reports zone exhaust loss by exhaust fans - for (ZoneLoop = 1; ZoneLoop <= state.dataGlobal->NumOfZones; ++ZoneLoop) { // Start of zone loads report variable update loop ... - CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); - H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); - ADSCorrectionFactor = 1.0; - if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { - if ((state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOn || state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOnZoneFansOnly) && - AirflowNetwork::AirflowNetworkZoneFlag(ZoneLoop)) { - ADSCorrectionFactor = 0.0; - } +} + +void UpdateZoneListAndGroupLoads(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Apparently someone who doesn't believe in documenting. + // DATE WRITTEN ??? + // MODIFIED na + // RE-ENGINEERED na + + // Using/Aliasing + using namespace DataHeatBalance; + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int ZoneNum; + int ListNum; + int GroupNum; + int Mult; + + auto &ZoneList(state.dataHeatBal->ZoneList); + auto &ZoneGroup(state.dataHeatBal->ZoneGroup); + auto &ListSNLoadHeatEnergy(state.dataHeatBal->ListSNLoadHeatEnergy); + auto &ListSNLoadCoolEnergy(state.dataHeatBal->ListSNLoadCoolEnergy); + auto &ListSNLoadHeatRate(state.dataHeatBal->ListSNLoadHeatRate); + auto &ListSNLoadCoolRate(state.dataHeatBal->ListSNLoadCoolRate); + + // Sum ZONE LIST and ZONE GROUP report variables + ListSNLoadHeatEnergy = 0.0; + ListSNLoadCoolEnergy = 0.0; + ListSNLoadHeatRate = 0.0; + ListSNLoadCoolRate = 0.0; + + for (ListNum = 1; ListNum <= state.dataHeatBal->NumOfZoneLists; ++ListNum) { + for (ZoneNum = 1; ZoneNum <= ZoneList(ListNum).NumOfZones; ++ZoneNum) { + Mult = state.dataHeatBal->Zone(ZoneNum).Multiplier; + ListSNLoadHeatEnergy(ListNum) += state.dataHeatBal->SNLoadHeatEnergy(ZoneList(ListNum).Zone(ZoneNum)) * Mult; + ListSNLoadCoolEnergy(ListNum) += state.dataHeatBal->SNLoadCoolEnergy(ZoneList(ListNum).Zone(ZoneNum)) * Mult; + ListSNLoadHeatRate(ListNum) += state.dataHeatBal->SNLoadHeatRate(ZoneList(ListNum).Zone(ZoneNum)) * Mult; + ListSNLoadCoolRate(ListNum) += state.dataHeatBal->SNLoadCoolRate(ZoneList(ListNum).Zone(ZoneNum)) * Mult; + } // ZoneNum + } // ListNum + + for (GroupNum = 1; GroupNum <= state.dataHeatBal->NumOfZoneGroups; ++GroupNum) { + Mult = state.dataHeatBal->ZoneGroup(GroupNum).Multiplier; + state.dataHeatBal->GroupSNLoadHeatEnergy(GroupNum) = ListSNLoadHeatEnergy(ZoneGroup(GroupNum).ZoneList) * Mult; + state.dataHeatBal->GroupSNLoadCoolEnergy(GroupNum) = ListSNLoadCoolEnergy(ZoneGroup(GroupNum).ZoneList) * Mult; + state.dataHeatBal->GroupSNLoadHeatRate(GroupNum) = ListSNLoadHeatRate(ZoneGroup(GroupNum).ZoneList) * Mult; + state.dataHeatBal->GroupSNLoadCoolRate(GroupNum) = ListSNLoadCoolRate(ZoneGroup(GroupNum).ZoneList) * Mult; + } // GroupNum +} + +void ReportAirHeatBalance(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Linda Lawrie + // DATE WRITTEN July 2000 + // MODIFIED Shirey, Jan 2008 (MIXING/CROSS MIXING outputs) + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This subroutine updates the report variables for the AirHeatBalance. + + // Using/Aliasing + using AirflowNetworkBalanceManager::ReportAirflowNetwork; + using DataHeatBalance::AirBalanceQuadrature; + using DataHVACGlobals::CycleOn; + using DataHVACGlobals::CycleOnZoneFansOnly; + using DataHVACGlobals::FanType_ZoneExhaust; + using Psychrometrics::PsyCpAirFnW; + using Psychrometrics::PsyHgAirFnWTdb; + using Psychrometrics::PsyRhoAirFnPbTdbW; + + // SUBROUTINE PARAMETER DEFINITIONS: + static std::string const RoutineName3("ReportAirHeatBalance:3"); + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int ZoneLoop; // Counter for the # of zones (nz) + int ZoneA; // Mated zone number for pair pf zones sharing refrigeration door opening + int ZoneB; // Mated zone number for pair pf zones sharing refrigeration door opening + int VentNum; // Counter for ventilation statements + int FanNum; // Counter for exhaust fans + Real64 AirDensity; // Density of air (kg/m^3) + Real64 CpAir; // Heat capacity of air (J/kg-C) + Real64 ADSCorrectionFactor; // Correction factor of air flow model values when ADS is simulated + Real64 H2OHtOfVap; // Heat of vaporization of air + Real64 TotalLoad; // Total loss or gain + int MixNum; // Counter for MIXING and Cross Mixing statements + static Array1D MixSenLoad; // Mixing sensible loss or gain + static Array1D MixLatLoad; // Mixing latent loss or gain + int j; // Index in a do-loop + int VentZoneNum; // Number of ventilation object per zone + Real64 VentZoneMassflow; // Total mass flow rate per zone + Real64 VentZoneAirTemp; // Average Zone inlet temperature + + state.dataHeatBal->ZoneTotalExfiltrationHeatLoss = 0.0; + state.dataHeatBal->ZoneTotalExhaustHeatLoss = 0.0; + + auto &Zone(state.dataHeatBal->Zone); + auto &ZnAirRpt(state.dataHeatBal->ZnAirRpt); + auto &Ventilation(state.dataHeatBal->Ventilation); + auto &Mixing(state.dataHeatBal->Mixing); + auto &CrossMixing(state.dataHeatBal->CrossMixing); + auto &RefDoorMixing(state.dataHeatBal->RefDoorMixing); + auto &ZoneEquipConfig(state.dataZoneEquip->ZoneEquipConfig); + auto &Fan(state.dataFans->Fan); + + // Ensure no airflownetwork and simple calculations + if (AirflowNetwork::SimulateAirflowNetwork == 0) return; + + if (AirflowNetwork::SimulateAirflowNetwork > AirflowNetwork::AirflowNetworkControlSimple) ReportAirflowNetwork(state); + + // Reports zone exhaust loss by exhaust fans + for (ZoneLoop = 1; ZoneLoop <= state.dataGlobal->NumOfZones; ++ZoneLoop) { // Start of zone loads report variable update loop ... + CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); + H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); + ADSCorrectionFactor = 1.0; + if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { + if ((state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOn || state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOnZoneFansOnly) && + AirflowNetwork::AirflowNetworkZoneFlag(ZoneLoop)) { + ADSCorrectionFactor = 0.0; } + } - ZnAirRpt(ZoneLoop).ExhTotalLoss = 0; - ZnAirRpt(ZoneLoop).ExhSensiLoss = 0; - - for (FanNum = 1; FanNum <= state.dataFans->NumFans; ++FanNum) { - // Add reportable vars - if (Fan(FanNum).FanType_Num == FanType_ZoneExhaust) { - for (int ExhNum = 1; ExhNum <= ZoneEquipConfig(ZoneLoop).NumExhaustNodes; ExhNum++) { - if (Fan(FanNum).InletNodeNum == ZoneEquipConfig(ZoneLoop).ExhaustNode(ExhNum)) { - ZnAirRpt(ZoneLoop).ExhTotalLoss += - Fan(FanNum).OutletAirMassFlowRate * (Fan(FanNum).OutletAirEnthalpy - state.dataEnvrn->OutEnthalpy) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).ExhSensiLoss += Fan(FanNum).OutletAirMassFlowRate * CpAir * - (Fan(FanNum).OutletAirTemp - Zone(ZoneLoop).OutDryBulbTemp) * ADSCorrectionFactor; - break; - } + ZnAirRpt(ZoneLoop).ExhTotalLoss = 0; + ZnAirRpt(ZoneLoop).ExhSensiLoss = 0; + + for (FanNum = 1; FanNum <= state.dataFans->NumFans; ++FanNum) { + // Add reportable vars + if (Fan(FanNum).FanType_Num == FanType_ZoneExhaust) { + for (int ExhNum = 1; ExhNum <= ZoneEquipConfig(ZoneLoop).NumExhaustNodes; ExhNum++) { + if (Fan(FanNum).InletNodeNum == ZoneEquipConfig(ZoneLoop).ExhaustNode(ExhNum)) { + ZnAirRpt(ZoneLoop).ExhTotalLoss += + Fan(FanNum).OutletAirMassFlowRate * (Fan(FanNum).OutletAirEnthalpy - state.dataEnvrn->OutEnthalpy) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).ExhSensiLoss += Fan(FanNum).OutletAirMassFlowRate * CpAir * + (Fan(FanNum).OutletAirTemp - Zone(ZoneLoop).OutDryBulbTemp) * ADSCorrectionFactor; + break; } } } - - ZnAirRpt(ZoneLoop).ExhLatentLoss = ZnAirRpt(ZoneLoop).ExhTotalLoss - ZnAirRpt(ZoneLoop).ExhSensiLoss; } - // Report results for SIMPLE option only - if (!(AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimple || - AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS)) - return; + ZnAirRpt(ZoneLoop).ExhLatentLoss = ZnAirRpt(ZoneLoop).ExhTotalLoss - ZnAirRpt(ZoneLoop).ExhSensiLoss; + } - if (ReportAirHeatBalanceFirstTimeFlag) { - MixSenLoad.allocate(state.dataGlobal->NumOfZones); - MixLatLoad.allocate(state.dataGlobal->NumOfZones); - ReportAirHeatBalanceFirstTimeFlag = false; - } + // Report results for SIMPLE option only + if (!(AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimple || + AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS)) + return; - for (ZoneLoop = 1; ZoneLoop <= state.dataGlobal->NumOfZones; ++ZoneLoop) { // Start of zone loads report variable update loop ... + if (state.dataHVACMgr->ReportAirHeatBalanceFirstTimeFlag) { + MixSenLoad.allocate(state.dataGlobal->NumOfZones); + MixLatLoad.allocate(state.dataGlobal->NumOfZones); + state.dataHVACMgr->ReportAirHeatBalanceFirstTimeFlag = false; + } - // Break the infiltration load into heat gain and loss components - ADSCorrectionFactor = 1.0; + for (ZoneLoop = 1; ZoneLoop <= state.dataGlobal->NumOfZones; ++ZoneLoop) { // Start of zone loads report variable update loop ... - if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { - // CR7608 IF (TurnFansOn .AND. AirflowNetworkZoneFlag(ZoneLoop)) ADSCorrectionFactor=0 - if ((state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOn || state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOnZoneFansOnly) && - AirflowNetwork::AirflowNetworkZoneFlag(ZoneLoop)) - ADSCorrectionFactor = 0.0; - } + // Break the infiltration load into heat gain and loss components + ADSCorrectionFactor = 1.0; - if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Zone(ZoneLoop).OutDryBulbTemp) { + if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { + // CR7608 IF (TurnFansOn .AND. AirflowNetworkZoneFlag(ZoneLoop)) ADSCorrectionFactor=0 + if ((state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOn || state.dataZoneEquip->ZoneEquipAvail(ZoneLoop) == CycleOnZoneFansOnly) && + AirflowNetwork::AirflowNetworkZoneFlag(ZoneLoop)) + ADSCorrectionFactor = 0.0; + } - ZnAirRpt(ZoneLoop).InfilHeatLoss = - 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) * (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilHeatGain = 0.0; + if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Zone(ZoneLoop).OutDryBulbTemp) { - } else if (state.dataHeatBalFanSys->MAT(ZoneLoop) <= Zone(ZoneLoop).OutDryBulbTemp) { + ZnAirRpt(ZoneLoop).InfilHeatLoss = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * + DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilHeatGain = 0.0; - ZnAirRpt(ZoneLoop).InfilHeatGain = - 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) * (Zone(ZoneLoop).OutDryBulbTemp - state.dataHeatBalFanSys->MAT(ZoneLoop)) * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilHeatLoss = 0.0; - } - // Report infiltration latent gains and losses - CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); - H2OHtOfVap = PsyHgAirFnWTdb(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop), state.dataHeatBalFanSys->MAT(ZoneLoop)); - if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { + } else if (state.dataHeatBalFanSys->MAT(ZoneLoop) <= Zone(ZoneLoop).OutDryBulbTemp) { - ZnAirRpt(ZoneLoop).InfilLatentLoss = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir * (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilLatentGain = 0.0; + ZnAirRpt(ZoneLoop).InfilHeatGain = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) * + (Zone(ZoneLoop).OutDryBulbTemp - state.dataHeatBalFanSys->MAT(ZoneLoop)) * TimeStepSys * + DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilHeatLoss = 0.0; + } + // Report infiltration latent gains and losses + CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); + H2OHtOfVap = PsyHgAirFnWTdb(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop), state.dataHeatBalFanSys->MAT(ZoneLoop)); + if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { + + ZnAirRpt(ZoneLoop).InfilLatentLoss = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap * + TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilLatentGain = 0.0; + + } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { + + ZnAirRpt(ZoneLoop).InfilLatentGain = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir * + (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * H2OHtOfVap * + TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilLatentLoss = 0.0; + } + // Total infiltration losses and gains + TotalLoad = ZnAirRpt(ZoneLoop).InfilHeatGain + ZnAirRpt(ZoneLoop).InfilLatentGain - ZnAirRpt(ZoneLoop).InfilHeatLoss - + ZnAirRpt(ZoneLoop).InfilLatentLoss; + if (TotalLoad > 0) { + ZnAirRpt(ZoneLoop).InfilTotalGain = TotalLoad * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilTotalLoss = 0.0; + } else { + ZnAirRpt(ZoneLoop).InfilTotalGain = 0.0; + ZnAirRpt(ZoneLoop).InfilTotalLoss = -TotalLoad * ADSCorrectionFactor; + } - } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { + // first calculate mass flows using outside air heat capacity for consistency with input to heat balance + CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); + ZnAirRpt(ZoneLoop).InfilMass = + (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilMdot = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilMass = + (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilMdot = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir) * ADSCorrectionFactor; + + // CR7751 second, calculate using indoor conditions for density property + AirDensity = PsyRhoAirFnPbTdbW(state, + state.dataEnvrn->OutBaroPress, + state.dataHeatBalFanSys->MAT(ZoneLoop), + state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneLoop), + RoutineName3); + ZnAirRpt(ZoneLoop).InfilVolumeCurDensity = + (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilAirChangeRate = ZnAirRpt(ZoneLoop).InfilVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); + ZnAirRpt(ZoneLoop).InfilVdotCurDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilVolumeCurDensity = + (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilAirChangeRate = ZnAirRpt(ZoneLoop).VentilVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); + ZnAirRpt(ZoneLoop).VentilVdotCurDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; + + // CR7751 third, calculate using standard dry air at nominal elevation + AirDensity = state.dataEnvrn->StdRhoAir; + ZnAirRpt(ZoneLoop).InfilVolumeStdDensity = + (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).InfilVdotStdDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilVolumeStdDensity = + (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilVdotStdDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; + + // ZnAirRpt(ZoneLoop)%VentilFanElec = 0.0 + ZnAirRpt(ZoneLoop).VentilAirTemp = 0.0; + ZnAirRpt(ZoneLoop).VentilHeatLoss = 0.0; + ZnAirRpt(ZoneLoop).VentilHeatGain = 0.0; + VentZoneNum = 0; + VentZoneMassflow = 0.0; + VentZoneAirTemp = 0.0; + + for (VentNum = 1; VentNum <= state.dataHeatBal->TotVentilation; ++VentNum) { + if (Ventilation(VentNum).ZonePtr == ZoneLoop) { + // moved into CalcAirFlowSimple + // ZnAirRpt(ZoneLoop)%VentilFanElec = + // ZnAirRpt(ZoneLoop)%VentilFanElec+Ventilation(VentNum)%FanPower*TimeStepSys*DataGlobalConstants::SecInHour() + // & + // *ADSCorrectionFactor + if (ADSCorrectionFactor > 0) { + ZnAirRpt(ZoneLoop).VentilAirTemp += Ventilation(VentNum).AirTemp * state.dataZoneEquip->VentMCP(VentNum); + VentZoneMassflow += state.dataZoneEquip->VentMCP(VentNum); + VentZoneAirTemp += Ventilation(VentNum).AirTemp; + } else { + ZnAirRpt(ZoneLoop).VentilAirTemp = Zone(ZoneLoop).OutDryBulbTemp; + } + // Break the ventilation load into heat gain and loss components + if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Ventilation(VentNum).AirTemp) { + ZnAirRpt(ZoneLoop).VentilHeatLoss += state.dataZoneEquip->VentMCP(VentNum) * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - Ventilation(VentNum).AirTemp) * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } else if (state.dataHeatBalFanSys->MAT(ZoneLoop) <= Ventilation(VentNum).AirTemp) { + ZnAirRpt(ZoneLoop).VentilHeatGain += state.dataZoneEquip->VentMCP(VentNum) * + (Ventilation(VentNum).AirTemp - state.dataHeatBalFanSys->MAT(ZoneLoop)) * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } - ZnAirRpt(ZoneLoop).InfilLatentGain = 0.001 * state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir * (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilLatentLoss = 0.0; - } - // Total infiltration losses and gains - TotalLoad = ZnAirRpt(ZoneLoop).InfilHeatGain + ZnAirRpt(ZoneLoop).InfilLatentGain - ZnAirRpt(ZoneLoop).InfilHeatLoss - - ZnAirRpt(ZoneLoop).InfilLatentLoss; - if (TotalLoad > 0) { - ZnAirRpt(ZoneLoop).InfilTotalGain = TotalLoad * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilTotalLoss = 0.0; - } else { - ZnAirRpt(ZoneLoop).InfilTotalGain = 0.0; - ZnAirRpt(ZoneLoop).InfilTotalLoss = -TotalLoad * ADSCorrectionFactor; + ++VentZoneNum; + if (VentZoneNum > 1) continue; + + // Report ventilation latent gains and losses + H2OHtOfVap = PsyHgAirFnWTdb(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop), state.dataHeatBalFanSys->MAT(ZoneLoop)); + if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { + ZnAirRpt(ZoneLoop).VentilLatentLoss = 0.001 * state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * + H2OHtOfVap * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilLatentGain = 0.0; + } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { + ZnAirRpt(ZoneLoop).VentilLatentGain = 0.001 * state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir * + (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * + H2OHtOfVap * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilLatentLoss = 0.0; + } + // Total ventilation losses and gains + TotalLoad = ZnAirRpt(ZoneLoop).VentilHeatGain + ZnAirRpt(ZoneLoop).VentilLatentGain - ZnAirRpt(ZoneLoop).VentilHeatLoss - + ZnAirRpt(ZoneLoop).VentilLatentLoss; + if (TotalLoad > 0) { + ZnAirRpt(ZoneLoop).VentilTotalGain = TotalLoad * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).VentilTotalLoss = 0.0; + } else { + ZnAirRpt(ZoneLoop).VentilTotalGain = 0.0; + ZnAirRpt(ZoneLoop).VentilTotalLoss = -TotalLoad * ADSCorrectionFactor; + } } + } - // first calculate mass flows using outside air heat capacity for consistency with input to heat balance - CpAir = PsyCpAirFnW(state.dataEnvrn->OutHumRat); - ZnAirRpt(ZoneLoop).InfilMass = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilMdot = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilMass = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilMdot = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir) * ADSCorrectionFactor; - - // CR7751 second, calculate using indoor conditions for density property - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, state.dataHeatBalFanSys->MAT(ZoneLoop), state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneLoop), RoutineName3); - ZnAirRpt(ZoneLoop).InfilVolumeCurDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilAirChangeRate = ZnAirRpt(ZoneLoop).InfilVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); - ZnAirRpt(ZoneLoop).InfilVdotCurDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilVolumeCurDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilAirChangeRate = ZnAirRpt(ZoneLoop).VentilVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); - ZnAirRpt(ZoneLoop).VentilVdotCurDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; - - // CR7751 third, calculate using standard dry air at nominal elevation - AirDensity = state.dataEnvrn->StdRhoAir; - ZnAirRpt(ZoneLoop).InfilVolumeStdDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).InfilVdotStdDensity = (state.dataHeatBalFanSys->MCPI(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilVolumeStdDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilVdotStdDensity = (state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir / AirDensity) * ADSCorrectionFactor; - - // ZnAirRpt(ZoneLoop)%VentilFanElec = 0.0 - ZnAirRpt(ZoneLoop).VentilAirTemp = 0.0; - ZnAirRpt(ZoneLoop).VentilHeatLoss = 0.0; - ZnAirRpt(ZoneLoop).VentilHeatGain = 0.0; - VentZoneNum = 0; - VentZoneMassflow = 0.0; - VentZoneAirTemp = 0.0; - - for (VentNum = 1; VentNum <= state.dataHeatBal->TotVentilation; ++VentNum) { - if (Ventilation(VentNum).ZonePtr == ZoneLoop) { - // moved into CalcAirFlowSimple - // ZnAirRpt(ZoneLoop)%VentilFanElec = ZnAirRpt(ZoneLoop)%VentilFanElec+Ventilation(VentNum)%FanPower*TimeStepSys*DataGlobalConstants::SecInHour() - // & - // *ADSCorrectionFactor - if (ADSCorrectionFactor > 0) { - ZnAirRpt(ZoneLoop).VentilAirTemp += Ventilation(VentNum).AirTemp * state.dataZoneEquip->VentMCP(VentNum); - VentZoneMassflow += state.dataZoneEquip->VentMCP(VentNum); - VentZoneAirTemp += Ventilation(VentNum).AirTemp; - } else { - ZnAirRpt(ZoneLoop).VentilAirTemp = Zone(ZoneLoop).OutDryBulbTemp; - } - // Break the ventilation load into heat gain and loss components - if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Ventilation(VentNum).AirTemp) { - ZnAirRpt(ZoneLoop).VentilHeatLoss += - state.dataZoneEquip->VentMCP(VentNum) * (state.dataHeatBalFanSys->MAT(ZoneLoop) - Ventilation(VentNum).AirTemp) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - } else if (state.dataHeatBalFanSys->MAT(ZoneLoop) <= Ventilation(VentNum).AirTemp) { - ZnAirRpt(ZoneLoop).VentilHeatGain += - state.dataZoneEquip->VentMCP(VentNum) * (Ventilation(VentNum).AirTemp - state.dataHeatBalFanSys->MAT(ZoneLoop)) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - } + if (ADSCorrectionFactor > 0 && VentZoneNum > 1 && VentZoneMassflow > 0.0) { + ZnAirRpt(ZoneLoop).VentilAirTemp /= VentZoneMassflow; + } else if (ADSCorrectionFactor > 0 && VentZoneNum == 1) { + ZnAirRpt(ZoneLoop).VentilAirTemp = VentZoneAirTemp; + } else { // Just in case + ZnAirRpt(ZoneLoop).VentilAirTemp = Zone(ZoneLoop).OutDryBulbTemp; + } - ++VentZoneNum; - if (VentZoneNum > 1) continue; - - // Report ventilation latent gains and losses - H2OHtOfVap = PsyHgAirFnWTdb(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop), state.dataHeatBalFanSys->MAT(ZoneLoop)); - if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { - ZnAirRpt(ZoneLoop).VentilLatentLoss = 0.001 * state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir * (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilLatentGain = 0.0; - } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { - ZnAirRpt(ZoneLoop).VentilLatentGain = 0.001 * state.dataHeatBalFanSys->MCPV(ZoneLoop) / CpAir * (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilLatentLoss = 0.0; - } - // Total ventilation losses and gains - TotalLoad = ZnAirRpt(ZoneLoop).VentilHeatGain + ZnAirRpt(ZoneLoop).VentilLatentGain - ZnAirRpt(ZoneLoop).VentilHeatLoss - - ZnAirRpt(ZoneLoop).VentilLatentLoss; - if (TotalLoad > 0) { - ZnAirRpt(ZoneLoop).VentilTotalGain = TotalLoad * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).VentilTotalLoss = 0.0; - } else { - ZnAirRpt(ZoneLoop).VentilTotalGain = 0.0; - ZnAirRpt(ZoneLoop).VentilTotalLoss = -TotalLoad * ADSCorrectionFactor; - } - } + // Report mixing sensible and latent loads + MixSenLoad = 0.0; // Initialize arrays to zero before starting to sum + MixLatLoad = 0.0; + ZnAirRpt(ZoneLoop).MixVolume = 0.0; // zero reported volume prior to summations below + ZnAirRpt(ZoneLoop).MixVdotCurDensity = 0.0; // zero reported volume flow rate prior to summations below + ZnAirRpt(ZoneLoop).MixVdotStdDensity = 0.0; // zero reported volume flow rate prior to summations below + ZnAirRpt(ZoneLoop).MixMass = 0.0; // ! zero reported mass prior to summations below + ZnAirRpt(ZoneLoop).MixMdot = 0.0; // ! zero reported mass flow rate prior to summations below + // MixingLoad = 0.0d0 + + for (MixNum = 1; MixNum <= state.dataHeatBal->TotMixing; ++MixNum) { + if ((Mixing(MixNum).ZonePtr == ZoneLoop) && state.dataZoneEquip->MixingReportFlag(MixNum)) { + // MixSenLoad(ZoneLoop) = MixSenLoad(ZoneLoop)+MCPM(ZoneLoop)*MAT(Mixing(MixNum)%FromZone) + // H2OHtOfVap = PsyHgAirFnWTdb(ZoneAirHumRat(ZoneLoop), MAT(ZoneLoop)) + // Per Jan 17, 2008 conference call, agreed to use average conditions for Rho, Cp and Hfg + // and to recalculate the report variable using end of time step temps and humrats + AirDensity = PsyRhoAirFnPbTdbW( + state, + state.dataEnvrn->OutBaroPress, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)) / 2.0, + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0, + std::string()); + CpAir = PsyCpAirFnW( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0); + ZnAirRpt(ZoneLoop).MixVolume += + Mixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotCurDensity += Mixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMass += + Mixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMdot += Mixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotStdDensity += + Mixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; + MixSenLoad(ZoneLoop) += Mixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)); + H2OHtOfVap = PsyHgAirFnWTdb( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)) / 2.0); + // MixLatLoad(ZoneLoop) = MixLatLoad(ZoneLoop)+MixingMassFlowZone(ZoneLoop)*(ZoneAirHumRat(ZoneLoop)- & + // ZoneAirHumRat(Mixing(MixNum)%FromZone))*H2OHtOfVap + MixLatLoad(ZoneLoop) += + Mixing(MixNum).DesiredAirFlowRate * AirDensity * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) * H2OHtOfVap; } + } - if (ADSCorrectionFactor > 0 && VentZoneNum > 1 && VentZoneMassflow > 0.0) { - ZnAirRpt(ZoneLoop).VentilAirTemp /= VentZoneMassflow; - } else if (ADSCorrectionFactor > 0 && VentZoneNum == 1) { - ZnAirRpt(ZoneLoop).VentilAirTemp = VentZoneAirTemp; - } else { // Just in case - ZnAirRpt(ZoneLoop).VentilAirTemp = Zone(ZoneLoop).OutDryBulbTemp; + for (MixNum = 1; MixNum <= state.dataHeatBal->TotCrossMixing; ++MixNum) { + if ((CrossMixing(MixNum).ZonePtr == ZoneLoop) && state.dataZoneEquip->CrossMixingReportFlag(MixNum)) { + // MixSenLoad(ZoneLoop) = MixSenLoad(ZoneLoop)+MCPM(ZoneLoop)*MAT(CrossMixing(MixNum)%FromZone) + // Per Jan 17, 2008 conference call, agreed to use average conditions for Rho, Cp and Hfg + // and to recalculate the report variable using end of time step temps and humrats + AirDensity = PsyRhoAirFnPbTdbW( + state, + state.dataEnvrn->OutBaroPress, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)) / 2.0, + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0, + std::string()); + CpAir = PsyCpAirFnW( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0); + ZnAirRpt(ZoneLoop).MixVolume += + CrossMixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotCurDensity += CrossMixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMass += + CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMdot += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotStdDensity += + CrossMixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; + MixSenLoad(ZoneLoop) += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)); + H2OHtOfVap = PsyHgAirFnWTdb( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)) / 2.0); + // MixLatLoad(ZoneLoop) = MixLatLoad(ZoneLoop)+MixingMassFlowZone(ZoneLoop)*(ZoneAirHumRat(ZoneLoop)- & + // ZoneAirHumRat(CrossMixing(MixNum)%FromZone))*H2OHtOfVap + MixLatLoad(ZoneLoop) += + CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) * + H2OHtOfVap; } - - // Report mixing sensible and latent loads - MixSenLoad = 0.0; // Initialize arrays to zero before starting to sum - MixLatLoad = 0.0; - ZnAirRpt(ZoneLoop).MixVolume = 0.0; // zero reported volume prior to summations below - ZnAirRpt(ZoneLoop).MixVdotCurDensity = 0.0; // zero reported volume flow rate prior to summations below - ZnAirRpt(ZoneLoop).MixVdotStdDensity = 0.0; // zero reported volume flow rate prior to summations below - ZnAirRpt(ZoneLoop).MixMass = 0.0; // ! zero reported mass prior to summations below - ZnAirRpt(ZoneLoop).MixMdot = 0.0; // ! zero reported mass flow rate prior to summations below - // MixingLoad = 0.0d0 - - for (MixNum = 1; MixNum <= state.dataHeatBal->TotMixing; ++MixNum) { - if ((Mixing(MixNum).ZonePtr == ZoneLoop) && state.dataZoneEquip->MixingReportFlag(MixNum)) { - // MixSenLoad(ZoneLoop) = MixSenLoad(ZoneLoop)+MCPM(ZoneLoop)*MAT(Mixing(MixNum)%FromZone) - // H2OHtOfVap = PsyHgAirFnWTdb(ZoneAirHumRat(ZoneLoop), MAT(ZoneLoop)) - // Per Jan 17, 2008 conference call, agreed to use average conditions for Rho, Cp and Hfg - // and to recalculate the report variable using end of time step temps and humrats - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)) / 2.0, - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0, - std::string()); - CpAir = PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0); - ZnAirRpt(ZoneLoop).MixVolume += Mixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotCurDensity += Mixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMass += Mixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMdot += Mixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotStdDensity += Mixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; - MixSenLoad(ZoneLoop) += Mixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)); - H2OHtOfVap = PsyHgAirFnWTdb((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) / 2.0, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(Mixing(MixNum).FromZone)) / 2.0); - // MixLatLoad(ZoneLoop) = MixLatLoad(ZoneLoop)+MixingMassFlowZone(ZoneLoop)*(ZoneAirHumRat(ZoneLoop)- & - // ZoneAirHumRat(Mixing(MixNum)%FromZone))*H2OHtOfVap - MixLatLoad(ZoneLoop) += Mixing(MixNum).DesiredAirFlowRate * AirDensity * - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(Mixing(MixNum).FromZone)) * H2OHtOfVap; - } + if ((CrossMixing(MixNum).FromZone == ZoneLoop) && state.dataZoneEquip->CrossMixingReportFlag(MixNum)) { + AirDensity = PsyRhoAirFnPbTdbW( + state, + state.dataEnvrn->OutBaroPress, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)) / 2.0, + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0, + std::string()); + CpAir = PsyCpAirFnW( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0); + ZnAirRpt(ZoneLoop).MixVolume += + CrossMixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotCurDensity += CrossMixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMass += + CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMdot += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotStdDensity += + CrossMixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; + MixSenLoad(ZoneLoop) += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)); + H2OHtOfVap = PsyHgAirFnWTdb( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)) / 2.0); + MixLatLoad(ZoneLoop) += + CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) * + H2OHtOfVap; } + } + + if (state.dataHeatBal->TotRefDoorMixing > 0) { + // IF(ZoneLoop .NE. NumOfZones)THEN !Refrigeration Door Mixing + // Note - do each Pair a Single time, so must do increment reports for both zones + // Can't have a pair that has ZoneA zone number = NumOfZones because organized + // in input with lowest zone # first no matter how input in idf + if (RefDoorMixing(ZoneLoop).RefDoorMixFlag) { // .TRUE. for both zoneA and zoneB + if (RefDoorMixing(ZoneLoop).ZonePtr == ZoneLoop) { + for (j = 1; j <= RefDoorMixing(ZoneLoop).NumRefDoorConnections; ++j) { + // Capture impact when zoneloop is the 'primary zone' + // that is, the zone of a pair with the lower zone number + if (RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) > 0.0) { + ZoneB = RefDoorMixing(ZoneLoop).MateZonePtr(j); + AirDensity = PsyRhoAirFnPbTdbW( + state, + state.dataEnvrn->OutBaroPress, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneB)) / 2.0, + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0, + std::string()); + CpAir = + PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0); + H2OHtOfVap = PsyHgAirFnWTdb( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneB)) / 2.0); + ZnAirRpt(ZoneLoop).MixVolume += + RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotCurDensity += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMass += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMdot += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotStdDensity += + RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; + MixSenLoad(ZoneLoop) += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * CpAir * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(ZoneB)); + MixLatLoad(ZoneLoop) += + RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) * H2OHtOfVap; + } // flow > 0 + } // J-1, numref connections + } // zone A (zoneptr = zoneloop) + for (ZoneA = 1; ZoneA <= (ZoneLoop - 1); ++ZoneA) { + // Capture impact when zoneloop is the 'mating zone' + // that is, the zone of a pair with the higher zone number(matezoneptr = zoneloop) + if (RefDoorMixing(ZoneA).RefDoorMixFlag) { + for (j = 1; j <= RefDoorMixing(ZoneA).NumRefDoorConnections; ++j) { + if (RefDoorMixing(ZoneA).MateZonePtr(j) == ZoneLoop) { + if (RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) > 0.0) { + AirDensity = PsyRhoAirFnPbTdbW( + state, + state.dataEnvrn->OutBaroPress, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneA)) / 2.0, + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0, + std::string()); + CpAir = PsyCpAirFnW( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0); + H2OHtOfVap = PsyHgAirFnWTdb( + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0, + (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneA)) / 2.0); + ZnAirRpt(ZoneLoop).MixVolume += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotCurDensity += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMass += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixMdot += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixVdotStdDensity += + RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; + MixSenLoad(ZoneLoop) += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * CpAir * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(ZoneA)); + MixLatLoad(ZoneLoop) += + RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) * + H2OHtOfVap; + } // volflowrate > 0 + } // matezoneptr (zoneB) = Zonelooop + } // NumRefDoorConnections + } // Refdoormix flag on ZoneA + } // zone A from 1 to (zoneloop - 1) + } // Refdoormix flag on zoneloop + } //(TotRefDoorMixing .GT. 0) + // end refrigeration door mixing reports + + // MixingLoad(ZoneLoop) = MCPM(ZoneLoop)*MAT(ZoneLoop) - MixSenLoad(ZoneLoop) + if (MixSenLoad(ZoneLoop) > 0.0) { + ZnAirRpt(ZoneLoop).MixHeatLoss = MixSenLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixHeatGain = 0.0; + } else { + ZnAirRpt(ZoneLoop).MixHeatLoss = 0.0; + ZnAirRpt(ZoneLoop).MixHeatGain = -MixSenLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } + // Report mixing latent loads + // MixingLoad(ZoneLoop) = MixLatLoad(ZoneLoop) + if (MixLatLoad(ZoneLoop) > 0.0) { + ZnAirRpt(ZoneLoop).MixLatentLoss = MixLatLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixLatentGain = 0.0; + } else { + ZnAirRpt(ZoneLoop).MixLatentLoss = 0.0; + ZnAirRpt(ZoneLoop).MixLatentGain = -MixLatLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } + // Total Mixing losses and gains + TotalLoad = + ZnAirRpt(ZoneLoop).MixHeatGain + ZnAirRpt(ZoneLoop).MixLatentGain - ZnAirRpt(ZoneLoop).MixHeatLoss - ZnAirRpt(ZoneLoop).MixLatentLoss; + if (TotalLoad > 0) { + ZnAirRpt(ZoneLoop).MixTotalGain = TotalLoad * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).MixTotalLoss = 0.0; + } else { + ZnAirRpt(ZoneLoop).MixTotalGain = 0.0; + ZnAirRpt(ZoneLoop).MixTotalLoss = -TotalLoad * ADSCorrectionFactor; + } - for (MixNum = 1; MixNum <= state.dataHeatBal->TotCrossMixing; ++MixNum) { - if ((CrossMixing(MixNum).ZonePtr == ZoneLoop) && state.dataZoneEquip->CrossMixingReportFlag(MixNum)) { - // MixSenLoad(ZoneLoop) = MixSenLoad(ZoneLoop)+MCPM(ZoneLoop)*MAT(CrossMixing(MixNum)%FromZone) - // Per Jan 17, 2008 conference call, agreed to use average conditions for Rho, Cp and Hfg - // and to recalculate the report variable using end of time step temps and humrats - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)) / 2.0, - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0, - std::string()); - CpAir = PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0); - ZnAirRpt(ZoneLoop).MixVolume += CrossMixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotCurDensity += CrossMixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMass += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMdot += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotStdDensity += CrossMixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; - MixSenLoad(ZoneLoop) += - CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)); - H2OHtOfVap = PsyHgAirFnWTdb((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) / 2.0, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).FromZone)) / 2.0); - // MixLatLoad(ZoneLoop) = MixLatLoad(ZoneLoop)+MixingMassFlowZone(ZoneLoop)*(ZoneAirHumRat(ZoneLoop)- & - // ZoneAirHumRat(CrossMixing(MixNum)%FromZone))*H2OHtOfVap - MixLatLoad(ZoneLoop) += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).FromZone)) * H2OHtOfVap; + // Reporting combined outdoor air flows + for (j = 1; j <= state.dataHeatBal->TotZoneAirBalance; ++j) { + if (state.dataHeatBal->ZoneAirBalance(j).BalanceMethod == AirBalanceQuadrature && + ZoneLoop == state.dataHeatBal->ZoneAirBalance(j).ZonePtr) { + if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Zone(ZoneLoop).OutDryBulbTemp) { + ZnAirRpt(ZoneLoop).OABalanceHeatLoss = state.dataHeatBalFanSys->MDotCPOA(ZoneLoop) * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceHeatGain = 0.0; + } else { + ZnAirRpt(ZoneLoop).OABalanceHeatLoss = 0.0; + ZnAirRpt(ZoneLoop).OABalanceHeatGain = -state.dataHeatBalFanSys->MDotCPOA(ZoneLoop) * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; } - if ((CrossMixing(MixNum).FromZone == ZoneLoop) && state.dataZoneEquip->CrossMixingReportFlag(MixNum)) { - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)) / 2.0, - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0, - std::string()); - CpAir = PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0); - ZnAirRpt(ZoneLoop).MixVolume += CrossMixing(MixNum).DesiredAirFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotCurDensity += CrossMixing(MixNum).DesiredAirFlowRate * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMass += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMdot += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotStdDensity += CrossMixing(MixNum).DesiredAirFlowRate * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; - MixSenLoad(ZoneLoop) += - CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * CpAir * (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)); - H2OHtOfVap = PsyHgAirFnWTdb((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) / 2.0, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(CrossMixing(MixNum).ZonePtr)) / 2.0); - MixLatLoad(ZoneLoop) += CrossMixing(MixNum).DesiredAirFlowRate * AirDensity * - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(CrossMixing(MixNum).ZonePtr)) * H2OHtOfVap; + H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); + if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { + ZnAirRpt(ZoneLoop).OABalanceLatentLoss = 0.001 * state.dataHeatBalFanSys->MDotOA(ZoneLoop) * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * + H2OHtOfVap * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceLatentGain = 0.0; + } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { + ZnAirRpt(ZoneLoop).OABalanceLatentGain = 0.001 * state.dataHeatBalFanSys->MDotOA(ZoneLoop) * + (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * + H2OHtOfVap * TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceLatentLoss = 0.0; } + // Total ventilation losses and gains + TotalLoad = ZnAirRpt(ZoneLoop).OABalanceHeatGain + ZnAirRpt(ZoneLoop).OABalanceLatentGain - ZnAirRpt(ZoneLoop).OABalanceHeatLoss - + ZnAirRpt(ZoneLoop).OABalanceLatentLoss; + if (TotalLoad > 0) { + ZnAirRpt(ZoneLoop).OABalanceTotalGain = TotalLoad * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceTotalLoss = 0.0; + } else { + ZnAirRpt(ZoneLoop).OABalanceTotalGain = 0.0; + ZnAirRpt(ZoneLoop).OABalanceTotalLoss = -TotalLoad * ADSCorrectionFactor; + } + ZnAirRpt(ZoneLoop).OABalanceMass = + (state.dataHeatBalFanSys->MDotOA(ZoneLoop)) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceMdot = (state.dataHeatBalFanSys->MDotOA(ZoneLoop)) * ADSCorrectionFactor; + AirDensity = PsyRhoAirFnPbTdbW(state, + state.dataEnvrn->OutBaroPress, + state.dataHeatBalFanSys->MAT(ZoneLoop), + state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneLoop), + std::string()); + ZnAirRpt(ZoneLoop).OABalanceVolumeCurDensity = + (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceAirChangeRate = ZnAirRpt(ZoneLoop).OABalanceVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); + ZnAirRpt(ZoneLoop).OABalanceVdotCurDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * ADSCorrectionFactor; + AirDensity = state.dataEnvrn->StdRhoAir; + ZnAirRpt(ZoneLoop).OABalanceVolumeStdDensity = + (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceVdotStdDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * ADSCorrectionFactor; + ZnAirRpt(ZoneLoop).OABalanceFanElec = ZnAirRpt(ZoneLoop).VentilFanElec; } - - if (state.dataHeatBal->TotRefDoorMixing > 0) { - // IF(ZoneLoop .NE. NumOfZones)THEN !Refrigeration Door Mixing - // Note - do each Pair a Single time, so must do increment reports for both zones - // Can't have a pair that has ZoneA zone number = NumOfZones because organized - // in input with lowest zone # first no matter how input in idf - if (RefDoorMixing(ZoneLoop).RefDoorMixFlag) { // .TRUE. for both zoneA and zoneB - if (RefDoorMixing(ZoneLoop).ZonePtr == ZoneLoop) { - for (j = 1; j <= RefDoorMixing(ZoneLoop).NumRefDoorConnections; ++j) { - // Capture impact when zoneloop is the 'primary zone' - // that is, the zone of a pair with the lower zone number - if (RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) > 0.0) { - ZoneB = RefDoorMixing(ZoneLoop).MateZonePtr(j); - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneB)) / 2.0, - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0, - std::string()); - CpAir = PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0); - H2OHtOfVap = - PsyHgAirFnWTdb((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) / 2.0, (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneB)) / 2.0); - ZnAirRpt(ZoneLoop).MixVolume += - RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotCurDensity += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMass += - RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMdot += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotStdDensity += - RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; - MixSenLoad(ZoneLoop) += - RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * CpAir * (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(ZoneB)); - MixLatLoad(ZoneLoop) += RefDoorMixing(ZoneLoop).VolRefDoorFlowRate(j) * AirDensity * - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneB)) * H2OHtOfVap; - } // flow > 0 - } // J-1, numref connections - } // zone A (zoneptr = zoneloop) - for (ZoneA = 1; ZoneA <= (ZoneLoop - 1); ++ZoneA) { - // Capture impact when zoneloop is the 'mating zone' - // that is, the zone of a pair with the higher zone number(matezoneptr = zoneloop) - if (RefDoorMixing(ZoneA).RefDoorMixFlag) { - for (j = 1; j <= RefDoorMixing(ZoneA).NumRefDoorConnections; ++j) { - if (RefDoorMixing(ZoneA).MateZonePtr(j) == ZoneLoop) { - if (RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) > 0.0) { - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneA)) / 2.0, - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0, - std::string()); - CpAir = PsyCpAirFnW((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0); - H2OHtOfVap = PsyHgAirFnWTdb((state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) + state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) / 2.0, - (state.dataHeatBalFanSys->MAT(ZoneLoop) + state.dataHeatBalFanSys->MAT(ZoneA)) / 2.0); - ZnAirRpt(ZoneLoop).MixVolume += - RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotCurDensity += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMass += - RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixMdot += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixVdotStdDensity += - RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * (AirDensity / state.dataEnvrn->StdRhoAir) * ADSCorrectionFactor; - MixSenLoad(ZoneLoop) += - RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * CpAir * (state.dataHeatBalFanSys->MAT(ZoneLoop) - state.dataHeatBalFanSys->MAT(ZoneA)); - MixLatLoad(ZoneLoop) += RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensity * - (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneA)) * H2OHtOfVap; - } // volflowrate > 0 - } // matezoneptr (zoneB) = Zonelooop - } // NumRefDoorConnections - } // Refdoormix flag on ZoneA - } // zone A from 1 to (zoneloop - 1) - } // Refdoormix flag on zoneloop - } //(TotRefDoorMixing .GT. 0) - // end refrigeration door mixing reports - - // MixingLoad(ZoneLoop) = MCPM(ZoneLoop)*MAT(ZoneLoop) - MixSenLoad(ZoneLoop) - if (MixSenLoad(ZoneLoop) > 0.0) { - ZnAirRpt(ZoneLoop).MixHeatLoss = MixSenLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixHeatGain = 0.0; - } else { - ZnAirRpt(ZoneLoop).MixHeatLoss = 0.0; - ZnAirRpt(ZoneLoop).MixHeatGain = -MixSenLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } + // Reports exfiltration loss + H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); + ZnAirRpt(ZoneLoop).SysInletMass = 0; + ZnAirRpt(ZoneLoop).SysOutletMass = 0; + if (!ZoneEquipConfig(ZoneLoop).IsControlled) { + for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumInletNodes; ++j) { + ZnAirRpt(ZoneLoop).SysInletMass += state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).InletNode(j)).MassFlowRate * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; } - // Report mixing latent loads - // MixingLoad(ZoneLoop) = MixLatLoad(ZoneLoop) - if (MixLatLoad(ZoneLoop) > 0.0) { - ZnAirRpt(ZoneLoop).MixLatentLoss = MixLatLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixLatentGain = 0.0; - } else { - ZnAirRpt(ZoneLoop).MixLatentLoss = 0.0; - ZnAirRpt(ZoneLoop).MixLatentGain = -MixLatLoad(ZoneLoop) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumExhaustNodes; ++j) { + ZnAirRpt(ZoneLoop).SysOutletMass += state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).ExhaustNode(j)).MassFlowRate * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; } - // Total Mixing losses and gains - TotalLoad = - ZnAirRpt(ZoneLoop).MixHeatGain + ZnAirRpt(ZoneLoop).MixLatentGain - ZnAirRpt(ZoneLoop).MixHeatLoss - ZnAirRpt(ZoneLoop).MixLatentLoss; - if (TotalLoad > 0) { - ZnAirRpt(ZoneLoop).MixTotalGain = TotalLoad * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).MixTotalLoss = 0.0; - } else { - ZnAirRpt(ZoneLoop).MixTotalGain = 0.0; - ZnAirRpt(ZoneLoop).MixTotalLoss = -TotalLoad * ADSCorrectionFactor; + for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumReturnNodes; ++j) { + ZnAirRpt(ZoneLoop).SysOutletMass += state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).ReturnNode(j)).MassFlowRate * TimeStepSys * + DataGlobalConstants::SecInHour * ADSCorrectionFactor; } + } - // Reporting combined outdoor air flows - for (j = 1; j <= state.dataHeatBal->TotZoneAirBalance; ++j) { - if (state.dataHeatBal->ZoneAirBalance(j).BalanceMethod == AirBalanceQuadrature && ZoneLoop == state.dataHeatBal->ZoneAirBalance(j).ZonePtr) { - if (state.dataHeatBalFanSys->MAT(ZoneLoop) > Zone(ZoneLoop).OutDryBulbTemp) { - ZnAirRpt(ZoneLoop).OABalanceHeatLoss = - state.dataHeatBalFanSys->MDotCPOA(ZoneLoop) * (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceHeatGain = 0.0; - } else { - ZnAirRpt(ZoneLoop).OABalanceHeatLoss = 0.0; - ZnAirRpt(ZoneLoop).OABalanceHeatGain = - -state.dataHeatBalFanSys->MDotCPOA(ZoneLoop) * (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - } - H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); - if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) > state.dataEnvrn->OutHumRat) { - ZnAirRpt(ZoneLoop).OABalanceLatentLoss = 0.001 * state.dataHeatBalFanSys->MDotOA(ZoneLoop) * (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceLatentGain = 0.0; - } else if (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) <= state.dataEnvrn->OutHumRat) { - ZnAirRpt(ZoneLoop).OABalanceLatentGain = 0.001 * state.dataHeatBalFanSys->MDotOA(ZoneLoop) * (state.dataEnvrn->OutHumRat - state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop)) * H2OHtOfVap * - TimeStepSys * DataGlobalConstants::SecInHour * 1000.0 * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceLatentLoss = 0.0; - } - // Total ventilation losses and gains - TotalLoad = ZnAirRpt(ZoneLoop).OABalanceHeatGain + ZnAirRpt(ZoneLoop).OABalanceLatentGain - ZnAirRpt(ZoneLoop).OABalanceHeatLoss - - ZnAirRpt(ZoneLoop).OABalanceLatentLoss; - if (TotalLoad > 0) { - ZnAirRpt(ZoneLoop).OABalanceTotalGain = TotalLoad * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceTotalLoss = 0.0; + ZnAirRpt(ZoneLoop).ExfilMass = ZnAirRpt(ZoneLoop).InfilMass + ZnAirRpt(ZoneLoop).VentilMass + ZnAirRpt(ZoneLoop).MixMass + + ZnAirRpt(ZoneLoop).OABalanceMass + ZnAirRpt(ZoneLoop).SysInletMass - ZnAirRpt(ZoneLoop).SysOutletMass; // kg + ZnAirRpt(ZoneLoop).ExfilSensiLoss = ZnAirRpt(ZoneLoop).ExfilMass / (TimeStepSys * DataGlobalConstants::SecInHour) * + (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * CpAir; // W + ZnAirRpt(ZoneLoop).ExfilLatentLoss = ZnAirRpt(ZoneLoop).ExfilMass / (TimeStepSys * DataGlobalConstants::SecInHour) * + (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap; + ZnAirRpt(ZoneLoop).ExfilTotalLoss = ZnAirRpt(ZoneLoop).ExfilLatentLoss + ZnAirRpt(ZoneLoop).ExfilSensiLoss; + + state.dataHeatBal->ZoneTotalExfiltrationHeatLoss += ZnAirRpt(ZoneLoop).ExfilTotalLoss * TimeStepSys * DataGlobalConstants::SecInHour; + state.dataHeatBal->ZoneTotalExhaustHeatLoss += ZnAirRpt(ZoneLoop).ExhTotalLoss * TimeStepSys * DataGlobalConstants::SecInHour; + } +} + +void SetHeatToReturnAirFlag(EnergyPlusData &state) +{ + + // SUBROUTINE INFORMATION: + // AUTHOR Fred Buhl + // DATE WRITTEN February 2008 + // MODIFIED na + // RE-ENGINEERED na + + // PURPOSE OF THIS SUBROUTINE: + // This sets some flags at the air loop and zone level: these flags indicate + // whether an air loop represents a "unitary" system, and whether the system is operating + // in a on/off (cycling fan) mode. At the zone level flags are set to indicate whether + // the zone is served by a zonal system only, and whether the air loop serving the zone (idf any) + // is in cycling fan mode. Using this information, the subroutine sets a flag at the zone level + // to tell ManageZoneAirUpdates (predict and correct) what to do with the heat to return air. + + // METHODOLOGY EMPLOYED: + // Uses program data structures AirLoopControlInfo and ZoneEquipInfo + + // Using/Aliasing + using DataHVACGlobals::NumPrimaryAirSys; + using DataSurfaces::AirFlowWindow_Destination_ReturnAir; + using ScheduleManager::CheckScheduleValue; + using ScheduleManager::GetCurrentScheduleValue; + using ScheduleManager::GetScheduleMaxValue; + + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + static int AirLoopNum(0); // the air loop index + int ControlledZoneNum; // controlled zone index + bool CyclingFan(false); // TRUE means air loop operates in cycling fan mode at some point + static int ZoneNum(0); // zone index + int LightNum; // Lights object index + int SurfNum; // Surface index + static Real64 CycFanMaxVal(0.0); // max value of cycling fan schedule + + auto &Zone(state.dataHeatBal->Zone); + auto &AirLoopControlInfo(state.dataAirLoop->AirLoopControlInfo); + auto &ZoneEquipConfig(state.dataZoneEquip->ZoneEquipConfig); + + if (!AirLoopsSimOnce) return; + + if (state.dataHVACMgr->MyOneTimeFlag) { + // set the air loop Any Continuous Fan flag + for (AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { + if (AirLoopControlInfo(AirLoopNum).UnitarySys) { // for unitary systems check the cycling fan schedule + if (AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { + CycFanMaxVal = GetScheduleMaxValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr); + if (CycFanMaxVal > 0.0) { + AirLoopControlInfo(AirLoopNum).AnyContFan = true; } else { - ZnAirRpt(ZoneLoop).OABalanceTotalGain = 0.0; - ZnAirRpt(ZoneLoop).OABalanceTotalLoss = -TotalLoad * ADSCorrectionFactor; + AirLoopControlInfo(AirLoopNum).AnyContFan = false; } - ZnAirRpt(ZoneLoop).OABalanceMass = (state.dataHeatBalFanSys->MDotOA(ZoneLoop)) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceMdot = (state.dataHeatBalFanSys->MDotOA(ZoneLoop)) * ADSCorrectionFactor; - AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, state.dataHeatBalFanSys->MAT(ZoneLoop), state.dataHeatBalFanSys->ZoneAirHumRatAvg(ZoneLoop), std::string()); - ZnAirRpt(ZoneLoop).OABalanceVolumeCurDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceAirChangeRate = ZnAirRpt(ZoneLoop).OABalanceVolumeCurDensity / (TimeStepSys * Zone(ZoneLoop).Volume); - ZnAirRpt(ZoneLoop).OABalanceVdotCurDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * ADSCorrectionFactor; - AirDensity = state.dataEnvrn->StdRhoAir; - ZnAirRpt(ZoneLoop).OABalanceVolumeStdDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceVdotStdDensity = (state.dataHeatBalFanSys->MDotOA(ZoneLoop) / AirDensity) * ADSCorrectionFactor; - ZnAirRpt(ZoneLoop).OABalanceFanElec = ZnAirRpt(ZoneLoop).VentilFanElec; + } else { // no schedule means always cycling fan + AirLoopControlInfo(AirLoopNum).AnyContFan = false; } + } else { // for nonunitary (central) all systems are continuous fan + AirLoopControlInfo(AirLoopNum).AnyContFan = true; } - // Reports exfiltration loss - H2OHtOfVap = PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, Zone(ZoneLoop).OutDryBulbTemp); - ZnAirRpt(ZoneLoop).SysInletMass = 0; - ZnAirRpt(ZoneLoop).SysOutletMass = 0; - if (!ZoneEquipConfig(ZoneLoop).IsControlled) { - for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumInletNodes; ++j) { - ZnAirRpt(ZoneLoop).SysInletMass += - state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).InletNode(j)).MassFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - } - for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumExhaustNodes; ++j) { - ZnAirRpt(ZoneLoop).SysOutletMass += - state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).ExhaustNode(j)).MassFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; - } - for (int j = 1; j <= ZoneEquipConfig(ZoneLoop).NumReturnNodes; ++j) { - ZnAirRpt(ZoneLoop).SysOutletMass += - state.dataLoopNodes->Node(ZoneEquipConfig(ZoneLoop).ReturnNode(j)).MassFlowRate * TimeStepSys * DataGlobalConstants::SecInHour * ADSCorrectionFactor; + } + // check to see if a controlled zone is served exclusively by a zonal system + for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { + ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; + bool airLoopFound = false; + for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { + if (ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode) > 0) { + airLoopFound = true; } } - - ZnAirRpt(ZoneLoop).ExfilMass = ZnAirRpt(ZoneLoop).InfilMass + ZnAirRpt(ZoneLoop).VentilMass + ZnAirRpt(ZoneLoop).MixMass + - ZnAirRpt(ZoneLoop).OABalanceMass + ZnAirRpt(ZoneLoop).SysInletMass - - ZnAirRpt(ZoneLoop).SysOutletMass; // kg - ZnAirRpt(ZoneLoop).ExfilSensiLoss = - ZnAirRpt(ZoneLoop).ExfilMass / (TimeStepSys * DataGlobalConstants::SecInHour) * (state.dataHeatBalFanSys->MAT(ZoneLoop) - Zone(ZoneLoop).OutDryBulbTemp) * CpAir; // W - ZnAirRpt(ZoneLoop).ExfilLatentLoss = - ZnAirRpt(ZoneLoop).ExfilMass / (TimeStepSys * DataGlobalConstants::SecInHour) * (state.dataHeatBalFanSys->ZoneAirHumRat(ZoneLoop) - state.dataEnvrn->OutHumRat) * H2OHtOfVap; - ZnAirRpt(ZoneLoop).ExfilTotalLoss = ZnAirRpt(ZoneLoop).ExfilLatentLoss + ZnAirRpt(ZoneLoop).ExfilSensiLoss; - - state.dataHeatBal->ZoneTotalExfiltrationHeatLoss += ZnAirRpt(ZoneLoop).ExfilTotalLoss * TimeStepSys * DataGlobalConstants::SecInHour; - state.dataHeatBal->ZoneTotalExhaustHeatLoss += ZnAirRpt(ZoneLoop).ExhTotalLoss * TimeStepSys * DataGlobalConstants::SecInHour; + if (!airLoopFound && ZoneEquipConfig(ControlledZoneNum).NumInletNodes == ZoneEquipConfig(ControlledZoneNum).NumExhaustNodes) { + ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly = true; + } } - } - - void SetHeatToReturnAirFlag(EnergyPlusData &state) - { - - // SUBROUTINE INFORMATION: - // AUTHOR Fred Buhl - // DATE WRITTEN February 2008 - // MODIFIED na - // RE-ENGINEERED na - - // PURPOSE OF THIS SUBROUTINE: - // This sets some flags at the air loop and zone level: these flags indicate - // whether an air loop represents a "unitary" system, and whether the system is operating - // in a on/off (cycling fan) mode. At the zone level flags are set to indicate whether - // the zone is served by a zonal system only, and whether the air loop serving the zone (idf any) - // is in cycling fan mode. Using this information, the subroutine sets a flag at the zone level - // to tell ManageZoneAirUpdates (predict and correct) what to do with the heat to return air. - - // METHODOLOGY EMPLOYED: - // Uses program data structures AirLoopControlInfo and ZoneEquipInfo - - // Using/Aliasing - using DataHVACGlobals::NumPrimaryAirSys; - using DataSurfaces::AirFlowWindow_Destination_ReturnAir; - using ScheduleManager::CheckScheduleValue; - using ScheduleManager::GetCurrentScheduleValue; - using ScheduleManager::GetScheduleMaxValue; - - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - static int AirLoopNum(0); // the air loop index - int ControlledZoneNum; // controlled zone index - bool CyclingFan(false); // TRUE means air loop operates in cycling fan mode at some point - static int ZoneNum(0); // zone index - int LightNum; // Lights object index - int SurfNum; // Surface index - static Real64 CycFanMaxVal(0.0); // max value of cycling fan schedule - - auto &Zone(state.dataHeatBal->Zone); - auto &AirLoopControlInfo(state.dataAirLoop->AirLoopControlInfo); - auto &ZoneEquipConfig(state.dataZoneEquip->ZoneEquipConfig); - - if (!AirLoopsSimOnce) return; - - if (MyOneTimeFlag) { - // set the air loop Any Continuous Fan flag - for (AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { - if (AirLoopControlInfo(AirLoopNum).UnitarySys) { // for unitary systems check the cycling fan schedule + // issue warning messages if zone is served by a zonal system or a cycling system and the input calls for + // heat gain to return air + for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { + if (!ZoneEquipConfig(ControlledZoneNum).IsControlled) continue; + ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; + CyclingFan = false; + for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { + AirLoopNum = ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode); + if (AirLoopNum > 0) { if (AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { - CycFanMaxVal = GetScheduleMaxValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr); - if (CycFanMaxVal > 0.0) { - AirLoopControlInfo(AirLoopNum).AnyContFan = true; - } else { - AirLoopControlInfo(AirLoopNum).AnyContFan = false; - } - } else { // no schedule means always cycling fan - AirLoopControlInfo(AirLoopNum).AnyContFan = false; + CyclingFan = CheckScheduleValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr, 0.0); } - } else { // for nonunitary (central) all systems are continuous fan - AirLoopControlInfo(AirLoopNum).AnyContFan = true; } } - // check to see if a controlled zone is served exclusively by a zonal system - for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { - ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; - bool airLoopFound = false; - for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { - if (ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode) > 0) { - airLoopFound = true; - } - } - if (!airLoopFound && ZoneEquipConfig(ControlledZoneNum).NumInletNodes == ZoneEquipConfig(ControlledZoneNum).NumExhaustNodes) { - ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly = true; + if (ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly || CyclingFan) { + if (Zone(ZoneNum).RefrigCaseRA) { + ShowWarningError(state, + "For zone=" + Zone(ZoneNum).Name + " return air cooling by refrigerated cases will be applied to the zone air."); + ShowContinueError(state, " This zone has no return air or is served by an on/off HVAC system."); } - } - // issue warning messages if zone is served by a zonal system or a cycling system and the input calls for - // heat gain to return air - for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { - if (!ZoneEquipConfig(ControlledZoneNum).IsControlled) continue; - ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; - CyclingFan = false; - for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { - AirLoopNum = ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode); - if (AirLoopNum > 0) { - if (AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { - CyclingFan = CheckScheduleValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr, 0.0); - } + for (LightNum = 1; LightNum <= state.dataHeatBal->TotLights; ++LightNum) { + if (state.dataHeatBal->Lights(LightNum).ZonePtr != ZoneNum) continue; + if (state.dataHeatBal->Lights(LightNum).FractionReturnAir > 0.0) { + ShowWarningError(state, + "For zone=" + Zone(ZoneNum).Name + " return air heat gain from lights will be applied to the zone air."); + ShowContinueError(state, " This zone has no return air or is served by an on/off HVAC system."); + break; } } - if (ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly || CyclingFan) { - if (Zone(ZoneNum).RefrigCaseRA) { - ShowWarningError(state, "For zone=" + Zone(ZoneNum).Name + - " return air cooling by refrigerated cases will be applied to the zone air."); + for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).HTSurfaceLast; ++SurfNum) { + if (state.dataSurface->SurfWinAirflowDestination(SurfNum) == AirFlowWindow_Destination_ReturnAir) { + ShowWarningError( + state, "For zone=" + Zone(ZoneNum).Name + " return air heat gain from air flow windows will be applied to the zone air."); ShowContinueError(state, " This zone has no return air or is served by an on/off HVAC system."); } - for (LightNum = 1; LightNum <= state.dataHeatBal->TotLights; ++LightNum) { - if (state.dataHeatBal->Lights(LightNum).ZonePtr != ZoneNum) continue; - if (state.dataHeatBal->Lights(LightNum).FractionReturnAir > 0.0) { - ShowWarningError(state, "For zone=" + Zone(ZoneNum).Name + " return air heat gain from lights will be applied to the zone air."); - ShowContinueError(state, " This zone has no return air or is served by an on/off HVAC system."); - break; - } - } - for (SurfNum = Zone(ZoneNum).HTSurfaceFirst; SurfNum <= Zone(ZoneNum).HTSurfaceLast; ++SurfNum) { - if (state.dataSurface->SurfWinAirflowDestination(SurfNum) == AirFlowWindow_Destination_ReturnAir) { - ShowWarningError(state, "For zone=" + Zone(ZoneNum).Name + - " return air heat gain from air flow windows will be applied to the zone air."); - ShowContinueError(state, " This zone has no return air or is served by an on/off HVAC system."); - } - } } } - MyOneTimeFlag = false; } + state.dataHVACMgr->MyOneTimeFlag = false; + } - // set the air loop fan operation mode - for (AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { - if (AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { - if (GetCurrentScheduleValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr) == 0.0) { - AirLoopControlInfo(AirLoopNum).FanOpMode = CycFanCycCoil; - } else { - AirLoopControlInfo(AirLoopNum).FanOpMode = ContFanCycCoil; - } + // set the air loop fan operation mode + for (AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { + if (AirLoopControlInfo(AirLoopNum).CycFanSchedPtr > 0) { + if (GetCurrentScheduleValue(state, AirLoopControlInfo(AirLoopNum).CycFanSchedPtr) == 0.0) { + AirLoopControlInfo(AirLoopNum).FanOpMode = CycFanCycCoil; + } else { + AirLoopControlInfo(AirLoopNum).FanOpMode = ContFanCycCoil; } } - // set the zone level NoHeatToReturnAir flag - // if any air loop in the zone is continuous fan, then set NoHeatToReturnAir = false and sort it out node-by-node - for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { - if (!ZoneEquipConfig(ControlledZoneNum).IsControlled) continue; - ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; - Zone(ZoneNum).NoHeatToReturnAir = true; - if (!ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly) { - for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { - AirLoopNum = ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode); - if (AirLoopNum > 0) { - if (AirLoopControlInfo(AirLoopNum).FanOpMode == ContFanCycCoil) { - Zone(ZoneNum).NoHeatToReturnAir = false; - break; - } + } + // set the zone level NoHeatToReturnAir flag + // if any air loop in the zone is continuous fan, then set NoHeatToReturnAir = false and sort it out node-by-node + for (ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) { + if (!ZoneEquipConfig(ControlledZoneNum).IsControlled) continue; + ZoneNum = ZoneEquipConfig(ControlledZoneNum).ActualZoneNum; + Zone(ZoneNum).NoHeatToReturnAir = true; + if (!ZoneEquipConfig(ControlledZoneNum).ZonalSystemOnly) { + for (int zoneInNode = 1; zoneInNode <= ZoneEquipConfig(ControlledZoneNum).NumInletNodes; ++zoneInNode) { + AirLoopNum = ZoneEquipConfig(ControlledZoneNum).InletNodeAirLoopNum(zoneInNode); + if (AirLoopNum > 0) { + if (AirLoopControlInfo(AirLoopNum).FanOpMode == ContFanCycCoil) { + Zone(ZoneNum).NoHeatToReturnAir = false; + break; } } } } } +} - void UpdateZoneInletConvergenceLog(EnergyPlusData &state) - { +void UpdateZoneInletConvergenceLog(EnergyPlusData &state) +{ - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneNum; - int NodeIndex; - int NodeNum; - Array1D tmpRealARR(DataConvergParams::ConvergLogStackDepth); + // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + int ZoneNum; + int NodeIndex; + int NodeNum; + Array1D tmpRealARR(DataConvergParams::ConvergLogStackDepth); - for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { + for (ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) { - for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { - NodeNum = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum; + for (NodeIndex = 1; NodeIndex <= state.dataConvergeParams->ZoneInletConvergence(ZoneNum).NumInletNodes; ++NodeIndex) { + NodeNum = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).NodeNum; - tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) = state.dataLoopNodes->Node(NodeNum).HumRat; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio({2, DataConvergParams::ConvergLogStackDepth}) = - tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio(1) = state.dataLoopNodes->Node(NodeNum).HumRat; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).HumidityRatio({2, DataConvergParams::ConvergLogStackDepth}) = + tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); - tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) = state.dataLoopNodes->Node(NodeNum).MassFlowRate; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate({2, DataConvergParams::ConvergLogStackDepth}) = - tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate(1) = + state.dataLoopNodes->Node(NodeNum).MassFlowRate; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).MassFlowRate({2, DataConvergParams::ConvergLogStackDepth}) = + tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); - tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) = state.dataLoopNodes->Node(NodeNum).Temp; - state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature({2, DataConvergParams::ConvergLogStackDepth}) = tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); - } + tmpRealARR = state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature(1) = state.dataLoopNodes->Node(NodeNum).Temp; + state.dataConvergeParams->ZoneInletConvergence(ZoneNum).InletNode(NodeIndex).Temperature({2, DataConvergParams::ConvergLogStackDepth}) = + tmpRealARR({1, DataConvergParams::ConvergLogStackDepth - 1}); } } - - void CheckAirLoopFlowBalance(EnergyPlusData &state) - { - // Check for unbalanced airloop - if (!state.dataGlobal->WarmupFlag && AirLoopsSimOnce) { - for (int AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { - auto &thisAirLoopFlow(state.dataAirLoop->AirLoopFlow(AirLoopNum)); - if (!thisAirLoopFlow.FlowError) { - Real64 unbalancedExhaustDelta = thisAirLoopFlow.SupFlow - thisAirLoopFlow.OAFlow - thisAirLoopFlow.SysRetFlow; - if (unbalancedExhaustDelta > SmallMassFlow) { - ShowSevereError(state, "CheckAirLoopFlowBalance: AirLoopHVAC " + state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Name + +} + +void CheckAirLoopFlowBalance(EnergyPlusData &state) +{ + // Check for unbalanced airloop + if (!state.dataGlobal->WarmupFlag && AirLoopsSimOnce) { + for (int AirLoopNum = 1; AirLoopNum <= NumPrimaryAirSys; ++AirLoopNum) { + auto &thisAirLoopFlow(state.dataAirLoop->AirLoopFlow(AirLoopNum)); + if (!thisAirLoopFlow.FlowError) { + Real64 unbalancedExhaustDelta = thisAirLoopFlow.SupFlow - thisAirLoopFlow.OAFlow - thisAirLoopFlow.SysRetFlow; + if (unbalancedExhaustDelta > SmallMassFlow) { + ShowSevereError(state, + "CheckAirLoopFlowBalance: AirLoopHVAC " + state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Name + " is unbalanced. Supply is > return plus outdoor air."); - ShowContinueErrorTimeStamp(state, ""); - ShowContinueError(state, - format(" Flows [m3/s at standard density]: Supply={:.6R} Return={:.6R} Outdoor Air={:.6R}", - thisAirLoopFlow.SupFlow / state.dataEnvrn->StdRhoAir, - thisAirLoopFlow.SysRetFlow / state.dataEnvrn->StdRhoAir, - thisAirLoopFlow.OAFlow / state.dataEnvrn->StdRhoAir)); - ShowContinueError(state, format(" Imbalance={:.6R}", unbalancedExhaustDelta / state.dataEnvrn->StdRhoAir)); - ShowContinueError(state, " This error will only be reported once per system."); - thisAirLoopFlow.FlowError = true; - } + ShowContinueErrorTimeStamp(state, ""); + ShowContinueError(state, + format(" Flows [m3/s at standard density]: Supply={:.6R} Return={:.6R} Outdoor Air={:.6R}", + thisAirLoopFlow.SupFlow / state.dataEnvrn->StdRhoAir, + thisAirLoopFlow.SysRetFlow / state.dataEnvrn->StdRhoAir, + thisAirLoopFlow.OAFlow / state.dataEnvrn->StdRhoAir)); + ShowContinueError(state, format(" Imbalance={:.6R}", unbalancedExhaustDelta / state.dataEnvrn->StdRhoAir)); + ShowContinueError(state, " This error will only be reported once per system."); + thisAirLoopFlow.FlowError = true; } } } } +} -} // namespace EnergyPlus +} // namespace EnergyPlus::HVACManager diff --git a/src/EnergyPlus/HVACManager.hh b/src/EnergyPlus/HVACManager.hh index bb82de41cba..acc81cbdd13 100644 --- a/src/EnergyPlus/HVACManager.hh +++ b/src/EnergyPlus/HVACManager.hh @@ -62,26 +62,16 @@ struct EnergyPlusData; namespace HVACManager { - // Data - // MODULE PARAMETER DEFINITIONS: - // na - - // MODULE VARIABLE DECLARATIONS: - - extern int HVACManageIteration; // counts iterations to enforce maximum iteration limit - extern int RepIterAir; - // SUBROUTINE SPECIFICATIONS FOR MODULE PrimaryPlantLoops // and zone equipment simulations // Functions - void clear_state(); - void ManageHVAC(EnergyPlusData &state); void SimHVAC(EnergyPlusData &state); - void SimSelectedEquipment(EnergyPlusData &state, bool &SimAirLoops, // True when the air loops need to be (re)simulated + void SimSelectedEquipment(EnergyPlusData &state, + bool &SimAirLoops, // True when the air loops need to be (re)simulated bool &SimZoneEquipment, // True when zone equipment components need to be (re)simulated bool &SimNonZoneEquipment, // True when non-zone equipment components need to be (re)simulated bool &SimPlantLoops, // True when the main plant loops need to be (re)simulated @@ -111,11 +101,38 @@ namespace HVACManager { } // namespace HVACManager -struct HVACManagerData : BaseGlobalStruct { +struct HVACManagerData : BaseGlobalStruct +{ + + int HVACManageIteration = 0; // counts iterations to enforce maximum iteration limit + int RepIterAir = 0; + bool SimHVACIterSetup = false; + bool TriggerGetAFN = true; + bool ReportAirHeatBalanceFirstTimeFlag = true; + bool MyOneTimeFlag = true; + bool PrintedWarmup = false; + bool MyEnvrnFlag = true; + bool DebugNamesReported = false; + bool MySetPointInit = true; + bool MyEnvrnFlag2 = true; + bool FlowMaxAvailAlreadyReset = false; + bool FlowResolutionNeeded = false; void clear_state() override { - + HVACManageIteration = 0; + RepIterAir = 0; + SimHVACIterSetup = false; + TriggerGetAFN = true; + ReportAirHeatBalanceFirstTimeFlag = true; + MyOneTimeFlag = true; + PrintedWarmup = false; + MyEnvrnFlag = true; + DebugNamesReported = false; + MySetPointInit = true; + MyEnvrnFlag2 = true; + FlowMaxAvailAlreadyReset = false; + FlowResolutionNeeded = false; } }; diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index f99742b7552..4dd7eb680c7 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -156,7 +155,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) HVACDXSystem::clear_state(); HVACHXAssistedCoolingCoil::clear_state(); HVACFan::clearHVACFanObjects(); - HVACManager::clear_state(); HVACMultiSpeedHeatPump::clear_state(); HVACSingleDuctInduc::clear_state(); HybridModel::clear_state(); From d28411e607c17536ac5815ee8acefe2a95bccf22 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 13:57:09 -0600 Subject: [PATCH 02/10] Global HVACMultiSpeedHeatPump: Enum classes --- src/EnergyPlus/HVACMultiSpeedHeatPump.cc | 29 +++--------------- src/EnergyPlus/HVACMultiSpeedHeatPump.hh | 38 +++++++++++++----------- 2 files changed, 24 insertions(+), 43 deletions(-) diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc index bc2d88bd721..a4e163e2eaa 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc @@ -113,15 +113,6 @@ namespace HVACMultiSpeedHeatPump { // usage. Neither the air-side performance nor the energy usage includes the effect // of supply air fan heat/energy usage. The supply air fan is modeled by other modules. - // METHODOLOGY EMPLOYED: - // na - - // REFERENCES: - // na - - // OTHER NOTES: - // na - // USE STATEMENTS: // Use statements for data only modules // Using/Aliasing @@ -146,18 +137,6 @@ namespace HVACMultiSpeedHeatPump { using namespace Psychrometrics; using namespace ScheduleManager; - // Data - // MODULE PARAMETER DEFINITIONS - - // Heating coil types - int const MultiSpeedHeatingCoil(1); // COIL:DX:MultiSpeed:Heating - // Cooling coil types - int const MultiSpeedCoolingCoil(2); // COIL:DX:MultiSpeed:Cooling - // Supplymental heating coil types - int const SuppHeatingCoilGas(1); // Supplymental heating coil type: COIL:GAS:HEATING - int const SuppHeatingCoilElec(2); // Supplymental heating coil type: COIL:ELECTRIC:HEATING - int const SuppHeatingCoilRec(3); // Supplymental heating coil type: COIL:ENGINEHEATRECOVERY:HEATING - // Curve Types enum class CurveType { Linear, // Linear curve type @@ -1089,7 +1068,7 @@ namespace HVACMultiSpeedHeatPump { // Get supplemental heating coil data MSHeatPump(MSHPNum).SuppHeatCoilName = Alphas(15); if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Fuel")) { - MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoilGas; + MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoil::Gas; errFlag = false; MSHeatPump(MSHPNum).SuppHeatCoilNum = GetHeatingCoilIndex(state, "Coil:Heating:Fuel", Alphas(15), errFlag); if (MSHeatPump(MSHPNum).SuppHeatCoilNum <= 0 || errFlag) { @@ -1131,7 +1110,7 @@ namespace HVACMultiSpeedHeatPump { "UNDEFINED"); } if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Electric")) { - MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoilElec; + MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoil::Electric; errFlag = false; MSHeatPump(MSHPNum).SuppHeatCoilNum = GetHeatingCoilIndex(state, "Coil:Heating:Electric", Alphas(15), errFlag); if (MSHeatPump(MSHPNum).SuppHeatCoilNum <= 0 || errFlag) { @@ -4356,7 +4335,7 @@ namespace HVACMultiSpeedHeatPump { { auto const SELECT_CASE_var(HeatCoilType); - if ((SELECT_CASE_var == SuppHeatingCoilGas) || (SELECT_CASE_var == SuppHeatingCoilElec)) { + if ((SELECT_CASE_var == SuppHeatingCoil::Gas) || (SELECT_CASE_var == SuppHeatingCoil::Electric)) { SimulateHeatingCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); } else if (SELECT_CASE_var == Coil_HeatingWater) { if (present(PartLoadFrac)) { @@ -4434,7 +4413,7 @@ namespace HVACMultiSpeedHeatPump { { auto const SELECT_CASE_var(HeatCoilType); - if ((SELECT_CASE_var == SuppHeatingCoilGas) || (SELECT_CASE_var == SuppHeatingCoilElec)) { + if ((SELECT_CASE_var == SuppHeatingCoil::Gas) || (SELECT_CASE_var == SuppHeatingCoil::Electric)) { SimulateHeatingCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); } else if (SELECT_CASE_var == Coil_HeatingWater) { mdot = 0.0; diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh index 58c1578d8d5..a3adcef1ad1 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh @@ -64,19 +64,20 @@ struct EnergyPlusData; namespace HVACMultiSpeedHeatPump { - // Using/Aliasing - - // Data - // MODULE PARAMETER DEFINITIONS + enum class MultiSpeedCoil + { + Unassigned, + Heating, // COIL:DX:MultiSpeed:Heating + Cooling // COIL:DX:MultiSpeed:Cooling + }; - // Heating coil types - extern int const MultiSpeedHeatingCoil; // COIL:DX:MultiSpeed:Heating - // Cooling coil types - extern int const MultiSpeedCoolingCoil; // COIL:DX:MultiSpeed:Cooling - // Supplymental heating coil types - extern int const SuppHeatingCoilGas; // Supplymental heating coil type: COIL:GAS:HEATING - extern int const SuppHeatingCoilElec; // Supplymental heating coil type: COIL:ELECTRIC:HEATING - extern int const SuppHeatingCoilRec; // Supplymental heating coil type: COIL:ENGINEHEATRECOVERY:HEATING + enum class SuppHeatingCoil + { + Unassigned, + Gas, + Electric, + EngineHeatRecovery + }; // Mode of operation enum class ModeOfOperation { @@ -101,7 +102,7 @@ namespace HVACMultiSpeedHeatPump { struct MSHeatPumpData { // Members - // Some variables in this type are arrays (dimension=MaxSpeed) to support the number of speeds + //Some variables in this type are arrays (dimension=MaxSpeed) to support the number of speeds std::string Name; // Name of the engine driven heat pump std::string AvaiSchedule; // Availability Schedule name int AvaiSchedPtr; // Pointer to the correct schedule @@ -126,16 +127,16 @@ namespace HVACMultiSpeedHeatPump { int FanSchedPtr; // Pointer to the Supply air fan operating mode schedule int OpMode; // mode of operation; 1=cycling fan, cycling compressor; 2=continuous fan, cycling compresor std::string DXHeatCoilName; // COIL:DX:MultiSpeed:Heating name - int HeatCoilType; // Heating coil type: 1 COIL:DX:MultiSpeed:Heating only + MultiSpeedCoil HeatCoilType; // Heating coil type: 1 COIL:DX:MultiSpeed:Heating only int HeatCoilNum; // Heating coil number int DXHeatCoilIndex; // DX heating coil index number std::string HeatCoilName; // Coil:Electric:MultiSpeed:Heating OR Coil:Gas:MultiSpeed:Heating name int HeatCoilIndex; // heating coil index number (Coil:Electric:MultiSpeed:Heating OR Coil:Gas:MultiSpeed:Heating) std::string DXCoolCoilName; // COIL:DX:MultiSpeed:Cooling name - int CoolCoilType; // Cooling coil type: 1 COIL:DX:MultiSpeed:Cooling only + MultiSpeedCoil CoolCoilType; // Cooling coil type: 1 COIL:DX:MultiSpeed:Cooling only int DXCoolCoilIndex; // DX cooling coil index number std::string SuppHeatCoilName; // Supplymental heating coil name - int SuppHeatCoilType; // Supplymental heating coil type: 1 Gas; 2 Electric; 3 Recovery + SuppHeatingCoil SuppHeatCoilType; // Supplymental heating coil type: 1 Gas; 2 Electric; 3 Recovery int SuppHeatCoilNum; // Supplymental heating coil number Real64 DesignSuppHeatingCapacity; // Supplemental heating coil design capacity Real64 SuppMaxAirTemp; // Maximum supply air temperature from supplemental heater @@ -239,8 +240,9 @@ namespace HVACMultiSpeedHeatPump { MSHeatPumpData() : AvaiSchedPtr(0), AirInletNodeNum(0), AirOutletNodeNum(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), ZoneSequenceHeatingNum(0), NodeNumOfControlledZone(0), FlowFraction(0.0), FanType(0), FanNum(0), FanPlaceType(0), FanInletNode(0), FanOutletNode(0), - FanVolFlow(0.0), FanSchedPtr(0), OpMode(0), HeatCoilType(0), HeatCoilNum(0), DXHeatCoilIndex(0), HeatCoilIndex(0), CoolCoilType(0), - DXCoolCoilIndex(0), SuppHeatCoilType(0), SuppHeatCoilNum(0), DesignSuppHeatingCapacity(0.0), SuppMaxAirTemp(0.0), SuppMaxOATemp(0.0), + FanVolFlow(0.0), FanSchedPtr(0), OpMode(0), HeatCoilType(MultiSpeedCoil::Unassigned), HeatCoilNum(0), DXHeatCoilIndex(0), + HeatCoilIndex(0), CoolCoilType(MultiSpeedCoil::Unassigned), DXCoolCoilIndex(0), SuppHeatCoilType(SuppHeatingCoil::Unassigned), + SuppHeatCoilNum(0), DesignSuppHeatingCapacity(0.0), SuppMaxAirTemp(0.0), SuppMaxOATemp(0.0), AuxOnCyclePower(0.0), AuxOffCyclePower(0.0), DesignHeatRecFlowRate(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), MaxHeatRecOutletTemp(0.0), DesignHeatRecMassFlowRate(0.0), HRLoopNum(0), HRLoopSideNum(0), HRBranchNum(0), HRCompNum(0), AuxElecPower(0.0), IdleVolumeAirRate(0.0), IdleMassFlowRate(0.0), IdleSpeedRatio(0.0), NumOfSpeedCooling(0), From d8619868158432be15f86bba14735982cdfd30f1 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 15:38:40 -0600 Subject: [PATCH 03/10] Global HVACMultiSpeedHeatPump: revert to constexpr --- src/EnergyPlus/HVACMultiSpeedHeatPump.cc | 732 +++++++++++++---------- src/EnergyPlus/HVACMultiSpeedHeatPump.hh | 88 ++- src/EnergyPlus/StateManagement.cc | 2 - 3 files changed, 468 insertions(+), 354 deletions(-) diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc index a4e163e2eaa..ebdd496b81a 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc @@ -148,59 +148,6 @@ namespace HVACMultiSpeedHeatPump { static std::string const fluidNameSteam("STEAM"); - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - int NumMSHeatPumps(0); // Number of multi speed heat pumps - int AirLoopPass(0); // Number of air loop pass - Real64 TempSteamIn(100.0); // steam coil steam inlet temperature - - std::string CurrentModuleObject; // Object type for getting and error messages - Real64 CompOnMassFlow(0.0); // System air mass flow rate w/ compressor ON - Real64 CompOffMassFlow(0.0); // System air mass flow rate w/ compressor OFF - Real64 CompOnFlowRatio(0.0); // fan flow ratio when coil on - Real64 CompOffFlowRatio(0.0); // fan flow ratio when coil off - Real64 FanSpeedRatio(0.0); // fan speed ratio passed to on/off fan object - Real64 SupHeaterLoad(0.0); // load to be met by supplemental heater [W] - Real64 SaveLoadResidual(0.0); // Saved load residual used to check convergence - Real64 SaveCompressorPLR(0.0); // holds compressor PLR from active DX coil - Array1D_bool CheckEquipName; - - // SUBROUTINE SPECIFICATIONS FOR MODULE - - // Object Data - Array1D MSHeatPump; - Array1D MSHeatPumpReport; - - bool GetInputFlag(true); // Get input flag - bool FlowFracFlagReady(true); // one time flag for calculating flow fraction through controlled zone - int ErrCountCyc(0); // Counter used to minimize the occurrence of output warnings - int ErrCountVar(0); // Counter used to minimize the occurrence of output warnings - - // Functions - void clear_state() - { - NumMSHeatPumps = 0; - AirLoopPass = 0; - TempSteamIn = 100.0; - CurrentModuleObject = ""; - CompOnMassFlow = 0.0; - CompOffMassFlow = 0.0; - CompOnFlowRatio = 0.0; - CompOffFlowRatio = 0.0; - FanSpeedRatio = 0.0; - SupHeaterLoad = 0.0; - SaveLoadResidual = 0.0; - SaveCompressorPLR = 0.0; - CheckEquipName.clear(); - MSHeatPump.clear(); - MSHeatPumpReport.clear(); - GetInputFlag = true; // Get input flag - FlowFracFlagReady = true; - ErrCountCyc = 0; - ErrCountVar = 0; - } - void SimMSHeatPump(EnergyPlusData &state, std::string const &CompName, // Name of the unitary engine driven heat pump system bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system time step @@ -228,9 +175,9 @@ namespace HVACMultiSpeedHeatPump { // First time SimMSHeatPump is called, get the input - if (GetInputFlag) { + if (state.dataHVACMultiSpdHP->GetInputFlag) { GetMSHeatPumpInput(state); - GetInputFlag = false; // Set GetInputFlag false so you don't get coil inputs again + state.dataHVACMultiSpdHP->GetInputFlag = false; // Set GetInputFlag false so you don't get coil inputs again } if (CompIndex == 0) { @@ -241,14 +188,14 @@ namespace HVACMultiSpeedHeatPump { CompIndex = MSHeatPumpNum; } else { MSHeatPumpNum = CompIndex; - if (MSHeatPumpNum > NumMSHeatPumps || MSHeatPumpNum < 1) { + if (MSHeatPumpNum > state.dataHVACMultiSpdHP->NumMSHeatPumps || MSHeatPumpNum < 1) { ShowFatalError(state, format("SimMSHeatPump: Invalid CompIndex passed={}, Number of MultiSpeed Heat Pumps={}, Heat Pump name={}", MSHeatPumpNum, - NumMSHeatPumps, + state.dataHVACMultiSpdHP->NumMSHeatPumps, CompName)); } - if (CheckEquipName(MSHeatPumpNum)) { + if (state.dataHVACMultiSpdHP->CheckEquipName(MSHeatPumpNum)) { if (CompName != MSHeatPump(MSHeatPumpNum).Name) { ShowFatalError(state, format("SimMSHeatPump: Invalid CompIndex passed={}, Heat Pump name={}{}", @@ -256,7 +203,7 @@ namespace HVACMultiSpeedHeatPump { CompName, MSHeatPump(MSHeatPumpNum).Name)); } - CheckEquipName(MSHeatPumpNum) = false; + state.dataHVACMultiSpdHP->CheckEquipName(MSHeatPumpNum) = false; } } @@ -324,7 +271,7 @@ namespace HVACMultiSpeedHeatPump { // zero the fan, DX coils, and supplemental electric heater electricity consumption DXElecHeatingPower = 0.0; DXElecCoolingPower = 0.0; - SaveCompressorPLR = 0.0; + state.dataHVACMultiSpdHP->SaveCompressorPLR = 0.0; ElecHeatingCoilPower = 0.0; DataHVACGlobals::SuppHeatingCoilPower = 0.0; @@ -402,14 +349,14 @@ namespace HVACMultiSpeedHeatPump { } if (MSHeatPump(MSHeatPumpNum).HeatCoilType != MultiSpeedHeatingCoil) { - SaveCompressorPLR = PartLoadFrac; + state.dataHVACMultiSpdHP->SaveCompressorPLR = PartLoadFrac; } else { if (SpeedNum > 1) { - SaveCompressorPLR = 1.0; + state.dataHVACMultiSpdHP->SaveCompressorPLR = 1.0; } - if (PartLoadFrac == 1.0 && SaveCompressorPLR < 1.0 && (!MSHeatPump(MSHeatPumpNum).Staged)) { - PartLoadFrac = SaveCompressorPLR; + if (PartLoadFrac == 1.0 && state.dataHVACMultiSpdHP->SaveCompressorPLR < 1.0 && (!MSHeatPump(MSHeatPumpNum).Staged)) { + PartLoadFrac = state.dataHVACMultiSpdHP->SaveCompressorPLR; } } @@ -431,7 +378,7 @@ namespace HVACMultiSpeedHeatPump { QTotUnitOut = AirMassFlow * (state.dataLoopNodes->Node(OutletNode).Enthalpy - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).NodeNumOfControlledZone).Enthalpy); // report variables - MSHeatPump(MSHeatPumpNum).CompPartLoadRatio = SaveCompressorPLR; + MSHeatPump(MSHeatPumpNum).CompPartLoadRatio = state.dataHVACMultiSpdHP->SaveCompressorPLR; if (MSHeatPump(MSHeatPumpNum).OpMode == CycFanCycCoil) { if (SupHeaterLoad > 0.0) { MSHeatPump(MSHeatPumpNum).FanPartLoadRatio = 1.0; @@ -471,8 +418,8 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).LatHeatEnergyRate = 0.0; } - MSHeatPump(MSHeatPumpNum).AuxElecPower = - MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * SaveCompressorPLR + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - SaveCompressorPLR); + MSHeatPump(MSHeatPumpNum).AuxElecPower = MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * state.dataHVACMultiSpdHP->SaveCompressorPLR + + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - state.dataHVACMultiSpdHP->SaveCompressorPLR); Real64 locFanElecPower = 0.0; locFanElecPower = Fans::GetFanPower(state, MSHeatPump(MSHeatPumpNum).FanNum); MSHeatPump(MSHeatPumpNum).ElecPower = locFanElecPower + DXElecCoolingPower + DXElecHeatingPower + ElecHeatingCoilPower + @@ -578,9 +525,10 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump.allocated()) return; - CurrentModuleObject = "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed"; // Object type for getting and error messages + state.dataHVACMultiSpdHP->CurrentModuleObject = + "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed"; // Object type for getting and error messages - inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, TotalArgs, NumAlphas, NumNumbers); + inputProcessor->getObjectDefMaxArgs(state, state.dataHVACMultiSpdHP->CurrentModuleObject, TotalArgs, NumAlphas, NumNumbers); MaxNums = max(MaxNums, NumNumbers); MaxAlphas = max(MaxAlphas, NumAlphas); @@ -591,20 +539,20 @@ namespace HVACMultiSpeedHeatPump { lAlphaBlanks.dimension(MaxAlphas, true); lNumericBlanks.dimension(MaxNums, true); - NumMSHeatPumps = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + state.dataHVACMultiSpdHP->NumMSHeatPumps = inputProcessor->getNumObjectsFound(state, state.dataHVACMultiSpdHP->CurrentModuleObject); - if (NumMSHeatPumps <= 0) { - ShowSevereError(state, "No " + CurrentModuleObject + " objects specified in input file."); + if (state.dataHVACMultiSpdHP->NumMSHeatPumps <= 0) { + ShowSevereError(state, "No " + state.dataHVACMultiSpdHP->CurrentModuleObject + " objects specified in input file."); ErrorsFound = true; } // ALLOCATE ARRAYS - MSHeatPump.allocate(NumMSHeatPumps); - MSHeatPumpReport.allocate(NumMSHeatPumps); - CheckEquipName.dimension(NumMSHeatPumps, true); + MSHeatPump.allocate(state.dataHVACMultiSpdHP->NumMSHeatPumps); + MSHeatPumpReport.allocate(state.dataHVACMultiSpdHP->NumMSHeatPumps); + state.dataHVACMultiSpdHP->CheckEquipName.dimension(state.dataHVACMultiSpdHP->NumMSHeatPumps, true); // Load arrays with reformulated electric EIR chiller data - for (MSHPNum = 1; MSHPNum <= NumMSHeatPumps; ++MSHPNum) { + for (MSHPNum = 1; MSHPNum <= state.dataHVACMultiSpdHP->NumMSHeatPumps; ++MSHPNum) { HeatingCoilInletNode = 0; HeatingCoilOutletNode = 0; @@ -614,7 +562,7 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilOutletNode = 0; inputProcessor->getObjectItem(state, - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHPNum, Alphas, NumAlphas, @@ -625,7 +573,7 @@ namespace HVACMultiSpeedHeatPump { lAlphaBlanks, cAlphaFields, cNumericFields); - UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); + UtilityRoutines::IsNameEmpty(state, Alphas(1), state.dataHVACMultiSpdHP->CurrentModuleObject, ErrorsFound); MSHeatPump(MSHPNum).Name = Alphas(1); if (lAlphaBlanks(2)) { @@ -633,26 +581,43 @@ namespace HVACMultiSpeedHeatPump { } else { MSHeatPump(MSHPNum).AvaiSchedPtr = GetScheduleIndex(state, Alphas(2)); if (MSHeatPump(MSHPNum).AvaiSchedPtr == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(2) + " not found: " + Alphas(2)); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(2) + + " not found: " + Alphas(2)); ErrorsFound = true; } } MSHeatPump(MSHPNum).AirInletNodeName = Alphas(3); MSHeatPump(MSHPNum).AirOutletNodeName = Alphas(4); - MSHeatPump(MSHPNum).AirInletNodeNum = - GetOnlySingleNode(state, Alphas(3), ErrorsFound, CurrentModuleObject, Alphas(1), DataLoopNode::NodeFluidType::Air, DataLoopNode::NodeConnectionType::Inlet, 1, ObjectIsParent); - - MSHeatPump(MSHPNum).AirOutletNodeNum = - GetOnlySingleNode(state, Alphas(4), ErrorsFound, CurrentModuleObject, Alphas(1), DataLoopNode::NodeFluidType::Air, DataLoopNode::NodeConnectionType::Outlet, 1, ObjectIsParent); - - TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes"); + MSHeatPump(MSHPNum).AirInletNodeNum = GetOnlySingleNode(state, + Alphas(3), + ErrorsFound, + state.dataHVACMultiSpdHP->CurrentModuleObject, + Alphas(1), + DataLoopNode::NodeFluidType::Air, + DataLoopNode::NodeConnectionType::Inlet, + 1, + ObjectIsParent); + + MSHeatPump(MSHPNum).AirOutletNodeNum = GetOnlySingleNode(state, + Alphas(4), + ErrorsFound, + state.dataHVACMultiSpdHP->CurrentModuleObject, + Alphas(1), + DataLoopNode::NodeFluidType::Air, + DataLoopNode::NodeConnectionType::Outlet, + 1, + ObjectIsParent); + + TestCompSet(state, state.dataHVACMultiSpdHP->CurrentModuleObject, Alphas(1), Alphas(3), Alphas(4), "Air Nodes"); // Get the Controlling Zone or Location of the engine driven heat pump Thermostat MSHeatPump(MSHPNum).ControlZoneNum = UtilityRoutines::FindItemInList(Alphas(5), state.dataHeatBal->Zone); MSHeatPump(MSHPNum).ControlZoneName = Alphas(5); if (MSHeatPump(MSHPNum).ControlZoneNum == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(5) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(5) + " not found: " + MSHeatPump(MSHPNum).ControlZoneName); ErrorsFound = true; } @@ -674,7 +639,7 @@ namespace HVACMultiSpeedHeatPump { if (!UtilityRoutines::SameString(state.dataAirSystemsData->PrimaryAirSystems(AirLoopNumber).Branch(BranchNum).Comp(CompNum).Name, MSHeatPump(MSHPNum).Name) || !UtilityRoutines::SameString(state.dataAirSystemsData->PrimaryAirSystems(AirLoopNumber).Branch(BranchNum).Comp(CompNum).TypeOf, - CurrentModuleObject)) + state.dataHVACMultiSpdHP->CurrentModuleObject)) continue; AirLoopFound = true; MSHeatPump(MSHPNum).AirLoopNumber = AirLoopNumber; @@ -701,12 +666,16 @@ namespace HVACMultiSpeedHeatPump { if (AirLoopFound) break; } if (!AirNodeFound) { - ShowSevereError(state, "Did not find Air Node (" + cAlphaFields(5) + "), " + CurrentModuleObject + " = \"\"" + MSHeatPump(MSHPNum).Name); + ShowSevereError(state, + "Did not find Air Node (" + cAlphaFields(5) + "), " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = \"\"" + + MSHeatPump(MSHPNum).Name); ShowContinueError(state, "Specified " + cAlphaFields(5) + " = " + Alphas(5)); ErrorsFound = true; } if (!AirLoopFound) { - ShowSevereError(state, "Did not find correct AirLoopHVAC for " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowSevereError(state, + "Did not find correct AirLoopHVAC for " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + + MSHeatPump(MSHPNum).Name); ShowContinueError(state, "The " + cAlphaFields(5) + " = " + Alphas(5) + " is not served by this Primary Air Loop equipment."); ErrorsFound = true; } @@ -717,26 +686,40 @@ namespace HVACMultiSpeedHeatPump { if (UtilityRoutines::SameString(Alphas(6), "Fan:OnOff") || UtilityRoutines::SameString(Alphas(6), "Fan:ConstantVolume")) { if (UtilityRoutines::SameString(Alphas(6), "Fan:OnOff")) { MSHeatPump(MSHPNum).FanType = FanType_SimpleOnOff; - SetUpCompSets(state, CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Fan:OnOff", MSHeatPump(MSHPNum).FanName, "UNDEFINED", "UNDEFINED"); + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, + MSHeatPump(MSHPNum).Name, + "Fan:OnOff", + MSHeatPump(MSHPNum).FanName, + "UNDEFINED", + "UNDEFINED"); MSHeatPump(MSHPNum).FanInletNode = GetFanInletNode(state, "Fan:OnOff", MSHeatPump(MSHPNum).FanName, ErrorsFound); MSHeatPump(MSHPNum).FanOutletNode = GetFanOutletNode(state, "Fan:OnOff", MSHeatPump(MSHPNum).FanName, ErrorsFound); } else { MSHeatPump(MSHPNum).FanType = FanType_SimpleConstVolume; SetUpCompSets(state, - CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Fan:ConstantVolume", MSHeatPump(MSHPNum).FanName, "UNDEFINED", "UNDEFINED"); + state.dataHVACMultiSpdHP->CurrentModuleObject, + MSHeatPump(MSHPNum).Name, + "Fan:ConstantVolume", + MSHeatPump(MSHPNum).FanName, + "UNDEFINED", + "UNDEFINED"); MSHeatPump(MSHPNum).FanInletNode = GetFanInletNode(state, "Fan:ConstantVolume", MSHeatPump(MSHPNum).FanName, ErrorsFound); MSHeatPump(MSHPNum).FanOutletNode = GetFanOutletNode(state, "Fan:ConstantVolume", MSHeatPump(MSHPNum).FanName, ErrorsFound); } - GetFanIndex(state, Alphas(7), MSHeatPump(MSHPNum).FanNum, ErrorsFound, CurrentModuleObject); + GetFanIndex(state, Alphas(7), MSHeatPump(MSHPNum).FanNum, ErrorsFound, state.dataHVACMultiSpdHP->CurrentModuleObject); GetFanType(state, Alphas(7), FanType, ErrorsFound); if (FanType != MSHeatPump(MSHPNum).FanType) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(6) + " and " + cAlphaFields(7) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(6) + + " and " + cAlphaFields(7) + " do not match in Fan objects."); ShowContinueError(state, "The entered " + cAlphaFields(7) + " = " + Alphas(7) + " and " + cAlphaFields(6) + " = " + Alphas(6)); ErrorsFound = true; } } else { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(6) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(6) + " is not allowed = " + Alphas(6)); ShowContinueError(state, "Valid choices are Fan:OnOff or Fan:ConstantVolume"); ErrorsFound = true; @@ -750,7 +733,8 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).FanPlaceType = DrawThru; } } else { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(8) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(8) + " is not allowed = " + Alphas(8)); ShowContinueError(state, "Valid choices are BlowThrough or DrawThrough"); ErrorsFound = true; @@ -759,13 +743,15 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).FanSchedule = Alphas(9); MSHeatPump(MSHPNum).FanSchedPtr = GetScheduleIndex(state, Alphas(9)); if (MSHeatPump(MSHPNum).FanSchedPtr == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(9) + " not found: " + Alphas(9)); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\" " + cAlphaFields(9) + + " not found: " + Alphas(9)); ErrorsFound = true; } if (MSHeatPump(MSHPNum).FanSchedPtr > 0 && MSHeatPump(MSHPNum).FanType == FanType_SimpleConstVolume) { if (!CheckScheduleValueMinMax(state, MSHeatPump(MSHPNum).FanSchedPtr, ">", 0.0, "<=", 1.0)) { - ShowSevereError(state, CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, cAlphaFields(9) + " must be continuous (fan operating mode schedule values > 0) for " + cAlphaFields(6) + " = Fan:ConstantVolume."); ShowContinueError(state, "Error found in " + cAlphaFields(9) + " = " + Alphas(9)); @@ -779,10 +765,11 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatCoilNum = inputProcessor->getObjectItemNum(state, "Coil:Heating:DX:MultiSpeed", Alphas(11)); MSHeatPump(MSHPNum).DXHeatCoilName = Alphas(11); if (MSHeatPump(MSHPNum).HeatCoilNum <= 0) { - ShowSevereError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowSevereError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(11) + " \"" + Alphas(11) + "\" not found."); ShowContinueError(state, cAlphaFields(10) + " must be Coil:Heating:DX:MultiSpeed "); - ShowFatalError(state, RoutineName + "Errors found in getting " + CurrentModuleObject + + ShowFatalError(state, + RoutineName + "Errors found in getting " + state.dataHVACMultiSpdHP->CurrentModuleObject + " input. Preceding condition(s) causes termination."); ErrorsFound = true; } @@ -795,31 +782,33 @@ namespace HVACMultiSpeedHeatPump { ObjexxFCL::Optional_bool_const()); if (LocalError) { ShowSevereError(state, "The index of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } HeatingCoilInletNode = GetDXCoilInletNode(state, Alphas(10), Alphas(11), LocalError); if (LocalError) { ShowSevereError(state, "The inlet node number of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } HeatingCoilOutletNode = GetDXCoilOutletNode(state, Alphas(10), Alphas(11), LocalError); if (LocalError) { ShowSevereError(state, "The outlet node number of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } MSHeatPump(MSHPNum).MinOATCompressorHeating = DXCoils::GetMinOATCompressorUsingIndex(state, MSHeatPump(MSHPNum).DXHeatCoilIndex, LocalError); if (LocalError) { - ShowContinueError(state, "...for heating coil. Occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, + "...for heating coil. Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); LocalError = false; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:DX:MultiSpeed", MSHeatPump(MSHPNum).DXHeatCoilName, @@ -832,10 +821,11 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatCoilType = Coil_HeatingElectric_MultiStage; MSHeatPump(MSHPNum).HeatCoilNum = inputProcessor->getObjectItemNum(state, "Coil:Heating:Electric:MultiStage", Alphas(11)); if (MSHeatPump(MSHPNum).HeatCoilNum <= 0) { - ShowSevereError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowSevereError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(11) + " \"" + Alphas(11) + "\" not found."); ShowContinueError(state, cAlphaFields(10) + " must be Coil:Heating:Electric:MultiStage "); - ShowFatalError(state, RoutineName + "Errors found in getting " + CurrentModuleObject + + ShowFatalError(state, + RoutineName + "Errors found in getting " + state.dataHVACMultiSpdHP->CurrentModuleObject + " input. Preceding condition(s) causes termination."); ErrorsFound = true; } @@ -843,10 +833,11 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatCoilType = Coil_HeatingGas_MultiStage; MSHeatPump(MSHPNum).HeatCoilNum = inputProcessor->getObjectItemNum(state, "Coil:Heating:Gas:MultiStage", Alphas(11)); if (MSHeatPump(MSHPNum).HeatCoilNum <= 0) { - ShowSevereError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowSevereError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(11) + " \"" + Alphas(11) + "\" not found."); ShowContinueError(state, cAlphaFields(10) + " must be Coil:Heating:Gas:MultiStage "); - ShowFatalError(state, RoutineName + "Errors found in getting " + CurrentModuleObject + + ShowFatalError(state, + RoutineName + "Errors found in getting " + state.dataHVACMultiSpdHP->CurrentModuleObject + " input. Preceding condition(s) causes termination."); ErrorsFound = true; } @@ -860,33 +851,35 @@ namespace HVACMultiSpeedHeatPump { } if (LocalError) { ShowSevereError(state, "The index of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } HeatingCoilInletNode = GetCoilInletNode(state, Alphas(10), Alphas(11), LocalError); if (LocalError) { ShowSevereError(state, "The inlet node number of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } HeatingCoilOutletNode = GetCoilOutletNode(state, Alphas(10), Alphas(11), LocalError); if (LocalError) { ShowSevereError(state, "The outlet node number of " + cAlphaFields(11) + " is not found \"" + Alphas(11) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } if (UtilityRoutines::SameString(Alphas(10), "Coil:Heating:Electric:MultiStage")) { - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Electric:MultiStage", MSHeatPump(MSHPNum).HeatCoilName, "UNDEFINED", "UNDEFINED"); } else { - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Gas:MultiStage", MSHeatPump(MSHPNum).HeatCoilName, @@ -895,9 +888,9 @@ namespace HVACMultiSpeedHeatPump { } } else if (UtilityRoutines::SameString(Alphas(10), "Coil:Heating:Water")) { MSHeatPump(MSHPNum).HeatCoilType = Coil_HeatingWater; - ValidateComponent(state, Alphas(10), Alphas(11), IsNotOK, CurrentModuleObject); + ValidateComponent(state, Alphas(10), Alphas(11), IsNotOK, state.dataHVACMultiSpdHP->CurrentModuleObject); if (IsNotOK) { - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " = " + Alphas(1)); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + Alphas(1)); ErrorsFound = true; } else { // mine data from heating coil object @@ -906,7 +899,7 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; MSHeatPump(MSHPNum).CoilControlNode = GetCoilWaterInletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -914,7 +907,7 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; MSHeatPump(MSHPNum).MaxCoilFluidFlow = GetCoilMaxWaterFlowRate(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -923,7 +916,7 @@ namespace HVACMultiSpeedHeatPump { HeatingCoilInletNode = GetWaterCoilInletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).HeatCoilName, errFlag); MSHeatPump(MSHPNum).CoilAirInletNode = HeatingCoilInletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -931,10 +924,11 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; HeatingCoilOutletNode = GetWaterCoilOutletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Water", MSHeatPump(MSHPNum).HeatCoilName, @@ -943,9 +937,9 @@ namespace HVACMultiSpeedHeatPump { } } else if (UtilityRoutines::SameString(Alphas(10), "Coil:Heating:Steam")) { MSHeatPump(MSHPNum).HeatCoilType = Coil_HeatingSteam; - ValidateComponent(state, Alphas(10), Alphas(11), IsNotOK, CurrentModuleObject); + ValidateComponent(state, Alphas(10), Alphas(11), IsNotOK, state.dataHVACMultiSpdHP->CurrentModuleObject); if (IsNotOK) { - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } else { // mine data from heating coil object @@ -953,8 +947,10 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; MSHeatPump(MSHPNum).HeatCoilNum = GetSteamCoilIndex(state, Alphas(10), MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (MSHeatPump(MSHPNum).HeatCoilNum == 0) { - ShowSevereError(state, CurrentModuleObject + " illegal " + cAlphaFields(10) + " = " + MSHeatPump(MSHPNum).HeatCoilName); - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + " illegal " + cAlphaFields(10) + " = " + + MSHeatPump(MSHPNum).HeatCoilName); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -962,7 +958,7 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; MSHeatPump(MSHPNum).CoilControlNode = GetCoilAirOutletNode(state, "Coil:Heating:Steam", MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -970,7 +966,8 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).MaxCoilFluidFlow = GetCoilMaxSteamFlowRate(state, MSHeatPump(MSHPNum).HeatCoilNum, errFlag); if (MSHeatPump(MSHPNum).MaxCoilFluidFlow > 0.0) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineNameNoColon); + SteamDensity = + GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineNameNoColon); MSHeatPump(MSHPNum).MaxCoilFluidFlow *= SteamDensity; } @@ -979,7 +976,7 @@ namespace HVACMultiSpeedHeatPump { HeatingCoilInletNode = GetSteamCoilAirInletNode(state, MSHeatPump(MSHPNum).HeatCoilNum, MSHeatPump(MSHPNum).HeatCoilName, errFlag); MSHeatPump(MSHPNum).CoilAirInletNode = HeatingCoilInletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -987,11 +984,12 @@ namespace HVACMultiSpeedHeatPump { errFlag = false; HeatingCoilOutletNode = GetCoilAirOutletNode(state, MSHeatPump(MSHPNum).HeatCoilNum, MSHeatPump(MSHPNum).HeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Steam", MSHeatPump(MSHPNum).HeatCoilName, @@ -1001,7 +999,7 @@ namespace HVACMultiSpeedHeatPump { } else { ShowSevereError(state, "The allowed " + cAlphaFields(10) + " are Coil:Heating:DX:MultiSpeed, Coil:Heating:Electric:MultiStage, and Coil:Heating:Gas:MultiStage in " + - CurrentModuleObject + " \"" + Alphas(1) + "\""); + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, "The entered " + cAlphaFields(10) + " = \"" + Alphas(10) + "\"."); ErrorsFound = true; } @@ -1012,10 +1010,11 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).CoolCoilType = MultiSpeedCoolingCoil; MSHeatPump(MSHPNum).DXCoolCoilName = Alphas(13); if (inputProcessor->getObjectItemNum(state, "Coil:Cooling:DX:MultiSpeed", Alphas(13)) <= 0) { - ShowSevereError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowSevereError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(13) + " \"" + Alphas(13) + "\" not found."); ShowContinueError(state, cAlphaFields(12) + " must be Coil:Cooling:DX:MultiSpeed "); - ShowFatalError(state, RoutineName + "Errors found in getting " + CurrentModuleObject + + ShowFatalError(state, + RoutineName + "Errors found in getting " + state.dataHVACMultiSpdHP->CurrentModuleObject + " input. Preceding condition(s) causes termination."); ErrorsFound = true; } @@ -1028,37 +1027,41 @@ namespace HVACMultiSpeedHeatPump { ObjexxFCL::Optional_bool_const()); if (LocalError) { ShowSevereError(state, "The index of " + cAlphaFields(13) + " is not found \"" + Alphas(13) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } CoolingCoilInletNode = GetDXCoilInletNode(state, Alphas(12), Alphas(13), LocalError); if (LocalError) { ShowSevereError(state, "The inlet node number of " + cAlphaFields(13) + " is not found \"" + Alphas(13) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } CoolingCoilOutletNode = GetDXCoilOutletNode(state, Alphas(12), Alphas(13), LocalError); if (LocalError) { ShowSevereError(state, "The outlet node number of " + cAlphaFields(13) + " is not found \"" + Alphas(13) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } MSHeatPump(MSHPNum).MinOATCompressorCooling = DXCoils::GetMinOATCompressorUsingIndex(state, MSHeatPump(MSHPNum).DXCoolCoilIndex, LocalError); if (LocalError) { - ShowContinueError(state, "...for cooling coil. Occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, + "...for cooling coil. Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); LocalError = false; } } else { - ShowSevereError(state, "The allowed " + cAlphaFields(12) + " is Coil:Cooling:DX:MultiSpeed in " + CurrentModuleObject + " \"" + Alphas(1) + + ShowSevereError(state, + "The allowed " + cAlphaFields(12) + " is Coil:Cooling:DX:MultiSpeed in " + + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, "The entered " + cAlphaFields(12) + " = \"" + Alphas(12) + "\"."); ErrorsFound = true; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Cooling:DX:MultiSpeed", MSHeatPump(MSHPNum).DXCoolCoilName, @@ -1068,11 +1071,11 @@ namespace HVACMultiSpeedHeatPump { // Get supplemental heating coil data MSHeatPump(MSHPNum).SuppHeatCoilName = Alphas(15); if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Fuel")) { - MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoil::Gas; + MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoilGas; errFlag = false; MSHeatPump(MSHPNum).SuppHeatCoilNum = GetHeatingCoilIndex(state, "Coil:Heating:Fuel", Alphas(15), errFlag); if (MSHeatPump(MSHPNum).SuppHeatCoilNum <= 0 || errFlag) { - ShowContinueError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(15) + " of type Coil:Heating:Fuel \"" + Alphas(15) + "\" not found."); ErrorsFound = true; } @@ -1082,14 +1085,14 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilInletNode = GetHeatingCoilInletNode(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The inlet node number of " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } SuppHeatCoilOutletNode = GetHeatingCoilOutletNode(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The outlet node number of " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } @@ -1098,11 +1101,12 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).DesignSuppHeatingCapacity = GetHeatingCoilCapacity(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The capacity " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Fuel", MSHeatPump(MSHPNum).SuppHeatCoilName, @@ -1110,11 +1114,11 @@ namespace HVACMultiSpeedHeatPump { "UNDEFINED"); } if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Electric")) { - MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoil::Electric; + MSHeatPump(MSHPNum).SuppHeatCoilType = SuppHeatingCoilElec; errFlag = false; MSHeatPump(MSHPNum).SuppHeatCoilNum = GetHeatingCoilIndex(state, "Coil:Heating:Electric", Alphas(15), errFlag); if (MSHeatPump(MSHPNum).SuppHeatCoilNum <= 0 || errFlag) { - ShowContinueError(state, "Configuration error in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "Configuration error in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ShowContinueError(state, cAlphaFields(15) + " of type Coil:Heating:Electric \"" + Alphas(15) + "\" not found."); ErrorsFound = true; } @@ -1124,14 +1128,14 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilInletNode = GetHeatingCoilInletNode(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The inlet node number of " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } SuppHeatCoilOutletNode = GetHeatingCoilOutletNode(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The outlet node number of " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } @@ -1140,12 +1144,13 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).DesignSuppHeatingCapacity = GetHeatingCoilCapacity(state, Alphas(14), Alphas(15), LocalError); if (LocalError) { ShowSevereError(state, "The capacity " + cAlphaFields(15) + " is not found \"" + Alphas(15) + "\""); - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " \"" + Alphas(1) + "\""); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + Alphas(1) + "\""); ErrorsFound = true; LocalError = false; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Electric", MSHeatPump(MSHPNum).SuppHeatCoilName, @@ -1155,9 +1160,9 @@ namespace HVACMultiSpeedHeatPump { if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Water")) { MSHeatPump(MSHPNum).SuppHeatCoilType = Coil_HeatingWater; - ValidateComponent(state, Alphas(14), MSHeatPump(MSHPNum).SuppHeatCoilName, IsNotOK, CurrentModuleObject); + ValidateComponent(state, Alphas(14), MSHeatPump(MSHPNum).SuppHeatCoilName, IsNotOK, state.dataHVACMultiSpdHP->CurrentModuleObject); if (IsNotOK) { - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " = " + Alphas(1)); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + Alphas(1)); ErrorsFound = true; } else { // mine data from heating coil object @@ -1166,7 +1171,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).SuppCoilControlNode = GetCoilWaterInletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1175,7 +1180,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).MaxSuppCoilFluidFlow = GetCoilMaxWaterFlowRate(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1184,7 +1189,7 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilInletNode = GetWaterCoilInletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); MSHeatPump(MSHPNum).SuppCoilAirInletNode = SuppHeatCoilInletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1193,10 +1198,11 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilOutletNode = GetWaterCoilOutletNode(state, "Coil:Heating:Water", MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); MSHeatPump(MSHPNum).SuppCoilAirOutletNode = SuppHeatCoilOutletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Water", MSHeatPump(MSHPNum).SuppHeatCoilName, @@ -1206,17 +1212,19 @@ namespace HVACMultiSpeedHeatPump { } if (UtilityRoutines::SameString(Alphas(14), "Coil:Heating:Steam")) { MSHeatPump(MSHPNum).SuppHeatCoilType = Coil_HeatingSteam; - ValidateComponent(state, Alphas(14), MSHeatPump(MSHPNum).SuppHeatCoilName, IsNotOK, CurrentModuleObject); + ValidateComponent(state, Alphas(14), MSHeatPump(MSHPNum).SuppHeatCoilName, IsNotOK, state.dataHVACMultiSpdHP->CurrentModuleObject); if (IsNotOK) { - ShowContinueError(state, "...occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "...occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } else { // mine data from heating coil object errFlag = false; MSHeatPump(MSHPNum).SuppHeatCoilNum = GetSteamCoilIndex(state, Alphas(14), MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); if (MSHeatPump(MSHPNum).SuppHeatCoilNum == 0) { - ShowSevereError(state, CurrentModuleObject + " illegal " + cAlphaFields(14) + " = " + MSHeatPump(MSHPNum).SuppHeatCoilName); - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + " illegal " + cAlphaFields(14) + " = " + + MSHeatPump(MSHPNum).SuppHeatCoilName); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1225,7 +1233,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).SuppCoilControlNode = GetCoilAirOutletNode(state, "Coil:Heating:Steam", MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1233,7 +1241,8 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).MaxSuppCoilFluidFlow = GetCoilMaxSteamFlowRate(state, MSHeatPump(MSHPNum).SuppHeatCoilNum, errFlag); if (MSHeatPump(MSHPNum).MaxSuppCoilFluidFlow > 0.0) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineNameNoColon); + SteamDensity = + GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineNameNoColon); MSHeatPump(MSHPNum).MaxSuppCoilFluidFlow *= SteamDensity; } @@ -1243,7 +1252,7 @@ namespace HVACMultiSpeedHeatPump { GetSteamCoilAirInletNode(state, MSHeatPump(MSHPNum).SuppHeatCoilNum, MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); MSHeatPump(MSHPNum).SuppCoilAirInletNode = SuppHeatCoilInletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } @@ -1252,11 +1261,12 @@ namespace HVACMultiSpeedHeatPump { SuppHeatCoilOutletNode = GetCoilAirOutletNode(state, MSHeatPump(MSHPNum).SuppHeatCoilNum, MSHeatPump(MSHPNum).SuppHeatCoilName, errFlag); MSHeatPump(MSHPNum).SuppCoilAirOutletNode = SuppHeatCoilOutletNode; if (errFlag) { - ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); + ShowContinueError(state, "Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHPNum).Name); ErrorsFound = true; } - SetUpCompSets(state, CurrentModuleObject, + SetUpCompSets(state, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHPNum).Name, "Coil:Heating:Steam", MSHeatPump(MSHPNum).SuppHeatCoilName, @@ -1266,7 +1276,8 @@ namespace HVACMultiSpeedHeatPump { } if (MSHeatPump(MSHPNum).SuppHeatCoilType == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(14) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cAlphaFields(14) + " is not allowed = " + Alphas(14)); ShowContinueError(state, "Valid choices are Coil:Heating:Fuel,Coil:Heating:Electric,Coil:Heating:Steam,or Coil:Heating:Water"); ErrorsFound = true; @@ -1275,7 +1286,9 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).SuppMaxAirTemp = Numbers(2); MSHeatPump(MSHPNum).SuppMaxOATemp = Numbers(3); if (MSHeatPump(MSHPNum).SuppMaxOATemp > 21.0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(3) + " is greater than 21.0"); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(3) + + " is greater than 21.0"); ShowContinueError(state, format("The input value is {:.2R}", Numbers(3))); ErrorsFound = true; } @@ -1283,12 +1296,16 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).AuxOnCyclePower = Numbers(4); MSHeatPump(MSHPNum).AuxOffCyclePower = Numbers(5); if (MSHeatPump(MSHPNum).AuxOnCyclePower < 0.0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", A negative value for " + cNumericFields(4) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", A negative value for " + + cNumericFields(4) + " is not allowed "); ErrorsFound = true; } if (MSHeatPump(MSHPNum).AuxOffCyclePower < 0.0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", A negative value for " + cNumericFields(5) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", A negative value for " + + cNumericFields(5) + " is not allowed "); ErrorsFound = true; } @@ -1299,18 +1316,36 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatRecActive = true; MSHeatPump(MSHPNum).DesignHeatRecMassFlowRate = RhoH2O(DataGlobalConstants::HWInitConvTemp) * MSHeatPump(MSHPNum).DesignHeatRecFlowRate; MSHeatPump(MSHPNum).HeatRecInletNodeNum = GetOnlySingleNode(state, - Alphas(16), ErrorsFound, CurrentModuleObject, Alphas(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::NodeConnectionType::Inlet, 3, ObjectIsNotParent); + Alphas(16), + ErrorsFound, + state.dataHVACMultiSpdHP->CurrentModuleObject, + Alphas(1), + DataLoopNode::NodeFluidType::Water, + DataLoopNode::NodeConnectionType::Inlet, + 3, + ObjectIsNotParent); if (MSHeatPump(MSHPNum).HeatRecInletNodeNum == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", Missing " + cAlphaFields(16) + '.'); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", Missing " + + cAlphaFields(16) + '.'); ErrorsFound = true; } MSHeatPump(MSHPNum).HeatRecOutletNodeNum = GetOnlySingleNode(state, - Alphas(17), ErrorsFound, CurrentModuleObject, Alphas(1), DataLoopNode::NodeFluidType::Water, DataLoopNode::NodeConnectionType::Outlet, 3, ObjectIsNotParent); + Alphas(17), + ErrorsFound, + state.dataHVACMultiSpdHP->CurrentModuleObject, + Alphas(1), + DataLoopNode::NodeFluidType::Water, + DataLoopNode::NodeConnectionType::Outlet, + 3, + ObjectIsNotParent); if (MSHeatPump(MSHPNum).HeatRecOutletNodeNum == 0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", Missing " + cAlphaFields(17) + '.'); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", Missing " + + cAlphaFields(17) + '.'); ErrorsFound = true; } - TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(16), Alphas(17), "MSHP Heat receovery Nodes"); + TestCompSet(state, state.dataHVACMultiSpdHP->CurrentModuleObject, Alphas(1), Alphas(16), Alphas(17), "MSHP Heat receovery Nodes"); SetMSHPDXCoilHeatRecoveryFlag(state, MSHeatPump(MSHPNum).DXCoolCoilIndex); if (MSHeatPump(MSHPNum).DXHeatCoilIndex > 0) { SetMSHPDXCoilHeatRecoveryFlag(state, MSHeatPump(MSHPNum).DXHeatCoilIndex); @@ -1321,25 +1356,33 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatRecInletNodeNum = 0; MSHeatPump(MSHPNum).HeatRecOutletNodeNum = 0; if (!lAlphaBlanks(16) || !lAlphaBlanks(17)) { - ShowWarningError(state, "Since " + cNumericFields(6) + " = 0.0, heat recovery is inactive for " + CurrentModuleObject + " = " + + ShowWarningError(state, + "Since " + cNumericFields(6) + " = 0.0, heat recovery is inactive for " + + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + Alphas(1)); ShowContinueError(state, "However, " + cAlphaFields(16) + " or " + cAlphaFields(17) + " was specified."); } } MSHeatPump(MSHPNum).MaxHeatRecOutletTemp = Numbers(7); if (MSHeatPump(MSHPNum).MaxHeatRecOutletTemp < 0.0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", The value for " + cNumericFields(7) + " is below 0.0"); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", The value for " + + cNumericFields(7) + " is below 0.0"); ErrorsFound = true; } if (MSHeatPump(MSHPNum).MaxHeatRecOutletTemp > 100.0) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", The value for " + cNumericFields(7) + + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", The value for " + + cNumericFields(7) + " is above 100.0"); ErrorsFound = true; } MSHeatPump(MSHPNum).IdleVolumeAirRate = Numbers(8); if (MSHeatPump(MSHPNum).IdleVolumeAirRate < 0.0 && MSHeatPump(MSHPNum).IdleVolumeAirRate != AutoSize) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(8) + " cannot be less than zero."); + ShowSevereError(state, + state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(8) + + " cannot be less than zero."); ErrorsFound = true; } @@ -1356,14 +1399,14 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).NumOfSpeedHeating = Numbers(9); if (MSHeatPump(MSHPNum).NumOfSpeedHeating < 2 || MSHeatPump(MSHPNum).NumOfSpeedHeating > 4) { if (MSHeatPump(MSHPNum).HeatCoilType == MultiSpeedHeatingCoil) { - ShowSevereError(state, CurrentModuleObject + ", The maximum " + cNumericFields(9) + " is 4, and the minimum number is 2"); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", The maximum " + cNumericFields(9) + " is 4, and the minimum number is 2"); ShowContinueError(state, format("The input value is {:.0R}", Numbers(9))); ErrorsFound = true; } } MSHeatPump(MSHPNum).NumOfSpeedCooling = Numbers(10); if (MSHeatPump(MSHPNum).NumOfSpeedCooling < 2 || MSHeatPump(MSHPNum).NumOfSpeedCooling > 4) { - ShowSevereError(state, CurrentModuleObject + ", The maximum " + cNumericFields(10) + " is 4, and the minimum number is 2"); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", The maximum " + cNumericFields(10) + " is 4, and the minimum number is 2"); ShowContinueError(state, format("The input value is {:.0R}", Numbers(10))); ErrorsFound = true; } @@ -1378,7 +1421,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatVolumeFlowRate(i) = Numbers(10 + i); if (MSHeatPump(MSHPNum).HeatCoilType == MultiSpeedHeatingCoil) { if (MSHeatPump(MSHPNum).HeatVolumeFlowRate(i) <= 0.0 && MSHeatPump(MSHPNum).HeatVolumeFlowRate(i) != AutoSize) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(10 + i) + + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(10 + i) + " must be greater than zero."); ErrorsFound = true; } @@ -1396,7 +1439,7 @@ namespace HVACMultiSpeedHeatPump { } if (Found) { if (MSHeatPump(MSHPNum).HeatVolumeFlowRate(i) < MSHeatPump(MSHPNum).HeatVolumeFlowRate(j)) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(10 + i)); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(10 + i)); ShowContinueError(state, " cannot be less than " + cNumericFields(10 + j)); ErrorsFound = true; } @@ -1418,7 +1461,7 @@ namespace HVACMultiSpeedHeatPump { for (i = 1; i <= MSHeatPump(MSHPNum).NumOfSpeedCooling; ++i) { MSHeatPump(MSHPNum).CoolVolumeFlowRate(i) = Numbers(14 + i); if (MSHeatPump(MSHPNum).CoolVolumeFlowRate(i) <= 0.0 && MSHeatPump(MSHPNum).CoolVolumeFlowRate(i) != AutoSize) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(14 + i) + + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(14 + i) + " must be greater than zero."); ErrorsFound = true; } @@ -1435,7 +1478,7 @@ namespace HVACMultiSpeedHeatPump { } if (Found) { if (MSHeatPump(MSHPNum).CoolVolumeFlowRate(i) < MSHeatPump(MSHPNum).CoolVolumeFlowRate(j)) { - ShowSevereError(state, CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(14 + i)); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + ", \"" + MSHeatPump(MSHPNum).Name + "\", " + cNumericFields(14 + i)); ShowContinueError(state, " cannot be less than " + cNumericFields(14 + j)); ErrorsFound = true; } @@ -1446,14 +1489,14 @@ namespace HVACMultiSpeedHeatPump { // Check node integrity if (MSHeatPump(MSHPNum).FanPlaceType == BlowThru) { if (MSHeatPump(MSHPNum).FanInletNode != MSHeatPump(MSHPNum).AirInletNodeNum) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a blow through fan is specified, the fan inlet node name must be the same as the " + cAlphaFields(3)); ShowContinueError(state, "...Fan inlet node name = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).FanInletNode)); ShowContinueError(state, "..." + cAlphaFields(3) + " = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).AirInletNodeNum)); ErrorsFound = true; } if (MSHeatPump(MSHPNum).FanOutletNode != CoolingCoilInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a blow through fan is specified, the fan outlet node name must be the same as the cooling coil inlet node name."); ShowContinueError(state, "...Fan outlet node name = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).FanOutletNode)); @@ -1461,14 +1504,14 @@ namespace HVACMultiSpeedHeatPump { ErrorsFound = true; } if (CoolingCoilOutletNode != HeatingCoilInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The cooling coil outlet node name must be the same as the heating coil inlet node name."); ShowContinueError(state, "...Cooling coil outlet node name = " + state.dataLoopNodes->NodeID(CoolingCoilOutletNode)); ShowContinueError(state, "...Heating coil inlet node name = " + state.dataLoopNodes->NodeID(HeatingCoilInletNode)); ErrorsFound = true; } if (HeatingCoilOutletNode != SuppHeatCoilInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a blow through fan is specified, the heating coil outlet node name must be the same as the reheat coil " "inlet node name."); ShowContinueError(state, "...Heating coil outlet node name = " + state.dataLoopNodes->NodeID(HeatingCoilOutletNode)); @@ -1476,7 +1519,7 @@ namespace HVACMultiSpeedHeatPump { ErrorsFound = true; } if (SuppHeatCoilOutletNode != MSHeatPump(MSHPNum).AirOutletNodeNum) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The supplemental heating coil outlet node name must be the same as the " + cAlphaFields(4)); ShowContinueError(state, "...Supplemental heating coil outlet node name = " + state.dataLoopNodes->NodeID(SuppHeatCoilOutletNode)); ShowContinueError(state, "..." + cAlphaFields(4) + " = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).AirOutletNodeNum)); @@ -1484,7 +1527,7 @@ namespace HVACMultiSpeedHeatPump { } } else { if (CoolingCoilInletNode != MSHeatPump(MSHPNum).AirInletNodeNum) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a draw through fan is specified, the cooling coil inlet node name must be the same as the " + cAlphaFields(3)); ShowContinueError(state, "...Cooling coil inlet node name = " + state.dataLoopNodes->NodeID(CoolingCoilInletNode)); @@ -1492,14 +1535,14 @@ namespace HVACMultiSpeedHeatPump { ErrorsFound = true; } if (CoolingCoilOutletNode != HeatingCoilInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The cooling coil outlet node name must be the same as the heating coil inlet node name."); ShowContinueError(state, "...Cooling coil outlet node name = " + state.dataLoopNodes->NodeID(CoolingCoilOutletNode)); ShowContinueError(state, "...Heating coil inlet node name = " + state.dataLoopNodes->NodeID(HeatingCoilInletNode)); ErrorsFound = true; } if (HeatingCoilOutletNode != MSHeatPump(MSHPNum).FanInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a draw through fan is specified, the heating coil outlet node name must be the same as the fan inlet node name."); ShowContinueError(state, "...Heating coil outlet node name = " + state.dataLoopNodes->NodeID(HeatingCoilOutletNode)); @@ -1507,7 +1550,7 @@ namespace HVACMultiSpeedHeatPump { ErrorsFound = true; } if (MSHeatPump(MSHPNum).FanOutletNode != SuppHeatCoilInletNode) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "When a draw through fan is specified, the fan outlet node name must be the same as the reheat coil inlet node name."); ShowContinueError(state, "...Fan outlet node name = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).FanOutletNode)); @@ -1515,7 +1558,7 @@ namespace HVACMultiSpeedHeatPump { ErrorsFound = true; } if (SuppHeatCoilOutletNode != MSHeatPump(MSHPNum).AirOutletNodeNum) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The reheat coil outlet node name must be the same as the " + cAlphaFields(4)); ShowContinueError(state, "...Reheat coil outlet node name = " + state.dataLoopNodes->NodeID(SuppHeatCoilOutletNode)); ShowContinueError(state, "..." + cAlphaFields(4) + " = " + state.dataLoopNodes->NodeID(MSHeatPump(MSHPNum).AirOutletNodeNum)); @@ -1527,7 +1570,7 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHPNum).HeatCoilType == MultiSpeedHeatingCoil) { i = GetDXCoilNumberOfSpeeds(state, Alphas(10), Alphas(11), ErrorsFound); if (MSHeatPump(MSHPNum).NumOfSpeedHeating != i) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The " + cNumericFields(9) + " is not equal to the number defined in " + cAlphaFields(11) + " = " + Alphas(11)); ErrorsFound = true; } @@ -1535,25 +1578,25 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).HeatCoilType == Coil_HeatingGas_MultiStage) { i = GetHeatingCoilNumberOfStages(state, Alphas(10), Alphas(11), ErrorsFound); if (MSHeatPump(MSHPNum).NumOfSpeedHeating != i) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The " + cNumericFields(9) + " is not equal to the number defined in " + cAlphaFields(11) + " = " + Alphas(11)); ErrorsFound = true; } } i = GetDXCoilNumberOfSpeeds(state, Alphas(12), Alphas(13), ErrorsFound); if (MSHeatPump(MSHPNum).NumOfSpeedCooling != i) { - ShowSevereError(state, "For " + CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); + ShowSevereError(state, "For " + state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHPNum).Name + "\""); ShowContinueError(state, "The " + cNumericFields(10) + " is not equal to the number defined in " + cAlphaFields(13) + " = " + Alphas(13)); ErrorsFound = true; } } if (ErrorsFound) { - ShowFatalError(state, RoutineName + "Errors found in getting " + CurrentModuleObject + " input. Preceding condition(s) causes termination."); + ShowFatalError(state, RoutineName + "Errors found in getting " + state.dataHVACMultiSpdHP->CurrentModuleObject + " input. Preceding condition(s) causes termination."); } // End of multispeed heat pump - for (MSHPNum = 1; MSHPNum <= NumMSHeatPumps; ++MSHPNum) { + for (MSHPNum = 1; MSHPNum <= state.dataHVACMultiSpdHP->NumMSHeatPumps; ++MSHPNum) { // Setup Report Variables for MSHP Equipment SetupOutputVariable(state, "Unitary System Ancillary Electricity Rate", OutputProcessor::Unit::W, @@ -1786,8 +1829,8 @@ namespace HVACMultiSpeedHeatPump { NumOfSpeedCooling = MSHeatPump(MSHeatPumpNum).NumOfSpeedCooling; NumOfSpeedHeating = MSHeatPump(MSHeatPumpNum).NumOfSpeedHeating; - ++AirLoopPass; - if (AirLoopPass > 2) AirLoopPass = 1; + ++state.dataHVACMultiSpdHP->AirLoopPass; + if (state.dataHVACMultiSpdHP->AirLoopPass > 2) state.dataHVACMultiSpdHP->AirLoopPass = 1; if (MSHeatPump(MSHeatPumpNum).MyPlantScantFlag && allocated(state.dataPlnt->PlantLoop)) { if (MSHeatPump(MSHeatPumpNum).HeatRecActive) { @@ -1873,7 +1916,7 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow > 0.0) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed // TODO: Why do you want to re-look this up? - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineName); MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow *= SteamDensity; } @@ -1943,7 +1986,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow = GetCoilMaxSteamFlowRate(state, MSHeatPump(MSHeatPumpNum).SuppHeatCoilNum, ErrorsFound); if (MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow > 0.0) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineName); MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow *= SteamDensity; } @@ -1996,25 +2039,25 @@ namespace HVACMultiSpeedHeatPump { // Find the number of zones (zone Inlet Nodes) attached to an air loop from the air loop number NumAirLoopZones = state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesCooled + state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesHeated; if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && MSHeatPump(MSHeatPumpNum).MyFlowFracFlag) { - FlowFracFlagReady = true; + state.dataHVACMultiSpdHP->FlowFracFlagReady = true; for (ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) { // zone inlet nodes for cooling if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesCooled > 0) { if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitCoolInletNodes(ZoneInSysIndex) == -999) { // the data structure for the zones inlet nodes has not been filled - FlowFracFlagReady = false; + state.dataHVACMultiSpdHP->FlowFracFlagReady = false; } } // zone inlet nodes for heating if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumZonesHeated > 0) { if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitHeatInletNodes(ZoneInSysIndex) == -999) { // the data structure for the zones inlet nodes has not been filled - FlowFracFlagReady = false; + state.dataHVACMultiSpdHP->FlowFracFlagReady = false; } } } } - if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && FlowFracFlagReady) { + if (allocated(state.dataAirLoop->AirToZoneNodeInfo) && state.dataHVACMultiSpdHP->FlowFracFlagReady) { SumOfMassFlowRateMax = 0.0; // initialize the sum of the maximum flows for (ZoneInSysIndex = 1; ZoneInSysIndex <= NumAirLoopZones; ++ZoneInSysIndex) { ZoneInletNodeNum = state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).TermUnitCoolInletNodes(ZoneInSysIndex); @@ -2027,10 +2070,10 @@ namespace HVACMultiSpeedHeatPump { if (CntrlZoneTerminalUnitMassFlowRateMax >= SmallAirVolFlow) { MSHeatPump(MSHeatPumpNum).FlowFraction = CntrlZoneTerminalUnitMassFlowRateMax / SumOfMassFlowRateMax; } else { - ShowSevereError(state, CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); + ShowSevereError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); ShowContinueError(state, " The Fraction of Supply Air Flow That Goes Through the Controlling Zone is set to 1."); } - BaseSizer::reportSizerOutput(state, CurrentModuleObject, + BaseSizer::reportSizerOutput(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, "Fraction of Supply Air Flow That Goes Through the Controlling Zone", MSHeatPump(MSHeatPumpNum).FlowFraction); @@ -2116,7 +2159,8 @@ namespace HVACMultiSpeedHeatPump { if (CoilMaxVolFlowRate != AutoSize) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + SteamDensity = + GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineName); MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity; } InitComponentNodes(state, @@ -2168,7 +2212,8 @@ namespace HVACMultiSpeedHeatPump { if (CoilMaxVolFlowRate != AutoSize) { SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - SteamDensity = GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + SteamDensity = + GetSatDensityRefrig(state, fluidNameSteam, state.dataHVACMultiSpdHP->TempSteamIn, 1.0, SteamIndex, RoutineName); MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow = CoilMaxVolFlowRate * SteamDensity; } InitComponentNodes(state, @@ -2192,7 +2237,7 @@ namespace HVACMultiSpeedHeatPump { // IF MSHP system was not autosized and the fan is autosized, check that fan volumetric flow rate is greater than MSHP flow rates if (!state.dataGlobal->DoingSizing && MSHeatPump(MSHeatPumpNum).CheckFanFlow) { - CurrentModuleObject = "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed"; + state.dataHVACMultiSpdHP->CurrentModuleObject = "AirLoopHVAC:UnitaryHeatPump:AirToAir:MultiSpeed"; GetFanVolFlow(state, MSHeatPump(MSHeatPumpNum).FanNum, MSHeatPump(MSHeatPumpNum).FanVolFlow); if (MSHeatPump(MSHeatPumpNum).FanVolFlow != AutoSize) { // Check fan versus system supply air flow rates @@ -2200,13 +2245,13 @@ namespace HVACMultiSpeedHeatPump { ShowWarningError(state, format("{} - air flow rate = {:.7T} in fan object {} is less than the MSHP system air flow rate when cooling is " "required ({:.7T}).", - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).FanVolFlow, MSHeatPump(MSHeatPumpNum).FanName, MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(NumOfSpeedCooling))); ShowContinueError(state, " The MSHP system flow rate when cooling is required is reset to the fan flow rate and the simulation continues."); - ShowContinueError(state, " Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); + ShowContinueError(state, " Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(NumOfSpeedCooling) = MSHeatPump(MSHeatPumpNum).FanVolFlow; // Check flow rates in other speeds and ensure flow rates are not above the max flow rate for (i = NumOfSpeedCooling - 1; i >= 1; --i) { @@ -2215,7 +2260,7 @@ namespace HVACMultiSpeedHeatPump { format(" The MSHP system flow rate when cooling is required is reset to the flow rate at higher speed " "and the simulation continues at Speed{}.", i)); - ShowContinueError(state, " Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); + ShowContinueError(state, " Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i + 1); } } @@ -2224,13 +2269,13 @@ namespace HVACMultiSpeedHeatPump { ShowWarningError(state, format("{} - air flow rate = {:.7T} in fan object {} is less than the MSHP system air flow rate when heating is " "required ({:.7T}).", - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).FanVolFlow, MSHeatPump(MSHeatPumpNum).FanName, MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(NumOfSpeedHeating))); ShowContinueError(state, " The MSHP system flow rate when heating is required is reset to the fan flow rate and the simulation continues."); - ShowContinueError(state, " Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); + ShowContinueError(state, " Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(NumOfSpeedHeating) = MSHeatPump(MSHeatPumpNum).FanVolFlow; for (i = NumOfSpeedHeating - 1; i >= 1; --i) { if (MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) > MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i + 1)) { @@ -2238,7 +2283,7 @@ namespace HVACMultiSpeedHeatPump { format(" The MSHP system flow rate when heating is required is reset to the flow rate at higher speed " "and the simulation continues at Speed{}.", i)); - ShowContinueError(state, " Occurs in " + CurrentModuleObject + " system = " + MSHeatPump(MSHeatPumpNum).Name); + ShowContinueError(state, " Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " system = " + MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i + 1); } } @@ -2248,13 +2293,13 @@ namespace HVACMultiSpeedHeatPump { ShowWarningError(state, format("{} - air flow rate = {:.7T} in fan object {} is less than the MSHP system air flow rate when no heating " "or cooling is needed ({:.7T}).", - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).FanVolFlow, MSHeatPump(MSHeatPumpNum).FanName, MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate)); ShowContinueError(state, " The MSHP system flow rate when no heating or cooling is needed is reset to the fan flow rate and the " "simulation continues."); - ShowContinueError(state, " Occurs in " + CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); + ShowContinueError(state, " Occurs in " + state.dataHVACMultiSpdHP->CurrentModuleObject + " = " + MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate = MSHeatPump(MSHeatPumpNum).FanVolFlow; } RhoAir = state.dataEnvrn->StdRhoAir; @@ -2298,7 +2343,7 @@ namespace HVACMultiSpeedHeatPump { } // Calcuate air distribution losses - if (!FirstHVACIteration && AirLoopPass == 1) { + if (!FirstHVACIteration && state.dataHVACMultiSpdHP->AirLoopPass == 1) { ZoneInNode = MSHeatPump(MSHeatPumpNum).ZoneInletNode; DeltaMassRate = state.dataLoopNodes->Node(OutNode).MassFlowRate - state.dataLoopNodes->Node(ZoneInNode).MassFlowRate / MSHeatPump(MSHeatPumpNum).FlowFraction; if (DeltaMassRate < 0.0) DeltaMassRate = 0.0; @@ -2379,40 +2424,40 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).OpMode == ContFanCycCoil) { // constant fan mode if (QZnReq > SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(1); MSHeatPump(MSHeatPumpNum).LastMode = ModeOfOperation::HeatingMode; } else if (QZnReq < (-1.0 * SmallLoad) && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(1); MSHeatPump(MSHeatPumpNum).LastMode = ModeOfOperation::CoolingMode; } else { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).IdleMassFlowRate; - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).IdleSpeedRatio; + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).IdleMassFlowRate; + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).IdleSpeedRatio; } - CompOffMassFlow = MSHeatPump(MSHeatPumpNum).IdleMassFlowRate; - CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).IdleSpeedRatio; + state.dataHVACMultiSpdHP->CompOffMassFlow = MSHeatPump(MSHeatPumpNum).IdleMassFlowRate; + state.dataHVACMultiSpdHP->CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).IdleSpeedRatio; } else { // cycling fan mode if (QZnReq > SmallLoad && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(1); } else if (QZnReq < (-1.0 * SmallLoad) && !state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum)) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(1); } else { - CompOnMassFlow = 0.0; - CompOnFlowRatio = 0.0; + state.dataHVACMultiSpdHP->CompOnMassFlow = 0.0; + state.dataHVACMultiSpdHP->CompOnFlowRatio = 0.0; } - CompOffMassFlow = 0.0; - CompOffFlowRatio = 0.0; + state.dataHVACMultiSpdHP->CompOffMassFlow = 0.0; + state.dataHVACMultiSpdHP->CompOffFlowRatio = 0.0; } // Set the inlet node mass flow rate - if (GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) > 0.0 && CompOnMassFlow != 0.0) { + if (GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) > 0.0 && state.dataHVACMultiSpdHP->CompOnMassFlow != 0.0) { OnOffAirFlowRatio = 1.0; if (FirstHVACIteration) { - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).AirInletNodeNum).MassFlowRate = CompOnMassFlow; + state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).AirInletNodeNum).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; PartLoadFrac = 0.0; } else { if (MSHeatPump(MSHeatPumpNum).HeatCoolMode != ModeOfOperation::Unassigned) { @@ -2490,7 +2535,17 @@ namespace HVACMultiSpeedHeatPump { MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = 0.0; MSHeatPumpReport(MSHeatPumpNum).SpeedNum = 0; - CalcMSHeatPump(state, MSHeatPumpNum, FirstHVACIteration, On, 1, 0.0, PartLoadFrac, QSensUnitOut, QZnReq, OnOffAirFlowRatio, SupHeaterLoad); + CalcMSHeatPump(state, + MSHeatPumpNum, + FirstHVACIteration, + On, + 1, + 0.0, + PartLoadFrac, + QSensUnitOut, + QZnReq, + OnOffAirFlowRatio, + state.dataHVACMultiSpdHP->SupHeaterLoad); auto &e = MSHeatPump(MSHeatPumpNum); { @@ -2508,7 +2563,8 @@ namespace HVACMultiSpeedHeatPump { return; } - if ((MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::Unassigned && MSHeatPump(MSHeatPumpNum).OpMode == CycFanCycCoil) || CompOnMassFlow == 0.0) { + if ((MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::Unassigned && MSHeatPump(MSHeatPumpNum).OpMode == CycFanCycCoil) || + state.dataHVACMultiSpdHP->CompOnMassFlow == 0.0) { QZnReq = 0.0; PartLoadFrac = 0.0; state.dataLoopNodes->Node(InNode).MassFlowRate = 0.0; @@ -2546,7 +2602,7 @@ namespace HVACMultiSpeedHeatPump { if (FirstHVACIteration) { if (MSHeatPump(MSHeatPumpNum).HeatCoilType == Coil_HeatingWater) { // set air-side and steam-side mass flow rates - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).CoilAirInletNode).MassFlowRate = CompOnMassFlow; + state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).CoilAirInletNode).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; mdot = MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow; SetComponentFlowRate(state, mdot, MSHeatPump(MSHeatPumpNum).CoilControlNode, @@ -2563,7 +2619,7 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).HeatCoilType == Coil_HeatingSteam) { // set air-side and steam-side mass flow rates - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).CoilAirInletNode).MassFlowRate = CompOnMassFlow; + state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).CoilAirInletNode).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; mdot = MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow; SetComponentFlowRate(state, mdot, MSHeatPump(MSHeatPumpNum).CoilControlNode, @@ -2584,7 +2640,7 @@ namespace HVACMultiSpeedHeatPump { } // from IF(MSHeatPump(MSHeatPumpNum)%HeatCoilType == Coil_HeatingSteam) THEN if (MSHeatPump(MSHeatPumpNum).SuppHeatCoilType == Coil_HeatingWater) { // set air-side and steam-side mass flow rates - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).SuppCoilAirInletNode).MassFlowRate = CompOnMassFlow; + state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).SuppCoilAirInletNode).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; mdot = MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow; SetComponentFlowRate(state, mdot, MSHeatPump(MSHeatPumpNum).SuppCoilControlNode, @@ -2603,7 +2659,7 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).SuppHeatCoilType == Coil_HeatingSteam) { // set air-side and steam-side mass flow rates - state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).SuppCoilAirInletNode).MassFlowRate = CompOnMassFlow; + state.dataLoopNodes->Node(MSHeatPump(MSHeatPumpNum).SuppCoilAirInletNode).MassFlowRate = state.dataHVACMultiSpdHP->CompOnMassFlow; mdot = MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow; SetComponentFlowRate(state, mdot, MSHeatPump(MSHeatPumpNum).SuppCoilControlNode, @@ -2674,12 +2730,12 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i) == AutoSize) { if (state.dataSize->CurSysNum > 0) { if (i == NumOfSpeedCooling) { - CheckSysSizing(state, CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); + CheckSysSizing(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i) = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow; if (MSHeatPump(MSHeatPumpNum).FanVolFlow < MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i) && MSHeatPump(MSHeatPumpNum).FanVolFlow != AutoSize) { MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum).FanVolFlow; - ShowWarningError(state, CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); + ShowWarningError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); ShowContinueError(state, "The supply air flow rate at high speed is less than the autosized value for the supply air flow rate " "in cooling mode. Consider autosizing the fan for this simulation."); ShowContinueError(state, @@ -2699,7 +2755,7 @@ namespace HVACMultiSpeedHeatPump { } } BaseSizer::reportSizerOutput(state, - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, format("Speed {} Supply Air Flow Rate During Cooling Operation [m3/s]", i), MSHeatPump(MSHeatPumpNum).CoolVolumeFlowRate(i)); @@ -2711,12 +2767,12 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) == AutoSize) { if (state.dataSize->CurSysNum > 0) { if (i == NumOfSpeedHeating) { - CheckSysSizing(state, CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); + CheckSysSizing(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow; if (MSHeatPump(MSHeatPumpNum).FanVolFlow < MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) && MSHeatPump(MSHeatPumpNum).FanVolFlow != AutoSize) { MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i) = MSHeatPump(MSHeatPumpNum).FanVolFlow; - ShowWarningError(state, CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); + ShowWarningError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); ShowContinueError(state, "The supply air flow rate at high speed is less than the autosized value for the maximum air flow rate " "in heating mode. Consider autosizing the fan for this simulation."); ShowContinueError(state, "The maximum air flow rate at high speed in heating mode is reset to the supply air flow rate and the " @@ -2736,7 +2792,7 @@ namespace HVACMultiSpeedHeatPump { } } BaseSizer::reportSizerOutput(state, - CurrentModuleObject, + state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, format("Speed{}Supply Air Flow Rate During Heating Operation [m3/s]", i), MSHeatPump(MSHeatPumpNum).HeatVolumeFlowRate(i)); @@ -2746,12 +2802,12 @@ namespace HVACMultiSpeedHeatPump { if (MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate == AutoSize) { if (state.dataSize->CurSysNum > 0) { - CheckSysSizing(state, CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); + CheckSysSizing(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name); MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).DesMainVolFlow; if (MSHeatPump(MSHeatPumpNum).FanVolFlow < MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate && MSHeatPump(MSHeatPumpNum).FanVolFlow != AutoSize) { MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate = MSHeatPump(MSHeatPumpNum).FanVolFlow; - ShowWarningError(state, CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); + ShowWarningError(state, state.dataHVACMultiSpdHP->CurrentModuleObject + " \"" + MSHeatPump(MSHeatPumpNum).Name + "\""); ShowContinueError(state, "The supply air flow rate is less than the autosized value for the maximum air flow rate when no heating or " "cooling is needed. Consider autosizing the fan for this simulation."); ShowContinueError(state, "The maximum air flow rate when no heating or cooling is needed is reset to the supply air flow rate and the " @@ -2761,7 +2817,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate = 0.0; } - BaseSizer::reportSizerOutput(state, CurrentModuleObject, + BaseSizer::reportSizerOutput(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, "Supply Air Flow Rate When No Cooling or Heating is Needed [m3/s]", MSHeatPump(MSHeatPumpNum).IdleVolumeAirRate); @@ -2776,7 +2832,7 @@ namespace HVACMultiSpeedHeatPump { CheckZoneSizing(state, "Coil:Heating:Electric", MSHeatPump(MSHeatPumpNum).Name); } MSHeatPump(MSHeatPumpNum).SuppMaxAirTemp = state.dataSize->FinalSysSizing(state.dataSize->CurSysNum).HeatSupTemp; - BaseSizer::reportSizerOutput(state, CurrentModuleObject, + BaseSizer::reportSizerOutput(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, "Maximum Supply Air Temperature from Supplemental Heater [C]", MSHeatPump(MSHeatPumpNum).SuppMaxAirTemp); @@ -2794,7 +2850,7 @@ namespace HVACMultiSpeedHeatPump { } else { MSHeatPump(MSHeatPumpNum).DesignSuppHeatingCapacity = 0.0; } - BaseSizer::reportSizerOutput(state, CurrentModuleObject, + BaseSizer::reportSizerOutput(state, state.dataHVACMultiSpdHP->CurrentModuleObject, MSHeatPump(MSHeatPumpNum).Name, "Supplemental Heating Coil Nominal Capacity [W]", MSHeatPump(MSHeatPumpNum).DesignSuppHeatingCapacity); @@ -3123,13 +3179,13 @@ namespace HVACMultiSpeedHeatPump { SolveRoot(state, ErrorToler, MaxIte, SolFla, PartLoadFrac, MSHPCyclingResidual, 0.0, 1.0, Par); if (SolFla == -1) { if (!state.dataGlobal->WarmupFlag) { - if (ErrCountCyc == 0) { - ++ErrCountCyc; // TODO: Why is the error count shared among all heat pump units? + if (state.dataHVACMultiSpdHP->ErrCountCyc == 0) { + ++state.dataHVACMultiSpdHP->ErrCountCyc; // TODO: Why is the error count shared among all heat pump units? ShowWarningError(state, "Iteration limit exceeded calculating DX unit cycling ratio, for unit=" + MSHeatPump(MSHeatPumpNum).Name); ShowContinueErrorTimeStamp(state, format("Cycling ratio returned={:.2R}", PartLoadFrac)); } else { - ++ErrCountCyc; + ++state.dataHVACMultiSpdHP->ErrCountCyc; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + "\": Iteration limit warning exceeding calculating DX unit cycling ratio continues...", @@ -3187,13 +3243,13 @@ namespace HVACMultiSpeedHeatPump { SolveRoot(state, ErrorToler, MaxIte, SolFla, SpeedRatio, MSHPVarSpeedResidual, 0.0, 1.0, Par); if (SolFla == -1) { if (!state.dataGlobal->WarmupFlag) { - if (ErrCountVar == 0) { - ++ErrCountVar; + if (state.dataHVACMultiSpdHP->ErrCountVar == 0) { + ++state.dataHVACMultiSpdHP->ErrCountVar; ShowWarningError(state, "Iteration limit exceeded calculating DX unit speed ratio, for unit=" + MSHeatPump(MSHeatPumpNum).Name); ShowContinueErrorTimeStamp(state, format("Speed ratio returned=[{:.2R}], Speed number ={}", SpeedRatio, SpeedNum)); } else { - ++ErrCountVar; + ++state.dataHVACMultiSpdHP->ErrCountVar; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + "\": Iteration limit warning exceeding calculating DX unit speed ratio continues...", @@ -3232,13 +3288,13 @@ namespace HVACMultiSpeedHeatPump { SolveRoot(state, ErrorToler, MaxIte, SolFla, PartLoadFrac, MSHPCyclingResidual, 0.0, 1.0, Par); if (SolFla == -1) { if (!state.dataGlobal->WarmupFlag) { - if (ErrCountCyc == 0) { - ++ErrCountCyc; + if (state.dataHVACMultiSpdHP->ErrCountCyc == 0) { + ++state.dataHVACMultiSpdHP->ErrCountCyc; ShowWarningError(state, "Iteration limit exceeded calculating DX unit cycling ratio, for unit=" + MSHeatPump(MSHeatPumpNum).Name); ShowContinueErrorTimeStamp(state, format("Cycling ratio returned={:.2R}", PartLoadFrac)); } else { - ++ErrCountCyc; + ++state.dataHVACMultiSpdHP->ErrCountCyc; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + "\": Iteration limit warning exceeding calculating DX unit cycling ratio continues...", @@ -3289,14 +3345,14 @@ namespace HVACMultiSpeedHeatPump { SolveRoot(state, ErrorToler, MaxIte, SolFla, SpeedRatio, MSHPVarSpeedResidual, 0.0, 1.0, Par); if (SolFla == -1) { if (!state.dataGlobal->WarmupFlag) { - if (ErrCountVar == 0) { - ++ErrCountVar; + if (state.dataHVACMultiSpdHP->ErrCountVar == 0) { + ++state.dataHVACMultiSpdHP->ErrCountVar; ShowWarningError(state, "Iteration limit exceeded calculating DX unit speed ratio, for unit=" + MSHeatPump(MSHeatPumpNum).Name); ShowContinueErrorTimeStamp( state, format("Speed ratio returned=[{:.2R}], Speed number ={}", SpeedRatio, SpeedNum)); } else { - ++ErrCountVar; + ++state.dataHVACMultiSpdHP->ErrCountVar; ShowRecurringWarningErrorAtEnd(state, MSHeatPump(MSHeatPumpNum).Name + "\": Iteration limit warning exceeding calculating DX unit speed ratio continues...", @@ -3452,7 +3508,7 @@ namespace HVACMultiSpeedHeatPump { FanOutletNode = MSHeatPump(MSHeatPumpNum).FanOutletNode; FanInletNode = MSHeatPump(MSHeatPumpNum).FanInletNode; - SaveCompressorPLR = 0.0; + state.dataHVACMultiSpdHP->SaveCompressorPLR = 0.0; SavePartloadRatio = 0.0; MinWaterFlow = 0.0; ErrorToler = 0.001; @@ -3462,7 +3518,11 @@ namespace HVACMultiSpeedHeatPump { AirMassFlow = state.dataLoopNodes->Node(InletNode).MassFlowRate; // if blow through, simulate fan then coils if (MSHeatPump(MSHeatPumpNum).FanPlaceType == BlowThru) { - SimulateFanComponents(state, MSHeatPump(MSHeatPumpNum).FanName, FirstHVACIteration, MSHeatPump(MSHeatPumpNum).FanNum, FanSpeedRatio); + SimulateFanComponents(state, + MSHeatPump(MSHeatPumpNum).FanName, + FirstHVACIteration, + MSHeatPump(MSHeatPumpNum).FanNum, + state.dataHVACMultiSpdHP->FanSpeedRatio); if (QZnReq < (-1.0 * SmallLoad)) { if (OutsideDryBulbTemp > MSHeatPump(MSHeatPumpNum).MinOATCompressorCooling) { SimDXCoilMultiSpeed(state, @@ -3485,7 +3545,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXCoolCoilName, @@ -3519,7 +3579,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXHeatCoilName, @@ -3561,7 +3621,11 @@ namespace HVACMultiSpeedHeatPump { CalcNonDXHeatingCoils(state, MSHeatPumpNum, FirstHVACIteration, QZnReq, MSHeatPump(MSHeatPumpNum).OpMode, QCoilActual, PartLoadFrac); } // Call twice to ensure the fan outlet conditions are updated - SimulateFanComponents(state, MSHeatPump(MSHeatPumpNum).FanName, FirstHVACIteration, MSHeatPump(MSHeatPumpNum).FanNum, FanSpeedRatio); + SimulateFanComponents(state, + MSHeatPump(MSHeatPumpNum).FanName, + FirstHVACIteration, + MSHeatPump(MSHeatPumpNum).FanNum, + state.dataHVACMultiSpdHP->FanSpeedRatio); if (QZnReq < (-1.0 * SmallLoad)) { if (OutsideDryBulbTemp > MSHeatPump(MSHeatPumpNum).MinOATCompressorCooling) { SimDXCoilMultiSpeed(state, @@ -3584,7 +3648,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXCoolCoilName, @@ -3618,7 +3682,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXHeatCoilName, @@ -3686,7 +3750,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXCoolCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXCoolCoilName, @@ -3720,7 +3784,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).OpMode, CompOp); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); + state.dataHVACMultiSpdHP->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(MSHeatPump(MSHeatPumpNum).DXHeatCoilIndex); } else { SimDXCoilMultiSpeed(state, MSHeatPump(MSHeatPumpNum).DXHeatCoilName, @@ -3761,7 +3825,11 @@ namespace HVACMultiSpeedHeatPump { } else { CalcNonDXHeatingCoils(state, MSHeatPumpNum, FirstHVACIteration, QZnReq, MSHeatPump(MSHeatPumpNum).OpMode, QCoilActual, PartLoadFrac); } - SimulateFanComponents(state, MSHeatPump(MSHeatPumpNum).FanName, FirstHVACIteration, MSHeatPump(MSHeatPumpNum).FanNum, FanSpeedRatio); + SimulateFanComponents(state, + MSHeatPump(MSHeatPumpNum).FanName, + FirstHVACIteration, + MSHeatPump(MSHeatPumpNum).FanNum, + state.dataHVACMultiSpdHP->FanSpeedRatio); // Simulate supplemental heating coil for draw through fan if (MSHeatPump(MSHeatPumpNum).SuppHeatCoilNum > 0) { CalcNonDXHeatingCoils(state, MSHeatPumpNum, FirstHVACIteration, SupHeaterLoad, MSHeatPump(MSHeatPumpNum).OpMode, QCoilActual); @@ -3967,8 +4035,10 @@ namespace HVACMultiSpeedHeatPump { if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlMultiADS || AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOnMassFlowrate = CompOnMassFlow; - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOffMassFlowrate = CompOffMassFlow; + state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOnMassFlowrate = + state.dataHVACMultiSpdHP->CompOnMassFlow; + state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOffMassFlowrate = + state.dataHVACMultiSpdHP->CompOffMassFlow; state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopFanOperationMode = MSHeatPump(MSHeatPumpNum).OpMode; state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopOnOffFanPartLoadRatio = MSHeatPump(MSHeatPumpNum).FanPartLoadRatio; state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopCompCycRatio = MSHeatPumpReport(MSHeatPumpNum).CycRatio; @@ -4016,22 +4086,22 @@ namespace HVACMultiSpeedHeatPump { MSHeatPumpReport(MSHeatPumpNum).AuxElecHeatConsumption = 0.0; MSHeatPumpReport(MSHeatPumpNum).AuxElecCoolConsumption = 0.0; - MSHeatPump(MSHeatPumpNum).AuxElecPower = - MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * SaveCompressorPLR + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - SaveCompressorPLR); + MSHeatPump(MSHeatPumpNum).AuxElecPower = MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * state.dataHVACMultiSpdHP->SaveCompressorPLR + + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - state.dataHVACMultiSpdHP->SaveCompressorPLR); if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::CoolingMode) { MSHeatPumpReport(MSHeatPumpNum).AuxElecCoolConsumption = - MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * SaveCompressorPLR * ReportingConstant; + MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * state.dataHVACMultiSpdHP->SaveCompressorPLR * ReportingConstant; } if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::HeatingMode) { MSHeatPumpReport(MSHeatPumpNum).AuxElecHeatConsumption = - MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * SaveCompressorPLR * ReportingConstant; + MSHeatPump(MSHeatPumpNum).AuxOnCyclePower * state.dataHVACMultiSpdHP->SaveCompressorPLR * ReportingConstant; } if (MSHeatPump(MSHeatPumpNum).LastMode == ModeOfOperation::HeatingMode) { MSHeatPumpReport(MSHeatPumpNum).AuxElecHeatConsumption += - MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - SaveCompressorPLR) * ReportingConstant; + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - state.dataHVACMultiSpdHP->SaveCompressorPLR) * ReportingConstant; } else { MSHeatPumpReport(MSHeatPumpNum).AuxElecCoolConsumption += - MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - SaveCompressorPLR) * ReportingConstant; + MSHeatPump(MSHeatPumpNum).AuxOffCyclePower * (1.0 - state.dataHVACMultiSpdHP->SaveCompressorPLR) * ReportingConstant; } if (MSHeatPump(MSHeatPumpNum).FirstPass) { @@ -4144,28 +4214,28 @@ namespace HVACMultiSpeedHeatPump { if (!state.dataZoneEnergyDemand->CurDeadBandOrSetback(MSHeatPump(MSHeatPumpNum).ControlZoneNum) && present(SpeedNum)) { if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::HeatingMode) { if (SpeedNum == 1) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); } else if (SpeedNum > 1) { - CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum) + + state.dataHVACMultiSpdHP->CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum) + (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); - CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum) + + state.dataHVACMultiSpdHP->CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum) + (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum - 1); MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); } } else if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::CoolingMode) { if (SpeedNum == 1) { - CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); - CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); + state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); } else if (SpeedNum > 1) { - CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum) + + state.dataHVACMultiSpdHP->CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum) + (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); - CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum) + + state.dataHVACMultiSpdHP->CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum) + (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum - 1); MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); @@ -4176,35 +4246,39 @@ namespace HVACMultiSpeedHeatPump { // Set up fan flow rate during compressor off time if (MSHeatPump(MSHeatPumpNum).OpMode == ContFanCycCoil && present(SpeedNum)) { - if (MSHeatPump(MSHeatPumpNum).AirFlowControl == AirflowControl::UseCompressorOnFlow && CompOnMassFlow > 0.0) { + if (MSHeatPump(MSHeatPumpNum).AirFlowControl == AirflowControl::UseCompressorOnFlow && state.dataHVACMultiSpdHP->CompOnMassFlow > 0.0) { if (MSHeatPump(MSHeatPumpNum).LastMode == ModeOfOperation::HeatingMode) { - CompOffMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); - CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); + state.dataHVACMultiSpdHP->CompOffMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); } else { - CompOffMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); - CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); + state.dataHVACMultiSpdHP->CompOffMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); } } } if (present(SpeedNum)) { if (SpeedNum > 1) { - AverageUnitMassFlow = CompOnMassFlow; - FanSpeedRatio = CompOnFlowRatio; + AverageUnitMassFlow = state.dataHVACMultiSpdHP->CompOnMassFlow; + state.dataHVACMultiSpdHP->FanSpeedRatio = state.dataHVACMultiSpdHP->CompOnFlowRatio; } else { - AverageUnitMassFlow = (PartLoadRatio * CompOnMassFlow) + ((1 - PartLoadRatio) * CompOffMassFlow); - if (CompOffFlowRatio > 0.0) { - FanSpeedRatio = (PartLoadRatio * CompOnFlowRatio) + ((1 - PartLoadRatio) * CompOffFlowRatio); + AverageUnitMassFlow = + (PartLoadRatio * state.dataHVACMultiSpdHP->CompOnMassFlow) + ((1 - PartLoadRatio) * state.dataHVACMultiSpdHP->CompOffMassFlow); + if (state.dataHVACMultiSpdHP->CompOffFlowRatio > 0.0) { + state.dataHVACMultiSpdHP->FanSpeedRatio = (PartLoadRatio * state.dataHVACMultiSpdHP->CompOnFlowRatio) + + ((1 - PartLoadRatio) * state.dataHVACMultiSpdHP->CompOffFlowRatio); } else { - FanSpeedRatio = CompOnFlowRatio; + state.dataHVACMultiSpdHP->FanSpeedRatio = state.dataHVACMultiSpdHP->CompOnFlowRatio; } } } else { - AverageUnitMassFlow = (PartLoadRatio * CompOnMassFlow) + ((1 - PartLoadRatio) * CompOffMassFlow); - if (CompOffFlowRatio > 0.0) { - FanSpeedRatio = (PartLoadRatio * CompOnFlowRatio) + ((1 - PartLoadRatio) * CompOffFlowRatio); + AverageUnitMassFlow = + (PartLoadRatio * state.dataHVACMultiSpdHP->CompOnMassFlow) + ((1 - PartLoadRatio) * state.dataHVACMultiSpdHP->CompOffMassFlow); + if (state.dataHVACMultiSpdHP->CompOffFlowRatio > 0.0) { + state.dataHVACMultiSpdHP->FanSpeedRatio = + (PartLoadRatio * state.dataHVACMultiSpdHP->CompOnFlowRatio) + ((1 - PartLoadRatio) * state.dataHVACMultiSpdHP->CompOffFlowRatio); } else { - FanSpeedRatio = CompOnFlowRatio; + state.dataHVACMultiSpdHP->FanSpeedRatio = state.dataHVACMultiSpdHP->CompOnFlowRatio; } } @@ -4216,7 +4290,7 @@ namespace HVACMultiSpeedHeatPump { state.dataLoopNodes->Node(InletNode).MassFlowRate = AverageUnitMassFlow; state.dataLoopNodes->Node(InletNode).MassFlowRateMaxAvail = AverageUnitMassFlow; if (AverageUnitMassFlow > 0.0) { - OnOffAirFlowRatio = CompOnMassFlow / AverageUnitMassFlow; + OnOffAirFlowRatio = state.dataHVACMultiSpdHP->CompOnMassFlow / AverageUnitMassFlow; } else { OnOffAirFlowRatio = 0.0; } @@ -4284,7 +4358,6 @@ namespace HVACMultiSpeedHeatPump { Array1D Par(3); int SolFlag; - static std::string HeatCoilName; // TODO: What's the best plan here? int HeatCoilType; int HeatCoilNum; Real64 MaxCoilFluidFlow; @@ -4300,7 +4373,7 @@ namespace HVACMultiSpeedHeatPump { if (present(PartLoadFrac)) { HeatCoilType = MSHeatPump(MSHeatPumpNum).HeatCoilType; - HeatCoilName = MSHeatPump(MSHeatPumpNum).HeatCoilName; + state.dataHVACMultiSpdHP->HeatCoilName = MSHeatPump(MSHeatPumpNum).HeatCoilName; HeatCoilNum = MSHeatPump(MSHeatPumpNum).HeatCoilNum; MaxCoilFluidFlow = MSHeatPump(MSHeatPumpNum).MaxCoilFluidFlow; CoilControlNode = MSHeatPump(MSHeatPumpNum).CoilControlNode; @@ -4311,7 +4384,7 @@ namespace HVACMultiSpeedHeatPump { CompNum = MSHeatPump(MSHeatPumpNum).CompNum; } else { HeatCoilType = MSHeatPump(MSHeatPumpNum).SuppHeatCoilType; - HeatCoilName = MSHeatPump(MSHeatPumpNum).SuppHeatCoilName; + state.dataHVACMultiSpdHP->HeatCoilName = MSHeatPump(MSHeatPumpNum).SuppHeatCoilName; HeatCoilNum = MSHeatPump(MSHeatPumpNum).SuppHeatCoilNum; MaxCoilFluidFlow = MSHeatPump(MSHeatPumpNum).MaxSuppCoilFluidFlow; CoilControlNode = MSHeatPump(MSHeatPumpNum).SuppCoilControlNode; @@ -4328,24 +4401,27 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHeatPumpNum).HotWaterCompNum = CompNum; MSHeatPump(MSHeatPumpNum).HotWaterCoilControlNode = CoilControlNode; MSHeatPump(MSHeatPumpNum).HotWaterCoilOutletNode = CoilOutletNode; - MSHeatPump(MSHeatPumpNum).HotWaterCoilName = HeatCoilName; + MSHeatPump(MSHeatPumpNum).HotWaterCoilName = state.dataHVACMultiSpdHP->HeatCoilName; MSHeatPump(MSHeatPumpNum).HotWaterCoilNum = HeatCoilNum; if (HeatingLoad > SmallLoad) { { auto const SELECT_CASE_var(HeatCoilType); - if ((SELECT_CASE_var == SuppHeatingCoil::Gas) || (SELECT_CASE_var == SuppHeatingCoil::Electric)) { - SimulateHeatingCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); + if ((SELECT_CASE_var == SuppHeatingCoilGas) || (SELECT_CASE_var == SuppHeatingCoilElec)) { + SimulateHeatingCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); } else if (SELECT_CASE_var == Coil_HeatingWater) { if (present(PartLoadFrac)) { MaxHotWaterFlow = MaxCoilFluidFlow * PartLoadFrac; SetComponentFlowRate(state, MaxHotWaterFlow, CoilControlNode, CoilOutletNode, LoopNum, LoopSide, BranchNum, CompNum); - SimulateWaterCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); + SimulateWaterCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); } else { MaxHotWaterFlow = MaxCoilFluidFlow; SetComponentFlowRate(state, MaxHotWaterFlow, CoilControlNode, CoilOutletNode, LoopNum, LoopSide, BranchNum, CompNum); - SimulateWaterCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); + SimulateWaterCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); if (QCoilActual > (HeatingLoad + SmallLoad)) { // control water flow to obtain output matching HeatingLoad SolFlag = 0; @@ -4392,7 +4468,8 @@ namespace HVACMultiSpeedHeatPump { "[kg/s]"); } // simulate hot water supplemental heating coil - SimulateWaterCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); + SimulateWaterCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); } } } else if (SELECT_CASE_var == Coil_HeatingSteam) { @@ -4405,7 +4482,8 @@ namespace HVACMultiSpeedHeatPump { } SetComponentFlowRate(state, mdot, CoilControlNode, CoilOutletNode, LoopNum, LoopSide, BranchNum, CompNum); // simulate steam supplemental heating coil - SimulateSteamCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, SteamCoilHeatingLoad, QCoilActual, FanMode); + SimulateSteamCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, SteamCoilHeatingLoad, QCoilActual, FanMode); } } @@ -4413,17 +4491,19 @@ namespace HVACMultiSpeedHeatPump { { auto const SELECT_CASE_var(HeatCoilType); - if ((SELECT_CASE_var == SuppHeatingCoil::Gas) || (SELECT_CASE_var == SuppHeatingCoil::Electric)) { - SimulateHeatingCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); + if ((SELECT_CASE_var == SuppHeatingCoilGas) || (SELECT_CASE_var == SuppHeatingCoilElec)) { + SimulateHeatingCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatingLoad, HeatCoilNum, QCoilActual, true, FanMode); } else if (SELECT_CASE_var == Coil_HeatingWater) { mdot = 0.0; SetComponentFlowRate(state, mdot, CoilControlNode, CoilOutletNode, LoopNum, LoopSide, BranchNum, CompNum); - SimulateWaterCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); + SimulateWaterCoilComponents(state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, QCoilActual, FanMode); } else if (SELECT_CASE_var == Coil_HeatingSteam) { mdot = 0.0; SetComponentFlowRate(state, mdot, CoilControlNode, CoilOutletNode, LoopNum, LoopSide, BranchNum, CompNum); // simulate the steam supplemental heating coil - SimulateSteamCoilComponents(state, HeatCoilName, FirstHVACIteration, HeatCoilNum, HeatingLoad, QCoilActual, FanMode); + SimulateSteamCoilComponents( + state, state.dataHVACMultiSpdHP->HeatCoilName, FirstHVACIteration, HeatCoilNum, HeatingLoad, QCoilActual, FanMode); } } } diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh index a3adcef1ad1..5642afdc067 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh @@ -64,20 +64,14 @@ struct EnergyPlusData; namespace HVACMultiSpeedHeatPump { - enum class MultiSpeedCoil - { - Unassigned, - Heating, // COIL:DX:MultiSpeed:Heating - Cooling // COIL:DX:MultiSpeed:Cooling - }; - - enum class SuppHeatingCoil - { - Unassigned, - Gas, - Electric, - EngineHeatRecovery - }; + // Heating coil types + int constexpr MultiSpeedHeatingCoil(1); // COIL:DX:MultiSpeed:Heating + // Cooling coil types + int constexpr MultiSpeedCoolingCoil(2); // COIL:DX:MultiSpeed:Cooling + // Supplymental heating coil types + int constexpr SuppHeatingCoilGas(1); // Supplymental heating coil type: COIL:GAS:HEATING + int constexpr SuppHeatingCoilElec(2); // Supplymental heating coil type: COIL:ELECTRIC:HEATING + int constexpr SuppHeatingCoilRec(3); // Supplymental heating coil type: COIL:ENGINEHEATRECOVERY:HEATING // Mode of operation enum class ModeOfOperation { @@ -102,7 +96,7 @@ namespace HVACMultiSpeedHeatPump { struct MSHeatPumpData { // Members - //Some variables in this type are arrays (dimension=MaxSpeed) to support the number of speeds + // Some variables in this type are arrays (dimension=MaxSpeed) to support the number of speeds std::string Name; // Name of the engine driven heat pump std::string AvaiSchedule; // Availability Schedule name int AvaiSchedPtr; // Pointer to the correct schedule @@ -127,16 +121,16 @@ namespace HVACMultiSpeedHeatPump { int FanSchedPtr; // Pointer to the Supply air fan operating mode schedule int OpMode; // mode of operation; 1=cycling fan, cycling compressor; 2=continuous fan, cycling compresor std::string DXHeatCoilName; // COIL:DX:MultiSpeed:Heating name - MultiSpeedCoil HeatCoilType; // Heating coil type: 1 COIL:DX:MultiSpeed:Heating only + int HeatCoilType; // Heating coil type: 1 COIL:DX:MultiSpeed:Heating only int HeatCoilNum; // Heating coil number int DXHeatCoilIndex; // DX heating coil index number std::string HeatCoilName; // Coil:Electric:MultiSpeed:Heating OR Coil:Gas:MultiSpeed:Heating name int HeatCoilIndex; // heating coil index number (Coil:Electric:MultiSpeed:Heating OR Coil:Gas:MultiSpeed:Heating) std::string DXCoolCoilName; // COIL:DX:MultiSpeed:Cooling name - MultiSpeedCoil CoolCoilType; // Cooling coil type: 1 COIL:DX:MultiSpeed:Cooling only + int CoolCoilType; // Cooling coil type: 1 COIL:DX:MultiSpeed:Cooling only int DXCoolCoilIndex; // DX cooling coil index number std::string SuppHeatCoilName; // Supplymental heating coil name - SuppHeatingCoil SuppHeatCoilType; // Supplymental heating coil type: 1 Gas; 2 Electric; 3 Recovery + int SuppHeatCoilType; // Supplymental heating coil type: 1 Gas; 2 Electric; 3 Recovery int SuppHeatCoilNum; // Supplymental heating coil number Real64 DesignSuppHeatingCapacity; // Supplemental heating coil design capacity Real64 SuppMaxAirTemp; // Maximum supply air temperature from supplemental heater @@ -240,9 +234,8 @@ namespace HVACMultiSpeedHeatPump { MSHeatPumpData() : AvaiSchedPtr(0), AirInletNodeNum(0), AirOutletNodeNum(0), ControlZoneNum(0), ZoneSequenceCoolingNum(0), ZoneSequenceHeatingNum(0), NodeNumOfControlledZone(0), FlowFraction(0.0), FanType(0), FanNum(0), FanPlaceType(0), FanInletNode(0), FanOutletNode(0), - FanVolFlow(0.0), FanSchedPtr(0), OpMode(0), HeatCoilType(MultiSpeedCoil::Unassigned), HeatCoilNum(0), DXHeatCoilIndex(0), - HeatCoilIndex(0), CoolCoilType(MultiSpeedCoil::Unassigned), DXCoolCoilIndex(0), SuppHeatCoilType(SuppHeatingCoil::Unassigned), - SuppHeatCoilNum(0), DesignSuppHeatingCapacity(0.0), SuppMaxAirTemp(0.0), SuppMaxOATemp(0.0), + FanVolFlow(0.0), FanSchedPtr(0), OpMode(0), HeatCoilType(0), HeatCoilNum(0), DXHeatCoilIndex(0), HeatCoilIndex(0), CoolCoilType(0), + DXCoolCoilIndex(0), SuppHeatCoilType(0), SuppHeatCoilNum(0), DesignSuppHeatingCapacity(0.0), SuppMaxAirTemp(0.0), SuppMaxOATemp(0.0), AuxOnCyclePower(0.0), AuxOffCyclePower(0.0), DesignHeatRecFlowRate(0.0), HeatRecActive(false), HeatRecInletNodeNum(0), HeatRecOutletNodeNum(0), MaxHeatRecOutletTemp(0.0), DesignHeatRecMassFlowRate(0.0), HRLoopNum(0), HRLoopSideNum(0), HRBranchNum(0), HRCompNum(0), AuxElecPower(0.0), IdleVolumeAirRate(0.0), IdleMassFlowRate(0.0), IdleSpeedRatio(0.0), NumOfSpeedCooling(0), @@ -286,10 +279,6 @@ namespace HVACMultiSpeedHeatPump { extern Array1D MSHeatPump; extern Array1D MSHeatPumpReport; - // Functions - - void clear_state(); - void SimMSHeatPump(EnergyPlusData &state, std::string const &CompName, // Name of the unitary engine driven heat pump system bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system time step int const AirLoopNum, // air loop index @@ -398,9 +387,56 @@ namespace HVACMultiSpeedHeatPump { struct HVACMultiSpeedHeatPumpData : BaseGlobalStruct { + int NumMSHeatPumps = 0; // Number of multi speed heat pumps + int AirLoopPass = 0; // Number of air loop pass + Real64 TempSteamIn = 100.0; // steam coil steam inlet temperature + + std::string CurrentModuleObject; // Object type for getting and error messages + Real64 CompOnMassFlow = 0.0; // System air mass flow rate w/ compressor ON + Real64 CompOffMassFlow = 0.0; // System air mass flow rate w/ compressor OFF + Real64 CompOnFlowRatio = 0.0; // fan flow ratio when coil on + Real64 CompOffFlowRatio = 0.0; // fan flow ratio when coil off + Real64 FanSpeedRatio = 0.0; // fan speed ratio passed to on/off fan object + Real64 SupHeaterLoad = 0.0; // load to be met by supplemental heater [W] + Real64 SaveLoadResidual = 0.0; // Saved load residual used to check convergence + Real64 SaveCompressorPLR = 0.0; // holds compressor PLR from active DX coil + Array1D_bool CheckEquipName; + + // SUBROUTINE SPECIFICATIONS FOR MODULE + + // Object Data + Array1D MSHeatPump; + Array1D MSHeatPumpReport; + + bool GetInputFlag = true; // Get input flag + bool FlowFracFlagReady = true; // one time flag for calculating flow fraction through controlled zone + int ErrCountCyc = 0; // Counter used to minimize the occurrence of output warnings + int ErrCountVar = 0; // Counter used to minimize the occurrence of output warnings + + std::string HeatCoilName; // TODO: What's the best plan here? + void clear_state() override { - + this->NumMSHeatPumps = 0; + this->AirLoopPass = 0; + this->TempSteamIn = 100.0; + this->CurrentModuleObject = ""; + this->CompOnMassFlow = 0.0; + this->CompOffMassFlow = 0.0; + this->CompOnFlowRatio = 0.0; + this->CompOffFlowRatio = 0.0; + this->FanSpeedRatio = 0.0; + this->SupHeaterLoad = 0.0; + this->SaveLoadResidual = 0.0; + this->SaveCompressorPLR = 0.0; + this->CheckEquipName.clear(); + this->MSHeatPump.clear(); + this->MSHeatPumpReport.clear(); + this->GetInputFlag = true; // Get input flag + this->FlowFracFlagReady = true; + this->ErrCountCyc = 0; + this->ErrCountVar = 0; + this->HeatCoilName = ""; } }; diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index 4dd7eb680c7..28b995de571 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -82,7 +82,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +154,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) HVACDXSystem::clear_state(); HVACHXAssistedCoolingCoil::clear_state(); HVACFan::clearHVACFanObjects(); - HVACMultiSpeedHeatPump::clear_state(); HVACSingleDuctInduc::clear_state(); HybridModel::clear_state(); HysteresisPhaseChange::clear_state(); From 3081ae8549d0362d3337bb370c332cb39c75f79a Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 21:04:33 -0600 Subject: [PATCH 04/10] Global HVACDXHPsys --- src/EnergyPlus/HVACDXHeatPumpSystem.cc | 76 ++++++++++---------------- src/EnergyPlus/HVACDXHeatPumpSystem.hh | 19 +++++++ 2 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index 8790c789f20..78f246a7eda 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -130,13 +130,6 @@ namespace HVACDXHeatPumpSystem { Real64 AirMassFlow; // DX System air mass flow rate int InletNodeNum; // DX System inlet node number int OutletNodeNum; // DX System outlet node number - // local variables for calling variable speed coil - static Real64 QZnReq(0.001); // Zone load (W), input to variable-speed DX coil - static Real64 QLatReq(0.0); // Zone latent load, input to variable-speed DX coil - static Real64 MaxONOFFCyclesperHour(4.0); // Maximum cycling rate of heat pump [cycles/hr] - static Real64 HPTimeConstant(0.0); // Heat pump time constant [s] - static Real64 FanDelayTime(0.0); // Fan delay time, time delay for the HP's fan to - static Real64 OnOffAirFlowRatio(1.0); // ratio of compressor on flow to average flow over time step auto &NumDXHeatPumpSystems(state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems); auto &DXHeatPumpSystem(state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); @@ -205,16 +198,16 @@ namespace HVACDXHeatPumpSystem { SimVariableSpeedCoils(state, CompName, DXHeatPumpSystem(DXSystemNum).HeatPumpCoilIndex, DXHeatPumpSystem(DXSystemNum).FanOpMode, - MaxONOFFCyclesperHour, - HPTimeConstant, - FanDelayTime, + state.dataHVACDXHeatPumpSys->MaxONOFFCyclesperHour, + state.dataHVACDXHeatPumpSys->HPTimeConstant, + state.dataHVACDXHeatPumpSys->FanDelayTime, On, DXHeatPumpSystem(DXSystemNum).PartLoadFrac, DXHeatPumpSystem(DXSystemNum).SpeedNum, DXHeatPumpSystem(DXSystemNum).SpeedRatio, - QZnReq, - QLatReq, - OnOffAirFlowRatio); + state.dataHVACDXHeatPumpSys->QZnReq, + state.dataHVACDXHeatPumpSys->QLatReq, + state.dataHVACDXHeatPumpSys->OnOffAirFlowRatio); } else { ShowFatalError(state, "SimDXCoolingSystem: Invalid DX Heating System/Coil=" + DXHeatPumpSystem(DXSystemNum).HeatPumpCoilType); @@ -274,7 +267,6 @@ namespace HVACDXHeatPumpSystem { int NumNums; int IOStat; static std::string const RoutineName("GetDXHeatPumpSystemInput: "); // include trailing blank space - static bool ErrorsFound(false); // If errors detected in input bool IsNotOK; // Flag to verify name int DXHeatSysNum; std::string CurrentModuleObject; // for ease in getting objects @@ -284,9 +276,7 @@ namespace HVACDXHeatPumpSystem { Array1D Numbers; // Numeric input items for object Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE. - static int TotalArgs(0); // Total number of alpha and numeric arguments (max) for a - // certain object in the input file - + auto &NumDXHeatPumpSystems(state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems); auto &DXHeatPumpSystem(state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); @@ -296,7 +286,7 @@ namespace HVACDXHeatPumpSystem { DXHeatPumpSystem.allocate(NumDXHeatPumpSystems); state.dataHVACDXHeatPumpSys->CheckEquipName.dimension(NumDXHeatPumpSystems, true); - inputProcessor->getObjectDefMaxArgs(state, "CoilSystem:Heating:DX", TotalArgs, NumAlphas, NumNums); + inputProcessor->getObjectDefMaxArgs(state, "CoilSystem:Heating:DX", state.dataHVACDXHeatPumpSys->TotalArgs, NumAlphas, NumNums); Alphas.allocate(NumAlphas); cAlphaFields.allocate(NumAlphas); @@ -320,7 +310,7 @@ namespace HVACDXHeatPumpSystem { lAlphaBlanks, cAlphaFields, cNumericFields); - UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, ErrorsFound); + UtilityRoutines::IsNameEmpty(state, Alphas(1), CurrentModuleObject, state.dataHVACDXHeatPumpSys->ErrorsFound); DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpSystemType = CurrentModuleObject; // push Object Name into data array DXHeatPumpSystem(DXHeatSysNum).Name = Alphas(1); if (lAlphaBlanks(2)) { @@ -330,7 +320,7 @@ namespace HVACDXHeatPumpSystem { if (DXHeatPumpSystem(DXHeatSysNum).SchedPtr == 0) { ShowSevereError(state, RoutineName + CurrentModuleObject + ": invalid " + cAlphaFields(2) + " entered =" + Alphas(2) + " for " + cAlphaFields(1) + '=' + Alphas(1)); - ErrorsFound = true; + state.dataHVACDXHeatPumpSys->ErrorsFound = true; } } @@ -350,20 +340,28 @@ namespace HVACDXHeatPumpSystem { } else { ShowSevereError(state, "Invalid entry for " + cAlphaFields(3) + " :" + Alphas(3)); ShowContinueError(state, "In " + CurrentModuleObject + "=\"" + DXHeatPumpSystem(DXHeatSysNum).Name + "\"."); - ErrorsFound = true; + state.dataHVACDXHeatPumpSys->ErrorsFound = true; } if (DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType_Num == Coil_HeatingAirToAirVariableSpeed) { DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilInletNodeNum = GetCoilInletNodeVariableSpeed(state, - DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, ErrorsFound); + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, + state.dataHVACDXHeatPumpSys->ErrorsFound); DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilOutletNodeNum = GetCoilOutletNodeVariableSpeed(state, - DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, ErrorsFound); + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, + state.dataHVACDXHeatPumpSys->ErrorsFound); } else { - DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilInletNodeNum = - GetCoilInletNode(state, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, ErrorsFound); - - DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilOutletNodeNum = - GetCoilOutletNode(state, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, ErrorsFound); + DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilInletNodeNum = GetCoilInletNode(state, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, + state.dataHVACDXHeatPumpSys->ErrorsFound); + + DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilOutletNodeNum = GetCoilOutletNode(state, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, + DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, + state.dataHVACDXHeatPumpSys->ErrorsFound); } // Coil air-side outlet node is the control node @@ -379,7 +377,7 @@ namespace HVACDXHeatPumpSystem { DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilType, DXHeatPumpSystem(DXHeatSysNum).HeatPumpCoilName, IsNotOK, CurrentModuleObject); if (IsNotOK) { ShowContinueError(state, "In " + CurrentModuleObject + " = \"" + DXHeatPumpSystem(DXHeatSysNum).Name + "\"."); - ErrorsFound = true; + state.dataHVACDXHeatPumpSys->ErrorsFound = true; } SetUpCompSets(state, DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpSystemType, @@ -398,7 +396,7 @@ namespace HVACDXHeatPumpSystem { } // End of the DX System Loop - if (ErrorsFound) { + if (state.dataHVACDXHeatPumpSys->ErrorsFound) { ShowFatalError(state, RoutineName + "Errors found in input. Program terminates."); } @@ -452,23 +450,9 @@ namespace HVACDXHeatPumpSystem { using DataHVACGlobals::DoSetPointTest; using EMSManager::CheckIfNodeSetPointManagedByEMS; - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - - // SUBROUTINE PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: int ControlNode; // control node number int DXSysIndex; - // LOGICAL,SAVE :: MyOneTimeFlag = .TRUE. - static bool MySetPointCheckFlag(true); int OutdoorAirUnitNum; // "ONLY" for ZoneHVAC:OutdoorAirUnit Real64 OAUCoilOutletTemp; // "ONLY" for zoneHVAC:OutdoorAirUnit @@ -483,7 +467,7 @@ namespace HVACDXHeatPumpSystem { OAUCoilOutletTemp = OAUCoilOutTemp; } - if (!state.dataGlobal->SysSizingCalc && MySetPointCheckFlag && DoSetPointTest) { + if (!state.dataGlobal->SysSizingCalc && state.dataHVACDXHeatPumpSys->MySetPointCheckFlag && DoSetPointTest) { for (DXSysIndex = 1; DXSysIndex <= NumDXHeatPumpSystems; ++DXSysIndex) { ControlNode = DXHeatPumpSystem(DXSysIndex).DXSystemControlNodeNum; if (ControlNode > 0) { @@ -510,7 +494,7 @@ namespace HVACDXHeatPumpSystem { } } } - MySetPointCheckFlag = false; + state.dataHVACDXHeatPumpSys->MySetPointCheckFlag = false; } // These initializations are done every iteration diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.hh b/src/EnergyPlus/HVACDXHeatPumpSystem.hh index 1603aea96df..c939772bae6 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.hh +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.hh @@ -185,6 +185,16 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct { Array1D_bool CheckEquipName; Array1D DXHeatPumpSystem; + Real64 QZnReq = 0.001; // Zone load (W), input to variable-speed DX coil + Real64 QLatReq = 0.0; // Zone latent load, input to variable-speed DX coil + Real64 MaxONOFFCyclesperHour = 4.0; // Maximum cycling rate of heat pump [cycles/hr] + Real64 HPTimeConstant = 0.0; // Heat pump time constant [s] + Real64 FanDelayTime = 0.0; // Fan delay time, time delay for the HP's fan to + Real64 OnOffAirFlowRatio = 1.0; // ratio of compressor on flow to average flow over time step + bool ErrorsFound = false; // If errors detected in input + int TotalArgs = 0; // Total number of alpha and numeric arguments (max) for a certain object in the input file + bool MySetPointCheckFlag = true; + void clear_state() override { this->GetInputFlag = true; @@ -192,6 +202,15 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct { this->EconomizerFlag = false; this->CheckEquipName.deallocate(); this->DXHeatPumpSystem.deallocate(); + this->QZnReq = 0.001; + this->QLatReq = 0.0; + this->MaxONOFFCyclesperHour = 4.0; + this->HPTimeConstant = 0.0; + this->FanDelayTime = 0.0; + this->OnOffAirFlowRatio = 1.0; + this->ErrorsFound = false; + this->TotalArgs = 0; + this->MySetPointCheckFlag = true; } }; From 5a1bec7866ec54044fdb6fcbcd22d4270312eebc Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:05:38 -0600 Subject: [PATCH 05/10] Global HVACDXHeatPumpSystem --- src/EnergyPlus/HVACDXHeatPumpSystem.cc | 50 +++++++++----------------- src/EnergyPlus/HVACDXHeatPumpSystem.hh | 32 +++++++++++++++++ 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index 78f246a7eda..d8940bb9f6c 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -1134,14 +1134,6 @@ namespace HVACDXHeatPumpSystem { int CoilIndex; // index of this coil Real64 OutletAirTemp; // outlet air temperature [C] int FanOpMode; // Supply air fan operating mode - static int SpeedNum(1); // speed number of variable speed DX cooling coil - static Real64 QZnReq(0.001); // Zone load (W), input to variable-speed DX coil - static Real64 QLatReq(0.0); // Zone latent load, input to variable-speed DX coil - static Real64 MaxONOFFCyclesperHour(4.0); // Maximum cycling rate of heat pump [cycles/hr] - static Real64 HPTimeConstant(0.0); // Heat pump time constant [s] - static Real64 FanDelayTime(0.0); // Fan delay time, time delay for the HP's fan to - static Real64 OnOffAirFlowRatio(1.0); // ratio of compressor on flow to average flow over time step - static Real64 SpeedRatio(0.0); // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) CoilIndex = int(Par(1)); FanOpMode = int(Par(5)); @@ -1149,16 +1141,16 @@ namespace HVACDXHeatPumpSystem { SimVariableSpeedCoils(state, "", CoilIndex, FanOpMode, - MaxONOFFCyclesperHour, - HPTimeConstant, - FanDelayTime, + state.dataHVACDXHeatPumpSys->MaxONOFFCyclesperHour, + state.dataHVACDXHeatPumpSys->HPTimeConstant, + state.dataHVACDXHeatPumpSys->FanDelayTime, On, PartLoadRatio, - SpeedNum, - SpeedRatio, - QZnReq, - QLatReq, - OnOffAirFlowRatio); + state.dataHVACDXHeatPumpSys->SpeedNum, + state.dataHVACDXHeatPumpSys->SpeedRatio, + state.dataHVACDXHeatPumpSys->QZnReq, + state.dataHVACDXHeatPumpSys->QLatReq, + state.dataHVACDXHeatPumpSys->OnOffAirFlowRatio); OutletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).OutletAirDBTemp; Residuum = Par(2) - OutletAirTemp; @@ -1212,32 +1204,24 @@ namespace HVACDXHeatPumpSystem { int CoilIndex; // index of this coil Real64 OutletAirTemp; // outlet air temperature [C] int FanOpMode; // Supply air fan operating mode - static int SpeedNum(1); // speed number of variable speed DX cooling coil - static Real64 QZnReq(0.001); // Zone load (W), input to variable-speed DX coil - static Real64 QLatReq(0.0); // Zone latent load, input to variable-speed DX coil - static Real64 MaxONOFFCyclesperHour(4.0); // Maximum cycling rate of heat pump [cycles/hr] - static Real64 HPTimeConstant(0.0); // Heat pump time constant [s] - static Real64 FanDelayTime(0.0); // Fan delay time, time delay for the HP's fan to - static Real64 OnOffAirFlowRatio(1.0); // ratio of compressor on flow to average flow over time step - static Real64 PartLoadRatio(1.0); // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) CoilIndex = int(Par(1)); FanOpMode = int(Par(5)); - SpeedNum = int(Par(3)); + state.dataHVACDXHeatPumpSys->SpeedNumber = int(Par(3)); SimVariableSpeedCoils(state, "", CoilIndex, FanOpMode, - MaxONOFFCyclesperHour, - HPTimeConstant, - FanDelayTime, + state.dataHVACDXHeatPumpSys->MaxONOFFCyclesperHr, + state.dataHVACDXHeatPumpSys->HPTimeConst, + state.dataHVACDXHeatPumpSys->HPFanDelayTime, On, - PartLoadRatio, - SpeedNum, + state.dataHVACDXHeatPumpSys->SpeedPartLoadRatio, + state.dataHVACDXHeatPumpSys->SpeedNumber, SpeedRatio, - QZnReq, - QLatReq, - OnOffAirFlowRatio); + state.dataHVACDXHeatPumpSys->QZoneReq, + state.dataHVACDXHeatPumpSys->QLatentReq, + state.dataHVACDXHeatPumpSys->AirFlowOnOffRatio); OutletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).OutletAirDBTemp; Residuum = Par(2) - OutletAirTemp; diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.hh b/src/EnergyPlus/HVACDXHeatPumpSystem.hh index c939772bae6..27881d3fbd8 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.hh +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.hh @@ -194,6 +194,22 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct { bool ErrorsFound = false; // If errors detected in input int TotalArgs = 0; // Total number of alpha and numeric arguments (max) for a certain object in the input file bool MySetPointCheckFlag = true; + int SpeedNum = 1; // speed number of variable speed DX cooling coil + Real64 QZnReq = 0.001; // Zone load (W), input to variable-speed DX coil + Real64 QLatReq = 0.0; // Zone latent load, input to variable-speed DX coil + Real64 MaxONOFFCyclesperHour = 4.0; // Maximum cycling rate of heat pump [cycles/hr] + Real64 HPTimeConstant = 0.0; // Heat pump time constant [s] + Real64 FanDelayTime = 0.0; // Fan delay time, time delay for the HP's fan to + Real64 OnOffAirFlowRatio = 1.0; // ratio of compressor on flow to average flow over time step + Real64 SpeedRatio = 0.0; // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) + int SpeedNumber = 1; // speed number of variable speed DX cooling coil + Real64 QZoneReq = 0.001; // Zone load (W), input to variable-speed DX coil + Real64 QLatentReq = 0.0; // Zone latent load, input to variable-speed DX coil + Real64 MaxONOFFCyclesperHr = 4.0; // Maximum cycling rate of heat pump [cycles/hr] + Real64 HPTimeConst = 0.0; // Heat pump time constant [s] + Real64 HPFanDelayTime = 0.0; // Fan delay time, time delay for the HP's fan to + Real64 AirFlowOnOffRatio = 1.0; // ratio of compressor on flow to average flow over time step + Real64 SpeedPartLoadRatio = 1.0; // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) void clear_state() override { @@ -211,6 +227,22 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct { this->ErrorsFound = false; this->TotalArgs = 0; this->MySetPointCheckFlag = true; + this->SpeedNum = 1; + this->QZnReq = 0.001; + this->QLatReq = 0.0; + this->MaxONOFFCyclesperHour = 4.0; + this->HPTimeConstant = 0.0; + this->FanDelayTime = 0.0; + this->OnOffAirFlowRatio = 1.0; + this->SpeedRatio = 0.0; + this->SpeedNumber = 1; + this->QZoneReq = 0.001; + this->QLatentReq = 0.0; + this->MaxONOFFCyclesperHr = 4.0; + this->HPTimeConst = 0.0; + this->HPFanDelayTime = 0.0; + this->AirFlowOnOffRatio = 1.0; + this->SpeedPartLoadRatio = 1.0; } }; From 437c8f3846adcd6788a6868fe70023c1a2f818d7 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:05:49 -0600 Subject: [PATCH 06/10] fix errors --- src/EnergyPlus/HVACMultiSpeedHeatPump.hh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh index 5642afdc067..880135f8079 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.hh +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.hh @@ -275,10 +275,6 @@ namespace HVACMultiSpeedHeatPump { } }; - // Object Data - extern Array1D MSHeatPump; - extern Array1D MSHeatPumpReport; - void SimMSHeatPump(EnergyPlusData &state, std::string const &CompName, // Name of the unitary engine driven heat pump system bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system time step int const AirLoopNum, // air loop index From 0854aab9a14cd699492c019e3a3feadb810dc859 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:19:49 -0600 Subject: [PATCH 07/10] fix errors 2 --- src/EnergyPlus/HVACDXHeatPumpSystem.cc | 12 ++++++------ src/EnergyPlus/HVACDXHeatPumpSystem.hh | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index d8940bb9f6c..d5fff966927 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -1141,16 +1141,16 @@ namespace HVACDXHeatPumpSystem { SimVariableSpeedCoils(state, "", CoilIndex, FanOpMode, - state.dataHVACDXHeatPumpSys->MaxONOFFCyclesperHour, - state.dataHVACDXHeatPumpSys->HPTimeConstant, - state.dataHVACDXHeatPumpSys->FanDelayTime, + state.dataHVACDXHeatPumpSys->MaximumONOFFCyclesperHour, + state.dataHVACDXHeatPumpSys->TimeConstant, + state.dataHVACDXHeatPumpSys->HeatPumpFanDelayTime, On, PartLoadRatio, state.dataHVACDXHeatPumpSys->SpeedNum, state.dataHVACDXHeatPumpSys->SpeedRatio, - state.dataHVACDXHeatPumpSys->QZnReq, - state.dataHVACDXHeatPumpSys->QLatReq, - state.dataHVACDXHeatPumpSys->OnOffAirFlowRatio); + state.dataHVACDXHeatPumpSys->QZnReqr, + state.dataHVACDXHeatPumpSys->QLatReqr, + state.dataHVACDXHeatPumpSys->OnandOffAirFlowRatio); OutletAirTemp = state.dataVariableSpeedCoils->VarSpeedCoil(CoilIndex).OutletAirDBTemp; Residuum = Par(2) - OutletAirTemp; diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.hh b/src/EnergyPlus/HVACDXHeatPumpSystem.hh index 27881d3fbd8..aeb58bc0866 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.hh +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.hh @@ -195,12 +195,12 @@ struct HVACDXHeatPumpSystemData : BaseGlobalStruct { int TotalArgs = 0; // Total number of alpha and numeric arguments (max) for a certain object in the input file bool MySetPointCheckFlag = true; int SpeedNum = 1; // speed number of variable speed DX cooling coil - Real64 QZnReq = 0.001; // Zone load (W), input to variable-speed DX coil - Real64 QLatReq = 0.0; // Zone latent load, input to variable-speed DX coil - Real64 MaxONOFFCyclesperHour = 4.0; // Maximum cycling rate of heat pump [cycles/hr] - Real64 HPTimeConstant = 0.0; // Heat pump time constant [s] - Real64 FanDelayTime = 0.0; // Fan delay time, time delay for the HP's fan to - Real64 OnOffAirFlowRatio = 1.0; // ratio of compressor on flow to average flow over time step + Real64 QZnReqr = 0.001; // Zone load (W), input to variable-speed DX coil + Real64 QLatReqr = 0.0; // Zone latent load, input to variable-speed DX coil + Real64 MaximumONOFFCyclesperHour = 4.0; // Maximum cycling rate of heat pump [cycles/hr] + Real64 TimeConstant = 0.0; // Heat pump time constant [s] + Real64 HeatPumpFanDelayTime = 0.0; // Fan delay time, time delay for the HP's fan to + Real64 OnandOffAirFlowRatio = 1.0; // ratio of compressor on flow to average flow over time step Real64 SpeedRatio = 0.0; // SpeedRatio varies between 1.0 (higher speed) and 0.0 (lower speed) int SpeedNumber = 1; // speed number of variable speed DX cooling coil Real64 QZoneReq = 0.001; // Zone load (W), input to variable-speed DX coil From 8d476816d19874c212b2aa257d94d1a3ae40b3d2 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:21:26 -0600 Subject: [PATCH 08/10] cleanup --- src/EnergyPlus/HVACDXHeatPumpSystem.cc | 32 -------------------------- 1 file changed, 32 deletions(-) diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index d5fff966927..fe4722c2d85 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -1114,22 +1114,6 @@ namespace HVACDXHeatPumpSystem { // Return value Real64 Residuum; // residual to be minimized to zero - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // par(2) = desired air outlet temperature [C] - // par(5) = supply air fan operating mode (ContFanCycCoil) - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: int CoilIndex; // index of this coil Real64 OutletAirTemp; // outlet air temperature [C] @@ -1184,22 +1168,6 @@ namespace HVACDXHeatPumpSystem { // Return value Real64 Residuum; // residual to be minimized to zero - // Argument array dimensioning - - // Locals - // SUBROUTINE ARGUMENT DEFINITIONS: - // par(2) = desired air outlet temperature [C] - // par(5) = supply air fan operating mode (ContFanCycCoil) - - // FUNCTION PARAMETER DEFINITIONS: - // na - - // INTERFACE BLOCK SPECIFICATIONS - // na - - // DERIVED TYPE DEFINITIONS - // na - // FUNCTION LOCAL VARIABLE DECLARATIONS: int CoilIndex; // index of this coil Real64 OutletAirTemp; // outlet air temperature [C] From a9c23b506abd6d597c63324eba4faea3063fd094 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:32:23 -0600 Subject: [PATCH 09/10] fix errors 3 --- src/EnergyPlus/HVACMultiSpeedHeatPump.cc | 178 +++++++++++++---------- 1 file changed, 100 insertions(+), 78 deletions(-) diff --git a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc index ebdd496b81a..bcb7fc4927f 100644 --- a/src/EnergyPlus/HVACMultiSpeedHeatPump.cc +++ b/src/EnergyPlus/HVACMultiSpeedHeatPump.cc @@ -181,7 +181,7 @@ namespace HVACMultiSpeedHeatPump { } if (CompIndex == 0) { - MSHeatPumpNum = UtilityRoutines::FindItemInList(CompName, MSHeatPump); + MSHeatPumpNum = UtilityRoutines::FindItemInList(CompName, state.dataHVACMultiSpdHP->MSHeatPump); if (MSHeatPumpNum == 0) { ShowFatalError(state, "MultiSpeed Heat Pump is not found=" + CompName); } @@ -196,12 +196,12 @@ namespace HVACMultiSpeedHeatPump { CompName)); } if (state.dataHVACMultiSpdHP->CheckEquipName(MSHeatPumpNum)) { - if (CompName != MSHeatPump(MSHeatPumpNum).Name) { + if (CompName != state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).Name) { ShowFatalError(state, format("SimMSHeatPump: Invalid CompIndex passed={}, Heat Pump name={}{}", MSHeatPumpNum, CompName, - MSHeatPump(MSHeatPumpNum).Name)); + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).Name)); } state.dataHVACMultiSpdHP->CheckEquipName(MSHeatPumpNum) = false; } @@ -275,6 +275,8 @@ namespace HVACMultiSpeedHeatPump { ElecHeatingCoilPower = 0.0; DataHVACGlobals::SuppHeatingCoilPower = 0.0; + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); + // initialize local variables UnitOn = true; OutletNode = MSHeatPump(MSHeatPumpNum).AirOutletNodeNum; @@ -521,7 +523,7 @@ namespace HVACMultiSpeedHeatPump { int SteamIndex; // steam coil steam inlet density Real64 SteamDensity; // density of steam at 100C - + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); if (MSHeatPump.allocated()) return; @@ -548,7 +550,7 @@ namespace HVACMultiSpeedHeatPump { // ALLOCATE ARRAYS MSHeatPump.allocate(state.dataHVACMultiSpdHP->NumMSHeatPumps); - MSHeatPumpReport.allocate(state.dataHVACMultiSpdHP->NumMSHeatPumps); + state.dataHVACMultiSpdHP->MSHeatPumpReport.allocate(state.dataHVACMultiSpdHP->NumMSHeatPumps); state.dataHVACMultiSpdHP->CheckEquipName.dimension(state.dataHVACMultiSpdHP->NumMSHeatPumps, true); // Load arrays with reformulated electric EIR chiller data @@ -1606,7 +1608,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System Cooling Ancillary Electricity Energy", OutputProcessor::Unit::J, - MSHeatPumpReport(MSHPNum).AuxElecCoolConsumption, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).AuxElecCoolConsumption, "System", "Sum", MSHeatPump(MSHPNum).Name, @@ -1617,7 +1619,7 @@ namespace HVACMultiSpeedHeatPump { "System"); SetupOutputVariable(state, "Unitary System Heating Ancillary Electricity Energy", OutputProcessor::Unit::J, - MSHeatPumpReport(MSHPNum).AuxElecHeatConsumption, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).AuxElecHeatConsumption, "System", "Sum", MSHeatPump(MSHPNum).Name, @@ -1646,25 +1648,25 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System Electricity Energy", OutputProcessor::Unit::J, - MSHeatPumpReport(MSHPNum).ElecPowerConsumption, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).ElecPowerConsumption, "System", "Sum", MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System DX Coil Cycling Ratio", OutputProcessor::Unit::None, - MSHeatPumpReport(MSHPNum).CycRatio, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).CycRatio, "System", "Average", MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System DX Coil Speed Ratio", OutputProcessor::Unit::None, - MSHeatPumpReport(MSHPNum).SpeedRatio, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).SpeedRatio, "System", "Average", MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System DX Coil Speed Level", OutputProcessor::Unit::None, - MSHeatPumpReport(MSHPNum).SpeedNum, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).SpeedNum, "System", "Average", MSHeatPump(MSHPNum).Name); @@ -1731,7 +1733,7 @@ namespace HVACMultiSpeedHeatPump { MSHeatPump(MSHPNum).Name); SetupOutputVariable(state, "Unitary System Heat Recovery Energy", OutputProcessor::Unit::J, - MSHeatPumpReport(MSHPNum).HeatRecoveryEnergy, + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHPNum).HeatRecoveryEnergy, "System", "Sum", MSHeatPump(MSHPNum).Name); @@ -1823,6 +1825,7 @@ namespace HVACMultiSpeedHeatPump { Real64 QActual(0.0); // coil actual capacity int CoilAvailSchPtr(0); // DX coil availability schedule pointer + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); InNode = MSHeatPump(MSHeatPumpNum).AirInletNodeNum; OutNode = MSHeatPump(MSHeatPumpNum).AirOutletNodeNum; @@ -2531,9 +2534,9 @@ namespace HVACMultiSpeedHeatPump { } } - MSHeatPumpReport(MSHeatPumpNum).CycRatio = 0.0; - MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = 0.0; - MSHeatPumpReport(MSHeatPumpNum).SpeedNum = 0; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).CycRatio = 0.0; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = 0.0; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedNum = 0; CalcMSHeatPump(state, MSHeatPumpNum, @@ -2706,6 +2709,7 @@ namespace HVACMultiSpeedHeatPump { int NumOfSpeedHeating; // Number of speeds for heating int i; // Index to speed + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); if (state.dataSize->CurSysNum > 0 && state.dataSize->CurOASysNum == 0) { if (MSHeatPump(MSHeatPumpNum).FanType == DataHVACGlobals::FanType_SystemModelObject) { state.dataAirSystemsData->PrimaryAirSystems(state.dataSize->CurSysNum).supFanVecIndex = MSHeatPump(MSHeatPumpNum).FanNum; @@ -2928,6 +2932,8 @@ namespace HVACMultiSpeedHeatPump { OutsideDryBulbTemp = state.dataEnvrn->OutDryBulbTemp; + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); + //!!LKL Discrepancy with < 0 if (GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) == 0.0) return; @@ -2995,9 +3001,9 @@ namespace HVACMultiSpeedHeatPump { PartLoadFrac = 1.0; SpeedRatio = 1.0; if (MSHeatPump(MSHeatPumpNum).Staged && SpeedNum == 1) SpeedRatio = 0.0; - MSHeatPumpReport(MSHeatPumpNum).CycRatio = PartLoadFrac; - MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = SpeedRatio; - MSHeatPumpReport(MSHeatPumpNum).SpeedNum = SpeedNum; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).CycRatio = PartLoadFrac; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = SpeedRatio; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedNum = SpeedNum; return; } ErrorToler = 0.001; // Error tolerance for convergence from input deck @@ -3422,9 +3428,9 @@ namespace HVACMultiSpeedHeatPump { } } - MSHeatPumpReport(MSHeatPumpNum).CycRatio = PartLoadFrac; - MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = SpeedRatio; - MSHeatPumpReport(MSHeatPumpNum).SpeedNum = SpeedNum; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).CycRatio = PartLoadFrac; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedRatio = SpeedRatio; + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).SpeedNum = SpeedNum; } //****************************************************************************** @@ -3487,6 +3493,7 @@ namespace HVACMultiSpeedHeatPump { Real64 MinWaterFlow; // minimum water flow rate Real64 ErrorToler; // supplemental heating coil convergence tollerance + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); OutletNode = MSHeatPump(MSHeatPumpNum).AirOutletNodeNum; InletNode = MSHeatPump(MSHeatPumpNum).AirInletNodeNum; @@ -4029,19 +4036,22 @@ namespace HVACMultiSpeedHeatPump { // SUBROUTINE ARGUMENT DEFINITIONS: // Calculate heat recovery - if (MSHeatPump(MSHeatPumpNum).HeatRecActive) { + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecActive) { MSHPHeatRecovery(state, MSHeatPumpNum); } if (AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlMultiADS || AirflowNetwork::SimulateAirflowNetwork == AirflowNetwork::AirflowNetworkControlSimpleADS) { - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOnMassFlowrate = + state.dataAirLoop->AirLoopAFNInfo(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOnMassFlowrate = state.dataHVACMultiSpdHP->CompOnMassFlow; - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOffMassFlowrate = + state.dataAirLoop->AirLoopAFNInfo(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopSystemOffMassFlowrate = state.dataHVACMultiSpdHP->CompOffMassFlow; - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopFanOperationMode = MSHeatPump(MSHeatPumpNum).OpMode; - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopOnOffFanPartLoadRatio = MSHeatPump(MSHeatPumpNum).FanPartLoadRatio; - state.dataAirLoop->AirLoopAFNInfo(MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopCompCycRatio = MSHeatPumpReport(MSHeatPumpNum).CycRatio; + state.dataAirLoop->AirLoopAFNInfo(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopFanOperationMode = + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).OpMode; + state.dataAirLoop->AirLoopAFNInfo(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopOnOffFanPartLoadRatio = + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).FanPartLoadRatio; + state.dataAirLoop->AirLoopAFNInfo(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirLoopNumber).LoopCompCycRatio = + state.dataHVACMultiSpdHP->MSHeatPumpReport(MSHeatPumpNum).CycRatio; } } @@ -4079,6 +4089,9 @@ namespace HVACMultiSpeedHeatPump { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: Real64 ReportingConstant; + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); + auto &MSHeatPumpReport(state.dataHVACMultiSpdHP->MSHeatPumpReport); + ReportingConstant = TimeStepSys * DataGlobalConstants::SecInHour; MSHeatPumpReport(MSHeatPumpNum).ElecPowerConsumption = MSHeatPump(MSHeatPumpNum).ElecPower * ReportingConstant; // + & MSHeatPumpReport(MSHeatPumpNum).HeatRecoveryEnergy = MSHeatPump(MSHeatPumpNum).HeatRecoveryRate * ReportingConstant; @@ -4142,8 +4155,8 @@ namespace HVACMultiSpeedHeatPump { Real64 CpHeatRec; // Heat reclaim water inlet specific heat [J/kg-K] // Begin routine - HeatRecInNode = MSHeatPump(MSHeatPumpNum).HeatRecInletNodeNum; - HeatRecOutNode = MSHeatPump(MSHeatPumpNum).HeatRecOutletNodeNum; + HeatRecInNode = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecInletNodeNum; + HeatRecOutNode = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecOutletNodeNum; // Inlet node to the heat recovery heat exchanger HeatRecInletTemp = state.dataLoopNodes->Node(HeatRecInNode).Temp; @@ -4155,14 +4168,15 @@ namespace HVACMultiSpeedHeatPump { if (HeatRecMassFlowRate > 0.0) { - CpHeatRec = GetSpecificHeatGlycol(state, state.dataPlnt->PlantLoop(MSHeatPump(MSHeatPumpNum).HRLoopNum).FluidName, + CpHeatRec = GetSpecificHeatGlycol(state, + state.dataPlnt->PlantLoop(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HRLoopNum).FluidName, HeatRecInletTemp, - state.dataPlnt->PlantLoop(MSHeatPump(MSHeatPumpNum).HRLoopNum).FluidIndex, + state.dataPlnt->PlantLoop(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HRLoopNum).FluidIndex, RoutineName); HeatRecOutletTemp = QHeatRec / (HeatRecMassFlowRate * CpHeatRec) + HeatRecInletTemp; - if (HeatRecOutletTemp > MSHeatPump(MSHeatPumpNum).MaxHeatRecOutletTemp) { - HeatRecOutletTemp = max(HeatRecInletTemp, MSHeatPump(MSHeatPumpNum).MaxHeatRecOutletTemp); + if (HeatRecOutletTemp > state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).MaxHeatRecOutletTemp) { + HeatRecOutletTemp = max(HeatRecInletTemp, state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).MaxHeatRecOutletTemp); QHeatRec = HeatRecMassFlowRate * CpHeatRec * (HeatRecOutletTemp - HeatRecInletTemp); } } else { @@ -4174,10 +4188,10 @@ namespace HVACMultiSpeedHeatPump { // changed outputs state.dataLoopNodes->Node(HeatRecOutNode).Temp = HeatRecOutletTemp; - MSHeatPump(MSHeatPumpNum).HeatRecoveryRate = QHeatRec; - MSHeatPump(MSHeatPumpNum).HeatRecoveryInletTemp = HeatRecInletTemp; - MSHeatPump(MSHeatPumpNum).HeatRecoveryOutletTemp = HeatRecOutletTemp; - MSHeatPump(MSHeatPumpNum).HeatRecoveryMassFlowRate = HeatRecMassFlowRate; + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecoveryRate = QHeatRec; + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecoveryInletTemp = HeatRecInletTemp; + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecoveryOutletTemp = HeatRecOutletTemp; + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatRecoveryMassFlowRate = HeatRecMassFlowRate; } void SetAverageAirFlow(EnergyPlusData &state, @@ -4211,48 +4225,54 @@ namespace HVACMultiSpeedHeatPump { MSHPMassFlowRateLow = 0.0; // Mass flow rate at low speed MSHPMassFlowRateHigh = 0.0; // Mass flow rate at high speed - if (!state.dataZoneEnergyDemand->CurDeadBandOrSetback(MSHeatPump(MSHeatPumpNum).ControlZoneNum) && present(SpeedNum)) { - if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::HeatingMode) { + if (!state.dataZoneEnergyDemand->CurDeadBandOrSetback(state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).ControlZoneNum) && + present(SpeedNum)) { + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::HeatingMode) { if (SpeedNum == 1) { - state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); - state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); - MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); - MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnFlowRatio = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); + MSHPMassFlowRateLow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); + MSHPMassFlowRateHigh = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(1); } else if (SpeedNum > 1) { - state.dataHVACMultiSpdHP->CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum) + - (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); - state.dataHVACMultiSpdHP->CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum) + - (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum - 1); - MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); - MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnMassFlow = + SpeedRatio * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum) + + (1.0 - SpeedRatio) * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = + SpeedRatio * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum) + + (1.0 - SpeedRatio) * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum - 1); + MSHPMassFlowRateLow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum - 1); + MSHPMassFlowRateHigh = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); } - } else if (MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::CoolingMode) { + } else if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatCoolMode == ModeOfOperation::CoolingMode) { if (SpeedNum == 1) { - state.dataHVACMultiSpdHP->CompOnMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); - state.dataHVACMultiSpdHP->CompOnFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); - MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); - MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); + state.dataHVACMultiSpdHP->CompOnMassFlow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnFlowRatio = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); + MSHPMassFlowRateLow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); + MSHPMassFlowRateHigh = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(1); } else if (SpeedNum > 1) { - state.dataHVACMultiSpdHP->CompOnMassFlow = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum) + - (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); - state.dataHVACMultiSpdHP->CompOnFlowRatio = SpeedRatio * MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum) + - (1.0 - SpeedRatio) * MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum - 1); - MSHPMassFlowRateLow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); - MSHPMassFlowRateHigh = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOnMassFlow = + SpeedRatio * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum) + + (1.0 - SpeedRatio) * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); + state.dataHVACMultiSpdHP->CompOnFlowRatio = + SpeedRatio * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum) + + (1.0 - SpeedRatio) * state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum - 1); + MSHPMassFlowRateLow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum - 1); + MSHPMassFlowRateHigh = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); } } } - InletNode = MSHeatPump(MSHeatPumpNum).AirInletNodeNum; + InletNode = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirInletNodeNum; // Set up fan flow rate during compressor off time - if (MSHeatPump(MSHeatPumpNum).OpMode == ContFanCycCoil && present(SpeedNum)) { - if (MSHeatPump(MSHeatPumpNum).AirFlowControl == AirflowControl::UseCompressorOnFlow && state.dataHVACMultiSpdHP->CompOnMassFlow > 0.0) { - if (MSHeatPump(MSHeatPumpNum).LastMode == ModeOfOperation::HeatingMode) { - state.dataHVACMultiSpdHP->CompOffMassFlow = MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); - state.dataHVACMultiSpdHP->CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).OpMode == ContFanCycCoil && present(SpeedNum)) { + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AirFlowControl == AirflowControl::UseCompressorOnFlow && + state.dataHVACMultiSpdHP->CompOnMassFlow > 0.0) { + if (state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).LastMode == ModeOfOperation::HeatingMode) { + state.dataHVACMultiSpdHP->CompOffMassFlow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOffFlowRatio = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HeatingSpeedRatio(SpeedNum); } else { - state.dataHVACMultiSpdHP->CompOffMassFlow = MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); - state.dataHVACMultiSpdHP->CompOffFlowRatio = MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); + state.dataHVACMultiSpdHP->CompOffMassFlow = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolMassFlowRate(SpeedNum); + state.dataHVACMultiSpdHP->CompOffFlowRatio = state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).CoolingSpeedRatio(SpeedNum); } } } @@ -4283,7 +4303,7 @@ namespace HVACMultiSpeedHeatPump { } //!!LKL Discrepancy with > 0 - if (GetCurrentScheduleValue(state, MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) == 0.0) { + if (GetCurrentScheduleValue(state, state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).AvaiSchedPtr) == 0.0) { state.dataLoopNodes->Node(InletNode).MassFlowRate = 0.0; OnOffAirFlowRatio = 0.0; } else { @@ -4371,6 +4391,8 @@ namespace HVACMultiSpeedHeatPump { QCoilActual = 0.0; + auto &MSHeatPump(state.dataHVACMultiSpdHP->MSHeatPump); + if (present(PartLoadFrac)) { HeatCoilType = MSHeatPump(MSHeatPumpNum).HeatCoilType; state.dataHVACMultiSpdHP->HeatCoilName = MSHeatPump(MSHeatPumpNum).HeatCoilName; @@ -4566,19 +4588,19 @@ namespace HVACMultiSpeedHeatPump { QCoilActual = HeatCoilLoad; mdot = HWFlow; SetComponentFlowRate(state, mdot, - MSHeatPump(MSHeatPumpNum).HotWaterCoilControlNode, - MSHeatPump(MSHeatPumpNum).HotWaterCoilOutletNode, - MSHeatPump(MSHeatPumpNum).HotWaterLoopNum, - MSHeatPump(MSHeatPumpNum).HotWaterLoopSide, - MSHeatPump(MSHeatPumpNum).HotWaterBranchNum, - MSHeatPump(MSHeatPumpNum).HotWaterCompNum); + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterCoilControlNode, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterCoilOutletNode, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterLoopNum, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterLoopSide, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterBranchNum, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterCompNum); // simulate the hot water supplemental heating coil SimulateWaterCoilComponents(state, - MSHeatPump(MSHeatPumpNum).HotWaterCoilName, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterCoilName, FirstHVACSoln, - MSHeatPump(MSHeatPumpNum).HotWaterCoilNum, + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).HotWaterCoilNum, QCoilActual, - MSHeatPump(MSHeatPumpNum).OpMode); + state.dataHVACMultiSpdHP->MSHeatPump(MSHeatPumpNum).OpMode); if (HeatCoilLoad != 0.0) { Residuum = (QCoilActual - HeatCoilLoad) / HeatCoilLoad; } else { // Autodesk:Return Condition added to assure return value is set From 4aba4218f2dd5fd848c805c5be3087caa1cf9df3 Mon Sep 17 00:00:00 2001 From: Dareum Nam Date: Tue, 16 Mar 2021 22:39:41 -0600 Subject: [PATCH 10/10] Global HVACMultiSpeedHeatPump: fix unit tests --- .../unit/HVACMultiSpeedHeatPump.unit.cc | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc index 81e636a60f7..cb6dc18fdda 100644 --- a/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/HVACMultiSpeedHeatPump.unit.cc @@ -1297,12 +1297,12 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) HVACMultiSpeedHeatPump::GetMSHeatPumpInput(*state); state->dataGlobal->SysSizingCalc = true; // disable sizing calculation - MSHeatPump(1).TotHeatEnergyRate = 1000.0; - MSHeatPump(1).TotCoolEnergyRate = 1000.0; - MSHeatPump(2).TotHeatEnergyRate = 1000.0; - MSHeatPump(2).TotCoolEnergyRate = 1000.0; - MSHeatPump(1).FlowFraction = 1.0; - MSHeatPump(2).FlowFraction = 1.0; + state->dataHVACMultiSpdHP->MSHeatPump(1).TotHeatEnergyRate = 1000.0; + state->dataHVACMultiSpdHP->MSHeatPump(1).TotCoolEnergyRate = 1000.0; + state->dataHVACMultiSpdHP->MSHeatPump(2).TotHeatEnergyRate = 1000.0; + state->dataHVACMultiSpdHP->MSHeatPump(2).TotCoolEnergyRate = 1000.0; + state->dataHVACMultiSpdHP->MSHeatPump(1).FlowFraction = 1.0; + state->dataHVACMultiSpdHP->MSHeatPump(2).FlowFraction = 1.0; state->dataScheduleMgr->Schedule(17).CurrentValue = 1.0; state->dataScheduleMgr->Schedule(9).CurrentValue = 1.0; state->dataEnvrn->StdRhoAir = 1.2; @@ -1314,16 +1314,16 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) // InitMSHeatPump resets the current MSHeatPumpNum only HVACMultiSpeedHeatPump::InitMSHeatPump(*state, MSHeatPumpNum, FirstHVACIteration, AirLoopNum, QZnReq, OnOffAirFlowRatio); - EXPECT_DOUBLE_EQ(1000.0, MSHeatPump(1).TotHeatEnergyRate); - EXPECT_DOUBLE_EQ(1000.0, MSHeatPump(1).TotCoolEnergyRate); - EXPECT_DOUBLE_EQ(0.0, MSHeatPump(2).TotHeatEnergyRate); - EXPECT_DOUBLE_EQ(0.0, MSHeatPump(2).TotCoolEnergyRate); + EXPECT_DOUBLE_EQ(1000.0, state->dataHVACMultiSpdHP->MSHeatPump(1).TotHeatEnergyRate); + EXPECT_DOUBLE_EQ(1000.0, state->dataHVACMultiSpdHP->MSHeatPump(1).TotCoolEnergyRate); + EXPECT_DOUBLE_EQ(0.0, state->dataHVACMultiSpdHP->MSHeatPump(2).TotHeatEnergyRate); + EXPECT_DOUBLE_EQ(0.0, state->dataHVACMultiSpdHP->MSHeatPump(2).TotCoolEnergyRate); // verify min OAT from coil inputs - EXPECT_EQ(MSHeatPump(1).MinOATCompressorCooling, -25.0); - EXPECT_EQ(MSHeatPump(1).MinOATCompressorHeating, -8.0); - EXPECT_EQ(MSHeatPump(2).MinOATCompressorCooling, -25.0); - EXPECT_EQ(MSHeatPump(2).MinOATCompressorHeating, -8.0); + EXPECT_EQ(state->dataHVACMultiSpdHP->MSHeatPump(1).MinOATCompressorCooling, -25.0); + EXPECT_EQ(state->dataHVACMultiSpdHP->MSHeatPump(1).MinOATCompressorHeating, -8.0); + EXPECT_EQ(state->dataHVACMultiSpdHP->MSHeatPump(2).MinOATCompressorCooling, -25.0); + EXPECT_EQ(state->dataHVACMultiSpdHP->MSHeatPump(2).MinOATCompressorHeating, -8.0); state->dataLoopNodes->Node(9).Temp = 24.0; state->dataLoopNodes->Node(9).HumRat = 0.008; @@ -1348,17 +1348,17 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 23.363295, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.00796611, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 43744.6339, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.123500, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.123500, 0.0001); // Direct solution state->dataGlobal->DoCoilDirectSolutions = true; - MSHeatPump(2).FullOutput.allocate(2); + state->dataHVACMultiSpdHP->MSHeatPump(2).FullOutput.allocate(2); SimMSHP(*state, MSHeatPumpNum, FirstHVACIteration, AirLoopNum, QSensUnitOut, QZnReq, OnOffAirFlowRatio); // Check outlet conditions EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 23.3641, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.00796613, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 43745.5237, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.123430, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.123430, 0.0001); QZnReq = -10000.00; @@ -1367,18 +1367,18 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 21.4545, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.00792169, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 41684.8507, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.285914, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.285914, 0.0001); state->dataGlobal->DoCoilDirectSolutions = true; SimMSHP(*state, MSHeatPumpNum, FirstHVACIteration, AirLoopNum, QSensUnitOut, QZnReq, OnOffAirFlowRatio); EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 21.4545, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.00792169, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 41684.8507, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.285914, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.285914, 0.0001); // Heating QZnReq = 10000.00; - MSHeatPump(2).HeatCoolMode = EnergyPlus::HVACMultiSpeedHeatPump::ModeOfOperation::HeatingMode; + state->dataHVACMultiSpdHP->MSHeatPump(2).HeatCoolMode = EnergyPlus::HVACMultiSpeedHeatPump::ModeOfOperation::HeatingMode; state->dataEnvrn->OutDryBulbTemp = 5.0; state->dataEnvrn->OutHumRat = 0.008; state->dataGlobal->DoCoilDirectSolutions = false; @@ -1386,13 +1386,13 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_ReportVariableInitTest) EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 26.546664, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.008, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 47077.4613, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.1530992, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.1530992, 0.0001); state->dataGlobal->DoCoilDirectSolutions = true; SimMSHP(*state, MSHeatPumpNum, FirstHVACIteration, AirLoopNum, QSensUnitOut, QZnReq, OnOffAirFlowRatio); EXPECT_NEAR(state->dataLoopNodes->Node(22).Temp, 26.546664, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).HumRat, 0.008, 0.0001); EXPECT_NEAR(state->dataLoopNodes->Node(22).Enthalpy, 47077.4613, 0.0001); - EXPECT_NEAR(MSHeatPump(2).CompPartLoadRatio, 0.1530992, 0.0001); + EXPECT_NEAR(state->dataHVACMultiSpdHP->MSHeatPump(2).CompPartLoadRatio, 0.1530992, 0.0001); state->dataGlobal->DoCoilDirectSolutions = false; state->dataZoneEnergyDemand->ZoneSysEnergyDemand.deallocate(); @@ -1403,13 +1403,13 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_HeatRecoveryTest) { state->dataLoopNodes->Node.allocate(2); - MSHeatPump.allocate(1); + state->dataHVACMultiSpdHP->MSHeatPump.allocate(1); int HeatRecInNode(1); int HeatRecOutNode(2); - MSHeatPump(1).HeatRecInletNodeNum = HeatRecInNode; - MSHeatPump(1).HeatRecOutletNodeNum = HeatRecOutNode; - MSHeatPump(1).MaxHeatRecOutletTemp = 80; - MSHeatPump(1).HRLoopNum = 1; // index to plant + state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecInletNodeNum = HeatRecInNode; + state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecOutletNodeNum = HeatRecOutNode; + state->dataHVACMultiSpdHP->MSHeatPump(1).MaxHeatRecOutletTemp = 80; + state->dataHVACMultiSpdHP->MSHeatPump(1).HRLoopNum = 1; // index to plant state->dataLoopNodes->Node(HeatRecInNode).Temp = 50.0; DataHVACGlobals::MSHPWasteHeat = 1000.0; @@ -1423,10 +1423,10 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_HeatRecoveryTest) // outlet temp should equal inlet temp since mass flow rate = 0 Real64 calculatedOutletTemp = state->dataLoopNodes->Node(HeatRecInNode).Temp + DataHVACGlobals::MSHPWasteHeat / (state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate * 4181.0); - EXPECT_DOUBLE_EQ(0.0, MSHeatPump(1).HeatRecoveryRate); - EXPECT_DOUBLE_EQ(50.0, MSHeatPump(1).HeatRecoveryInletTemp); - EXPECT_DOUBLE_EQ(50.0, MSHeatPump(1).HeatRecoveryOutletTemp); - EXPECT_DOUBLE_EQ(0.0, MSHeatPump(1).HeatRecoveryMassFlowRate); + EXPECT_DOUBLE_EQ(0.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryRate); + EXPECT_DOUBLE_EQ(50.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryInletTemp); + EXPECT_DOUBLE_EQ(50.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryOutletTemp); + EXPECT_DOUBLE_EQ(0.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryMassFlowRate); state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate = 0.1; // initialize flow rate and test heat recovery result using 1 kW heat transfer to fluid HVACMultiSpeedHeatPump::MSHPHeatRecovery(*state, 1); @@ -1434,23 +1434,23 @@ TEST_F(EnergyPlusFixture, HVACMultiSpeedHeatPump_HeatRecoveryTest) // outlet temp should equal temperature rise due to 1 kW of heat input at 0.1 kg/s calculatedOutletTemp = state->dataLoopNodes->Node(HeatRecInNode).Temp + DataHVACGlobals::MSHPWasteHeat / (state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate * 4181.0); - EXPECT_DOUBLE_EQ(1000.0, MSHeatPump(1).HeatRecoveryRate); - EXPECT_DOUBLE_EQ(50.0, MSHeatPump(1).HeatRecoveryInletTemp); - EXPECT_DOUBLE_EQ(calculatedOutletTemp, MSHeatPump(1).HeatRecoveryOutletTemp); + EXPECT_DOUBLE_EQ(1000.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryRate); + EXPECT_DOUBLE_EQ(50.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryInletTemp); + EXPECT_DOUBLE_EQ(calculatedOutletTemp, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryOutletTemp); EXPECT_DOUBLE_EQ(52.391772303276724, calculatedOutletTemp); - EXPECT_DOUBLE_EQ(0.1, MSHeatPump(1).HeatRecoveryMassFlowRate); + EXPECT_DOUBLE_EQ(0.1, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryMassFlowRate); DataHVACGlobals::MSHPWasteHeat = 100000.0; // test very high heat transfer that would limit outlet water temperature state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate = 0.1; HVACMultiSpeedHeatPump::MSHPHeatRecovery(*state, 1); // outlet temp should equal max limit of 80 C since 100 kW would cause outlet water temperature to exceed 80 C - EXPECT_DOUBLE_EQ(50.0, MSHeatPump(1).HeatRecoveryInletTemp); - EXPECT_DOUBLE_EQ(80.0, MSHeatPump(1).HeatRecoveryOutletTemp); - EXPECT_DOUBLE_EQ(0.1, MSHeatPump(1).HeatRecoveryMassFlowRate); + EXPECT_DOUBLE_EQ(50.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryInletTemp); + EXPECT_DOUBLE_EQ(80.0, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryOutletTemp); + EXPECT_DOUBLE_EQ(0.1, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryMassFlowRate); Real64 QHeatRecovery = - state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate * 4181.0 * (MSHeatPump(1).HeatRecoveryOutletTemp - MSHeatPump(1).HeatRecoveryInletTemp); - EXPECT_DOUBLE_EQ(QHeatRecovery, MSHeatPump(1).HeatRecoveryRate); + state->dataLoopNodes->Node(HeatRecInNode).MassFlowRate * 4181.0 * (state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryOutletTemp - state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryInletTemp); + EXPECT_DOUBLE_EQ(QHeatRecovery, state->dataHVACMultiSpdHP->MSHeatPump(1).HeatRecoveryRate); EXPECT_DOUBLE_EQ(12543.0, QHeatRecovery); } } // namespace EnergyPlus