diff --git a/src/EnergyPlus/EcoRoofManager.cc b/src/EnergyPlus/EcoRoofManager.cc index 9cc430fa8dc..205c057d8fe 100644 --- a/src/EnergyPlus/EcoRoofManager.cc +++ b/src/EnergyPlus/EcoRoofManager.cc @@ -95,29 +95,6 @@ namespace EcoRoofManager { using namespace DataSurfaces; using namespace DataHeatBalance; - Real64 CumRunoff(0.0); // Cumulative runoff, updated each time step (m) mult by roof area to get volume - Real64 CumET(0.0); // Cumulative evapotranspiration from soil and plants (m) - Real64 CumPrecip(0.0); - Real64 CumIrrigation(0.0); // Cumulative irrigation, updated each time step (m) mult by roof area to get volume - Real64 CurrentRunoff; - Real64 CurrentET; - Real64 CurrentPrecipitation; // units of (m) per timestep - Real64 CurrentIrrigation; // units of (m) per timestep - - Real64 Tfold; // leaf temperature from the previous time step - Real64 Tgold; // ground temperature from the previous time step // TODO: These probably need to be re-initialized - bool EcoRoofbeginFlag(true); - bool CalcEcoRoofMyEnvrnFlag(true); - - void clear_state() { - EcoRoofbeginFlag = true; - CalcEcoRoofMyEnvrnFlag = true; - } - - // MODULE SUBROUTINES: - - //************************************************************************* - // Functions void CalcEcoRoof(EnergyPlusData &state, @@ -320,8 +297,8 @@ namespace EcoRoofManager { Latm = 1.0 * Sigma * 1.0 * state.dataSurface->Surface(SurfNum).ViewFactorGround * pow_4(state.dataEnvrn->GroundTempKelvin) + 1.0 * Sigma * 1.0 * state.dataSurface->Surface(SurfNum).ViewFactorSky * pow_4(state.dataEnvrn->SkyTempKelvin); - if (EcoRoofbeginFlag) { - EcoRoofbeginFlag = false; + if (state.dataEcoRoofMgr->EcoRoofbeginFlag) { + state.dataEcoRoofMgr->EcoRoofbeginFlag = false; if (state.dataSurface->Surface(SurfNum).HeatTransferAlgorithm != HeatTransferModel_CTF) ShowSevereError(state, "CalcEcoRoof: EcoRoof simulation but HeatBalanceAlgorithm is not ConductionTransferFunction(CTF). EcoRoof model " @@ -371,15 +348,57 @@ namespace EcoRoofManager { SetupOutputVariable(state, "Green Roof Soil Latent Heat Transfer Rate per Area", OutputProcessor::Unit::W_m2, Lg, "Zone", "State", "Environment"); - SetupOutputVariable(state, "Green Roof Cumulative Precipitation Depth", OutputProcessor::Unit::m, CumPrecip, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Cumulative Irrigation Depth", OutputProcessor::Unit::m, CumIrrigation, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Cumulative Runoff Depth", OutputProcessor::Unit::m, CumRunoff, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Cumulative Evapotranspiration Depth", OutputProcessor::Unit::m, CumET, "Zone", "Sum", "Environment"); SetupOutputVariable(state, - "Green Roof Current Precipitation Depth", OutputProcessor::Unit::m, CurrentPrecipitation, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Current Irrigation Depth", OutputProcessor::Unit::m, CurrentIrrigation, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Current Runoff Depth", OutputProcessor::Unit::m, CurrentRunoff, "Zone", "Sum", "Environment"); - SetupOutputVariable(state, "Green Roof Current Evapotranspiration Depth", OutputProcessor::Unit::m, CurrentET, "Zone", "Sum", "Environment"); + "Green Roof Cumulative Precipitation Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CumPrecip, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable(state, + "Green Roof Cumulative Irrigation Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CumIrrigation, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable( + state, "Green Roof Cumulative Runoff Depth", OutputProcessor::Unit::m, state.dataEcoRoofMgr->CumRunoff, "Zone", "Sum", "Environment"); + SetupOutputVariable(state, + "Green Roof Cumulative Evapotranspiration Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CumET, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable(state, + "Green Roof Current Precipitation Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CurrentPrecipitation, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable(state, + "Green Roof Current Irrigation Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CurrentIrrigation, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable(state, + "Green Roof Current Runoff Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CurrentRunoff, + "Zone", + "Sum", + "Environment"); + SetupOutputVariable(state, + "Green Roof Current Evapotranspiration Depth", + OutputProcessor::Unit::m, + state.dataEcoRoofMgr->CurrentET, + "Zone", + "Sum", + "Environment"); // DJS NOVEMBER 2010 - end of calls to setup output of ecoroof variables @@ -396,26 +415,26 @@ namespace EcoRoofManager { } // DJS July 2007 - if (state.dataGlobal->BeginEnvrnFlag && CalcEcoRoofMyEnvrnFlag) { - Tgold = OutDryBulbTempAt(state, state.dataSurface->Surface(SurfNum).Centroid.z); // OutDryBulbTemp ! initial guess - Tfold = OutDryBulbTempAt(state, state.dataSurface->Surface(SurfNum).Centroid.z); // OutDryBulbTemp ! initial guess + if (state.dataGlobal->BeginEnvrnFlag && state.dataEcoRoofMgr->CalcEcoRoofMyEnvrnFlag) { + state.dataEcoRoofMgr->Tgold = OutDryBulbTempAt(state, state.dataSurface->Surface(SurfNum).Centroid.z); // OutDryBulbTemp ! initial guess + state.dataEcoRoofMgr->Tfold = OutDryBulbTempAt(state, state.dataSurface->Surface(SurfNum).Centroid.z); // OutDryBulbTemp ! initial guess Tg = 10.0; Tf = 10.0; Vfluxf = 0.0; Vfluxg = 0.0; - CumRunoff = 0.0; - CumET = 0.0; - CumPrecip = 0.0; - CumIrrigation = 0.0; - CurrentRunoff = 0.0; - CurrentET = 0.0; - CurrentPrecipitation = 0.0; - CurrentIrrigation = 0.0; - CalcEcoRoofMyEnvrnFlag = false; + state.dataEcoRoofMgr->CumRunoff = 0.0; + state.dataEcoRoofMgr->CumET = 0.0; + state.dataEcoRoofMgr->CumPrecip = 0.0; + state.dataEcoRoofMgr->CumIrrigation = 0.0; + state.dataEcoRoofMgr->CurrentRunoff = 0.0; + state.dataEcoRoofMgr->CurrentET = 0.0; + state.dataEcoRoofMgr->CurrentPrecipitation = 0.0; + state.dataEcoRoofMgr->CurrentIrrigation = 0.0; + state.dataEcoRoofMgr->CalcEcoRoofMyEnvrnFlag = false; } if (!state.dataGlobal->BeginEnvrnFlag) { - CalcEcoRoofMyEnvrnFlag = true; + state.dataEcoRoofMgr->CalcEcoRoofMyEnvrnFlag = true; } // If current surface is = FirstEcoSurf then for this time step we need to update the soil moisture @@ -424,8 +443,8 @@ namespace EcoRoofManager { state, Moisture, MeanRootMoisture, MoistureMax, MoistureResidual, SoilThickness, Vfluxf, Vfluxg, ConstrNum, Alphag, unit, Tg, Tf, Qsoil); Ta = OutDryBulbTempAt(state, state.dataSurface->Surface(SurfNum).Centroid.z); // temperature outdoor - Surface is dry, use normal correlation - Tg = Tgold; - Tf = Tfold; + Tg = state.dataEcoRoofMgr->Tgold; + Tf = state.dataEcoRoofMgr->Tfold; if (state.dataConstruction->Construct(ConstrNum).CTFCross(0) > 0.01) { QuickConductionSurf = true; @@ -516,7 +535,7 @@ namespace EcoRoofManager { // equation is Henderson-Sellers (1984) Lef = 1.91846e6 * pow_2((Tif + DataGlobalConstants::KelvinConv) / (Tif + DataGlobalConstants::KelvinConv - 33.91)); // Check to see if ice is sublimating or frost is forming. - if (Tfold < 0.0) Lef = 2.838e6; // per FASST documentation p.15 after eqn. 37. + if (state.dataEcoRoofMgr->Tfold < 0.0) Lef = 2.838e6; // per FASST documentation p.15 after eqn. 37. // Derivative of Saturation vapor pressure, which is used in the calculation of // derivative of saturation specific humidity. @@ -532,7 +551,7 @@ namespace EcoRoofManager { // Latent heat vaporization at the ground temperature Leg = 1.91846e6 * pow_2(Tgk / (Tgk - 33.91)); // Check to see if ice is sublimating or frost is forming. - if (Tgold < 0.0) Leg = 2.838e6; // per FASST documentation p.15 after eqn. 37. + if (state.dataEcoRoofMgr->Tgold < 0.0) Leg = 2.838e6; // per FASST documentation p.15 after eqn. 37. Desg = 611.2 * std::exp(17.67 * (Tg / (Tg + DataGlobalConstants::KelvinConv - 29.65))) * (17.67 * Tg * (-1.0) * std::pow(Tg + DataGlobalConstants::KelvinConv - 29.65, -2) + 17.67 / (DataGlobalConstants::KelvinConv - 29.65 + Tg)); @@ -650,14 +669,14 @@ namespace EcoRoofManager { } // This loop does an iterative solution of the simultaneous equations Qsoil = -1.0 * (Qsoilpart1 - Qsoilpart2 * (SoilTK - DataGlobalConstants::KelvinConv)); // This is heat flux INTO top of the soil - Tfold = LeafTK - DataGlobalConstants::KelvinConv; - Tgold = SoilTK - DataGlobalConstants::KelvinConv; + state.dataEcoRoofMgr->Tfold = LeafTK - DataGlobalConstants::KelvinConv; + state.dataEcoRoofMgr->Tgold = SoilTK - DataGlobalConstants::KelvinConv; } // if firstecosurface (if not we do NOT need to recalculate ecoroof energybalance as all ecoroof surfaces MUST be the same // this endif was moved here from the if statement regarding whether we are looking at the first ecoroof surface or not. - TH(1, 1, SurfNum) = Tgold; // SoilTemperature - TempExt = Tgold; + TH(1, 1, SurfNum) = state.dataEcoRoofMgr->Tgold; // SoilTemperature + TempExt = state.dataEcoRoofMgr->Tgold; } void UpdateSoilProps(EnergyPlusData &state, @@ -825,47 +844,47 @@ namespace EcoRoofManager { UpdatebeginFlag = false; } - CurrentRunoff = 0.0; // Initialize current time step runoff as it is used in several spots below... + state.dataEcoRoofMgr->CurrentRunoff = 0.0; // Initialize current time step runoff as it is used in several spots below... // FIRST Subtract water evaporated by plants and at soil surface Moisture -= (Vfluxg)*state.dataGlobal->MinutesPerTimeStep * 60.0 / TopDepth; // soil surface evaporation MeanRootMoisture -= (Vfluxf)*state.dataGlobal->MinutesPerTimeStep * 60.0 / RootDepth; // plant extraction from root zone // NEXT Update evapotranspiration summary variable for print out - CurrentET = (Vfluxg + Vfluxf) * state.dataGlobal->MinutesPerTimeStep * 60.0; // units are meters + state.dataEcoRoofMgr->CurrentET = (Vfluxg + Vfluxf) * state.dataGlobal->MinutesPerTimeStep * 60.0; // units are meters if (!state.dataGlobal->WarmupFlag) { - CumET += CurrentET; + state.dataEcoRoofMgr->CumET += state.dataEcoRoofMgr->CurrentET; } // NEXT Add Precipitation to surface soil moisture variable (if a schedule exists) if (!state.dataGlobal->WarmupFlag) { - CurrentPrecipitation = 0.0; // first initialize to zero + state.dataEcoRoofMgr->CurrentPrecipitation = 0.0; // first initialize to zero } - CurrentPrecipitation = 0.0; // first initialize to zero + state.dataEcoRoofMgr->CurrentPrecipitation = 0.0; // first initialize to zero if (state.dataWaterData->RainFall.ModeID == DataWater::RainfallMode::RainSchedDesign) { - CurrentPrecipitation = state.dataWaterData->RainFall.CurrentAmount; // units of m - Moisture += CurrentPrecipitation / TopDepth; // x (m) evenly put into top layer + state.dataEcoRoofMgr->CurrentPrecipitation = state.dataWaterData->RainFall.CurrentAmount; // units of m + Moisture += state.dataEcoRoofMgr->CurrentPrecipitation / TopDepth; // x (m) evenly put into top layer if (!state.dataGlobal->WarmupFlag) { - CumPrecip += CurrentPrecipitation; + state.dataEcoRoofMgr->CumPrecip += state.dataEcoRoofMgr->CurrentPrecipitation; } } // NEXT Add Irrigation to surface soil moisture variable (if a schedule exists) - CurrentIrrigation = 0.0; // first initialize to zero + state.dataEcoRoofMgr->CurrentIrrigation = 0.0; // first initialize to zero state.dataWaterData->Irrigation.ActualAmount = 0.0; if (state.dataWaterData->Irrigation.ModeID == DataWater::RainfallMode::IrrSchedDesign) { - CurrentIrrigation = state.dataWaterData->Irrigation.ScheduledAmount; // units of m - state.dataWaterData->Irrigation.ActualAmount = CurrentIrrigation; + state.dataEcoRoofMgr->CurrentIrrigation = state.dataWaterData->Irrigation.ScheduledAmount; // units of m + state.dataWaterData->Irrigation.ActualAmount = state.dataEcoRoofMgr->CurrentIrrigation; // elseif (Irrigation%ModeID ==IrrSmartSched .and. moisture .lt. 0.4d0*MoistureMax) then } else if (state.dataWaterData->Irrigation.ModeID == DataWater::RainfallMode::IrrSmartSched && Moisture < state.dataWaterData->Irrigation.IrrigationThreshold * MoistureMax) { // Smart schedule only irrigates when scheduled AND the soil is less than 40% saturated - CurrentIrrigation = state.dataWaterData->Irrigation.ScheduledAmount; // units of m - state.dataWaterData->Irrigation.ActualAmount = CurrentIrrigation; + state.dataEcoRoofMgr->CurrentIrrigation = state.dataWaterData->Irrigation.ScheduledAmount; // units of m + state.dataWaterData->Irrigation.ActualAmount = state.dataEcoRoofMgr->CurrentIrrigation; } - Moisture += CurrentIrrigation / TopDepth; // irrigation in (m)/timestep put into top layer + Moisture += state.dataEcoRoofMgr->CurrentIrrigation / TopDepth; // irrigation in (m)/timestep put into top layer if (!state.dataGlobal->WarmupFlag) { - CumIrrigation += CurrentIrrigation; + state.dataEcoRoofMgr->CumIrrigation += state.dataEcoRoofMgr->CurrentIrrigation; } // Note: If soil top layer gets a massive influx of rain &/or irrigation some of @@ -880,16 +899,18 @@ namespace EcoRoofManager { // I suspect that 15 minute intervals may be needed. Another option is to have an internal moisture // overflow bin that will hold extra moisture and then distribute it in subsequent hours. This way the // soil still gets the same total moisture... it is just distributed over a longer period. - if (CurrentIrrigation + CurrentPrecipitation > 0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0) { - CurrentRunoff = CurrentIrrigation + CurrentPrecipitation - (0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0); + if (state.dataEcoRoofMgr->CurrentIrrigation + state.dataEcoRoofMgr->CurrentPrecipitation > + 0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0) { + state.dataEcoRoofMgr->CurrentRunoff = state.dataEcoRoofMgr->CurrentIrrigation + state.dataEcoRoofMgr->CurrentPrecipitation - + (0.5 * 0.0254 * state.dataGlobal->MinutesPerTimeStep / 60.0); // If we get here then TOO much moisture has already been added to soil (must now subtract excess) - Moisture -= CurrentRunoff / TopDepth; // currently any incident moisture in excess of 1/4 " per hour + Moisture -= state.dataEcoRoofMgr->CurrentRunoff / TopDepth; // currently any incident moisture in excess of 1/4 " per hour // simply runs off the top of the soil. } // Now, if top layer is beyond saturation... the excess simply runs off without penetrating into the lower // layers. if (Moisture > MoistureMax) { - CurrentRunoff += (Moisture - MoistureMax) * TopDepth; + state.dataEcoRoofMgr->CurrentRunoff += (Moisture - MoistureMax) * TopDepth; Moisture = MoistureMax; } @@ -978,7 +999,7 @@ namespace EcoRoofManager { // Now limit the soil from going over the moisture maximum and takes excess to create runoff if (Moisture >= MoistureMax) { // This statement makes sure that the top layer is not over the moisture maximum for the soil. Moisture = 0.9999 * MoistureMax; // then it takes any moisture over the maximum amount and makes it runoff - CurrentRunoff += (Moisture - MoistureMax * 0.9999) * TopDepth; + state.dataEcoRoofMgr->CurrentRunoff += (Moisture - MoistureMax * 0.9999) * TopDepth; } // Now make sure that the soil does not go below the moisture minimum @@ -1003,7 +1024,7 @@ namespace EcoRoofManager { // Limit the moisture from going over the saturation limit and create runoff: if (MeanRootMoisture >= MoistureMax) { MeanRootMoisture = 0.9999 * MoistureMax; - CurrentRunoff += (Moisture - MoistureMax * 0.9999) * RootDepth; + state.dataEcoRoofMgr->CurrentRunoff += (Moisture - MoistureMax * 0.9999) * RootDepth; } // Limit the soil from going below the soil saturation limit: @@ -1012,7 +1033,7 @@ namespace EcoRoofManager { } // Next, track runoff from the bottom of the soil: - CurrentRunoff += SoilConductivityAveRoot * TimeStepZoneSec; + state.dataEcoRoofMgr->CurrentRunoff += SoilConductivityAveRoot * TimeStepZoneSec; //~~~END SF EDITS } @@ -1020,7 +1041,7 @@ namespace EcoRoofManager { // NEXT Limit moisture values to saturation (create RUNOFF that we can track) // CurrentRunoff is sum of "overwatering" in a timestep and excess moisture content if (!state.dataGlobal->WarmupFlag) { - CumRunoff += CurrentRunoff; + state.dataEcoRoofMgr->CumRunoff += state.dataEcoRoofMgr->CurrentRunoff; } if (MeanRootMoisture <= MoistureResidual * 1.00001) { diff --git a/src/EnergyPlus/EcoRoofManager.hh b/src/EnergyPlus/EcoRoofManager.hh index 2772d56a5da..00d192b8ecc 100644 --- a/src/EnergyPlus/EcoRoofManager.hh +++ b/src/EnergyPlus/EcoRoofManager.hh @@ -59,19 +59,6 @@ struct EnergyPlusData; namespace EcoRoofManager { - extern Real64 CumRunoff; // Cumulative runoff, updated each time step (m) mult by roof area to get volume - extern Real64 CumET; // Cumulative evapotranspiration from soil and plants (m) - extern Real64 CumPrecip; - extern Real64 CumIrrigation; // Cumulative irrigation, updated each time step (m) mult by roof area to get volume - extern Real64 CurrentRunoff; - extern Real64 CurrentET; - extern Real64 CurrentPrecipitation; // units of (m) per timestep - extern Real64 CurrentIrrigation; // units of (m) per timestep - - extern Real64 Tfold; // leaf temperature from the previous time step - extern Real64 Tgold; // ground temperature from the previous time step - extern bool EcoRoofbeginFlag; - // Functions void CalcEcoRoof(EnergyPlusData &state, @@ -101,9 +88,24 @@ namespace EcoRoofManager { struct EcoRoofManagerData : BaseGlobalStruct { + Real64 CumRunoff; // Cumulative runoff, updated each time step (m) mult by roof area to get volume + Real64 CumET; // Cumulative evapotranspiration from soil and plants (m) + Real64 CumPrecip; + Real64 CumIrrigation; // Cumulative irrigation, updated each time step (m) mult by roof area to get volume + Real64 CurrentRunoff; + Real64 CurrentET; + Real64 CurrentPrecipitation; // units of (m) per timestep + Real64 CurrentIrrigation; // units of (m) per timestep + + Real64 Tfold; // leaf temperature from the previous time step + Real64 Tgold; // ground temperature from the previous time step + bool EcoRoofbeginFlag = true; + bool CalcEcoRoofMyEnvrnFlag = true; + void clear_state() override { - + this->EcoRoofbeginFlag = true; + this->CalcEcoRoofMyEnvrnFlag = true; } }; diff --git a/src/EnergyPlus/FaultsManager.cc b/src/EnergyPlus/FaultsManager.cc index fe1c3630242..bfd654a88f6 100644 --- a/src/EnergyPlus/FaultsManager.cc +++ b/src/EnergyPlus/FaultsManager.cc @@ -930,22 +930,22 @@ namespace FaultsManager { } } else if (UtilityRoutines::SameString(SELECT_CASE_VAR, "CoilSystem:Heating:DX")) { // Read in DXCoolingSystem input if not done yet - if (HVACDXHeatPumpSystem::GetInputFlag) { + if (state.dataHVACDXHeatPumpSys->GetInputFlag) { HVACDXHeatPumpSystem::GetDXHeatPumpSystemInput(state); - HVACDXHeatPumpSystem::GetInputFlag = false; + state.dataHVACDXHeatPumpSys->GetInputFlag = false; } // Check the coil name and coil type int CoilSysNum = - UtilityRoutines::FindItemInList(FaultsCoilSATSensor(jFault_CoilSAT).CoilName, HVACDXHeatPumpSystem::DXHeatPumpSystem); + UtilityRoutines::FindItemInList(FaultsCoilSATSensor(jFault_CoilSAT).CoilName, state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); if (CoilSysNum <= 0) { ShowSevereError(state, cFaultCurrentObject + " = \"" + cAlphaArgs(1) + "\" invalid " + cAlphaFieldNames(5) + " = \"" + cAlphaArgs(5) + "\" not found."); ErrorsFound = true; } else { // Link the coil system with the fault model - HVACDXHeatPumpSystem::DXHeatPumpSystem(CoilSysNum).FaultyCoilSATFlag = true; - HVACDXHeatPumpSystem::DXHeatPumpSystem(CoilSysNum).FaultyCoilSATIndex = jFault_CoilSAT; + state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(CoilSysNum).FaultyCoilSATFlag = true; + state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(CoilSysNum).FaultyCoilSATIndex = jFault_CoilSAT; } } else if (UtilityRoutines::SameString(SELECT_CASE_VAR, "AirLoopHVAC:UnitarySystem")) { // UnitarySystem model connects to FaultManager via function call to FaultsManager::SetFaultyCoilSATSensor diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.cc b/src/EnergyPlus/HVACDXHeatPumpSystem.cc index f36b2159954..eb7a6e7fd6e 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.cc +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.cc @@ -98,45 +98,6 @@ namespace HVACDXHeatPumpSystem { using namespace DataHVACGlobals; using namespace ScheduleManager; - // Data - // MODULE PARAMETER DEFINITIONS - Real64 const MinAirMassFlow(0.001); - - bool GetInputFlag(true); // Flag to get input only once - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - int NumDXHeatPumpSystems(0); // The Number of DXHeatPumpSystems found in the Input - bool EconomizerFlag(false); // holds air loop economizer status - - // Make this type allocatable - Array1D_bool CheckEquipName; - - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Update routine to check convergence and update nodes - - // Object Data - Array1D DXHeatPumpSystem; - - // MODULE SUBROUTINES: - //************************************************************************* - - // Functions - - void clear_state() - { - GetInputFlag = true; - NumDXHeatPumpSystems = 0; - EconomizerFlag = false; - CheckEquipName.deallocate(); - DXHeatPumpSystem.deallocate(); - } - void SimDXHeatPumpSystem(EnergyPlusData &state, std::string const &DXHeatPumpSystemName, // Name of DXSystem:Airloop object bool const FirstHVACIteration, // True when first HVAC iteration int const AirLoopNum, // Primary air loop number @@ -177,11 +138,14 @@ namespace HVACDXHeatPumpSystem { 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); + // Obtains and Allocates DX Cooling System related parameters from input file - if (GetInputFlag) { // First time subroutine has been entered + if (state.dataHVACDXHeatPumpSys->GetInputFlag) { // First time subroutine has been entered // Get the DXCoolingSystem input GetDXHeatPumpSystemInput(state); - GetInputFlag = false; + state.dataHVACDXHeatPumpSys->GetInputFlag = false; } // Find the correct DXSystemNumber @@ -200,7 +164,7 @@ namespace HVACDXHeatPumpSystem { NumDXHeatPumpSystems, DXHeatPumpSystemName)); } - if (CheckEquipName(DXSystemNum)) { + if (state.dataHVACDXHeatPumpSys->CheckEquipName(DXSystemNum)) { if (DXHeatPumpSystemName != DXHeatPumpSystem(DXSystemNum).Name) { ShowFatalError(state, format("SimDXHeatPumpSystem: Invalid CompIndex passed={}, DX Unit name={}, stored DX Unit Name for that index={}", @@ -208,7 +172,7 @@ namespace HVACDXHeatPumpSystem { DXHeatPumpSystemName, DXHeatPumpSystem(DXSystemNum).Name)); } - CheckEquipName(DXSystemNum) = false; + state.dataHVACDXHeatPumpSys->CheckEquipName(DXSystemNum) = false; } } @@ -323,11 +287,14 @@ namespace HVACDXHeatPumpSystem { 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); + CurrentModuleObject = "CoilSystem:Heating:DX"; NumDXHeatPumpSystems = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); DXHeatPumpSystem.allocate(NumDXHeatPumpSystems); - CheckEquipName.dimension(NumDXHeatPumpSystems, true); + state.dataHVACDXHeatPumpSys->CheckEquipName.dimension(NumDXHeatPumpSystems, true); inputProcessor->getObjectDefMaxArgs(state, "CoilSystem:Heating:DX", TotalArgs, NumAlphas, NumNums); @@ -505,6 +472,8 @@ namespace HVACDXHeatPumpSystem { int OutdoorAirUnitNum; // "ONLY" for ZoneHVAC:OutdoorAirUnit Real64 OAUCoilOutletTemp; // "ONLY" for zoneHVAC:OutdoorAirUnit + auto &NumDXHeatPumpSystems(state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems); + auto &DXHeatPumpSystem(state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); // IF (MyOneTimeFlag) THEN // MyOneTimeFlag = .FALSE. @@ -551,7 +520,7 @@ namespace HVACDXHeatPumpSystem { } else if (AirLoopNum != -1) { // Not Outdoor Air Unit ControlNode = DXHeatPumpSystem(DXSystemNum).DXSystemControlNodeNum; - EconomizerFlag = state.dataAirLoop->AirLoopControlInfo(AirLoopNum).EconoActive; + state.dataHVACDXHeatPumpSys->EconomizerFlag = state.dataAirLoop->AirLoopControlInfo(AirLoopNum).EconoActive; DXHeatPumpSystem(DXSystemNum).DesiredOutletTemp = Node(ControlNode).TempSetPoint; } } @@ -630,6 +599,8 @@ namespace HVACDXHeatPumpSystem { int I; // interation increment Real64 SpeedRatio; // speed ratio between two neighboring speeds + auto &DXHeatPumpSystem(state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); + // Set local variables // Retrieve the load on the controlled zone OutletNode = DXHeatPumpSystem(DXSystemNum).DXHeatPumpCoilOutletNodeNum; @@ -1294,16 +1265,16 @@ namespace HVACDXHeatPumpSystem { int NodeNum; int DXHeatSysNum; - if (GetInputFlag) { // First time subroutine has been entered + if (state.dataHVACDXHeatPumpSys->GetInputFlag) { // First time subroutine has been entered GetDXHeatPumpSystemInput(state); - GetInputFlag = false; + state.dataHVACDXHeatPumpSys->GetInputFlag = false; } NodeNum = 0; - if (NumDXHeatPumpSystems > 0) { - DXHeatSysNum = UtilityRoutines::FindItemInList(DXHeatCoilSysName, DXHeatPumpSystem); - if (DXHeatSysNum > 0 && DXHeatSysNum <= NumDXHeatPumpSystems) { - NodeNum = DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilInletNodeNum; + if (state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems > 0) { + DXHeatSysNum = UtilityRoutines::FindItemInList(DXHeatCoilSysName, state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); + if (DXHeatSysNum > 0 && DXHeatSysNum <= state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems) { + NodeNum = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilInletNodeNum; } } if (NodeNum == 0) InletNodeErrFlag = true; @@ -1323,16 +1294,16 @@ namespace HVACDXHeatPumpSystem { int NodeNum; int DXHeatSysNum; - if (GetInputFlag) { // First time subroutine has been entered + if (state.dataHVACDXHeatPumpSys->GetInputFlag) { // First time subroutine has been entered GetDXHeatPumpSystemInput(state); - GetInputFlag = false; + state.dataHVACDXHeatPumpSys->GetInputFlag = false; } NodeNum = 0; - if (NumDXHeatPumpSystems > 0) { - DXHeatSysNum = UtilityRoutines::FindItemInList(DXHeatCoilSysName, DXHeatPumpSystem); - if (DXHeatSysNum > 0 && DXHeatSysNum <= NumDXHeatPumpSystems) { - NodeNum = DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilOutletNodeNum; + if (state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems > 0) { + DXHeatSysNum = UtilityRoutines::FindItemInList(DXHeatCoilSysName, state.dataHVACDXHeatPumpSys->DXHeatPumpSystem); + if (DXHeatSysNum > 0 && DXHeatSysNum <= state.dataHVACDXHeatPumpSys->NumDXHeatPumpSystems) { + NodeNum = state.dataHVACDXHeatPumpSys->DXHeatPumpSystem(DXHeatSysNum).DXHeatPumpCoilOutletNodeNum; } } if (NodeNum == 0) OutletNodeErrFlag = true; diff --git a/src/EnergyPlus/HVACDXHeatPumpSystem.hh b/src/EnergyPlus/HVACDXHeatPumpSystem.hh index 42eff683ae5..1603aea96df 100644 --- a/src/EnergyPlus/HVACDXHeatPumpSystem.hh +++ b/src/EnergyPlus/HVACDXHeatPumpSystem.hh @@ -64,35 +64,14 @@ struct EnergyPlusData; namespace HVACDXHeatPumpSystem { - // Using/Aliasing - - // Data // MODULE PARAMETER DEFINITIONS - extern Real64 const MinAirMassFlow; + constexpr Real64 MinAirMassFlow(0.001); // Compressor operation constexpr int On(1); // normal compressor operation constexpr int Off(0); // signal DXCoil that compressor shouldn't run - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - extern int NumDXHeatPumpSystems; // The Number of DXHeatPumpSystems found in the Input - extern bool EconomizerFlag; // holds air loop economizer status - extern bool GetInputFlag; // Flag to get input only once - - // Make this type allocatable - extern Array1D_bool CheckEquipName; - - // Subroutine Specifications for the Module - // Driver/Manager Routines - - // Get Input routines for module - - // Update routine to check convergence and update nodes - // Types - struct DXHeatPumpSystemStruct { // Members @@ -136,13 +115,6 @@ namespace HVACDXHeatPumpSystem { } }; - // Object Data - extern Array1D DXHeatPumpSystem; - - // Functions - - void clear_state(); - void SimDXHeatPumpSystem(EnergyPlusData &state, std::string const &DXHeatPumpSystemName, // Name of DXSystem:Airloop object bool const FirstHVACIteration, // True when first HVAC iteration int const AirLoopNum, // Primary air loop number @@ -206,10 +178,20 @@ namespace HVACDXHeatPumpSystem { } // namespace HVACDXHeatPumpSystem struct HVACDXHeatPumpSystemData : BaseGlobalStruct { + + int NumDXHeatPumpSystems = 0; // The Number of DXHeatPumpSystems found in the Input + bool EconomizerFlag = false; // holds air loop economizer status + bool GetInputFlag = true; // Flag to get input only once + Array1D_bool CheckEquipName; + Array1D DXHeatPumpSystem; void clear_state() override { - + this->GetInputFlag = true; + this->NumDXHeatPumpSystems = 0; + this->EconomizerFlag = false; + this->CheckEquipName.deallocate(); + this->DXHeatPumpSystem.deallocate(); } }; diff --git a/src/EnergyPlus/HVACUnitaryBypassVAV.cc b/src/EnergyPlus/HVACUnitaryBypassVAV.cc index 2eb3bb0c489..a0d11d62ae4 100644 --- a/src/EnergyPlus/HVACUnitaryBypassVAV.cc +++ b/src/EnergyPlus/HVACUnitaryBypassVAV.cc @@ -128,68 +128,8 @@ namespace HVACUnitaryBypassVAV { // "Ventilation for Changeover-Bypass VAV Systems," D. Stanke, ASHRAE Journal Vol. 46, No. 11, November 2004. // Lawrence Berkeley Laboratory. Nov. 1993. DOE-2 Supplement Version 2.1E, Winklemann et.al. - // Dehumidification control modes (DehumidControlMode) for Multimode units only - int const DehumidControl_None(0); - int const DehumidControl_Multimode(1); - int const DehumidControl_CoolReheat(2); - - // Mode of operation - int const CoolingMode(1); // System operating mode is cooling - int const HeatingMode(2); // System operating mode is heating - - // Priority control mode (prioritized thermostat signal) - int const CoolingPriority(1); // Controls CBVAV system based on cooling priority - int const HeatingPriority(2); // Controls CBVAV system based on heating priority - int const ZonePriority(3); // Controls CBVAV system based on number of zones priority - int const LoadPriority(4); // Controls CBVAV system based on total load priority - - // Airflow control for contant fan mode - int const UseCompressorOnFlow(1); // Set compressor OFF air flow rate equal to compressor ON air flow rate - int const UseCompressorOffFlow(2); // Set compressor OFF air flow rate equal to user defined value - static std::string const fluidNameSteam("STEAM"); - int NumCBVAV(0); // Number of CBVAV systems in input file - Real64 CompOnMassFlow(0.0); // System air mass flow rate w/ compressor ON - Real64 OACompOnMassFlow(0.0); // OA mass flow rate w/ compressor ON - Real64 CompOffMassFlow(0.0); // System air mass flow rate w/ compressor OFF - Real64 OACompOffMassFlow(0.0); // OA 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); // ratio of air flow ratio passed to fan object - Real64 BypassDuctFlowFraction(0.0); // Fraction of unit mass flow that returns to inlet of CBVAV unit through bypass duct - Real64 PartLoadFrac(0.0); // Compressor part-load fraction - Real64 SaveCompressorPLR(0.0); // Holds DX compressor PLR from active DX coil - Real64 TempSteamIn(100.0); // steam coil steam inlet temperature - Array1D_bool CheckEquipName; - bool GetInputFlag(true); // Flag set to make sure you get input once - - // SUBROUTINE SPECIFICATIONS FOR MODULE - - // Object Data - Array1D CBVAV; - - // Functions - - void clear_state() - { - CBVAV.deallocate(); - NumCBVAV = 0; - CompOnMassFlow = 0.0; - OACompOnMassFlow = 0.0; - CompOffMassFlow = 0.0; - OACompOffMassFlow = 0.0; - CompOnFlowRatio = 0.0; - CompOffFlowRatio = 0.0; - FanSpeedRatio = 0.0; - BypassDuctFlowFraction = 0.0; - PartLoadFrac = 0.0; - SaveCompressorPLR = 0.0; - TempSteamIn = 100.0; - CheckEquipName.deallocate(); - GetInputFlag = true; - } - void SimUnitaryBypassVAV(EnergyPlusData &state, std::string const &CompName, // Name of the CBVAV system bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system time step @@ -210,35 +150,37 @@ namespace HVACUnitaryBypassVAV { Real64 QUnitOut = 0.0; // Sensible capacity delivered by this air loop system // First time SimUnitaryBypassVAV is called, get the input for all the CBVAVs - if (GetInputFlag) { + if (state.dataHVACUnitaryBypassVAV->GetInputFlag) { GetCBVAV(state); - GetInputFlag = false; + state.dataHVACUnitaryBypassVAV->GetInputFlag = false; } // Find the correct changeover-bypass VAV unit if (CompIndex == 0) { - CBVAVNum = UtilityRoutines::FindItemInList(CompName, CBVAV); + CBVAVNum = UtilityRoutines::FindItemInList(CompName, state.dataHVACUnitaryBypassVAV->CBVAV); if (CBVAVNum == 0) { ShowFatalError(state, "SimUnitaryBypassVAV: Unit not found=" + CompName); } CompIndex = CBVAVNum; } else { CBVAVNum = CompIndex; - if (CBVAVNum > NumCBVAV || CBVAVNum < 1) { + if (CBVAVNum > state.dataHVACUnitaryBypassVAV->NumCBVAV || CBVAVNum < 1) { ShowFatalError( state, - format( - "SimUnitaryBypassVAV: Invalid CompIndex passed={}, Number of Units={}, Entered Unit name={}", CBVAVNum, NumCBVAV, CompName)); + format("SimUnitaryBypassVAV: Invalid CompIndex passed={}, Number of Units={}, Entered Unit name={}", + CBVAVNum, + state.dataHVACUnitaryBypassVAV->NumCBVAV, + CompName)); } - if (CheckEquipName(CBVAVNum)) { - if (CompName != CBVAV(CBVAVNum).Name) { + if (state.dataHVACUnitaryBypassVAV->CheckEquipName(CBVAVNum)) { + if (CompName != state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum).Name) { ShowFatalError(state, format("SimUnitaryBypassVAV: Invalid CompIndex passed={}, Unit name={}, stored Unit Name for that index={}", CBVAVNum, CompName, - CBVAV(CBVAVNum).Name)); + state.dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum).Name)); } - CheckEquipName(CBVAVNum) = false; + state.dataHVACUnitaryBypassVAV->CheckEquipName(CBVAVNum) = false; } } @@ -276,12 +218,14 @@ namespace HVACUnitaryBypassVAV { QSensUnitOut = 0.0; // probably don't need this initialization Real64 HeatingPower; // Power consumption of DX heating coil or electric heating coil [W] + + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); // zero the fan and DX coils electricity consumption DataHVACGlobals::DXElecCoolingPower = 0.0; DataHVACGlobals::DXElecHeatingPower = 0.0; DataHVACGlobals::ElecHeatingCoilPower = 0.0; - SaveCompressorPLR = 0.0; + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = 0.0; // initialize local variables bool UnitOn = true; @@ -330,7 +274,7 @@ namespace HVACUnitaryBypassVAV { Psychrometrics::PsyHFnTdbW(DataLoopNode::Node(InletNode).Temp, MinOutletHumRat)); // report variables - CBVAV(CBVAVNum).CompPartLoadRatio = SaveCompressorPLR; + CBVAV(CBVAVNum).CompPartLoadRatio = state.dataHVACUnitaryBypassVAV->SaveCompressorPLR; if (UnitOn) { CBVAV(CBVAVNum).FanPartLoadRatio = 1.0; } else { @@ -409,11 +353,15 @@ namespace HVACUnitaryBypassVAV { // find the number of each type of CBVAV unit std::string CurrentModuleObject = "AirLoopHVAC:UnitaryHeatCool:VAVChangeoverBypass"; + + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + auto &NumCBVAV(state.dataHVACUnitaryBypassVAV->NumCBVAV); + NumCBVAV = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); // allocate the data structures CBVAV.allocate(NumCBVAV); - CheckEquipName.dimension(NumCBVAV, true); + state.dataHVACUnitaryBypassVAV->CheckEquipName.dimension(NumCBVAV, true); // loop over CBVAV units; get and load the input data for (int CBVAVNum = 1; CBVAVNum <= NumCBVAV; ++CBVAVNum) { @@ -889,9 +837,9 @@ namespace HVACUnitaryBypassVAV { // UseCompressorOffFlow = operate at value specified by user (no input for this object type, UseCompONFlow) // AirFlowControl only valid if fan opmode = DataHVACGlobals::ContFanCycCoil if (CBVAV(CBVAVNum).MaxNoCoolHeatAirVolFlow == 0.0) { - CBVAV(CBVAVNum).AirFlowControl = UseCompressorOnFlow; + CBVAV(CBVAVNum).AirFlowControl = AirFlowCtrlMode::UseCompressorOnFlow; } else { - CBVAV(CBVAVNum).AirFlowControl = UseCompressorOffFlow; + CBVAV(CBVAVNum).AirFlowControl = AirFlowCtrlMode::UseCompressorOffFlow; } } @@ -903,9 +851,9 @@ namespace HVACUnitaryBypassVAV { } CBVAV(CBVAVNum).OpMode = DataHVACGlobals::ContFanCycCoil; if (CBVAV(CBVAVNum).MaxNoCoolHeatAirVolFlow == 0.0) { - CBVAV(CBVAVNum).AirFlowControl = UseCompressorOnFlow; + CBVAV(CBVAVNum).AirFlowControl = AirFlowCtrlMode::UseCompressorOnFlow; } else { - CBVAV(CBVAVNum).AirFlowControl = UseCompressorOffFlow; + CBVAV(CBVAVNum).AirFlowControl = AirFlowCtrlMode::UseCompressorOffFlow; } } @@ -1010,8 +958,8 @@ namespace HVACUnitaryBypassVAV { SteamCoils::GetCoilSteamInletNode(state, CBVAV(CBVAVNum).HeatCoilIndex, CBVAV(CBVAVNum).HeatCoilName, errFlag); CBVAV(CBVAVNum).MaxHeatCoilFluidFlow = SteamCoils::GetCoilMaxSteamFlowRate(state, CBVAV(CBVAVNum).HeatCoilIndex, errFlag); int SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - Real64 SteamDensity = - FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, getUnitaryHeatCoolVAVChangeoverBypass); + Real64 SteamDensity = FluidProperties::GetSatDensityRefrig( + state, fluidNameSteam, state.dataHVACUnitaryBypassVAV->TempSteamIn, 1.0, SteamIndex, getUnitaryHeatCoolVAVChangeoverBypass); if (CBVAV(CBVAVNum).MaxHeatCoilFluidFlow > 0.0) { CBVAV(CBVAVNum).MaxHeatCoilFluidFlow = SteamCoils::GetCoilMaxSteamFlowRate(state, CBVAV(CBVAVNum).HeatCoilIndex, errFlag) * SteamDensity; @@ -1064,13 +1012,13 @@ namespace HVACUnitaryBypassVAV { } if (UtilityRoutines::SameString(Alphas(18), "CoolingPriority")) { - CBVAV(CBVAVNum).PriorityControl = CoolingPriority; + CBVAV(CBVAVNum).PriorityControl = PriorityCtrlMode::CoolingPriority; } else if (UtilityRoutines::SameString(Alphas(18), "HeatingPriority")) { - CBVAV(CBVAVNum).PriorityControl = HeatingPriority; + CBVAV(CBVAVNum).PriorityControl = PriorityCtrlMode::HeatingPriority; } else if (UtilityRoutines::SameString(Alphas(18), "ZonePriority")) { - CBVAV(CBVAVNum).PriorityControl = ZonePriority; + CBVAV(CBVAVNum).PriorityControl = PriorityCtrlMode::ZonePriority; } else if (UtilityRoutines::SameString(Alphas(18), "LoadPriority")) { - CBVAV(CBVAVNum).PriorityControl = LoadPriority; + CBVAV(CBVAVNum).PriorityControl = PriorityCtrlMode::LoadPriority; } else { ShowSevereError(state, CurrentModuleObject + " illegal " + cAlphaFields(18) + " = " + Alphas(18)); ShowContinueError(state, "Occurs in " + CurrentModuleObject + " = " + CBVAV(CBVAVNum).Name); @@ -1099,28 +1047,28 @@ namespace HVACUnitaryBypassVAV { // Dehumidification control mode if (UtilityRoutines::SameString(Alphas(19), "None")) { - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_None; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } else if (UtilityRoutines::SameString(Alphas(19), "")) { - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_None; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } else if (UtilityRoutines::SameString(Alphas(19), "Multimode")) { if (CBVAV(CBVAVNum).DXCoolCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoStageWHumControl) { - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_Multimode; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::Multimode; } else { ShowWarningError(state, "Invalid " + cAlphaFields(19) + " = " + Alphas(19)); ShowContinueError(state, "In " + CurrentModuleObject + " \"" + CBVAV(CBVAVNum).Name + "\"."); ShowContinueError(state, "Valid only with " + cAlphaFields(14) + " = Coil:Cooling:DX:TwoStageWithHumidityControlMode."); ShowContinueError(state, "Setting " + cAlphaFields(19) + " to \"None\" and the simulation continues."); - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_None; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } } else if (UtilityRoutines::SameString(Alphas(19), "CoolReheat")) { if (CBVAV(CBVAVNum).DXCoolCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoStageWHumControl) { - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_CoolReheat; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::CoolReheat; } else { ShowWarningError(state, "Invalid " + cAlphaFields(19) + " = " + Alphas(19)); ShowContinueError(state, "In " + CurrentModuleObject + " \"" + CBVAV(CBVAVNum).Name + "\"."); ShowContinueError(state, "Valid only with " + cAlphaFields(14) + " = Coil:Cooling:DX:TwoStageWithHumidityControlMode."); ShowContinueError(state, "Setting " + cAlphaFields(19) + " to \"None\" and the simulation continues."); - CBVAV(CBVAVNum).DehumidControlType = DehumidControl_None; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } } else { ShowSevereError(state, "Invalid " + cAlphaFields(19) + " =" + Alphas(19)); @@ -1448,6 +1396,9 @@ namespace HVACUnitaryBypassVAV { bool ErrorFlag; // local error flag returned from data mining Real64 mdot; // heating coil fluid mass flow rate, kg/s + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + auto &NumCBVAV(state.dataHVACUnitaryBypassVAV->NumCBVAV); + int InNode = CBVAV(CBVAVNum).AirInNode; int OutNode = CBVAV(CBVAVNum).AirOutNode; @@ -1529,7 +1480,8 @@ namespace HVACUnitaryBypassVAV { if (CBVAV(CBVAVNum).MaxHeatCoilFluidFlow > 0.0) { int SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - Real64 FluidDensity = FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + Real64 FluidDensity = FluidProperties::GetSatDensityRefrig( + state, fluidNameSteam, state.dataHVACUnitaryBypassVAV->TempSteamIn, 1.0, SteamIndex, RoutineName); CBVAV(CBVAVNum).MaxHeatCoilFluidFlow = SteamCoils::GetCoilMaxSteamFlowRate(state, CBVAV(CBVAVNum).HeatCoilIndex, ErrorsFound) * FluidDensity; } @@ -1627,7 +1579,8 @@ namespace HVACUnitaryBypassVAV { } if (CoilMaxVolFlowRate != DataSizing::AutoSize) { int SteamIndex = 0; // Function GetSatDensityRefrig will look up steam index if 0 is passed - Real64 FluidDensity = FluidProperties::GetSatDensityRefrig(state, fluidNameSteam, TempSteamIn, 1.0, SteamIndex, RoutineName); + Real64 FluidDensity = FluidProperties::GetSatDensityRefrig( + state, fluidNameSteam, state.dataHVACUnitaryBypassVAV->TempSteamIn, 1.0, SteamIndex, RoutineName); CBVAV(CBVAVNum).MaxHeatCoilFluidFlow = CoilMaxVolFlowRate * FluidDensity; } } @@ -1788,64 +1741,64 @@ namespace HVACUnitaryBypassVAV { if (CBVAV(CBVAVNum).OpMode == DataHVACGlobals::ContFanCycCoil) { // constant fan mode if (CBVAV(CBVAVNum).HeatCoolMode == HeatingMode) { - CompOnMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; } else if (CBVAV(CBVAVNum).HeatCoolMode == CoolingMode) { - CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; } else { - CompOnMassFlow = CBVAV(CBVAVNum).MaxNoCoolHeatAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).NoHeatCoolSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).NoCoolHeatOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxNoCoolHeatAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).NoHeatCoolSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).NoCoolHeatOutAirMassFlow * OutsideAirMultiplier; } - if (CBVAV(CBVAVNum).AirFlowControl == UseCompressorOnFlow) { + if (CBVAV(CBVAVNum).AirFlowControl == AirFlowCtrlMode::UseCompressorOnFlow) { if (CBVAV(CBVAVNum).LastMode == HeatingMode) { - CompOffMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; - CompOffFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; - OACompOffMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOffMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOffFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOffMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; } else { - CompOffMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; - CompOffFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; - OACompOffMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOffMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOffFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOffMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; } } else { - CompOffMassFlow = CBVAV(CBVAVNum).MaxNoCoolHeatAirMassFlow; - CompOffFlowRatio = CBVAV(CBVAVNum).NoHeatCoolSpeedRatio; - OACompOffMassFlow = CBVAV(CBVAVNum).NoCoolHeatOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOffMassFlow = CBVAV(CBVAVNum).MaxNoCoolHeatAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOffFlowRatio = CBVAV(CBVAVNum).NoHeatCoolSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOffMassFlow = CBVAV(CBVAVNum).NoCoolHeatOutAirMassFlow * OutsideAirMultiplier; } } else { // cycling fan mode if (CBVAV(CBVAVNum).HeatCoolMode == HeatingMode) { - CompOnMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxHeatAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).HeatingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).HeatOutAirMassFlow * OutsideAirMultiplier; } else if (CBVAV(CBVAVNum).HeatCoolMode == CoolingMode) { - CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; } else { - CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; - CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; - OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; + state.dataHVACUnitaryBypassVAV->CompOnMassFlow = CBVAV(CBVAVNum).MaxCoolAirMassFlow; + state.dataHVACUnitaryBypassVAV->CompOnFlowRatio = CBVAV(CBVAVNum).CoolingSpeedRatio; + state.dataHVACUnitaryBypassVAV->OACompOnMassFlow = CBVAV(CBVAVNum).CoolOutAirMassFlow * OutsideAirMultiplier; } - CompOffMassFlow = 0.0; - CompOffFlowRatio = 0.0; - OACompOffMassFlow = 0.0; + state.dataHVACUnitaryBypassVAV->CompOffMassFlow = 0.0; + state.dataHVACUnitaryBypassVAV->CompOffFlowRatio = 0.0; + state.dataHVACUnitaryBypassVAV->OACompOffMassFlow = 0.0; } // Check for correct control node at outlet of unit if (CBVAV(CBVAVNum).HumRatMaxCheck) { - if (CBVAV(CBVAVNum).DehumidControlType > 0) { + if (CBVAV(CBVAVNum).DehumidControlType != DehumidControl::None) { if (DataLoopNode::Node(OutNode).HumRatMax == DataLoopNode::SensedNodeFlagValue) { if (!state.dataGlobal->AnyEnergyManagementSystemInModel) { ShowWarningError(state, "Unitary System:VAV:ChangeOverBypass = " + CBVAV(CBVAVNum).Name); ShowContinueError(state, "Use SetpointManager:SingleZone:Humidity:Maximum to place a humidity setpoint at the air outlet node of " "the unitary system."); ShowContinueError(state, "Setting Dehumidification Control Type to None and simulation continues."); - CBVAV(CBVAVNum).DehumidControlType = 0; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } else { // need call to EMS to check node EMSSetPointCheck = false; @@ -1859,7 +1812,7 @@ namespace HVACUnitaryBypassVAV { ShowContinueError(state, "Or use an EMS Actuator to place a maximum humidity setpoint at the air outlet node of the unitary system."); ShowContinueError(state, "Setting Dehumidification Control Type to None and simulation continues."); - CBVAV(CBVAVNum).DehumidControlType = 0; + CBVAV(CBVAVNum).DehumidControlType = DehumidControl::None; } else if (!foundControl) { // Couldn't find a control, but no error? There are some plugins, so adjust warning message accordingly ShowWarningError(state, "Unitary System:VAV:ChangeOverBypass = " + CBVAV(CBVAVNum).Name); @@ -1883,31 +1836,32 @@ namespace HVACUnitaryBypassVAV { } // Set the inlet node mass flow rate - if (ScheduleManager::GetCurrentScheduleValue(state, CBVAV(CBVAVNum).SchedPtr) > 0.0 && CompOnMassFlow != 0.0) { + if (ScheduleManager::GetCurrentScheduleValue(state, CBVAV(CBVAVNum).SchedPtr) > 0.0 && state.dataHVACUnitaryBypassVAV->CompOnMassFlow != 0.0) { OnOffAirFlowRatio = 1.0; if (FirstHVACIteration) { - DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate = CompOnMassFlow; - DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate = CompOnMassFlow; - DataLoopNode::Node(CBVAV(CBVAVNum).MixerOutsideAirNode).MassFlowRate = OACompOnMassFlow; - DataLoopNode::Node(CBVAV(CBVAVNum).MixerReliefAirNode).MassFlowRate = OACompOnMassFlow; - BypassDuctFlowFraction = 0.0; - PartLoadFrac = 0.0; + DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; + DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; + DataLoopNode::Node(CBVAV(CBVAVNum).MixerOutsideAirNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->OACompOnMassFlow; + DataLoopNode::Node(CBVAV(CBVAVNum).MixerReliefAirNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->OACompOnMassFlow; + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = 0.0; + state.dataHVACUnitaryBypassVAV->PartLoadFrac = 0.0; } else { if (CBVAV(CBVAVNum).HeatCoolMode != 0) { - PartLoadFrac = 1.0; + state.dataHVACUnitaryBypassVAV->PartLoadFrac = 1.0; } else { - PartLoadFrac = 0.0; + state.dataHVACUnitaryBypassVAV->PartLoadFrac = 0.0; } if (CBVAV(CBVAVNum).OpMode == DataHVACGlobals::CycFanCycCoil) { - BypassDuctFlowFraction = 0.0; + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = 0.0; } else { if (CBVAV(CBVAVNum).PlenumMixerInletAirNode == 0) { - BypassDuctFlowFraction = max(0.0, 1.0 - (DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate / CompOnMassFlow)); + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = max( + 0.0, 1.0 - (DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate / state.dataHVACUnitaryBypassVAV->CompOnMassFlow)); } } } } else { - PartLoadFrac = 0.0; + state.dataHVACUnitaryBypassVAV->PartLoadFrac = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).AirOutNode).MassFlowRate = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).AirOutNode).MassFlowRateMaxAvail = 0.0; @@ -1917,10 +1871,10 @@ namespace HVACUnitaryBypassVAV { DataLoopNode::Node(CBVAV(CBVAVNum).MixerReliefAirNode).MassFlowRate = 0.0; OnOffAirFlowRatio = 1.0; - BypassDuctFlowFraction = 0.0; + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = 0.0; } - CalcCBVAV(state, CBVAVNum, FirstHVACIteration, PartLoadFrac, QSensUnitOut, OnOffAirFlowRatio, HXUnitOn); + CalcCBVAV(state, CBVAVNum, FirstHVACIteration, state.dataHVACUnitaryBypassVAV->PartLoadFrac, QSensUnitOut, OnOffAirFlowRatio, HXUnitOn); // If unit is scheduled OFF, setpoint is equal to inlet node temperature. if (ScheduleManager::GetCurrentScheduleValue(state, CBVAV(CBVAVNum).SchedPtr) == 0.0) { @@ -1945,7 +1899,7 @@ namespace HVACUnitaryBypassVAV { WaterCoils::SimulateWaterCoilComponents(state, CBVAV(CBVAVNum).HeatCoilName, FirstHVACIteration, CBVAV(CBVAVNum).HeatCoilIndex); // set air-side and steam-side mass flow rates - DataLoopNode::Node(CBVAV(CBVAVNum).HeatingCoilInletNode).MassFlowRate = CompOnMassFlow; + DataLoopNode::Node(CBVAV(CBVAVNum).HeatingCoilInletNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; mdot = CBVAV(CBVAVNum).MaxHeatCoilFluidFlow; PlantUtilities::SetComponentFlowRate(state, mdot, CBVAV(CBVAVNum).CoilControlNode, @@ -1965,7 +1919,7 @@ namespace HVACUnitaryBypassVAV { if (CBVAV(CBVAVNum).HeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) { // set air-side and steam-side mass flow rates - DataLoopNode::Node(CBVAV(CBVAVNum).HeatingCoilInletNode).MassFlowRate = CompOnMassFlow; + DataLoopNode::Node(CBVAV(CBVAVNum).HeatingCoilInletNode).MassFlowRate = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; mdot = CBVAV(CBVAVNum).MaxHeatCoilFluidFlow; PlantUtilities::SetComponentFlowRate(state, mdot, CBVAV(CBVAVNum).CoilControlNode, @@ -1987,8 +1941,9 @@ namespace HVACUnitaryBypassVAV { } // from IF(CBVAV(CBVAVNum)%HeatCoilType_Num == DataHVACGlobals::Coil_HeatingSteam) THEN } // from IF( FirstHVACIteration ) THEN - if ((CBVAV(CBVAVNum).HeatCoolMode == 0 && CBVAV(CBVAVNum).OpMode == DataHVACGlobals::CycFanCycCoil) || CompOnMassFlow == 0.0) { - PartLoadFrac = 0.0; + if ((CBVAV(CBVAVNum).HeatCoolMode == 0 && CBVAV(CBVAVNum).OpMode == DataHVACGlobals::CycFanCycCoil) || + state.dataHVACUnitaryBypassVAV->CompOnMassFlow == 0.0) { + state.dataHVACUnitaryBypassVAV->PartLoadFrac = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).AirInNode).MassFlowRate = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).AirOutNode).MassFlowRateMaxAvail = 0.0; DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate = 0.0; @@ -2013,6 +1968,8 @@ namespace HVACUnitaryBypassVAV { int curSysNum = state.dataSize->CurSysNum; int curOASysNum = state.dataSize->CurOASysNum; + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + if (curSysNum > 0 && curOASysNum == 0) { if (CBVAV(CBVAVNum).FanType_Num == DataHVACGlobals::FanType_SystemModelObject) { state.dataAirSystemsData->PrimaryAirSystems(curSysNum).supFanVecIndex = CBVAV(CBVAVNum).FanIndex; @@ -2191,6 +2148,8 @@ namespace HVACUnitaryBypassVAV { Real64 FullOutput = 0; // Unit full output when compressor is operating [W] PartLoadFrac = 0.0; + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + if (ScheduleManager::GetCurrentScheduleValue(state, CBVAV(CBVAVNum).SchedPtr) == 0.0) return; // Get operating result @@ -2239,6 +2198,7 @@ namespace HVACUnitaryBypassVAV { Real64 OutdoorDryBulbTemp; // Dry-bulb temperature at outdoor condenser Real64 OutdoorBaroPress; // Barometric pressure at outdoor condenser + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); int OutletNode = CBVAV(CBVAVNum).AirOutNode; int InletNode = CBVAV(CBVAVNum).AirInNode; @@ -2250,7 +2210,7 @@ namespace HVACUnitaryBypassVAV { OutdoorBaroPress = state.dataEnvrn->OutBaroPress; } - SaveCompressorPLR = 0.0; + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = 0.0; // Bypass excess system air through bypass duct and calculate new mixed air conditions at OA mixer inlet node if (CBVAV(CBVAVNum).plenumIndex > 0 || CBVAV(CBVAVNum).mixerIndex > 0) { @@ -2259,9 +2219,11 @@ namespace HVACUnitaryBypassVAV { DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate = saveMixerInletAirNodeFlow; } else { DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).Temp = - (1.0 - BypassDuctFlowFraction) * DataLoopNode::Node(InletNode).Temp + BypassDuctFlowFraction * DataLoopNode::Node(OutletNode).Temp; - DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).HumRat = (1.0 - BypassDuctFlowFraction) * DataLoopNode::Node(InletNode).HumRat + - BypassDuctFlowFraction * DataLoopNode::Node(OutletNode).HumRat; + (1.0 - state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction) * DataLoopNode::Node(InletNode).Temp + + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction * DataLoopNode::Node(OutletNode).Temp; + DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).HumRat = + (1.0 - state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction) * DataLoopNode::Node(InletNode).HumRat + + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction * DataLoopNode::Node(OutletNode).HumRat; DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).Enthalpy = Psychrometrics::PsyHFnTdbW( DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).Temp, DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).HumRat); } @@ -2271,7 +2233,8 @@ namespace HVACUnitaryBypassVAV { if (CBVAV(CBVAVNum).FanType_Num == DataHVACGlobals::FanType_SystemModelObject) { HVACFan::fanObjs[CBVAV(CBVAVNum).FanIndex]->simulate(state, 1.0 / OnOffAirFlowRatio, _, _, _); } else { - Fans::SimulateFanComponents(state, CBVAV(CBVAVNum).FanName, FirstHVACIteration, CBVAV(CBVAVNum).FanIndex, FanSpeedRatio); + Fans::SimulateFanComponents( + state, CBVAV(CBVAVNum).FanName, FirstHVACIteration, CBVAV(CBVAVNum).FanIndex, state.dataHVACUnitaryBypassVAV->FanSpeedRatio); } } // Simulate cooling coil if zone load is negative (cooling load) @@ -2436,7 +2399,8 @@ namespace HVACUnitaryBypassVAV { } } } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = + state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); } else if (SELECT_CASE_var == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) { Real64 QZnReq(0.0); // Zone load (W), input to variable-speed DX coil Real64 QLatReq(0.0); // Zone latent load, input to variable-speed DX coil @@ -2715,7 +2679,8 @@ namespace HVACUnitaryBypassVAV { } else if (PartLoadFrac < 0.0) { PartLoadFrac = 0.0; } - SaveCompressorPLR = VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).CoolCoilCompIndex); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = + VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).CoolCoilCompIndex); // variable-speed air-to-air cooling coil, end ------------------------- } else if (SELECT_CASE_var == DataHVACGlobals::CoilDX_CoolingTwoStageWHumControl) { @@ -2801,7 +2766,7 @@ namespace HVACUnitaryBypassVAV { if ((DataLoopNode::Node(CBVAV(CBVAVNum).DXCoilOutletNode).HumRat > DataLoopNode::Node(OutletNode).HumRatMax) && (DataLoopNode::Node(CBVAV(CBVAVNum).DXCoilInletNode).HumRat > DataLoopNode::Node(OutletNode).HumRatMax) && - (CBVAV(CBVAVNum).DehumidControlType == DehumidControl_Multimode) && DataLoopNode::Node(OutletNode).HumRatMax > 0.0) { + (CBVAV(CBVAVNum).DehumidControlType == DehumidControl::Multimode) && DataLoopNode::Node(OutletNode).HumRatMax > 0.0) { // Determine required part load for enhanced dehumidification mode 1 @@ -2875,7 +2840,7 @@ namespace HVACUnitaryBypassVAV { if ((DataLoopNode::Node(CBVAV(CBVAVNum).DXCoilOutletNode).HumRat > DataLoopNode::Node(OutletNode).HumRatMax) && (DataLoopNode::Node(CBVAV(CBVAVNum).DXCoilInletNode).HumRat > DataLoopNode::Node(OutletNode).HumRatMax) && - (CBVAV(CBVAVNum).DehumidControlType == DehumidControl_CoolReheat) && DataLoopNode::Node(OutletNode).HumRatMax > 0.0) { + (CBVAV(CBVAVNum).DehumidControlType == DehumidControl::CoolReheat) && DataLoopNode::Node(OutletNode).HumRatMax > 0.0) { // Determine revised desired outlet temperature - use approach temperature control strategy // based on CONTROLLER:SIMPLE TEMPANDHUMRAT control type. @@ -2960,7 +2925,8 @@ namespace HVACUnitaryBypassVAV { } else if (PartLoadFrac < 0.0) { PartLoadFrac = 0.0; } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = + state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); } else { ShowFatalError(state, "SimCBVAV System: Invalid DX Cooling Coil=" + CBVAV(CBVAVNum).DXCoolCoilType); @@ -2977,7 +2943,7 @@ namespace HVACUnitaryBypassVAV { CBVAV(CBVAVNum).CoolCoilCompIndex, DataHVACGlobals::ContFanCycCoil, HXUnitOn); - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); } else if (CBVAV(CBVAVNum).DXCoolCoilType_Num == DataHVACGlobals::CoilDX_CoolingSingleSpeed) { DXCoils::SimDXCoil(state, CBVAV(CBVAVNum).DXCoolCoilName, @@ -2987,7 +2953,7 @@ namespace HVACUnitaryBypassVAV { DataHVACGlobals::ContFanCycCoil, 0.0, OnOffAirFlowRatio); - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); } else if (CBVAV(CBVAVNum).DXCoolCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoStageWHumControl) { DXCoils::SimDXCoilMultiMode(state, CBVAV(CBVAVNum).DXCoolCoilName, @@ -2997,7 +2963,7 @@ namespace HVACUnitaryBypassVAV { 0, CBVAV(CBVAVNum).CoolCoilCompIndex, DataHVACGlobals::ContFanCycCoil); - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXCoolCoilIndexNum); } else if (CBVAV(CBVAVNum).DXCoolCoilType_Num == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) { Real64 QZnReq(0.0); // Zone load (W), input to variable-speed DX coil Real64 QLatReq(0.0); // Zone latent load, input to variable-speed DX coil @@ -3021,7 +2987,8 @@ namespace HVACUnitaryBypassVAV { SpeedRatio, QZnReq, QLatReq); - SaveCompressorPLR = VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).CoolCoilCompIndex); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = + VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).CoolCoilCompIndex); } } @@ -3141,7 +3108,7 @@ namespace HVACUnitaryBypassVAV { 0.0, OnOffAirFlowRatio); } - SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXHeatCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = state.dataDXCoils->DXCoilPartLoadRatio(CBVAV(CBVAVNum).DXHeatCoilIndexNum); } else { // HeatCoolMode = CoolingMode // simulate DX heating coil with compressor off when cooling load is required DXCoils::SimDXCoil(state, @@ -3452,7 +3419,8 @@ namespace HVACUnitaryBypassVAV { } else if (PartLoadFrac < 0.0) { PartLoadFrac = 0.0; } - SaveCompressorPLR = VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).DXHeatCoilIndexNum); + state.dataHVACUnitaryBypassVAV->SaveCompressorPLR = + VariableSpeedCoils::getVarSpeedPartLoadRatio(state, CBVAV(CBVAVNum).DXHeatCoilIndexNum); } else if ((SELECT_CASE_var == DataHVACGlobals::Coil_HeatingGasOrOtherFuel) || (SELECT_CASE_var == DataHVACGlobals::Coil_HeatingElectric) || (SELECT_CASE_var == DataHVACGlobals::Coil_HeatingWater) || (SELECT_CASE_var == DataHVACGlobals::Coil_HeatingSteam)) { // not a DX heating coil @@ -3475,7 +3443,8 @@ namespace HVACUnitaryBypassVAV { if (CBVAV(CBVAVNum).FanType_Num == DataHVACGlobals::FanType_SystemModelObject) { HVACFan::fanObjs[CBVAV(CBVAVNum).FanIndex]->simulate(state, 1.0 / OnOffAirFlowRatio, _, _, _); } else { - Fans::SimulateFanComponents(state, CBVAV(CBVAVNum).FanName, FirstHVACIteration, CBVAV(CBVAVNum).FanIndex, FanSpeedRatio); + Fans::SimulateFanComponents( + state, CBVAV(CBVAVNum).FanName, FirstHVACIteration, CBVAV(CBVAVNum).FanIndex, state.dataHVACUnitaryBypassVAV->FanSpeedRatio); } } int splitterOutNode = CBVAV(CBVAVNum).SplitterOutletAirNode; @@ -3483,15 +3452,16 @@ namespace HVACUnitaryBypassVAV { DataLoopNode::Node(OutletNode) = DataLoopNode::Node(splitterOutNode); DataLoopNode::Node(OutletNode).TempSetPoint = CBVAV(CBVAVNum).OutletTempSetPoint; DataLoopNode::Node(OutletNode).MassFlowRate = - (1.0 - BypassDuctFlowFraction) * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; + (1.0 - state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction) * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; // report variable - CBVAV(CBVAVNum).BypassMassFlowRate = BypassDuctFlowFraction * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; + CBVAV(CBVAVNum).BypassMassFlowRate = + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; // initialize bypass duct connected to mixer or plenum with flow rate and conditions if (CBVAV(CBVAVNum).plenumIndex > 0 || CBVAV(CBVAVNum).mixerIndex > 0) { int plenumOrMixerInletNode = CBVAV(CBVAVNum).PlenumMixerInletAirNode; DataLoopNode::Node(plenumOrMixerInletNode) = DataLoopNode::Node(splitterOutNode); DataLoopNode::Node(plenumOrMixerInletNode).MassFlowRate = - BypassDuctFlowFraction * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction * DataLoopNode::Node(CBVAV(CBVAVNum).MixerInletAirNode).MassFlowRate; DataLoopNode::Node(plenumOrMixerInletNode).MassFlowRateMaxAvail = DataLoopNode::Node(plenumOrMixerInletNode).MassFlowRate; state.dataAirLoop->AirLoopFlow(CBVAV(CBVAVNum).AirLoopNumber).BypassMassFlow = DataLoopNode::Node(plenumOrMixerInletNode).MassFlowRate; } @@ -3526,6 +3496,8 @@ namespace HVACUnitaryBypassVAV { int lastDayOfSim(0); // used during warmup to reset changeOverTimer since need to do same thing next warmup day Real64 ZoneLoad = 0.0; // Total load in controlled zone [W] + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + int dayOfSim = state.dataGlobal->DayOfSim; // DayOfSim increments during Warmup when it actually simulates the same day if (state.dataGlobal->WarmupFlag) { // when warmupday increments then reset timer @@ -3580,19 +3552,19 @@ namespace HVACUnitaryBypassVAV { { auto const SELECT_CASE_var(CBVAV(CBVAVNum).PriorityControl); - if (SELECT_CASE_var == CoolingPriority) { + if (SELECT_CASE_var == PriorityCtrlMode::CoolingPriority) { if (QZoneReqCool < 0.0) { CBVAV(CBVAVNum).HeatCoolMode = CoolingMode; } else if (QZoneReqHeat > 0.0) { CBVAV(CBVAVNum).HeatCoolMode = HeatingMode; } - } else if (SELECT_CASE_var == HeatingPriority) { + } else if (SELECT_CASE_var == PriorityCtrlMode::HeatingPriority) { if (QZoneReqHeat > 0.0) { CBVAV(CBVAVNum).HeatCoolMode = HeatingMode; } else if (QZoneReqCool < 0.0) { CBVAV(CBVAVNum).HeatCoolMode = CoolingMode; } - } else if (SELECT_CASE_var == ZonePriority) { + } else if (SELECT_CASE_var == PriorityCtrlMode::ZonePriority) { if (CBVAV(CBVAVNum).NumZonesHeated > CBVAV(CBVAVNum).NumZonesCooled) { if (QZoneReqHeat > 0.0) { CBVAV(CBVAVNum).HeatCoolMode = HeatingMode; @@ -3614,7 +3586,7 @@ namespace HVACUnitaryBypassVAV { CBVAV(CBVAVNum).HeatCoolMode = CoolingMode; } } - } else if (SELECT_CASE_var == LoadPriority) { + } else if (SELECT_CASE_var == PriorityCtrlMode::LoadPriority) { if (std::abs(QZoneReqCool) > std::abs(QZoneReqHeat) && QZoneReqCool != 0.0) { CBVAV(CBVAVNum).HeatCoolMode = CoolingMode; } else if (std::abs(QZoneReqCool) < std::abs(QZoneReqHeat) && QZoneReqHeat != 0.0) { @@ -3673,6 +3645,8 @@ namespace HVACUnitaryBypassVAV { Real64 SupplyAirTempToHeatSetPt; // Supply air temperature required to reach the heating setpoint [C] Real64 SupplyAirTempToCoolSetPt; // Supply air temperature required to reach the cooling setpoint [C] + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + Real64 DXCoolCoilInletTemp = DataLoopNode::Node(CBVAV(CBVAVNumber).DXCoilInletNode).Temp; Real64 OutAirTemp = DataLoopNode::Node(CBVAV(CBVAVNumber).AirOutNode).Temp; Real64 OutAirHumRat = DataLoopNode::Node(CBVAV(CBVAVNumber).AirOutNode).HumRat; @@ -3830,6 +3804,8 @@ namespace HVACUnitaryBypassVAV { bool FirstHVACIter = (Par(5) == 1.0); bool HXUnitOn = (Par(6) == 1.0); // flag to enable heat exchanger + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + HVACHXAssistedCoolingCoil::SimHXAssistedCoolingCoil( state, CBVAV(CBVAVNumTemp).DXCoolCoilName, FirstHVACIter, On, PartLoadFrac, CoilIndex, DataHVACGlobals::ContFanCycCoil, HXUnitOn); @@ -3920,6 +3896,8 @@ namespace HVACUnitaryBypassVAV { Real64 ZoneMassFlow; // Zone mass flow rate required to meet zone load [kg/s] Real64 ZoneLoad; // Zone load calculated by ZoneTempPredictor [W] + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + int InletNode = CBVAV(CBVAVNum).AirInNode; // Inlet node number for CBVAVNum int OutletNode = CBVAV(CBVAVNum).AirOutNode; // Outlet node number for CBVAVNum int MixerMixedAirNode = CBVAV(CBVAVNum).MixerMixedAirNode; // Mixed air node number in OA mixer @@ -3962,9 +3940,9 @@ namespace HVACUnitaryBypassVAV { max(DataLoopNode::Node(BoxOutletNodeNum).MassFlowRateMin, min(ZoneMassFlow, DataLoopNode::Node(BoxOutletNodeNum).MassFlowRateMax)); } - Real64 AverageUnitMassFlow = CompOnMassFlow; - Real64 AverageOAMassFlow = OACompOnMassFlow; - FanSpeedRatio = CompOnFlowRatio; + Real64 AverageUnitMassFlow = state.dataHVACUnitaryBypassVAV->CompOnMassFlow; + Real64 AverageOAMassFlow = state.dataHVACUnitaryBypassVAV->OACompOnMassFlow; + state.dataHVACUnitaryBypassVAV->FanSpeedRatio = state.dataHVACUnitaryBypassVAV->CompOnFlowRatio; DataLoopNode::Node(MixerInletAirNode) = DataLoopNode::Node(InletNode); @@ -3975,7 +3953,7 @@ namespace HVACUnitaryBypassVAV { DataLoopNode::Node(MixerOutsideAirNode).MassFlowRate = 0.0; DataLoopNode::Node(MixerReliefAirNode).MassFlowRate = 0.0; OnOffAirFlowRatio = 0.0; - BypassDuctFlowFraction = 0.0; + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = 0.0; } else { DataLoopNode::Node(MixerInletAirNode).MassFlowRate = AverageUnitMassFlow; DataLoopNode::Node(MixerOutsideAirNode).MassFlowRate = AverageOAMassFlow; @@ -3986,7 +3964,7 @@ namespace HVACUnitaryBypassVAV { for (int i = 1; i <= CBVAV(CBVAVNum).NumControlledZones; ++i) { boxOutletNodeFlow += DataLoopNode::Node(cbVAVBoxOut(i)).MassFlowRate; } - BypassDuctFlowFraction = max(0.0, 1.0 - (boxOutletNodeFlow / AverageUnitMassFlow)); + state.dataHVACUnitaryBypassVAV->BypassDuctFlowFraction = max(0.0, 1.0 - (boxOutletNodeFlow / AverageUnitMassFlow)); } } @@ -4000,6 +3978,8 @@ namespace HVACUnitaryBypassVAV { // PURPOSE OF THIS SUBROUTINE: // Fills some of the report variables for the changeover-bypass VAV system + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + Real64 ReportingConstant = DataHVACGlobals::TimeStepSys * DataGlobalConstants::SecInHour; CBVAV(CBVAVNum).TotCoolEnergy = CBVAV(CBVAVNum).TotCoolEnergyRate * ReportingConstant; @@ -4053,6 +4033,9 @@ namespace HVACUnitaryBypassVAV { int SolFlag; // error flag Real64 QCoilActual = 0.0; // actual heating load met + + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + if (HeatCoilLoad > DataHVACGlobals::SmallLoad) { { auto const SELECT_CASE_var(CBVAV(CBVAVNum).HeatCoilType_Num); @@ -4206,6 +4189,8 @@ namespace HVACUnitaryBypassVAV { // Return value Real64 Residuum; // residual to be minimized to zero + auto &CBVAV(state.dataHVACUnitaryBypassVAV->CBVAV); + int CBVAVNum = int(Par(1)); bool FirstHVACSoln = (Par(2) > 0.0); Real64 HeatCoilLoad = Par(3); diff --git a/src/EnergyPlus/HVACUnitaryBypassVAV.hh b/src/EnergyPlus/HVACUnitaryBypassVAV.hh index b7b1996a569..03f1cedce84 100644 --- a/src/EnergyPlus/HVACUnitaryBypassVAV.hh +++ b/src/EnergyPlus/HVACUnitaryBypassVAV.hh @@ -71,46 +71,34 @@ namespace HVACUnitaryBypassVAV { constexpr int On(1); // Normal compressor operation constexpr int Off(0); // Signal DXCoil that compressor should not run - // Dehumidification control modes (DehumidControlMode) for Multimode units only - extern int const DehumidControl_None; - extern int const DehumidControl_Multimode; - extern int const DehumidControl_CoolReheat; - // Mode of operation - extern int const CoolingMode; // System operating mode is cooling - extern int const HeatingMode; // System operating mode is heating - - // Priority control mode (prioritized thermostat signal) - extern int const CoolingPriority; // Controls CBVAV system based on cooling priority - extern int const HeatingPriority; // Controls CBVAV system based on heating priority - extern int const ZonePriority; // Controls CBVAV system based on number of zones priority - extern int const LoadPriority; // Controls CBVAV system based on total load priority - - // Airflow control for contant fan mode - extern int const UseCompressorOnFlow; // Set compressor OFF air flow rate equal to compressor ON air flow rate - extern int const UseCompressorOffFlow; // Set compressor OFF air flow rate equal to user defined value - - // DERIVED TYPE DEFINITIONS - - // MODULE VARIABLE DECLARATIONS: - - extern int NumCBVAV; // Number of CBVAV systems in input file - extern Real64 CompOnMassFlow; // System air mass flow rate w/ compressor ON - extern Real64 OACompOnMassFlow; // OA mass flow rate w/ compressor ON - extern Real64 CompOffMassFlow; // System air mass flow rate w/ compressor OFF - extern Real64 OACompOffMassFlow; // OA mass flow rate w/ compressor OFF - extern Real64 CompOnFlowRatio; // fan flow ratio when coil on - extern Real64 CompOffFlowRatio; // fan flow ratio when coil off - extern Real64 FanSpeedRatio; // ratio of air flow ratio passed to fan object - extern Real64 BypassDuctFlowFraction; // Fraction of unit mass flow that returns to inlet of CBVAV unit through bypass duct - extern Real64 PartLoadFrac; // Compressor part-load fraction - extern Real64 SaveCompressorPLR; // Holds DX compressor PLR from active DX coil - extern Real64 TempSteamIn; // steam coil steam inlet temperature - extern Array1D_bool CheckEquipName; + int constexpr CoolingMode(1); // System operating mode is cooling + int constexpr HeatingMode(2); // System operating mode is heating - // SUBROUTINE SPECIFICATIONS FOR MODULE + enum class DehumidControl // Dehumidification control modes (DehumidControlMode) for Multimode units only + { + None, + Multimode, + CoolReheat + }; + + enum class PriorityCtrlMode // Priority control mode (prioritized thermostat signal) + { + Unassigned, + CoolingPriority, // Controls CBVAV system based on cooling priority + HeatingPriority, // Controls CBVAV system based on heating priority + ZonePriority, // Controls CBVAV system based on number of zones priority + LoadPriority // Controls CBVAV system based on total load priority + }; + + enum class AirFlowCtrlMode // Airflow control for contant fan mode + { + Unassigned, + UseCompressorOnFlow, // Set compressor OFF air flow rate equal to compressor ON air flow rate + UseCompressorOffFlow // Set compressor OFF air flow rate equal to user defined value + }; - // Types + // SUBROUTINE SPECIFICATIONS FOR MODULE struct CBVAVData { @@ -203,7 +191,7 @@ namespace HVACUnitaryBypassVAV { Real64 FanPartLoadRatio; // Fan part-load ratio for time step Real64 CompPartLoadRatio; // Compressor part-load ratio for time step int LastMode; // Last mode of operation, coolingmode or heatingmode - int AirFlowControl; // Fan control mode, UseCompressorOnFlow or UseCompressorOffFlow + AirFlowCtrlMode AirFlowControl; // Fan control mode, UseCompressorOnFlow or UseCompressorOffFlow Real64 CompPartLoadFrac; // Compressor part load ratio int AirLoopNumber; // Air loop served by the CBVAV system int NumControlledZones; @@ -213,7 +201,7 @@ namespace HVACUnitaryBypassVAV { Array1D_int CBVAVBoxOutletNode; // Outlet node of CBVAV Box in controlled zone Array1D_int ZoneSequenceCoolingNum; // Index to cooling sequence/priority for this zone Array1D_int ZoneSequenceHeatingNum; // Index to heating sequence/priority for this zone - int PriorityControl; // Control mode - CoolingPriority, HeatingPriority, ZonePriority or LoadPriority + PriorityCtrlMode PriorityControl; // Control mode - CoolingPriority, HeatingPriority, ZonePriority or LoadPriority int NumZonesCooled; // Number of zones requesting cooling int NumZonesHeated; // Number of zones requesting heating int PLRMaxIter; // Counter for recurring warning message @@ -228,7 +216,7 @@ namespace HVACUnitaryBypassVAV { int HeatCoolMode; // System operating mode (0 = floating, 1 = cooling, 2 = heating) Real64 BypassMassFlowRate; // Bypass mass flow rate report variable [m3/s] int DehumidificationMode; // Dehumidification mode (0=normal, 1=enhanced) - int DehumidControlType; // Dehumidification control type (currently only for multimode coil) + DehumidControl DehumidControlType; // Dehumidification control type (currently only for multimode coil) bool HumRatMaxCheck; // Used in Init for warning messages int DXIterationExceeded; // Counter for DX coil messages int DXIterationExceededIndex; // Counter for DX coil messages @@ -284,10 +272,10 @@ namespace HVACUnitaryBypassVAV { MinOATCompressor(0.0), MinLATCooling(0.0), MaxLATHeating(0.0), TotHeatEnergyRate(0.0), TotHeatEnergy(0.0), TotCoolEnergyRate(0.0), TotCoolEnergy(0.0), SensHeatEnergyRate(0.0), SensHeatEnergy(0.0), SensCoolEnergyRate(0.0), SensCoolEnergy(0.0), LatHeatEnergyRate(0.0), LatHeatEnergy(0.0), LatCoolEnergyRate(0.0), LatCoolEnergy(0.0), ElecPower(0.0), ElecConsumption(0.0), FanPartLoadRatio(0.0), - CompPartLoadRatio(0.0), LastMode(0), AirFlowControl(0), CompPartLoadFrac(0.0), AirLoopNumber(0), NumControlledZones(0), - PriorityControl(0), NumZonesCooled(0), NumZonesHeated(0), PLRMaxIter(0), PLRMaxIterIndex(0), DXCoilInletNode(0), DXCoilOutletNode(0), + CompPartLoadRatio(0.0), LastMode(0), AirFlowControl(AirFlowCtrlMode::Unassigned), CompPartLoadFrac(0.0), AirLoopNumber(0), NumControlledZones(0), + PriorityControl(PriorityCtrlMode::Unassigned), NumZonesCooled(0), NumZonesHeated(0), PLRMaxIter(0), PLRMaxIterIndex(0), DXCoilInletNode(0), DXCoilOutletNode(0), HeatingCoilInletNode(0), HeatingCoilOutletNode(0), FanInletNodeNum(0), OutletTempSetPoint(0.0), CoilTempSetPoint(0.0), HeatCoolMode(0), - BypassMassFlowRate(0.0), DehumidificationMode(0), DehumidControlType(0), HumRatMaxCheck(true), DXIterationExceeded(0), + BypassMassFlowRate(0.0), DehumidificationMode(0), DehumidControlType(DehumidControl::None), HumRatMaxCheck(true), DXIterationExceeded(0), DXIterationExceededIndex(0), DXIterationFailed(0), DXIterationFailedIndex(0), DXCyclingIterationExceeded(0), DXCyclingIterationExceededIndex(0), DXCyclingIterationFailed(0), DXCyclingIterationFailedIndex(0), DXHeatIterationExceeded(0), DXHeatIterationExceededIndex(0), DXHeatIterationFailed(0), DXHeatIterationFailedIndex(0), DXHeatCyclingIterationExceeded(0), @@ -301,14 +289,6 @@ namespace HVACUnitaryBypassVAV { } }; - // Object Data - extern Array1D CBVAV; - extern bool GetInputFlag; // Flag set to make sure you get input once - - // Functions - - void clear_state(); - void SimUnitaryBypassVAV(EnergyPlusData &state, std::string const &CompName, // Name of the CBVAV system bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system time step int const AirLoopNum, // air loop index @@ -398,9 +378,41 @@ namespace HVACUnitaryBypassVAV { struct HVACUnitaryBypassVAVData : BaseGlobalStruct { + int NumCBVAV = 0; // Number of CBVAV systems in input file + Real64 CompOnMassFlow = 0.0; // System air mass flow rate w/ compressor ON + Real64 OACompOnMassFlow = 0.0; // OA mass flow rate w/ compressor ON + Real64 CompOffMassFlow = 0.0; // System air mass flow rate w/ compressor OFF + Real64 OACompOffMassFlow = 0.0; // OA 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; // ratio of air flow ratio passed to fan object + Real64 BypassDuctFlowFraction = 0.0; // Fraction of unit mass flow that returns to inlet of CBVAV unit through bypass duct + Real64 PartLoadFrac = 0.0; // Compressor part-load fraction + Real64 SaveCompressorPLR = 0.0; // Holds DX compressor PLR from active DX coil + Real64 TempSteamIn = 100.0; // steam coil steam inlet temperature + Array1D_bool CheckEquipName; + + Array1D CBVAV; + bool GetInputFlag = true; // Flag set to make sure you get input once + + void clear_state() override { - + this->CBVAV.deallocate(); + this->NumCBVAV = 0; + this->CompOnMassFlow = 0.0; + this->OACompOnMassFlow = 0.0; + this->CompOffMassFlow = 0.0; + this->OACompOffMassFlow = 0.0; + this->CompOnFlowRatio = 0.0; + this->CompOffFlowRatio = 0.0; + this->FanSpeedRatio = 0.0; + this->BypassDuctFlowFraction = 0.0; + this->PartLoadFrac = 0.0; + this->SaveCompressorPLR = 0.0; + this->TempSteamIn = 100.0; + this->CheckEquipName.deallocate(); + this->GetInputFlag = true; } }; diff --git a/src/EnergyPlus/InternalHeatGains.cc b/src/EnergyPlus/InternalHeatGains.cc index d92025deb38..b4345a26275 100644 --- a/src/EnergyPlus/InternalHeatGains.cc +++ b/src/EnergyPlus/InternalHeatGains.cc @@ -140,18 +140,8 @@ namespace InternalHeatGains { int const ITEInletZoneAirNode(1); int const ITEInletRoomAirModel(2); - bool GetInternalHeatGainsInputFlag(true); // Controls the GET routine calling (limited to first time) - bool ErrorsFound(false); // if errors were found in the input - static std::string const BlankString; - // Functions - void clear_state() - { - GetInternalHeatGainsInputFlag = true; - ErrorsFound = false; - } - void ManageInternalHeatGains(EnergyPlusData &state, Optional_bool_const InitOnly) // when true, just calls the get input, if appropriate and returns. { @@ -165,9 +155,9 @@ namespace InternalHeatGains { // This is the main driver subroutine for the internal heat gains. - if (GetInternalHeatGainsInputFlag) { + if (state.dataInternalHeatGains->GetInternalHeatGainsInputFlag) { GetInternalHeatGainsInput(state); - GetInternalHeatGainsInputFlag = false; + state.dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; } if (present(InitOnly)) { @@ -279,6 +269,7 @@ namespace InternalHeatGains { } }; + auto &ErrorsFound(state.dataInternalHeatGains->ErrorsFound); state.dataHeatBal->ZoneIntGain.allocate(state.dataGlobal->NumOfZones); state.dataHeatBal->ZnRpt.allocate(state.dataGlobal->NumOfZones); @@ -6406,7 +6397,7 @@ namespace InternalHeatGains { // FUNCTION LOCAL VARIABLE DECLARATIONS: int Loop; - if (GetInternalHeatGainsInputFlag) { + if (state.dataInternalHeatGains->GetInternalHeatGainsInputFlag) { ShowFatalError(state, "GetDesignLightingLevelForZone: Function called prior to Getting Lights Input."); } @@ -6460,7 +6451,7 @@ namespace InternalHeatGains { Real64 LightsRepMax; // Maximum Lighting replacement fraction for any lights statement for this zone int NumLights; // Number of Lights statement for that zone. - if (GetInternalHeatGainsInputFlag) { + if (state.dataInternalHeatGains->GetInternalHeatGainsInputFlag) { ShowFatalError(state, "CheckLightsReplaceableMinMaxForZone: Function called prior to Getting Lights Input."); } diff --git a/src/EnergyPlus/InternalHeatGains.hh b/src/EnergyPlus/InternalHeatGains.hh index a02c2078146..634da97316a 100644 --- a/src/EnergyPlus/InternalHeatGains.hh +++ b/src/EnergyPlus/InternalHeatGains.hh @@ -63,12 +63,6 @@ struct EnergyPlusData; namespace InternalHeatGains { - extern bool GetInternalHeatGainsInputFlag; // Controls the GET routine calling (limited to first time) - extern bool ErrorsFound; // if errors were found in the input - - // Functions - void clear_state(); - void ManageInternalHeatGains(EnergyPlusData &state, Optional_bool_const InitOnly = _); // when true, just calls the get input, if appropriate and returns. void GetInternalHeatGainsInput(EnergyPlusData &state); @@ -196,8 +190,13 @@ namespace InternalHeatGains { struct InternalHeatGainsData : BaseGlobalStruct { + bool GetInternalHeatGainsInputFlag = true; // Controls the GET routine calling (limited to first time) + bool ErrorsFound = false; // if errors were found in the input + void clear_state() override { + this->GetInternalHeatGainsInputFlag = true; + this->ErrorsFound = false; } }; diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 206c4eafe3a..ccb73c64269 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -103,17 +103,6 @@ namespace RoomAirModelManager { // Using/Aliasing using namespace DataRoomAirModel; - bool GetUCSDDVDataFlag(true); // UCSD - bool GetAirModelData(true); // Used to "get" all air model data - bool MyOneTimeFlag(true); - - void clear_state() - { - GetUCSDDVDataFlag = true; - GetAirModelData = true; - MyOneTimeFlag = true; - } - void ManageAirModel(EnergyPlusData &state, int &ZoneNum) { @@ -136,9 +125,9 @@ namespace RoomAirModelManager { using UFADManager::ManageUCSDUFModels; - if (GetAirModelData) { + if (state.dataRoomAirModelMgr->GetAirModelData) { GetAirModelDatas(state); - GetAirModelData = false; + state.dataRoomAirModelMgr->GetAirModelData = false; } if (state.dataRoomAirMod->UCSDModelUsed) { @@ -1863,7 +1852,7 @@ namespace RoomAirModelManager { static int NodeNum2(0); // The Second node number in an AirflowNetwork linkage data // Do the one time initializations - if (MyOneTimeFlag) { + if (state.dataRoomAirModelMgr->MyOneTimeFlag) { MyEnvrnFlag.allocate(state.dataGlobal->NumOfZones); @@ -2532,7 +2521,7 @@ namespace RoomAirModelManager { MyEnvrnFlag = true; - MyOneTimeFlag = false; + state.dataRoomAirModelMgr->MyOneTimeFlag = false; } // Do the Begin Environment initializations @@ -2677,9 +2666,9 @@ namespace RoomAirModelManager { int I; // Zone index // Obtains and Allocates RoomAirSettings : AirflowNetwork - if (GetAirModelData) { + if (state.dataRoomAirModelMgr->GetAirModelData) { GetAirModelDatas(state); - GetAirModelData = false; + state.dataRoomAirModelMgr->GetAirModelData = false; } Errorfound = false; diff --git a/src/EnergyPlus/RoomAirModelManager.hh b/src/EnergyPlus/RoomAirModelManager.hh index 9e51aaf3a52..51a83a10e40 100644 --- a/src/EnergyPlus/RoomAirModelManager.hh +++ b/src/EnergyPlus/RoomAirModelManager.hh @@ -59,11 +59,6 @@ struct EnergyPlusData; namespace RoomAirModelManager { - extern bool GetUCSDDVDataFlag; // UCSD - extern bool GetAirModelData; // Used to "get" all air model data - - void clear_state(); - void ManageAirModel(EnergyPlusData &state, int &ZoneNum); void GetAirModelDatas(EnergyPlusData &state); @@ -100,9 +95,15 @@ namespace RoomAirModelManager { struct RoomAirModelManagerData : BaseGlobalStruct { + bool GetUCSDDVDataFlag = true; // UCSD + bool GetAirModelData = true; // Used to "get" all air model data + bool MyOneTimeFlag = true; + void clear_state() override { - + this->GetUCSDDVDataFlag = true; + this->GetAirModelData = true; + this->MyOneTimeFlag = true; } }; diff --git a/src/EnergyPlus/StateManagement.cc b/src/EnergyPlus/StateManagement.cc index b612e743053..81b1fb4acf4 100644 --- a/src/EnergyPlus/StateManagement.cc +++ b/src/EnergyPlus/StateManagement.cc @@ -87,7 +87,6 @@ #include #include #include -#include #include #include #include @@ -95,7 +94,6 @@ #include #include #include -#include #include #include #include @@ -107,7 +105,6 @@ #include #include #include -#include #include #include #include @@ -122,7 +119,6 @@ #include #include #include -#include #include #include #include @@ -178,17 +174,14 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) HVACControllers::clear_state(); HVACCooledBeam::clear_state(); HVACDuct::clear_state(); - HVACDXHeatPumpSystem::clear_state(); HVACDXSystem::clear_state(); HVACHXAssistedCoolingCoil::clear_state(); HVACFan::clearHVACFanObjects(); HVACManager::clear_state(); HVACMultiSpeedHeatPump::clear_state(); HVACSingleDuctInduc::clear_state(); - HVACUnitaryBypassVAV::clear_state(); HybridModel::clear_state(); HysteresisPhaseChange::clear_state(); - InternalHeatGains::clear_state(); LowTempRadiantSystem::clear_state(); OutputReportTabular::clear_state(state); OutputReportTabularAnnual::clear_state(); @@ -200,7 +193,6 @@ void EnergyPlus::clearAllStates(EnergyPlusData &state) PVWatts::clear_state(); clearCoilSelectionReportObj(); // ReportCoilSelection RoomAirModelAirflowNetwork::clear_state(); - RoomAirModelManager::clear_state(); RoomAirModelUserTempPattern::clear_state(); RuntimeLanguageProcessor::clear_state(); ScheduleManager::clear_state(); diff --git a/tst/EnergyPlus/unit/DElightManager.unit.cc b/tst/EnergyPlus/unit/DElightManager.unit.cc index 5b5db472856..7687541af39 100644 --- a/tst/EnergyPlus/unit/DElightManager.unit.cc +++ b/tst/EnergyPlus/unit/DElightManager.unit.cc @@ -341,7 +341,7 @@ TEST_F(EnergyPlusFixture, DElightManagerF_GetInputDElightComplexFenestration_Tes state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); ScheduleManager::UpdateScheduleValues(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); - InternalHeatGains::GetInternalHeatGainsInputFlag = false; + state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; GetInputDElightComplexFenestration(*state, foundErrors); compare_err_stream(""); diff --git a/tst/EnergyPlus/unit/DaylightingManager.unit.cc b/tst/EnergyPlus/unit/DaylightingManager.unit.cc index aae4f67e948..cbd1e11dfb0 100644 --- a/tst/EnergyPlus/unit/DaylightingManager.unit.cc +++ b/tst/EnergyPlus/unit/DaylightingManager.unit.cc @@ -854,7 +854,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_GetDaylParamInGeoTrans_Test) state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); ScheduleManager::UpdateScheduleValues(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); - InternalHeatGains::GetInternalHeatGainsInputFlag = false; + state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; GetDaylightingParametersInput(*state); compare_err_stream(""); @@ -1340,7 +1340,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_DayltgInteriorIllum_Test) int ZoneNum = UtilityRoutines::FindItemInList("EAST ZONE", state->dataHeatBal->Zone); InternalHeatGains::GetInternalHeatGainsInput(*state); - InternalHeatGains::GetInternalHeatGainsInputFlag = false; + state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; DaylightingManager::GetInputDayliteRefPt(*state, foundErrors); DaylightingManager::GetDaylightingParametersInput(*state); state->dataDaylightingManager->GILSK = 100.0; @@ -2128,7 +2128,7 @@ TEST_F(EnergyPlusFixture, DaylightingManager_OutputFormats) state->dataEnvrn->DayOfYear_Schedule = General::OrdinalDay(state->dataEnvrn->Month, state->dataEnvrn->DayOfMonth, 1); ScheduleManager::UpdateScheduleValues(*state); InternalHeatGains::GetInternalHeatGainsInput(*state); - InternalHeatGains::GetInternalHeatGainsInputFlag = false; + state->dataInternalHeatGains->GetInternalHeatGainsInputFlag = false; GetDaylightingParametersInput(*state); compare_err_stream(""); diff --git a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc index f2592915c29..923cffa9020 100644 --- a/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc +++ b/tst/EnergyPlus/unit/HVACUnitaryBypassVAV.unit.cc @@ -184,9 +184,9 @@ class CBVAVSys : public EnergyPlusFixture DataLoopNode::Node.allocate(50); // note no fan used for these tests - HVACUnitaryBypassVAV::NumCBVAV = 1; - HVACUnitaryBypassVAV::CBVAV.allocate(1); - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(1)); + state->dataHVACUnitaryBypassVAV->NumCBVAV = 1; + state->dataHVACUnitaryBypassVAV->CBVAV.allocate(1); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.Name = "CBVAVAirLoop"; cbvav.UnitType = "AirLoopHVAC:UnitaryHeatCool:VAVChangeoverBypass"; cbvav.SchedPtr = -1; @@ -685,7 +685,7 @@ TEST_F(EnergyPlusFixture, UnitaryBypassVAV_GetInputZoneEquipment) int CBVAVNum = 1; int zoneIndex = 1; - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(CBVAVNum)); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(CBVAVNum)); // should be the second zone in the zone list as well as actual zone number EXPECT_EQ(2, cbvav.ControlledZoneNum(CBVAVNum)); EXPECT_EQ(2, cbvav.ActualZoneNum(CBVAVNum)); @@ -719,7 +719,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_AutoSize) { // reference CBVAV and FinalSysSizing data - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(1)); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); auto &finalSysSizing(state->dataSize->FinalSysSizing(state->dataSize->CurSysNum)); state->dataSize->SysSizingRunDone = true; // inform sizing that system sizing run is done @@ -761,7 +761,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_NoOASys) { // reference CBVAV data - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(1)); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.FanVolFlow = 0.5; cbvav.MaxCoolAirVolFlow = 0.5; cbvav.MaxHeatAirVolFlow = 0.5; @@ -800,7 +800,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_NoOASys) EXPECT_EQ(cbvav.changeOverTimer, -1.0); // expect no change in timer, remains at default value // initialize priority control - cbvav.PriorityControl = HVACUnitaryBypassVAV::CoolingPriority; + cbvav.PriorityControl = HVACUnitaryBypassVAV::PriorityCtrlMode::CoolingPriority; // initialize cooling load state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).SequencedOutputRequiredToCoolingSP(1) = -9000.0; // load to cooling set point @@ -856,7 +856,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_InternalOAMixer) { // reference CBVAV data - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(1)); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.FanVolFlow = 0.5; cbvav.MaxCoolAirVolFlow = 0.5; cbvav.MaxHeatAirVolFlow = 0.5; @@ -892,7 +892,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_InternalOAMixer) EXPECT_NE(DataLoopNode::Node(cbvav.AirInNode).Enthalpy, DataLoopNode::Node(cbvav.AirOutNode).Enthalpy); // initialize priority control - cbvav.PriorityControl = HVACUnitaryBypassVAV::CoolingPriority; + cbvav.PriorityControl = HVACUnitaryBypassVAV::PriorityCtrlMode::CoolingPriority; // initialize cooling load state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).SequencedOutputRequiredToCoolingSP(1) = -9000.0; // load to cooling set point @@ -942,7 +942,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_Mixerconnected) { // reference CBVAV data - auto &cbvav(HVACUnitaryBypassVAV::CBVAV(1)); + auto &cbvav(state->dataHVACUnitaryBypassVAV->CBVAV(1)); cbvav.FanVolFlow = 0.5; cbvav.MaxCoolAirVolFlow = 0.5; cbvav.MaxHeatAirVolFlow = 0.5; @@ -978,7 +978,7 @@ TEST_F(CBVAVSys, UnitaryBypassVAV_Mixerconnected) EXPECT_NEAR(DataLoopNode::Node(cbvav.AirInNode).Enthalpy, DataLoopNode::Node(cbvav.AirOutNode).Enthalpy, 0.1); // initialize priority control - cbvav.PriorityControl = HVACUnitaryBypassVAV::CoolingPriority; + cbvav.PriorityControl = HVACUnitaryBypassVAV::PriorityCtrlMode::CoolingPriority; // initialize cooling load state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).SequencedOutputRequiredToCoolingSP(1) = -9000.0; // load to cooling set point diff --git a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc index b4ad029562f..f02ac3eec80 100644 --- a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc +++ b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc @@ -305,7 +305,7 @@ TEST_F(EnergyPlusFixture, InternalHeatGains_AllowBlankFieldsForAdaptiveComfortMo state->dataScheduleMgr->Schedule(2).MaxMinSet = true; InternalHeatGains::GetInternalHeatGainsInput(*state); - EXPECT_FALSE(InternalHeatGains::ErrorsFound); + EXPECT_FALSE(state->dataInternalHeatGains->ErrorsFound); } TEST_F(EnergyPlusFixture, InternalHeatGains_ElectricEquipITE_BeginEnvironmentReset)